src/Pure/Tools/phabricator.scala
changeset 71051 4eeff87c5072
parent 71050 8198ceef0301
child 71052 6bf53035baf0
equal deleted inserted replaced
71050:8198ceef0301 71051:4eeff87c5072
   164       """).check
   164       """).check
   165 
   165 
   166     val config = Config(name, root_path)
   166     val config = Config(name, root_path)
   167     write_config(configs ::: List(config))
   167     write_config(configs ::: List(config))
   168 
   168 
       
   169     config.execute("config set pygments.enabled true")
       
   170 
   169 
   171 
   170     /* local repository directory */
   172     /* local repository directory */
   171 
   173 
   172     if (!Isabelle_System.bash("mkdir -p " + File.bash_path(repo_path)).ok) {
   174     if (!Isabelle_System.bash("mkdir -p " + File.bash_path(repo_path)).ok) {
   173       error("Failed to create local repository directory " + repo_path)
   175       error("Failed to create local repository directory " + repo_path)
   185 
   187 
   186     /* MySQL setup */
   188     /* MySQL setup */
   187 
   189 
   188     progress.echo("MySQL setup...")
   190     progress.echo("MySQL setup...")
   189 
   191 
       
   192     File.write(Path.explode("/etc/mysql/mysql.conf.d/phabricator.cnf"),
       
   193 """[mysqld]
       
   194 max_allowed_packet = 32M
       
   195 innodb_buffer_pool_size = 1600M
       
   196 local_infile = 0
       
   197 """)
       
   198 
       
   199     Linux.service_restart("mysql")
       
   200 
       
   201 
   190     def mysql_conf(R: Regex): Option[String] =
   202     def mysql_conf(R: Regex): Option[String] =
   191       split_lines(File.read(Path.explode(options.string("phabricator_mysql_config")))).
   203       split_lines(File.read(Path.explode(options.string("phabricator_mysql_config")))).
   192         collectFirst({ case R(a) => a })
   204         collectFirst({ case R(a) => a })
   193 
   205 
   194     for (user <- mysql_conf("""^user\s*=\s*(\S*)\s*$""".r)) {
   206     for (user <- mysql_conf("""^user\s*=\s*(\S*)\s*$""".r)) {
   199       config.execute("config set mysql.pass " + Bash.string(pass))
   211       config.execute("config set mysql.pass " + Bash.string(pass))
   200     }
   212     }
   201 
   213 
   202     config.execute("config set storage.default-namespace " +
   214     config.execute("config set storage.default-namespace " +
   203       Bash.string(prefix_name.replace("-", "_")))
   215       Bash.string(prefix_name.replace("-", "_")))
       
   216 
       
   217     config.execute("config set storage.mysql-engine.max-size 8388608")
   204 
   218 
   205     config.execute("storage upgrade --force")
   219     config.execute("storage upgrade --force")
   206 
   220 
   207 
   221 
   208     /* PHP daemon */
   222     /* PHP daemon */
   245       name + " ALL=(" + daemon_user + ") SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack, /usr/bin/hg, /usr/bin/svnserve, /usr/bin/ssh, /usr/bin/id\n")
   259       name + " ALL=(" + daemon_user + ") SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack, /usr/bin/hg, /usr/bin/svnserve, /usr/bin/ssh, /usr/bin/id\n")
   246 
   260 
   247     Isabelle_System.bash("chmod 0440 " + File.bash_path(sudoers_file)).check
   261     Isabelle_System.bash("chmod 0440 " + File.bash_path(sudoers_file)).check
   248 
   262 
   249 
   263 
       
   264     /* PHP setup */
       
   265 
       
   266     val php_version =
       
   267       Isabelle_System.bash("""php --run 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;'""")
       
   268         .check.out
       
   269 
       
   270     val php_conf =
       
   271       Path.explode("/etc/php") + Path.basic(php_version) +  // educated guess
       
   272         Path.explode("apache2/conf.d/phabricator.ini")
       
   273 
       
   274     File.write(php_conf,
       
   275       "post_max_size = 32M\n" +
       
   276       "opcache.validate_timestamps = 0\n" +
       
   277       "memory_limit = 512M\n")
       
   278 
       
   279 
   250     /* Apache setup */
   280     /* Apache setup */
   251 
   281 
   252     progress.echo("Apache setup...")
   282     progress.echo("Apache setup...")
   253 
   283 
   254     val apache_root = Path.explode(options.string("phabricator_apache_root"))
   284     val apache_root = Path.explode(options.string("phabricator_apache_root"))
   269 </VirtualHost>
   299 </VirtualHost>
   270 
   300 
   271 # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
   301 # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
   272 """)
   302 """)
   273 
   303 
   274     Isabelle_System.bash("""
   304     Isabelle_System.bash( """
   275       set -e
   305       set -e
   276       a2enmod rewrite
   306       a2enmod rewrite
   277       a2ensite """ + Bash.string(prefix_name) + """
   307       a2ensite """ + Bash.string(prefix_name)).check
   278       systemctl restart apache2
   308 
   279 """).check
   309     Linux.service_restart("apache2")
   280 
   310 
   281     progress.echo("\nDONE\nWeb configuration via http://" + prefix_name + ".lvh.me")
   311     progress.echo("\nDONE\nWeb configuration via http://" + prefix_name + ".lvh.me")
   282   }
   312   }
   283 
   313 
   284 
   314