go-watchdog/cmd/watchdog/install.go

64 lines
1.5 KiB
Go
Raw Normal View History

2019-06-27 08:54:51 +00:00
package main
import (
"fmt"
"log"
"os"
"strings"
"git.rootprojects.org/root/watchdog.go/cmd/watchdog/installer"
)
func install(binpath string, args []string) {
system := true
production := false
config := "./config.json"
for i := range os.Args {
switch {
case strings.HasSuffix(os.Args[i], "userspace"):
system = false
case strings.HasSuffix(os.Args[i], "production"):
fmt.Println("Warning: production options don't work on all systems. If you have trouble, drop this first.")
production = false
case "-c" == os.Args[i]:
if len(os.Args) <= i+1 {
fmt.Println("-c requires a string path to the config file")
os.Exit(1)
}
config = os.Args[i+1]
}
}
/*
j, err := static.ReadFile("dist/etc/systemd/system/watchdog.service.json")
if err != nil {
log.Fatal(err)
return
}
//conf := map[string]string{}
conf := &Config{}
err = json.Unmarshal(j, &conf)
if nil != err {
log.Fatal(err)
return
}
*/
err := installer.Install(&installer.Config{
Title: "Watchdog",
Desc: "Get notified when sites go down",
URL: "https://git.rootprojects.org/root/watchdog.go",
Name: "watchdog",
Exec: "watchdog",
Local: "",
System: system,
Restart: true,
Argv: []string{"-c", config},
PrivilegedPorts: false,
MultiuserProtection: false,
Production: production,
})
if nil != err {
log.Fatal(err)
}
}