From 86df520638e22e1ee42b1fe30672fa2473b5a6ad Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 15 Oct 2024 11:02:54 -0500 Subject: [PATCH] start works from the command line Signed-off-by: Jeff Carr --- Makefile.help | 1 + http.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile.help b/Makefile.help index da38520..a5116b0 100644 --- a/Makefile.help +++ b/Makefile.help @@ -14,6 +14,7 @@ curl-kill: curl http://localhost:2520/kill status: + dpkg -s virtigod systemctl status virtigod.service enable: diff --git a/http.go b/http.go index 85bdbb0..66d7fd0 100644 --- a/http.go +++ b/http.go @@ -6,6 +6,7 @@ import ( "os" "strings" + "go.wit.com/lib/gui/shell" "go.wit.com/log" ) @@ -17,6 +18,10 @@ func cleanURL(url string) string { func okHandler(w http.ResponseWriter, r *http.Request) { var tmp string + + log.Info("Got URL Path: ", r.URL.Path) + log.Info("Got URL Query:", r.URL.Query().Get("start")) + tmp = cleanURL(r.URL.Path) log.Info("Got URL:", tmp) @@ -48,7 +53,13 @@ func okHandler(w http.ResponseWriter, r *http.Request) { if tmp == "/start" { start := r.URL.Query().Get("start") - fmt.Fprint(w,"Handling URL:", tmp, "should start here: droplet", start) + xml := "/root/jcarr/machines/autostart/" + start + ".xml" + cmd := []string{"virsh", "create", xml} + fmt.Fprintln(w, "Handling URL:", tmp, "should start here: droplet") + fmt.Fprintln(w, "start returned: ", start) + log.Warn("should start droplet", start, "here") + log.Warn("cmd :", cmd) + shell.Run(cmd) return }