docs(README): update installation instructions for various distributions
This commit is contained in:
@@ -13,11 +13,11 @@ const systemUnitTemplate = `# /etc/systemd/system/{{.ServiceName}}
|
||||
|
||||
[Unit]
|
||||
Description=Unitdore: {{.Unit.Name}} ({{.Unit.Runtime}})
|
||||
After=network.target
|
||||
After=network.target{{with .RuntimeService}} {{.}}
|
||||
Requires={{.}}{{end}}
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User={{.ServiceUser}}
|
||||
ExecStart={{.ExecStart}}
|
||||
ExecStop={{.ExecStop}}
|
||||
Restart=on-failure
|
||||
@@ -46,11 +46,11 @@ WantedBy=default.target
|
||||
`
|
||||
|
||||
type templateData struct {
|
||||
ServiceName string
|
||||
Unit config.Unit
|
||||
ExecStart string
|
||||
ExecStop string
|
||||
ServiceUser string
|
||||
ServiceName string
|
||||
Unit config.Unit
|
||||
ExecStart string
|
||||
ExecStop string
|
||||
RuntimeService string
|
||||
}
|
||||
|
||||
// ServiceName returns the systemd service name for a unit, with optional prefix/suffix.
|
||||
@@ -59,15 +59,15 @@ func ServiceName(u config.Unit, prefix, suffix string) string {
|
||||
}
|
||||
|
||||
// Generate produces the .service file content for a unit.
|
||||
func Generate(u config.Unit, prefix, suffix, serviceUser string) (string, error) {
|
||||
func Generate(u config.Unit, prefix, suffix string) (string, error) {
|
||||
execStart, execStop := buildExecCommands(u)
|
||||
|
||||
data := templateData{
|
||||
ServiceName: ServiceName(u, prefix, suffix),
|
||||
Unit: u,
|
||||
ExecStart: execStart,
|
||||
ExecStop: execStop,
|
||||
ServiceUser: serviceUser,
|
||||
ServiceName: ServiceName(u, prefix, suffix),
|
||||
Unit: u,
|
||||
ExecStart: execStart,
|
||||
ExecStop: execStop,
|
||||
RuntimeService: runtimeService(u.Runtime),
|
||||
}
|
||||
|
||||
tmplStr := systemUnitTemplate
|
||||
@@ -87,6 +87,15 @@ func Generate(u config.Unit, prefix, suffix, serviceUser string) (string, error)
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
||||
// runtimeService returns the systemd service name that must be running for the
|
||||
// given container runtime, or "" if none is required (e.g. daemonless podman).
|
||||
func runtimeService(runtime string) string {
|
||||
if runtime == "docker" {
|
||||
return "docker.service"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func buildExecCommands(u config.Unit) (start, stop string) {
|
||||
// If a custom command is provided, use it directly
|
||||
if u.Command != "" {
|
||||
|
||||
Reference in New Issue
Block a user