Update launchd template (#346)
* Update XML prolog and DTD Also converts single-quotes to double-quotes * Remove whitespace from parent dict * Only populate EnvironmentVariables when available * Only add additional arguments when defined Also cleans up whitespace around each argument * Cleanup whitespace and only populate when defined * Convert remaining spaces to tabs * Sort keys. Similar to `plutil -convert xml1`
This commit is contained in:
+37
-25
@@ -290,46 +290,58 @@ func (s *darwinLaunchdService) SystemLogger(errs chan<- error) (Logger, error) {
|
||||
return newSysLogger(s.Name, errs)
|
||||
}
|
||||
|
||||
var launchdConfig = `<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
|
||||
<plist version='1.0'>
|
||||
var launchdConfig = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Disabled</key>
|
||||
<false/>
|
||||
{{- if .EnvVars}}
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
{{range $k, $v := .EnvVars -}}
|
||||
{{- range $k, $v := .EnvVars}}
|
||||
<key>{{html $k}}</key>
|
||||
<string>{{html $v}}</string>
|
||||
{{end -}}
|
||||
{{- end}}
|
||||
</dict>
|
||||
{{- end}}
|
||||
<key>KeepAlive</key>
|
||||
<{{bool .KeepAlive}}/>
|
||||
<key>Label</key>
|
||||
<string>{{html .Name}}</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>{{html .Path}}</string>
|
||||
{{range .Config.Arguments}}
|
||||
{{- if .Config.Arguments}}
|
||||
{{- range .Config.Arguments}}
|
||||
<string>{{html .}}</string>
|
||||
{{end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
</array>
|
||||
{{if .UserName}}<key>UserName</key>
|
||||
<string>{{html .UserName}}</string>{{end}}
|
||||
{{if .ChRoot}}<key>RootDirectory</key>
|
||||
<string>{{html .ChRoot}}</string>{{end}}
|
||||
{{if .WorkingDirectory}}<key>WorkingDirectory</key>
|
||||
<string>{{html .WorkingDirectory}}</string>{{end}}
|
||||
<key>SessionCreate</key>
|
||||
<{{bool .SessionCreate}}/>
|
||||
<key>KeepAlive</key>
|
||||
<{{bool .KeepAlive}}/>
|
||||
{{- if .ChRoot}}
|
||||
<key>RootDirectory</key>
|
||||
<string>{{html .ChRoot}}</string>
|
||||
{{- end}}
|
||||
<key>RunAtLoad</key>
|
||||
<{{bool .RunAtLoad}}/>
|
||||
<key>Disabled</key>
|
||||
<false/>
|
||||
|
||||
{{if .StandardOutPath}}<key>StandardOutPath</key>
|
||||
<string>{{html .StandardOutPath}}</string>{{end}}
|
||||
{{if .StandardErrorPath}}<key>StandardErrorPath</key>
|
||||
<string>{{html .StandardErrorPath}}</string>{{end}}
|
||||
<key>SessionCreate</key>
|
||||
<{{bool .SessionCreate}}/>
|
||||
{{- if .StandardErrorPath}}
|
||||
<key>StandardErrorPath</key>
|
||||
<string>{{html .StandardErrorPath}}</string>
|
||||
{{- end}}
|
||||
{{- if .StandardOutPath}}
|
||||
<key>StandardOutPath</key>
|
||||
<string>{{html .StandardOutPath}}</string>
|
||||
{{- end}}
|
||||
{{- if .UserName}}
|
||||
<key>UserName</key>
|
||||
<string>{{html .UserName}}</string>
|
||||
{{- end}}
|
||||
{{- if .WorkingDirectory}}
|
||||
<key>WorkingDirectory</key>
|
||||
<string>{{html .WorkingDirectory}}</string>
|
||||
{{- end}}
|
||||
</dict>
|
||||
</plist>
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user