awg-ctrl: update, reinstall and uninstall from the menu
The awg-ctrl menu only started, stopped and changed the panel login; updating or removing an installation meant finding and running install.sh by hand. The menu gets "Обновить", "Переустановить" and "Удалить" (7–9), and the same as `awg-ctrl update | reinstall | uninstall`. The work stays in install.sh, which now takes ACTION=update|reinstall|uninstall to skip its own menu. The CLI fetches it — the latest from INSTALLER_URL (GitHub by default) for update and reinstall, the copy shipped in the release archive for uninstall, so removal works offline — writes it to a temp file and execs bash on it in the same terminal. It must not run from /opt/awg-control or via `bash -c`: kill_related kills every process whose command line holds the install path, and would kill the installer itself. The CLI passes its original environment, not the one with cli.env loaded, or the installer would take UI_PORT, SERVER_NAME and the rest as explicit overrides. The installer deletes its temp copy on start. The release archive now includes install.sh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013bNGYiDst62wH3ZGTRPFLJ
This commit is contained in:
+5
-2
@@ -638,10 +638,10 @@ func (c *CLI) confirmYes(q string) bool {
|
||||
|
||||
// ── Точка входа ─────────────────────────────────────────────────────────────
|
||||
|
||||
const usage = "Usage: cli <start|stop|restart|status|credentials [user|pass]|join <awgjoin://…> [--no-panel]|unjoin|rehome <хост[:порт]>|peers [drop <область>]|monitor <install|status|remove>|migrate <export [файл]|import <файл>|cancel>>"
|
||||
const usage = "Usage: cli <start|stop|restart|status|credentials [user|pass]|join <awgjoin://…> [--no-panel]|unjoin|rehome <хост[:порт]>|peers [drop <область>]|monitor <install|status|remove>|migrate <export [файл]|import <файл>|cancel>|update|reinstall|uninstall>"
|
||||
|
||||
// Commands — команды оператора; main передаёт сюда всё, что не роль сервиса.
|
||||
var Commands = []string{"start", "stop", "restart", "status", "credentials", "join", "unjoin", "rehome", "peers", "monitor", "migrate"}
|
||||
var Commands = []string{"start", "stop", "restart", "status", "credentials", "join", "unjoin", "rehome", "peers", "monitor", "migrate", "update", "reinstall", "uninstall"}
|
||||
|
||||
// Main выполняет команду CLI (args — без имени бинарника). Пусто — интерактивное меню.
|
||||
func Main(args []string) {
|
||||
@@ -686,6 +686,9 @@ func Main(args []string) {
|
||||
c.peersCmd(sub, hasSub, a2, hasA2)
|
||||
case "monitor":
|
||||
c.monitorCmd(sub)
|
||||
case "update", "reinstall", "uninstall":
|
||||
// Из командной строки — без своего вопроса: установщик сам спросит, что нужно.
|
||||
c.runInstaller(args[0], false)
|
||||
default:
|
||||
fmt.Println(usage)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user