src/Pure/System/linux.scala
changeset 71111 cd166c3904dd
parent 71108 783d5786255d
child 71114 6cfec8029831
equal deleted inserted replaced
71110:070a9b62f44a 71111:cd166c3904dd
   119   def service_disable(name: String) { service_operation("disable", name) }
   119   def service_disable(name: String) { service_operation("disable", name) }
   120   def service_start(name: String) { service_operation("start", name) }
   120   def service_start(name: String) { service_operation("start", name) }
   121   def service_stop(name: String) { service_operation("stop", name) }
   121   def service_stop(name: String) { service_operation("stop", name) }
   122   def service_restart(name: String) { service_operation("restart", name) }
   122   def service_restart(name: String) { service_operation("restart", name) }
   123 
   123 
       
   124   def service_shutdown(name: String)
       
   125   {
       
   126     try { service_stop(name) }
       
   127     catch { case ERROR(_) => }
       
   128   }
       
   129 
   124   def service_install(name: String, spec: String)
   130   def service_install(name: String, spec: String)
   125   {
   131   {
       
   132     service_shutdown(name)
       
   133 
   126     val service_file = Path.explode("/lib/systemd/system") + Path.basic(name).ext("service")
   134     val service_file = Path.explode("/lib/systemd/system") + Path.basic(name).ext("service")
   127     File.write(service_file, spec)
   135     File.write(service_file, spec)
   128     Isabelle_System.bash("chmod 0644 " + File.bash_path(service_file)).check
   136     Isabelle_System.bash("chmod 0644 " + File.bash_path(service_file)).check
   129 
   137 
   130     service_enable(name)
   138     service_enable(name)