Browse Source

fix #5: only use group when specified in both dry-run and real templates

smaller-size
AJ ONeal 5 years ago
parent
commit
c78cd82059
  1. 2
      manager/dist/Library/LaunchDaemons/_rdns_.plist.tmpl
  2. 25
      manager/install_linux.go
  3. 6
      manager/static/ab0x.go

2
manager/dist/Library/LaunchDaemons/_rdns_.plist.tmpl

@ -27,6 +27,8 @@
{{if .User -}}
<key>UserName</key>
<string>{{ .User }}</string>
{{end -}}
{{if .Group -}}
<key>GroupName</key>
<string>{{ .Group }}</string>
<key>InitGroups</key>

25
manager/install_linux.go

@ -159,7 +159,10 @@ func stop(conf *service.Service) error {
return nil
}
// Render will create a systemd .service file using a simple the internal template
func Render(c *service.Service) ([]byte, error) {
defaultUserGroup(c)
// Create service file from template
b, err := static.ReadFile("dist/etc/systemd/system/_name_.service.tmpl")
if err != nil {
@ -181,15 +184,7 @@ func Render(c *service.Service) ([]byte, error) {
}
func install(c *service.Service) (string, error) {
// Linux-specific config options
if c.System {
if "" == c.User {
c.User = "root"
}
}
if "" == c.Group {
c.Group = c.User
}
defaultUserGroup(c)
// Check paths first
serviceDir := srvSysPath
@ -230,3 +225,15 @@ func install(c *service.Service) (string, error) {
return "systemd", nil
}
func defaultUserGroup(c *service.Service) {
// Linux-specific config options
if c.System {
if "" == c.User {
c.User = "root"
}
}
if "" == c.Group {
c.Group = c.User
}
}

6
manager/static/ab0x.go

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save