feat: update nodes — rebuild container from fw.conf, preserve config

This commit is contained in:
admin 2026-08-08 14:36:25 +00:00
parent 6fd758bb1f
commit 3149b15cef

View file

@ -199,6 +199,7 @@ def main():
n += 1 n += 1
if deployed: if deployed:
print(f" [{n}] Update nodes"); ops['update'] = str(n); n += 1
print(f" [{n}] Edit nodes"); ops['edit'] = str(n); n += 1 print(f" [{n}] Edit nodes"); ops['edit'] = str(n); n += 1
print(f" [{n}] Delete a node"); ops['del'] = str(n); n += 1 print(f" [{n}] Delete a node"); ops['del'] = str(n); n += 1
print(f" [{n}] Status"); ops['status'] = str(n); n += 1 print(f" [{n}] Status"); ops['status'] = str(n); n += 1
@ -220,6 +221,8 @@ def main():
str(nc.get("upstream_port","80")), "", str(nc.get("upstream_port","80")), "",
nc.get("mode","monitoring")) nc.get("mode","monitoring"))
deployed.add(name) deployed.add(name)
elif c == ops.get('update') and deployed:
update_nodes()
elif c == ops.get('edit') and deployed: elif c == ops.get('edit') and deployed:
edit_nodes() edit_nodes()
elif c == ops.get('del') and deployed: elif c == ops.get('del') and deployed:
@ -439,3 +442,29 @@ def start_debug():
if __name__ == "__main__": if __name__ == "__main__":
main() main()
def update_nodes():
"""Rebuild containers using current config — no config changes, just apply template updates."""
cfg = load_config()
s = load_state().get("nodes", [])
if not s: print("No nodes."); return
print("\n─── Update Nodes ───")
for i, n in enumerate(s):
print(f" [{i+1}] {n['name']} (port {n.get('port','')})")
print(" [a] All [b] Back")
c = input("\nSelect: ").strip()
if c.lower() == 'b': return
nodes_to_update = s if c.lower() == 'a' else ([s[int(c)-1]] if c.isdigit() and 1 <= int(c) <= len(s) else [])
if not nodes_to_update: return
for n in nodes_to_update:
name = n['name']
nc = cfg.get(name, {})
if not nc: continue
print(f"\nUpdating {name}...")
deploy_container(name, nc["token"], nc.get("cloud","EU"),
str(nc.get("port","8081")), nc.get("upstream_ip",""),
str(nc.get("upstream_port","80")), "",
nc.get("mode","monitoring"))
print(f"{name} updated.")