// Copyright 2024 WIT.COM Inc Licensed GPL 3.0 package main import ( "os" "strings" "go.wit.com/lib/gui/shell" "go.wit.com/log" ) var urlbase string = "http://zookeeper.grid.wit.com:8080" func send() { } func pingStatus() error { var url string url = urlbase + "/status?hostname=" + me.hostname msg, err := me.machine.Packages.Marshal() if err != nil { log.Info("proto.Marshal() failed:", err) return err } log.Info("proto Marshal len =", len(msg)) body, err := httpPost(url, msg) if err != nil { log.Info("httpPost() failed:", err) return err } test := strings.TrimSpace(string(body)) // log.Info("virtigo returned body:", test) for _, line := range strings.Split(test, "\n") { switch line { case "upgrade": log.Info("should upgrade now") default: log.Info("GOT:", line) } } return nil } func sendMachine(s string) error { var url string url = urlbase + "/machine" msg, err := me.machine.Marshal() if err != nil { log.Info("proto.Marshal() failed:", err) return err } body, err := httpPost(url, msg) if err != nil { log.Info("httpPost() failed:", err) return err } test := strings.TrimSpace(string(body)) // log.Info("virtigo returned body:", test) for _, line := range strings.Split(test, "\n") { if line == "upgrade" { log.Info(s, "zookeeper is healthy", len(msg)) } else if line == "kill" { os.Exit(0) } else if strings.HasPrefix(line, "apt update") { log.Info("machine upgrade now", line) shell.Run([]string{"apt", "update"}) shell.Run([]string{"apt", "install", "zood"}) log.Sleep(1) os.Exit(0) } else { log.Info(urlbase, "is maybe not working GOT:", line) } } return nil }