more robust: system ssh service is required for Phabricator ssh service;
authorwenzelm
Wed, 13 Nov 2019 18:30:43 +0100
changeset 71111 cd166c3904dd
parent 71110 070a9b62f44a
child 71112 eed5b6188371
more robust: system ssh service is required for Phabricator ssh service;
src/Pure/System/linux.scala
src/Pure/Tools/phabricator.scala
--- 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
--- a/src/Pure/Tools/phabricator.scala	Wed Nov 13 17:34:35 2019 +0100
+++ b/src/Pure/Tools/phabricator.scala	Wed Nov 13 18:30:43 2019 +0100
@@ -569,14 +569,16 @@
     val ssh_name = isabelle_phabricator_name(name = "ssh")
     val ssh_command = Path.explode("/usr/local/bin") + Path.basic(ssh_name)
 
+    Linux.service_shutdown(ssh_name)
+
     val old_system_port = read_ssh_port(sshd_conf_system)
     if (old_system_port != system_port) {
       progress.echo("Reconfigurig system ssh service")
-      Linux.service_stop("ssh")
+      Linux.service_shutdown("ssh")
       write_ssh_port(sshd_conf_system, system_port)
+      Linux.service_start("ssh")
     }
 
-
     progress.echo("Configuring " + ssh_name + " service")
 
     File.write(ssh_command,
@@ -651,11 +653,6 @@
           Bash.string(config.name) + """@localhost conduit conduit.ping""").print
       }
     }
-
-    if (old_system_port != system_port) {
-      progress.echo("Restarting system ssh service")
-      Linux.service_start("ssh")
-    }
   }