Ensure config directory is created.

This commit is contained in:
GRMrGecko 2025-01-08 09:40:06 -06:00
parent 56c843cfc1
commit 7a4fc3491a
2 changed files with 9 additions and 9 deletions

View File

@ -112,6 +112,14 @@ func ConfigPath() (fileDir, fileName string) {
if 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
}
@ -481,14 +489,6 @@ func SaveConfig() error {
// Find the file name.
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.
err = os.WriteFile(filepath.Join(fileDir, fileName), data, 0644)
return err

View File

@ -6,7 +6,7 @@ const (
serviceDisplayName = "Virtual VXLAN"
serviceVendor = "com.mrgeckosmedia"
serviceDescription = "Virtual VXLAN using TUN interfaces"
serviceVersion = "0.1.5"
serviceVersion = "0.1.6"
defaultConfigFile = "config.yaml"
)