WIP tested linux system installer
This commit is contained in:
parent
fb4f0c5a69
commit
c9b6fd62a0
|
@ -1,16 +1,15 @@
|
|||
# Pre-req
|
||||
# sudo mkdir -p {{ .Local }}/opt/{{ .Name }}/ {{ .Local }}/var/log/{{ .Name }}
|
||||
{{ if not .Local -}}
|
||||
{{ if .User -}}
|
||||
{{- if and .User ( ne "root" .User ) -}}
|
||||
# sudo adduser {{ .User }} --home /opt/{{ .Name }}
|
||||
# sudo chown -R {{ .User }}:{{ .Group }} /opt/{{ .Name }}/ /var/log/{{ .Name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{ end -}}
|
||||
# Post-install
|
||||
# sudo systemctl {{ if .Local -}} --user {{- end }} daemon-reload
|
||||
# sudo systemctl {{ if .Local -}} --user {{- end }} restart {{ .Name }}.service
|
||||
# sudo journalctl {{ if .Local -}} --user {{- end }} -xefu {{ .Name }}
|
||||
# sudo systemctl {{ if .Local -}} --user {{ end -}} daemon-reload
|
||||
# sudo systemctl {{ if .Local -}} --user {{ end -}} restart {{ .Name }}.service
|
||||
# sudo journalctl {{ if .Local -}} --user {{ end -}} -xefu {{ .Name }}
|
||||
|
||||
[Unit]
|
||||
Description={{ .Title }} - {{ .Desc }}
|
||||
|
|
|
@ -32,7 +32,7 @@ func install(c *Config) error {
|
|||
// https://wiki.archlinux.org/index.php/Systemd/User
|
||||
serviceDir = filepath.Join(c.home, ".local/share/systemd/user")
|
||||
}
|
||||
err = os.MkdirAll(filepath.Dir(serviceDir), 0750)
|
||||
err := os.MkdirAll(filepath.Dir(serviceDir), 0750)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
@ -59,7 +59,18 @@ func install(c *Config) error {
|
|||
if err := ioutil.WriteFile(servicePath, rw.Bytes(), 0644); err != nil {
|
||||
return fmt.Errorf("ioutil.WriteFile error: %v", err)
|
||||
}
|
||||
fmt.Printf("Wrote %q\n", servicePath)
|
||||
|
||||
// TODO template this as well?
|
||||
userspace := ""
|
||||
sudo := "sudo "
|
||||
if !c.System {
|
||||
userspace = "--user "
|
||||
sudo = ""
|
||||
}
|
||||
fmt.Printf("System service installed as '%s'.\n", servicePath)
|
||||
fmt.Printf("Run the following to start '%s':\n", c.Name)
|
||||
fmt.Printf("\t" + sudo + "systemctl " + userspace + "daemon-reload\n")
|
||||
fmt.Printf("\t"+sudo+"systemctl "+userspace+"restart %s.service\n", c.Name)
|
||||
fmt.Printf("\t"+sudo+"journalctl "+userspace+"-xefu %s\n", c.Name)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue