src/Pure/System/linux.scala
changeset 71111 cd166c3904dd
parent 71108 783d5786255d
child 71114 6cfec8029831
--- a/src/Pure/System/linux.scala	Wed Nov 13 17:34:35 2019 +0100
+++ b/src/Pure/System/linux.scala	Wed Nov 13 18:30:43 2019 +0100
@@ -121,8 +121,16 @@
   def service_stop(name: String) { service_operation("stop", name) }
   def service_restart(name: String) { service_operation("restart", name) }
 
+  def service_shutdown(name: String)
+  {
+    try { service_stop(name) }
+    catch { case ERROR(_) => }
+  }
+
   def service_install(name: String, spec: String)
   {
+    service_shutdown(name)
+
     val service_file = Path.explode("/lib/systemd/system") + Path.basic(name).ext("service")
     File.write(service_file, spec)
     Isabelle_System.bash("chmod 0644 " + File.bash_path(service_file)).check