This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (43 loc) · 1.52 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"fmt"
"os"
"github.com/AtlasInsideCorp/UTMStackInstaller/utils"
"github.com/akamensky/argparse"
)
var tag string
var lite bool
func main() {
tag = os.Getenv("TAG")
if tag == "" {
tag = "v9"
}
if os.Getenv("LITE") == "true" {
lite = true
} else {
lite = false
}
utils.CheckErr(utils.CheckDistro("ubuntu"))
parser := argparse.NewParser("", "UTMStack installer")
removeCmd := parser.NewCommand("remove", "Uninstall UTMStack")
masterCmd := parser.NewCommand("master", "Install Master")
masterDataDir := "/utmstack"
masterPass := masterCmd.String("", "db-pass", &argparse.Options{Required: true, Help: "Master password. Please use a secure password"})
probeCmd := parser.NewCommand("probe", "Install Probe")
probeDataDir := "/utmstack"
probePass := probeCmd.String("", "db-pass", &argparse.Options{Required: true, Help: "Master password. Generated when the master was installed"})
host := probeCmd.String("", "host", &argparse.Options{Required: true, Help: "Master server IP or FQDN"})
if len(os.Args) == 1 {
tui()
} else if err := parser.Parse(os.Args); err != nil {
fmt.Print(parser.Usage(err))
} else if removeCmd.Happened() {
utils.CheckErr(utils.Uninstall("cli"))
} else if masterCmd.Happened() {
utils.CheckErr(utils.InstallMaster("cli", masterDataDir, *masterPass, tag, lite))
fmt.Println("Successfully installed.")
} else if probeCmd.Happened() {
utils.CheckErr(utils.InstallProbe("cli", probeDataDir, *probePass, *host, tag, lite))
fmt.Println("Successfully installed.")
}
}