src/Pure/Tools/phabricator.scala
changeset 71295 6aadbd650280
parent 71292 8b745b4d71b5
child 71299 51c19a44cfed
equal deleted inserted replaced
71294:aba1f84a7160 71295:6aadbd650280
   704   /* phabricator_setup_ssh */
   704   /* phabricator_setup_ssh */
   705 
   705 
   706   def phabricator_setup_ssh(
   706   def phabricator_setup_ssh(
   707     server_port: Int = default_server_port,
   707     server_port: Int = default_server_port,
   708     system_port: Int = default_system_port,
   708     system_port: Int = default_system_port,
   709     test_server: Boolean = false,
       
   710     progress: Progress = No_Progress)
   709     progress: Progress = No_Progress)
   711   {
   710   {
   712     Linux.check_system_root()
   711     Linux.check_system_root()
   713 
   712 
   714     val configs = read_config()
   713     val configs = read_config()
   783 
   782 
   784     for (config <- configs) {
   783     for (config <- configs) {
   785       progress.echo("phabricator " + quote(config.name) + " port " +  server_port)
   784       progress.echo("phabricator " + quote(config.name) + " port " +  server_port)
   786       config.execute("config set diffusion.ssh-port " + Bash.string(server_port.toString))
   785       config.execute("config set diffusion.ssh-port " + Bash.string(server_port.toString))
   787       if (server_port == 22) config.execute("config delete diffusion.ssh-port")
   786       if (server_port == 22) config.execute("config delete diffusion.ssh-port")
   788 
       
   789       if (test_server) {
       
   790         progress.bash(
       
   791           """unset DISPLAY
       
   792           echo "{}" | ssh -p """ + Bash.string(server_port.toString) +
       
   793           " -o StrictHostKeyChecking=false " +
       
   794           Bash.string(config.name) + """@localhost conduit conduit.ping""").print
       
   795       }
       
   796     }
   787     }
   797   }
   788   }
   798 
   789 
   799 
   790 
   800   /* Isabelle tool wrapper */
   791   /* Isabelle tool wrapper */
   803     Isabelle_Tool("phabricator_setup_ssh",
   794     Isabelle_Tool("phabricator_setup_ssh",
   804       "setup ssh service for all Phabricator installations", args =>
   795       "setup ssh service for all Phabricator installations", args =>
   805     {
   796     {
   806       var server_port = default_server_port
   797       var server_port = default_server_port
   807       var system_port = default_system_port
   798       var system_port = default_system_port
   808       var test_server = false
       
   809 
   799 
   810       val getopts =
   800       val getopts =
   811         Getopts("""
   801         Getopts("""
   812 Usage: isabelle phabricator_setup_ssh [OPTIONS]
   802 Usage: isabelle phabricator_setup_ssh [OPTIONS]
   813 
   803 
   814   Options are:
   804   Options are:
   815     -p PORT      sshd port for Phabricator servers (default: """ + default_server_port + """)
   805     -p PORT      sshd port for Phabricator servers (default: """ + default_server_port + """)
   816     -q PORT      sshd port for the operating system (default: """ + default_system_port + """)
   806     -q PORT      sshd port for the operating system (default: """ + default_system_port + """)
   817     -T           test the ssh service for each Phabricator installation
       
   818 
   807 
   819   Configure ssh service for all Phabricator installations: a separate sshd
   808   Configure ssh service for all Phabricator installations: a separate sshd
   820   is run in addition to the one of the operating system, and ports need to
   809   is run in addition to the one of the operating system, and ports need to
   821   be distinct.
   810   be distinct.
   822 
   811 
   823   A particular Phabricator installation is addressed by using its
   812   A particular Phabricator installation is addressed by using its
   824   name as the ssh user; the actual Phabricator user is determined via
   813   name as the ssh user; the actual Phabricator user is determined via
   825   stored ssh keys.
   814   stored ssh keys.
   826 """,
   815 """,
   827           "p:" -> (arg => server_port = Value.Int.parse(arg)),
   816           "p:" -> (arg => server_port = Value.Int.parse(arg)),
   828           "q:" -> (arg => system_port = Value.Int.parse(arg)),
   817           "q:" -> (arg => system_port = Value.Int.parse(arg)))
   829           "T" -> (_ => test_server = true))
       
   830 
   818 
   831       val more_args = getopts(args)
   819       val more_args = getopts(args)
   832       if (more_args.nonEmpty) getopts.usage()
   820       if (more_args.nonEmpty) getopts.usage()
   833 
   821 
   834       val progress = new Console_Progress
   822       val progress = new Console_Progress
   835 
   823 
   836       phabricator_setup_ssh(
   824       phabricator_setup_ssh(
   837         server_port = server_port, system_port = system_port, test_server = test_server,
   825         server_port = server_port, system_port = system_port, progress = progress)
   838         progress = progress)
       
   839     })
   826     })
   840 }
   827 }