freebsd: ensure config directory is created

Otherwise, freebsdService.Install will fail because config file could
not be created.

Fixes #359
This commit is contained in:
Cuong Manh Le
2023-02-15 23:25:29 +07:00
committed by Daniel Theophanes
parent 3596dfaf34
commit 9832e01049

View File

@@ -8,11 +8,13 @@ import (
"fmt"
"os"
"os/signal"
"path/filepath"
"syscall"
"text/template"
)
const version = "freebsd"
const configDir = "/usr/local/etc/rc.d"
type freebsdSystem struct{}
@@ -88,7 +90,11 @@ func (s *freebsdService) template() *template.Template {
}
func (s *freebsdService) configPath() (cp string, err error) {
cp = "/usr/local/etc/rc.d/" + s.Config.Name
if oserr := os.MkdirAll(configDir, 0755); oserr != nil {
err = oserr
return
}
cp = filepath.Join(configDir, s.Config.Name)
return
}