equal
deleted
inserted
replaced
69 /** global configuration **/ |
69 /** global configuration **/ |
70 |
70 |
71 val global_config = Path.explode("/etc/" + isabelle_phabricator_name(ext = "conf")) |
71 val global_config = Path.explode("/etc/" + isabelle_phabricator_name(ext = "conf")) |
72 |
72 |
73 def global_config_script( |
73 def global_config_script( |
74 header: Boolean = false, |
|
75 init: String = "", |
74 init: String = "", |
76 body: String = "", |
75 body: String = "", |
77 exit: String = ""): String = |
76 exit: String = ""): String = |
78 { |
77 { |
79 (if (header) "#!/bin/bash\n" else "") + |
78 """#!/bin/bash |
80 """ |
79 |
81 {""" + (if (init.nonEmpty) "\n" + Library.prefix_lines(" ", init) else "") + """ |
80 {""" + (if (init.nonEmpty) "\n" + Library.prefix_lines(" ", init) else "") + """ |
82 while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; } |
81 while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; } |
83 do |
82 do |
84 NAME="$(echo "$REPLY" | cut -d: -f1)" |
83 NAME="$(echo "$REPLY" | cut -d: -f1)" |
85 ROOT="$(echo "$REPLY" | cut -d: -f2)" |
84 ROOT="$(echo "$REPLY" | cut -d: -f2)" |
178 error("User " + quote(name) + " already exists --" + |
177 error("User " + quote(name) + " already exists --" + |
179 " for Phabricator it should have the description:\n " + quote(description)) |
178 " for Phabricator it should have the description:\n " + quote(description)) |
180 } |
179 } |
181 } |
180 } |
182 |
181 |
183 def command_setup(name: String, body: String, exit: String = ""): Path = |
182 def command_setup(name: String, |
|
183 init: String = "", |
|
184 body: String = "", |
|
185 exit: String = ""): Path = |
184 { |
186 { |
185 val command = Path.explode("/usr/local/bin") + Path.basic(name) |
187 val command = Path.explode("/usr/local/bin") + Path.basic(name) |
186 File.write(command, global_config_script(header = true, body = body, exit = exit)) |
188 File.write(command, global_config_script(init = init, body = body, exit = exit)) |
187 Isabelle_System.chmod("755", command) |
189 Isabelle_System.chmod("755", command) |
188 Isabelle_System.chown("root:root", command) |
190 Isabelle_System.chown("root:root", command) |
189 command |
191 command |
190 } |
192 } |
191 |
193 |
369 |
371 |
370 |
372 |
371 /* database dump */ |
373 /* database dump */ |
372 |
374 |
373 val dump_name = isabelle_phabricator_name(name = "dump") |
375 val dump_name = isabelle_phabricator_name(name = "dump") |
374 command_setup(dump_name, |
376 command_setup(dump_name, body = |
375 """mkdir -p "$ROOT/database" && chown root:root "$ROOT/database" && chmod 700 "$ROOT/database" |
377 """mkdir -p "$ROOT/database" && chown root:root "$ROOT/database" && chmod 700 "$ROOT/database" |
376 [ -e "$ROOT/database/dump.sql.gz" ] && mv -f "$ROOT/database/dump.sql.gz" "$ROOT/database/dump-old.sql.gz" |
378 [ -e "$ROOT/database/dump.sql.gz" ] && mv -f "$ROOT/database/dump.sql.gz" "$ROOT/database/dump-old.sql.gz" |
377 echo "Creating $ROOT/database/dump.sql.gz" |
379 echo "Creating $ROOT/database/dump.sql.gz" |
378 "$ROOT/phabricator/bin/storage" dump --compress --output "$ROOT/database/dump.sql.gz" 2>&1 | fgrep -v '[Warning] Using a password on the command line interface can be insecure' """) |
380 "$ROOT/phabricator/bin/storage" dump --compress --output "$ROOT/database/dump.sql.gz" 2>&1 | fgrep -v '[Warning] Using a password on the command line interface can be insecure' """) |
379 |
381 |
448 config.execute("config set phd.log-directory /var/tmp/phd/" + |
450 config.execute("config set phd.log-directory /var/tmp/phd/" + |
449 isabelle_phabricator_name(name = name) + "/log") |
451 isabelle_phabricator_name(name = name) + "/log") |
450 |
452 |
451 val phd_name = isabelle_phabricator_name(name = "phd") |
453 val phd_name = isabelle_phabricator_name(name = "phd") |
452 Linux.service_shutdown(phd_name) |
454 Linux.service_shutdown(phd_name) |
453 val phd_command = command_setup(phd_name, """"$ROOT/phabricator/bin/phd" "$@" """) |
455 val phd_command = command_setup(phd_name, body = """"$ROOT/phabricator/bin/phd" "$@" """) |
454 try { |
456 try { |
455 Linux.service_install(phd_name, |
457 Linux.service_install(phd_name, |
456 """[Unit] |
458 """[Unit] |
457 Description=PHP daemon manager for Isabelle/Phabricator |
459 Description=PHP daemon manager for Isabelle/Phabricator |
458 After=syslog.target network.target apache2.service mysql.service |
460 After=syslog.target network.target apache2.service mysql.service |
691 Linux.service_start("ssh") |
693 Linux.service_start("ssh") |
692 } |
694 } |
693 |
695 |
694 progress.echo("Configuring " + ssh_name + " service") |
696 progress.echo("Configuring " + ssh_name + " service") |
695 |
697 |
696 val ssh_command = command_setup(ssh_name, |
698 val ssh_command = command_setup(ssh_name, body = |
697 """if [ "$1" = "$NAME" ] |
699 """if [ "$1" = "$NAME" ] |
698 then |
700 then |
699 exec "$ROOT/phabricator/bin/ssh-auth" "$@" |
701 exec "$ROOT/phabricator/bin/ssh-auth" "$@" |
700 fi""", exit = "exit 1") |
702 fi""", exit = "exit 1") |
701 |
703 |