diff --git a/Makefile b/Makefile index 6f12125..4066ee3 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,7 @@ all: ./virtigo --help xml-add: - ./virtigo --add-xml /home/nfs3/xml/*.xml - # ./virtigo --add-xml /etc/libvirt/qemu/*xml + ./virtigo --add-xml /tmp/xml/*.xml start-all-droplets: curl --silent http://localhost:8080/start?start=git.wit.org diff --git a/argv.go b/argv.go index e244a96..4b06219 100644 --- a/argv.go +++ b/argv.go @@ -11,12 +11,12 @@ import "go.wit.com/log" var argv args type args struct { - Dir string `arg:"--dir" help:"defaults to ~/.config/virtigo/"` - Port int `arg:"--port" default:"8080" help:"specify a different default port"` + Xml []string `arg:"--add-xml" help:"add libvirt xml files"` + CfgDir string `arg:"--dir" help:"defaults to ~/.config/virtigo/"` Hosts []string `arg:"--hosts" help:"hosts to connect to"` + Port int `arg:"--port" default:"8080" help:"allow droplet events via http"` Uptime bool `arg:"--uptime" default:"true" help:"allow uptime checks for things like Kuma"` Daemon bool `arg:"--daemon" help:"run in daemon mode"` - Xml []string `arg:"--add-xml" help:"add libvirt xml files"` Save bool `arg:"--save" default:"false" help:"save xml changes to the protobuf values"` } @@ -24,7 +24,9 @@ func (a args) Description() string { return ` virtigo will help control your cluster of hypervisiors -go install go.wit.com/apps/virtigo@latest +This maintains a master list of all your vm's (aka 'droplets') +in your homelab cloud. You can import libvirt xml files. +This app talks to your hypervisors via the virtigod daemon. ` } diff --git a/configfiles.go b/configfiles.go index 4ea72e0..220db76 100644 --- a/configfiles.go +++ b/configfiles.go @@ -84,12 +84,14 @@ func readConfigFile(filename string) error { } func writeConfigFile() { - test := time.Now().Format("YYYYMMDD-HH-MM") - if !writeConfigFileTmp("virtigo.json.new." + test) { - log.Println("config file write error") - os.Exit(-1) - } - if !writeConfigFileTmp("virtigo.json") { + // Get the current time + now := time.Now() + + // Format the time to match your desired format: YYYY.MM.DD.HHMMSS + timestamp := now.Format("2006.01.02.150405") + + filename := "virtigo.json.new." + timestamp + if !writeConfigFileTmp(filename) { log.Println("config file write error") os.Exit(-1) } @@ -101,10 +103,15 @@ func writeConfigFile() { log.Printf("rename fail: %s", err) os.Exit(-1) } + + if !writeConfigFileTmp("virtigo.json") { + log.Println("config file write error") + os.Exit(-1) + } } func writeConfigFileTmp(filename string) bool { - fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "virtigo.json") + fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), filename) cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666) defer cfgfile.Close() if err != nil {