Ensure config directory is created.
This commit is contained in:
parent
56c843cfc1
commit
7a4fc3491a
16
config.go
16
config.go
@ -112,6 +112,14 @@ func ConfigPath() (fileDir, fileName string) {
|
|||||||
if flags.ConfigPath != "" {
|
if flags.ConfigPath != "" {
|
||||||
fileDir, fileName = filepath.Split(flags.ConfigPath)
|
fileDir, fileName = filepath.Split(flags.ConfigPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify directory exists.
|
||||||
|
if _, ferr := os.Stat(fileDir); ferr != nil {
|
||||||
|
err := os.MkdirAll(fileDir, 0755)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Failed to make directory:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,14 +489,6 @@ func SaveConfig() error {
|
|||||||
// Find the file name.
|
// Find the file name.
|
||||||
fileDir, fileName := ConfigPath()
|
fileDir, fileName := ConfigPath()
|
||||||
|
|
||||||
// Verify directory exists.
|
|
||||||
if _, ferr := os.Stat(fileDir); ferr != nil {
|
|
||||||
err = os.MkdirAll(fileDir, 0755)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Failed to make directory:", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the configuration file.
|
// Write the configuration file.
|
||||||
err = os.WriteFile(filepath.Join(fileDir, fileName), data, 0644)
|
err = os.WriteFile(filepath.Join(fileDir, fileName), data, 0644)
|
||||||
return err
|
return err
|
||||||
|
2
main.go
2
main.go
@ -6,7 +6,7 @@ const (
|
|||||||
serviceDisplayName = "Virtual VXLAN"
|
serviceDisplayName = "Virtual VXLAN"
|
||||||
serviceVendor = "com.mrgeckosmedia"
|
serviceVendor = "com.mrgeckosmedia"
|
||||||
serviceDescription = "Virtual VXLAN using TUN interfaces"
|
serviceDescription = "Virtual VXLAN using TUN interfaces"
|
||||||
serviceVersion = "0.1.5"
|
serviceVersion = "0.1.6"
|
||||||
defaultConfigFile = "config.yaml"
|
defaultConfigFile = "config.yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user