|
|
@ -27,11 +27,17 @@ func LoadConfig(path string) (*Config, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func CreateConfig(path string, cfg *Config) {
|
|
|
|
func CreateConfig(path string, cfg *Config) {
|
|
|
|
|
|
|
|
err := os.MkdirAll(filepath.Dir(path), 0755)
|
|
|
|
|
|
|
|
Check(err, "Failed to make directories for %q, err: %s", path, err)
|
|
|
|
conf, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
|
|
|
|
conf, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
|
|
|
|
Check(err, "Couldn't open %q, err: %s", path, err)
|
|
|
|
Check(err, "Couldn't open %q, err: %s", path, err)
|
|
|
|
encoder := toml.NewEncoder(conf)
|
|
|
|
encoder := toml.NewEncoder(conf)
|
|
|
|
log.Printf("ZeroooConfig: %#v", cfg)
|
|
|
|
log.Printf("ZeroooConfig: %#v", cfg)
|
|
|
|
err = encoder.Encode(cfg)
|
|
|
|
err = encoder.Encode(cfg)
|
|
|
|
|
|
|
|
if cfg.Zerooo.Location == "" {
|
|
|
|
|
|
|
|
cfg.Zerooo.Location = "/etc/zerooo"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if cfg.Zerooo.Location[0] != '/' {
|
|
|
|
if cfg.Zerooo.Location[0] != '/' {
|
|
|
|
cfg.Zerooo.Location = filepath.Join(filepath.Dir(path), cfg.Zerooo.Location)
|
|
|
|
cfg.Zerooo.Location = filepath.Join(filepath.Dir(path), cfg.Zerooo.Location)
|
|
|
|
}
|
|
|
|
}
|
|
|
|