Port the CLI to Go: awg-control <start|stop|…>
internal/cli reimplements cli/src: start/stop/restart/status with the awg-ctrl health gate, credentials, join/unjoin, peers [drop], monitor install/status/remove and the interactive menu. Same cli.env, pid files, logs and messages. Without arguments or with an operator command the binary acts as the CLI; ctrl/ui/agent stay service roles. - services are started as the same binary (`awg-control ctrl|ui|agent`), detached into their own session, from the same working directories - processes started by the Node CLI (tsx … index.ts / server.ts) are still recognised, so `stop` and `status` work across the switch - after join the fresh restart gets the original environment, so a rejoin picks up the new cli.env instead of the inherited old CORE_* values - install root: AWG_ROOT, else the nearest parent of the binary with cli/ or .env, else /opt/awg-control Checked end to end on stubbed awg: start/status/stop, credentials, join to the panel's own hub (with and without --no-panel), peers listing and drop, unjoin, menu.
This commit is contained in:
@@ -9,14 +9,16 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/maeneko/forgetting/internal/agent"
|
||||
"github.com/maeneko/forgetting/internal/cli"
|
||||
"github.com/maeneko/forgetting/internal/ctrl"
|
||||
"github.com/maeneko/forgetting/internal/ui"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Без аргументов или с командой оператора — CLI (меню, start/stop/…), как прежний awg-ctrl.
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Fprintln(os.Stderr, "usage: awg-control <ctrl|ui|agent|start|stop|restart|status|…>")
|
||||
os.Exit(1)
|
||||
cli.Main(nil)
|
||||
return
|
||||
}
|
||||
switch os.Args[1] {
|
||||
case "ctrl":
|
||||
@@ -54,7 +56,6 @@ func main() {
|
||||
defer stop()
|
||||
a.Run(ctx)
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "awg-control: неизвестная команда %q\n", os.Args[1])
|
||||
os.Exit(1)
|
||||
cli.Main(os.Args[1:])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user