Added a makefile and specifying the config path, added a backup path at /etc/burgerbackup/<server / client>.ini as well as a --help document.

This commit is contained in:
Tracker-Friendly 2024-07-13 10:30:35 +01:00
parent 130fe0258d
commit 84e3071a25
4 changed files with 71 additions and 9 deletions

View File

@ -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:**

24
Makefile Normal file
View File

@ -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)

View File

@ -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 </path/to/config/file>")
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()

View File

@ -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 </path/to/config/file>")
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()