Skip to content

Commit 9832e01

Browse files
cuonglmkardianos
authored andcommitted
freebsd: ensure config directory is created
Otherwise, freebsdService.Install will fail because config file could not be created. Fixes #359
1 parent 3596dfa commit 9832e01

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

service_freebsd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import (
88
"fmt"
99
"os"
1010
"os/signal"
11+
"path/filepath"
1112
"syscall"
1213
"text/template"
1314
)
1415

1516
const version = "freebsd"
17+
const configDir = "/usr/local/etc/rc.d"
1618

1719
type freebsdSystem struct{}
1820

@@ -88,7 +90,11 @@ func (s *freebsdService) template() *template.Template {
8890
}
8991

9092
func (s *freebsdService) configPath() (cp string, err error) {
91-
cp = "/usr/local/etc/rc.d/" + s.Config.Name
93+
if oserr := os.MkdirAll(configDir, 0755); oserr != nil {
94+
err = oserr
95+
return
96+
}
97+
cp = filepath.Join(configDir, s.Config.Name)
9298
return
9399
}
94100

0 commit comments

Comments
 (0)