110 } |
110 } |
111 |
111 |
112 |
112 |
113 /* system services */ |
113 /* system services */ |
114 |
114 |
115 def service_start(name: String): Unit = |
115 def service_operation(op: String, name: String): Unit = |
116 Isabelle_System.bash("systemctl start " + Bash.string(name)).check |
116 Isabelle_System.bash("systemctl " + Bash.string(op) + " " + Bash.string(name)).check |
117 |
117 |
118 def service_stop(name: String): Unit = |
118 def service_enable(name: String) { service_operation("enable", name) } |
119 Isabelle_System.bash("systemctl stop " + Bash.string(name)).check |
119 def service_disable(name: String) { service_operation("disable", name) } |
120 |
120 def service_start(name: String) { service_operation("start", name) } |
121 def service_restart(name: String): Unit = |
121 def service_stop(name: String) { service_operation("stop", name) } |
122 Isabelle_System.bash("systemctl restart " + Bash.string(name)).check |
122 def service_restart(name: String) { service_operation("restart", name) } |
123 |
123 |
124 def service_install(name: String, spec: String) |
124 def service_install(name: String, spec: String) |
125 { |
125 { |
126 val service_file = Path.explode("/lib/systemd/system") + Path.basic(name).ext("service") |
126 val service_file = Path.explode("/lib/systemd/system") + Path.basic(name).ext("service") |
127 File.write(service_file, spec) |
127 File.write(service_file, spec) |
|
128 Isabelle_System.bash("chmod 0644 " + File.bash_path(service_file)).check |
128 |
129 |
129 Isabelle_System.bash(""" |
130 service_enable(name) |
130 set -e |
131 service_start(name) |
131 chmod 0644 """ + File.bash_path(service_file) + """ |
|
132 systemctl enable """ + Bash.string(name) + """ |
|
133 systemctl start """ + Bash.string(name)).check |
|
134 } |
132 } |
135 } |
133 } |