diff --git a/LICENSE.md b/LICENSE.md index f906faa..99b603b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -19,12 +19,12 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of 3. **Distribution Conditions:** - You may not include the Software as a whole or in part in any other software not listed in the compatible licenses without prior permission from the author. - - If included in incompatible software, it must be distributed independently of the software it is included in, listed on a publicly-accessible website, or have the option for the software to be sent, free of charge, by physical media. It cannot be considered a part of the software it is included in. - - The original license must be included in the software, or a hyperlink to the original license must be provided in the software's documentation or website. It is your responsibility to ensure this hyperlink remains valid. + - If included in incompatible software, it must be distributed independently of the software it is included in, listed on a publicly-accessible website, or have the option for the software to be sent, free of charge, by physical media. It cannot be considered a part of the software it is 4. **Commercial Use:** - All rules set in the Distribution Conditions section apply to commercial use. - - You may not sell the Software or any software derived from it without prior permission from the copyright holder of the original Software and all authors of any derivatives. + - You may not sell the Software or any software derived from it without prior permission from the copyright holder of the original Software and all authors of any derivatives. included in. + - The original license must be included in the software, or a hyperlink to the original license must be provided in the software's documentation or website. It is your responsibility to ensure this hyperlink remains valid. - If included in sold software, it must be distributed independently of the software it is included in, listed on a publicly-accessible website, or have the option for the software to be sent, free of charge, by physical media. It cannot be considered a part of the software it is included in. 5. **Disclaimer:** diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8fb9ad1 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +DESTDIR ?= /usr +BUILDDIR ?= dist + +all: client server + +client ./bin/client/main.go: + mkdir -p $(BUILDDIR)/bin/ + go build -o $(BUILDDIR)/bin/client ./bin/client/main.go + +server ./bin/server/main.go: + mkdir -p $(BUILDDIR)/bin/ + go build -o $(BUILDDIR)/bin/server ./bin/server/main.go + +install: + install -d $(DESTDIR)/bin + install -m 755 $(BUILDDIR)/bin/client $(DESTDIR)/bin/burgerbackup-client + install -m 755 $(BUILDDIR)/bin/server $(DESTDIR)/bin/burgerbackup-server + +uninstall: + rm -f $(DESTDIR)/bin/burgerbackup-client + rm -f $(DESTDIR)/bin/burgerbackup-server + +clean: + rm -rf $(BUILDDIR) \ No newline at end of file diff --git a/bin/client/main.go b/bin/client/main.go index 7f324f0..8670edf 100644 --- a/bin/client/main.go +++ b/bin/client/main.go @@ -10,15 +10,34 @@ import ( ) func main() { - if _, err := os.Stat("config.ini"); err == nil { + var configPath = "./config.ini" + if len(os.Args) > 1 { + if os.Args[1] == "-h" || os.Args[1] == "--help" { + log.Println("[INFO] Usage: burgerbackup-client ") + os.Exit(0) + } else { + configPath = os.Args[1] + } + } + + if _, err := os.Stat(configPath); err == nil { log.Println("[INFO] Config loaded at", time.Now().Unix()) } else if os.IsNotExist(err) { - log.Fatalln("[FATAL] config.ini does not exist") + originalConfigPath := configPath + configPath = "/etc/burgerbackup/client.ini" + if _, err := os.Stat(configPath); err == nil { + log.Println("[INFO] Config loaded at", time.Now().Unix()) + log.Println("[WARN] The config file was not found at", originalConfigPath, "so the default config path of", configPath, "was used.") + } else if os.IsNotExist(err) { + log.Fatalln("[FATAL]", originalConfigPath, "does not exist") + } else { + log.Fatalln("[FATAL] File is in quantum uncertainty:", err) + } } else { log.Fatalln("[FATAL] File is in quantum uncertainty:", err) } - viper.SetConfigName("config") + viper.SetConfigName(configPath) viper.AddConfigPath("./") viper.AutomaticEnv() diff --git a/bin/server/main.go b/bin/server/main.go index 3bec8c7..f46f024 100644 --- a/bin/server/main.go +++ b/bin/server/main.go @@ -17,15 +17,34 @@ import ( ) func main() { - if _, err := os.Stat("config.ini"); err == nil { + var configPath = "./config.ini" + if len(os.Args) > 1 { + if os.Args[1] == "-h" || os.Args[1] == "--help" { + log.Println("[INFO] Usage: burgerbackup-client ") + os.Exit(0) + } else { + configPath = os.Args[1] + } + } + + if _, err := os.Stat(configPath); err == nil { log.Println("[INFO] Config loaded at", time.Now().Unix()) } else if os.IsNotExist(err) { - log.Fatalln("[FATAL] config.ini does not exist") + originalConfigPath := configPath + configPath = "/etc/burgerbackup/server.ini" + if _, err := os.Stat(configPath); err == nil { + log.Println("[INFO] Config loaded at", time.Now().Unix()) + log.Println("[WARN] The config file was not found at", originalConfigPath, "so the default config path of", configPath, "was used.") + } else if os.IsNotExist(err) { + log.Fatalln("[FATAL]", originalConfigPath, "does not exist") + } else { + log.Fatalln("[FATAL] File is in quantum uncertainty:", err) + } } else { log.Fatalln("[FATAL] File is in quantum uncertainty:", err) } - viper.SetConfigName("config") + viper.SetConfigName(configPath) viper.AddConfigPath("./") viper.AutomaticEnv()