# HG changeset patch # User wenzelm # Date 1572968879 -3600 # Node ID 5f02ecbb19d6a140b734492e495fe285d00b7cfc # Parent 87c132cf5860e3b4b9440ff744769417fd164826 support for system services; diff -r 87c132cf5860 -r 5f02ecbb19d6 src/Pure/System/linux.scala --- a/src/Pure/System/linux.scala Tue Nov 05 14:28:00 2019 +0100 +++ b/src/Pure/System/linux.scala Tue Nov 05 16:47:59 2019 +0100 @@ -104,4 +104,25 @@ """).check } } + + + /* system services */ + + def service_start(name: String): Unit = + Isabelle_System.bash("systemctl start " + Bash.string(name)).check + + def service_stop(name: String): Unit = + Isabelle_System.bash("systemctl stop " + Bash.string(name)).check + + def service_install(name: String, spec: String) + { + val service_file = Path.explode("/lib/systemd/system") + Path.basic(name).ext("service") + File.write(service_file, spec) + + Isabelle_System.bash(""" + set -e + chmod 0644 """ + File.bash_path(service_file) + """ + systemctl enable """ + Bash.string(name) + """ + systemctl start """ + Bash.string(name)).check + } }