Apache setup;
authorwenzelm
Wed, 30 Oct 2019 19:23:01 +0100
changeset 70968 46847076477c
parent 70967 79736ffe77c3
child 70969 a48112873f81
Apache setup; proper "-" for URL: avoid problems with "_";
etc/options
src/Pure/Tools/phabricator.scala
--- a/etc/options	Wed Oct 30 15:50:57 2019 +0100
+++ b/etc/options	Wed Oct 30 19:23:01 2019 +0100
@@ -350,6 +350,8 @@
 option phabricator_www_user : string = "www-data"
 option phabricator_www_root : string = "/var/www"
 
+option phabricator_apache_root : string = "/etc/apache2"
+
 option phabricator_smtp_host : string = ""
 option phabricator_smtp_port : int = 465
 option phabricator_smtp_user : string = ""
--- a/src/Pure/Tools/phabricator.scala	Wed Oct 30 15:50:57 2019 +0100
+++ b/src/Pure/Tools/phabricator.scala	Wed Oct 30 19:23:01 2019 +0100
@@ -15,7 +15,7 @@
 
   val default_name = "vcs"
 
-  def default_prefix(name: String): String = "phabricator_" + name
+  def default_prefix(name: String): String = "phabricator-" + name
 
   def default_root(options: Options, name: String): Path =
     Path.explode(options.string("phabricator_www_root")) + Path.basic(default_prefix(name))
@@ -36,6 +36,9 @@
   val global_config = Path.explode("/etc/isabelle-phabricator.conf")
 
   sealed case class Config(name: String, root: Path)
+  {
+    def www_root: Path = root + Path.explode("phabricator/webroot")
+  }
 
   def read_config(): List[Config] =
   {
@@ -113,6 +116,40 @@
 
     val config = Config(name, root_path)
     write_config(configs ::: List(config))
+
+
+    /* Apache setup */
+
+    progress.echo("Apache setup...")
+
+    val apache_root = Path.explode(options.string("phabricator_apache_root"))
+    val apache_sites = apache_root + Path.explode("sites-available")
+
+    if (!apache_sites.is_dir) error("Bad Apache sites directory " + apache_sites)
+
+    File.write(apache_sites + Path.basic(prefix_name + ".conf"),
+"""<VirtualHost *:80>
+    #ServerName: "lvh.me" is an alias for "localhost" for testing
+    ServerName """ + prefix_name + """.lvh.me
+    ServerAdmin webmaster@localhost
+    DocumentRoot """ + config.www_root.implode + """
+
+    ErrorLog ${APACHE_LOG_DIR}/error.log
+    RewriteEngine on
+    RewriteRule ^(.*)$  /index.php?__path__=$1  [B,L,QSA]
+</VirtualHost>
+
+# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
+""")
+
+    Isabelle_System.bash("""
+      set -e
+      a2enmod rewrite
+      a2ensite """ + Bash.string(prefix_name) + """
+      systemctl restart apache2
+""").check
+
+    progress.echo("\nDONE\nWeb configuration via http://" + prefix_name + ".lvh.me")
   }