Skip to content

Commit

Permalink
freebsd: ensure config directory is created
Browse files Browse the repository at this point in the history
Otherwise, freebsdService.Install will fail because config file could
not be created.

Fixes #359
  • Loading branch information
cuonglm authored and kardianos committed Feb 15, 2023
1 parent 3596dfa commit 9832e01
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion service_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 9832e01

Please sign in to comment.