networkd: Create config directory before writing config

This commit is contained in:
Alex Crawford 2014-07-08 16:48:42 -07:00
parent c820f2b1cf
commit fe388a3ab6

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net" "net"
"os"
"os/exec" "os/exec"
"path" "path"
"strings" "strings"
@ -103,6 +104,8 @@ func writeConfig(filename string, config string) error {
if config == "" { if config == "" {
return nil return nil
} }
if err := os.MkdirAll(path.Dir(filename), 0755); err != nil {
return err
}
return ioutil.WriteFile(filename, []byte(config), 0444) return ioutil.WriteFile(filename, []byte(config), 0444)
} }