| author | wenzelm |
| Fri, 30 Oct 2020 22:56:15 +0100 | |
| changeset 72521 | 354bfab78cbf |
| parent 72520 | 581d9d74e1e4 |
| child 72522 | 6e27af808c17 |
| permissions | -rw-r--r-- |
| 70967 | 1 |
/* Title: Pure/Tools/phabricator.scala |
2 |
Author: Makarius |
|
3 |
||
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
4 |
Support for Phabricator server, notably for Ubuntu 18.04 LTS. |
|
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
5 |
|
|
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
6 |
See also: |
| 70967 | 7 |
- https://www.phacility.com/phabricator |
8 |
- https://secure.phabricator.com/book/phabricator |
|
9 |
*/ |
|
10 |
||
11 |
package isabelle |
|
12 |
||
13 |
||
| 71330 | 14 |
import scala.collection.mutable |
| 70969 | 15 |
import scala.util.matching.Regex |
16 |
||
17 |
||
| 70967 | 18 |
object Phabricator |
19 |
{
|
|
20 |
/** defaults **/ |
|
21 |
||
| 71049 | 22 |
/* required packages */ |
23 |
||
| 72521 | 24 |
val packages_ubuntu_18_04: List[String] = |
| 72494 | 25 |
Build_Docker.packages ::: |
| 71049 | 26 |
List( |
27 |
// https://secure.phabricator.com/source/phabricator/browse/master/scripts/install/install_ubuntu.sh 15e6e2adea61 |
|
28 |
"git", "mysql-server", "apache2", "libapache2-mod-php", "php", "php-mysql", |
|
29 |
"php-gd", "php-curl", "php-apcu", "php-cli", "php-json", "php-mbstring", |
|
30 |
// more packages |
|
| 71288 | 31 |
"php-xml", "php-zip", "python-pygments", "ssh", "subversion", |
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
32 |
// mercurial build packages |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
33 |
"make", "gcc", "python", "python-dev", "python-docutils", "python-pygments", "python-openssl") |
| 71049 | 34 |
|
| 72521 | 35 |
val packages_ubuntu_20_04: List[String] = |
36 |
packages_ubuntu_18_04.map((name: String) => |
|
37 |
if (name.startsWith("python")) name.replace("python", "python3") else name)
|
|
38 |
||
39 |
def packages: List[String] = |
|
40 |
{
|
|
41 |
val release = Linux.Release() |
|
42 |
if (release.is_ubuntu_18_04) packages_ubuntu_18_04 |
|
43 |
else if (release.is_ubuntu_20_04) packages_ubuntu_20_04 |
|
44 |
else error("Bad Linux version: expected Ubuntu 18.04 or 20.04 LTS")
|
|
45 |
} |
|
46 |
||
| 71049 | 47 |
|
48 |
/* global system resources */ |
|
49 |
||
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
50 |
val www_user = "www-data" |
|
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
51 |
|
| 71049 | 52 |
val daemon_user = "phabricator" |
53 |
||
| 71601 | 54 |
val sshd_config: Path = Path.explode("/etc/ssh/sshd_config")
|
| 71049 | 55 |
|
56 |
||
57 |
/* installation parameters */ |
|
58 |
||
| 70967 | 59 |
val default_name = "vcs" |
60 |
||
|
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
61 |
def phabricator_name(name: String = "", ext: String = ""): String = |
|
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
62 |
"phabricator" + (if (name.isEmpty) "" else "-" + name) + (if (ext.isEmpty) "" else "." + ext) |
|
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
63 |
|
|
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
64 |
def isabelle_phabricator_name(name: String = "", ext: String = ""): String = |
|
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
65 |
"isabelle-" + phabricator_name(name = name, ext = ext) |
| 70967 | 66 |
|
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
67 |
def default_root(name: String): Path = |
|
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
68 |
Path.explode("/var/www") + Path.basic(phabricator_name(name = name))
|
| 70967 | 69 |
|
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
70 |
def default_repo(name: String): Path = default_root(name) + Path.basic("repo")
|
| 70967 | 71 |
|
| 71072 | 72 |
val default_mailers: Path = Path.explode("mailers.json")
|
| 71066 | 73 |
|
| 71601 | 74 |
val default_system_port: Int = SSH.default_port |
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
75 |
val alternative_system_port = 222 |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
76 |
val default_server_port = 2222 |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
77 |
|
|
71440
8b0b8b9ea653
afford newer Mercurial version, just before odd problems in 4.0 and 4.1;
wenzelm
parents:
71439
diff
changeset
|
78 |
val standard_mercurial_source = "https://www.mercurial-scm.org/release/mercurial-3.9.2.tar.gz" |
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
79 |
|
| 70967 | 80 |
|
81 |
||
82 |
/** global configuration **/ |
|
83 |
||
| 71601 | 84 |
val global_config: Path = Path.explode("/etc/" + isabelle_phabricator_name(ext = "conf"))
|
| 70967 | 85 |
|
| 71122 | 86 |
def global_config_script( |
87 |
init: String = "", |
|
88 |
body: String = "", |
|
89 |
exit: String = ""): String = |
|
90 |
{
|
|
| 71282 | 91 |
"""#!/bin/bash |
| 71284 | 92 |
""" + (if (init.nonEmpty) "\n" + init else "") + """ |
93 |
{
|
|
| 71122 | 94 |
while { unset REPLY; read -r; test "$?" = 0 -o -n "$REPLY"; }
|
95 |
do |
|
96 |
NAME="$(echo "$REPLY" | cut -d: -f1)" |
|
97 |
ROOT="$(echo "$REPLY" | cut -d: -f2)" |
|
| 71284 | 98 |
{
|
99 |
""" + Library.prefix_lines(" ", body) + """
|
|
100 |
} < /dev/null |
|
101 |
done |
|
102 |
} < """ + File.bash_path(global_config) + "\n" + |
|
103 |
(if (exit.nonEmpty) "\n" + exit + "\n" else "") |
|
| 71122 | 104 |
} |
105 |
||
| 70967 | 106 |
sealed case class Config(name: String, root: Path) |
| 70968 | 107 |
{
|
|
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
108 |
def home: Path = root + Path.explode(phabricator_name()) |
| 70969 | 109 |
|
110 |
def execute(command: String): Process_Result = |
|
| 71102 | 111 |
Isabelle_System.bash("bin/" + command, cwd = home.file, redirect = true).check
|
| 70968 | 112 |
} |
| 70967 | 113 |
|
114 |
def read_config(): List[Config] = |
|
115 |
{
|
|
116 |
if (global_config.is_file) {
|
|
117 |
for (entry <- Library.trim_split_lines(File.read(global_config)) if entry.nonEmpty) |
|
118 |
yield {
|
|
119 |
space_explode(':', entry) match {
|
|
120 |
case List(name, root) => Config(name, Path.explode(root)) |
|
121 |
case _ => error("Malformed config file " + global_config + "\nentry " + quote(entry))
|
|
122 |
} |
|
123 |
} |
|
124 |
} |
|
125 |
else Nil |
|
126 |
} |
|
127 |
||
128 |
def write_config(configs: List[Config]) |
|
129 |
{
|
|
130 |
File.write(global_config, |
|
131 |
configs.map(config => config.name + ":" + config.root.implode).mkString("", "\n", "\n"))
|
|
132 |
} |
|
133 |
||
134 |
def get_config(name: String): Config = |
|
135 |
read_config().find(config => config.name == name) getOrElse |
|
136 |
error("Bad Isabelle/Phabricator installation " + quote(name))
|
|
137 |
||
138 |
||
139 |
||
| 71299 | 140 |
/** administrative tools **/ |
| 71097 | 141 |
|
142 |
/* Isabelle tool wrapper */ |
|
143 |
||
144 |
val isabelle_tool1 = |
|
145 |
Isabelle_Tool("phabricator", "invoke command-line tool within Phabricator home directory", args =>
|
|
146 |
{
|
|
| 71101 | 147 |
var list = false |
| 71097 | 148 |
var name = default_name |
149 |
||
150 |
val getopts = |
|
151 |
Getopts("""
|
|
152 |
Usage: isabelle phabricator [OPTIONS] COMMAND [ARGS...] |
|
153 |
||
154 |
Options are: |
|
| 71101 | 155 |
-l list available Phabricator installations |
| 71097 | 156 |
-n NAME Phabricator installation name (default: """ + quote(default_name) + """) |
157 |
||
| 71103 | 158 |
Invoke a command-line tool within the home directory of the named |
159 |
Phabricator installation. |
|
| 71097 | 160 |
""", |
| 71101 | 161 |
"l" -> (_ => list = true), |
| 71097 | 162 |
"n:" -> (arg => name = arg)) |
163 |
||
164 |
val more_args = getopts(args) |
|
| 71101 | 165 |
if (more_args.isEmpty && !list) getopts.usage() |
| 71097 | 166 |
|
167 |
val progress = new Console_Progress |
|
168 |
||
| 71101 | 169 |
if (list) {
|
170 |
for (config <- read_config()) {
|
|
| 71103 | 171 |
progress.echo("phabricator " + quote(config.name) + " root " + config.root)
|
| 71101 | 172 |
} |
173 |
} |
|
|
71276
b4401dfd6544
clarified "isabelle phabricator -l": avoid surprise with non-existent default installation;
wenzelm
parents:
71274
diff
changeset
|
174 |
else {
|
|
b4401dfd6544
clarified "isabelle phabricator -l": avoid surprise with non-existent default installation;
wenzelm
parents:
71274
diff
changeset
|
175 |
val config = get_config(name) |
|
b4401dfd6544
clarified "isabelle phabricator -l": avoid surprise with non-existent default installation;
wenzelm
parents:
71274
diff
changeset
|
176 |
val result = progress.bash(Bash.strings(more_args), cwd = config.home.file, echo = true) |
| 71747 | 177 |
if (!result.ok) error(result.print_return_code) |
|
71276
b4401dfd6544
clarified "isabelle phabricator -l": avoid surprise with non-existent default installation;
wenzelm
parents:
71274
diff
changeset
|
178 |
} |
| 71097 | 179 |
}) |
180 |
||
181 |
||
182 |
||
| 70967 | 183 |
/** setup **/ |
184 |
||
| 71049 | 185 |
def user_setup(name: String, description: String, ssh_setup: Boolean = false) |
186 |
{
|
|
187 |
if (!Linux.user_exists(name)) {
|
|
|
71054
b64fc38327ae
prefer system user setup, e.g. avoid occurrence on login screen;
wenzelm
parents:
71053
diff
changeset
|
188 |
Linux.user_add(name, description = description, system = true, ssh_setup = ssh_setup) |
| 71049 | 189 |
} |
190 |
else if (Linux.user_description(name) != description) {
|
|
191 |
error("User " + quote(name) + " already exists --" +
|
|
192 |
" for Phabricator it should have the description:\n " + quote(description)) |
|
193 |
} |
|
194 |
} |
|
195 |
||
| 71282 | 196 |
def command_setup(name: String, |
197 |
init: String = "", |
|
198 |
body: String = "", |
|
199 |
exit: String = ""): Path = |
|
| 71270 | 200 |
{
|
201 |
val command = Path.explode("/usr/local/bin") + Path.basic(name)
|
|
| 71282 | 202 |
File.write(command, global_config_script(init = init, body = body, exit = exit)) |
| 71270 | 203 |
Isabelle_System.chmod("755", command)
|
204 |
Isabelle_System.chown("root:root", command)
|
|
205 |
command |
|
206 |
} |
|
207 |
||
|
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71601
diff
changeset
|
208 |
def mercurial_setup(mercurial_source: String, progress: Progress = new Progress) |
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
209 |
{
|
| 71281 | 210 |
progress.echo("\nMercurial installation from source " + quote(mercurial_source) + " ...")
|
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
211 |
Isabelle_System.with_tmp_dir("mercurial")(tmp_dir =>
|
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
212 |
{
|
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
213 |
val archive = |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
214 |
if (Url.is_wellformed(mercurial_source)) {
|
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
215 |
val archive = tmp_dir + Path.basic("mercurial.tar.gz")
|
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
216 |
Bytes.write(archive, Url.read_bytes(Url(mercurial_source))) |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
217 |
archive |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
218 |
} |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
219 |
else Path.explode(mercurial_source) |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
220 |
|
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
221 |
Isabelle_System.gnutar("-xzf " + File.bash_path(archive), dir = tmp_dir).check
|
| 72442 | 222 |
val build_dir = tmp_dir + Path.basic(File.get_dir(tmp_dir)) |
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
223 |
|
| 72442 | 224 |
progress.bash("make all && make install", cwd = build_dir.file, echo = true).check
|
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
225 |
}) |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
226 |
} |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
227 |
|
| 70967 | 228 |
def phabricator_setup( |
|
71422
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
229 |
options: Options, |
| 70967 | 230 |
name: String = default_name, |
231 |
root: String = "", |
|
232 |
repo: String = "", |
|
| 71047 | 233 |
package_update: Boolean = false, |
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
234 |
mercurial_source: String = "", |
|
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71601
diff
changeset
|
235 |
progress: Progress = new Progress) |
| 70967 | 236 |
{
|
237 |
/* system environment */ |
|
238 |
||
239 |
Linux.check_system_root() |
|
240 |
||
| 71079 | 241 |
progress.echo("System packages ...")
|
242 |
||
| 71047 | 243 |
if (package_update) {
|
244 |
Linux.package_update(progress = progress) |
|
245 |
Linux.check_reboot_required() |
|
246 |
} |
|
| 70967 | 247 |
|
248 |
Linux.package_install(packages, progress = progress) |
|
249 |
Linux.check_reboot_required() |
|
250 |
||
251 |
||
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
252 |
if (mercurial_source.nonEmpty) {
|
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
253 |
for { name <- List("mercurial", "mercurial-common") if Linux.package_installed(name) } {
|
| 71326 | 254 |
error("Cannot install Mercurial from source:\n" +
|
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
255 |
"package package " + quote(name) + " already installed") |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
256 |
} |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
257 |
mercurial_setup(mercurial_source, progress = progress) |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
258 |
} |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
259 |
|
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
260 |
|
| 71049 | 261 |
/* users */ |
262 |
||
| 72520 | 263 |
if (name.exists((c: Char) => !(Symbol.is_ascii_letter(c) || Symbol.is_ascii_digit(c))) || |
| 71269 | 264 |
Set("", "ssh", "phd", "dump", daemon_user).contains(name)) {
|
| 71125 | 265 |
error("Bad installation name: " + quote(name))
|
| 71049 | 266 |
} |
267 |
||
268 |
user_setup(daemon_user, "Phabricator Daemon User", ssh_setup = true) |
|
269 |
user_setup(name, "Phabricator SSH User") |
|
270 |
||
271 |
||
| 70967 | 272 |
/* basic installation */ |
273 |
||
| 71079 | 274 |
progress.echo("\nPhabricator installation ...")
|
| 71076 | 275 |
|
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
276 |
val root_path = if (root.nonEmpty) Path.explode(root) else default_root(name) |
|
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
277 |
val repo_path = if (repo.nonEmpty) Path.explode(repo) else default_repo(name) |
| 70967 | 278 |
|
279 |
val configs = read_config() |
|
280 |
||
281 |
for (config <- configs if config.name == name) {
|
|
282 |
error("Duplicate Phabricator installation " + quote(name) + " in " + config.root)
|
|
283 |
} |
|
284 |
||
285 |
if (!Isabelle_System.bash("mkdir -p " + File.bash_path(root_path)).ok) {
|
|
286 |
error("Failed to create root directory " + root_path)
|
|
287 |
} |
|
288 |
||
| 71116 | 289 |
Isabelle_System.chown(Bash.string(www_user) + ":" + Bash.string(www_user), root_path) |
290 |
Isabelle_System.chmod("755", root_path)
|
|
291 |
||
| 70967 | 292 |
progress.bash(cwd = root_path.file, echo = true, |
293 |
script = """ |
|
294 |
set -e |
|
| 71126 | 295 |
echo "Cloning distribution repositories:" |
|
71287
71fd25a7bbe2
more robust setup: avoid blind shot at "the latest" version;
wenzelm
parents:
71285
diff
changeset
|
296 |
|
|
71422
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
297 |
git clone --branch stable https://github.com/phacility/arcanist.git |
|
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
298 |
git -C arcanist reset --hard """ + |
|
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
299 |
Bash.string(options.string("phabricator_version_arcanist")) + """
|
|
71287
71fd25a7bbe2
more robust setup: avoid blind shot at "the latest" version;
wenzelm
parents:
71285
diff
changeset
|
300 |
|
| 71283 | 301 |
git clone --branch stable https://github.com/phacility/phabricator.git |
|
71422
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
302 |
git -C phabricator reset --hard """ + |
|
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
303 |
Bash.string(options.string("phabricator_version_phabricator")) + """
|
| 70967 | 304 |
""").check |
305 |
||
306 |
val config = Config(name, root_path) |
|
307 |
write_config(configs ::: List(config)) |
|
| 70968 | 308 |
|
| 71051 | 309 |
config.execute("config set pygments.enabled true")
|
310 |
||
| 70968 | 311 |
|
| 71050 | 312 |
/* local repository directory */ |
313 |
||
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
314 |
progress.echo("\nRepository hosting setup ...")
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
315 |
|
| 71050 | 316 |
if (!Isabelle_System.bash("mkdir -p " + File.bash_path(repo_path)).ok) {
|
317 |
error("Failed to create local repository directory " + repo_path)
|
|
318 |
} |
|
319 |
||
| 71114 | 320 |
Isabelle_System.chown( |
321 |
"-R " + Bash.string(daemon_user) + ":" + Bash.string(daemon_user), repo_path) |
|
322 |
Isabelle_System.chmod("755", repo_path)
|
|
| 71050 | 323 |
|
324 |
config.execute("config set repository.default-local-path " + File.bash_path(repo_path))
|
|
325 |
||
326 |
||
| 71277 | 327 |
val sudoers_file = |
328 |
Path.explode("/etc/sudoers.d") + Path.basic(isabelle_phabricator_name(name = name))
|
|
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
329 |
File.write(sudoers_file, |
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
330 |
www_user + " ALL=(" + daemon_user + ") SETENV: NOPASSWD: /usr/bin/git, /usr/local/bin/hg, /usr/bin/hg, /usr/bin/ssh, /usr/bin/id\n" +
|
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
331 |
name + " ALL=(" + daemon_user + ") SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack, /usr/local/bin/hg, /usr/bin/hg, /usr/bin/svnserve, /usr/bin/ssh, /usr/bin/id\n")
|
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
332 |
|
| 71115 | 333 |
Isabelle_System.chmod("440", sudoers_file)
|
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
334 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
335 |
config.execute("config set diffusion.ssh-user " + Bash.string(config.name))
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
336 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
337 |
|
| 70969 | 338 |
/* MySQL setup */ |
339 |
||
| 71079 | 340 |
progress.echo("\nMySQL setup ...")
|
| 70969 | 341 |
|
|
71055
27a998cdc0f4
back to plain name, to have it accepted my mysql;
wenzelm
parents:
71054
diff
changeset
|
342 |
File.write(Path.explode("/etc/mysql/mysql.conf.d/" + phabricator_name(ext = "cnf")),
|
| 71051 | 343 |
"""[mysqld] |
344 |
max_allowed_packet = 32M |
|
345 |
innodb_buffer_pool_size = 1600M |
|
346 |
local_infile = 0 |
|
347 |
""") |
|
348 |
||
349 |
Linux.service_restart("mysql")
|
|
350 |
||
351 |
||
|
71266
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
352 |
def mysql_conf(R: Regex, which: String): String = |
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
353 |
{
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
354 |
val conf = Path.explode("/etc/mysql/debian.cnf")
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
355 |
split_lines(File.read(conf)).collectFirst({ case R(a) => a }) match {
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
356 |
case Some(res) => res |
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
357 |
case None => error("Cannot determine " + which + " from " + conf)
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
358 |
} |
| 70969 | 359 |
} |
360 |
||
|
71266
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
361 |
val mysql_root_user = mysql_conf("""^user\s*=\s*(\S*)\s*$""".r, "superuser name")
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
362 |
val mysql_root_password = mysql_conf("""^password\s*=\s*(\S*)\s*$""".r, "superuser password")
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
363 |
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
364 |
val mysql_name = phabricator_name(name = name).replace("-", "_")
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
365 |
val mysql_user_string = SQL.string(mysql_name) + "@'localhost'" |
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
366 |
val mysql_password = Linux.generate_password() |
| 70969 | 367 |
|
|
71266
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
368 |
Isabelle_System.bash("mysql --user=" + Bash.string(mysql_root_user) +
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
369 |
" --password=" + Bash.string(mysql_root_password) + " --execute=" + |
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
370 |
Bash.string( |
| 71274 | 371 |
"""DROP USER IF EXISTS """ + mysql_user_string + "; " + |
372 |
"""CREATE USER """ + mysql_user_string + |
|
|
71266
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
373 |
""" IDENTIFIED BY """ + SQL.string(mysql_password) + """ PASSWORD EXPIRE NEVER; """ + |
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
374 |
"""GRANT ALL ON `""" + (mysql_name + "_%").replace("_", "\\_") +
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
375 |
"""`.* TO """ + mysql_user_string + ";")).check |
| 70969 | 376 |
|
|
71266
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
377 |
config.execute("config set mysql.user " + Bash.string(mysql_name))
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
378 |
config.execute("config set mysql.pass " + Bash.string(mysql_password))
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
379 |
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
380 |
config.execute("config set phabricator.cache-namespace " + Bash.string(mysql_name))
|
|
8451c86ffa85
proper mysql user setup: avoid superuser powers in production;
wenzelm
parents:
71265
diff
changeset
|
381 |
config.execute("config set storage.default-namespace " + Bash.string(mysql_name))
|
| 71051 | 382 |
config.execute("config set storage.mysql-engine.max-size 8388608")
|
383 |
||
| 71102 | 384 |
progress.bash("bin/storage upgrade --force", cwd = config.home.file, echo = true).check
|
| 70969 | 385 |
|
386 |
||
| 71269 | 387 |
/* database dump */ |
388 |
||
389 |
val dump_name = isabelle_phabricator_name(name = "dump") |
|
| 71282 | 390 |
command_setup(dump_name, body = |
| 71269 | 391 |
"""mkdir -p "$ROOT/database" && chown root:root "$ROOT/database" && chmod 700 "$ROOT/database" |
392 |
[ -e "$ROOT/database/dump.sql.gz" ] && mv -f "$ROOT/database/dump.sql.gz" "$ROOT/database/dump-old.sql.gz" |
|
| 71328 | 393 |
echo -n "Creating $ROOT/database/dump.sql.gz ..." |
394 |
"$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' |
|
395 |
echo " $(ls -hs "$ROOT/database/dump.sql.gz" | cut -d" " -f1)" """) |
|
| 71269 | 396 |
|
397 |
||
| 71283 | 398 |
/* Phabricator upgrade */ |
399 |
||
400 |
command_setup(isabelle_phabricator_name(name = "upgrade"), |
|
401 |
init = |
|
| 71285 | 402 |
"""BRANCH="${1:-stable}"
|
| 71283 | 403 |
if [ "$BRANCH" != "master" -a "$BRANCH" != "stable" ] |
404 |
then |
|
405 |
echo "Bad branch: \"$BRANCH\"" |
|
406 |
exit 1 |
|
407 |
fi |
|
408 |
||
409 |
systemctl stop isabelle-phabricator-phd |
|
410 |
systemctl stop apache2 |
|
411 |
""", |
|
412 |
body = |
|
413 |
"""echo -e "\nUpgrading phabricator \"$NAME\" root \"$ROOT\" ..." |
|
| 71845 | 414 |
for REPO in arcanist phabricator |
| 71283 | 415 |
do |
416 |
cd "$ROOT/$REPO" |
|
417 |
echo -e "\nUpdating \"$REPO\" ..." |
|
418 |
git checkout "$BRANCH" |
|
419 |
git pull |
|
420 |
done |
|
421 |
echo -e "\nUpgrading storage ..." |
|
422 |
"$ROOT/phabricator/bin/storage" upgrade --force |
|
423 |
""", |
|
424 |
exit = |
|
425 |
"""systemctl start apache2 |
|
426 |
systemctl start isabelle-phabricator-phd""") |
|
427 |
||
428 |
||
| 71051 | 429 |
/* PHP setup */ |
430 |
||
431 |
val php_version = |
|
432 |
Isabelle_System.bash("""php --run 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;'""")
|
|
433 |
.check.out |
|
434 |
||
435 |
val php_conf = |
|
436 |
Path.explode("/etc/php") + Path.basic(php_version) + // educated guess
|
|
|
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
437 |
Path.explode("apache2/conf.d") +
|
|
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
438 |
Path.basic(isabelle_phabricator_name(ext = "ini")) |
| 71051 | 439 |
|
440 |
File.write(php_conf, |
|
441 |
"post_max_size = 32M\n" + |
|
442 |
"opcache.validate_timestamps = 0\n" + |
|
| 71129 | 443 |
"memory_limit = 512M\n" + |
444 |
"max_execution_time = 120\n") |
|
| 71051 | 445 |
|
446 |
||
| 70968 | 447 |
/* Apache setup */ |
448 |
||
| 71079 | 449 |
progress.echo("Apache setup ...")
|
| 70968 | 450 |
|
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
451 |
val apache_root = Path.explode("/etc/apache2")
|
| 70968 | 452 |
val apache_sites = apache_root + Path.explode("sites-available")
|
453 |
||
454 |
if (!apache_sites.is_dir) error("Bad Apache sites directory " + apache_sites)
|
|
455 |
||
| 71058 | 456 |
val server_name = phabricator_name(name = name, ext = "lvh.me") // alias for "localhost" for testing |
|
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
457 |
val server_url = "http://" + server_name |
|
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
458 |
|
| 71058 | 459 |
File.write(apache_sites + Path.basic(isabelle_phabricator_name(name = name, ext = "conf")), |
| 70968 | 460 |
"""<VirtualHost *:80> |
|
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
461 |
ServerName """ + server_name + """ |
| 70968 | 462 |
ServerAdmin webmaster@localhost |
| 70969 | 463 |
DocumentRoot """ + config.home.implode + """/webroot |
| 70968 | 464 |
|
465 |
ErrorLog ${APACHE_LOG_DIR}/error.log
|
|
|
71439
760e19aa9b09
afford more logging (following defaults on Ubuntu);
wenzelm
parents:
71422
diff
changeset
|
466 |
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
|
760e19aa9b09
afford more logging (following defaults on Ubuntu);
wenzelm
parents:
71422
diff
changeset
|
467 |
|
| 70968 | 468 |
RewriteEngine on |
469 |
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA] |
|
470 |
</VirtualHost> |
|
471 |
||
472 |
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet |
|
473 |
""") |
|
474 |
||
| 71051 | 475 |
Isabelle_System.bash( """ |
| 70968 | 476 |
set -e |
477 |
a2enmod rewrite |
|
| 71058 | 478 |
a2ensite """ + Bash.string(isabelle_phabricator_name(name = name))).check |
| 71051 | 479 |
|
| 71057 | 480 |
config.execute("config set phabricator.base-uri " + Bash.string(server_url))
|
481 |
||
| 71051 | 482 |
Linux.service_restart("apache2")
|
| 70968 | 483 |
|
| 71328 | 484 |
progress.echo("\nFurther manual configuration via " + server_url)
|
|
71128
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
485 |
|
| 71053 | 486 |
|
487 |
/* PHP daemon */ |
|
488 |
||
|
71128
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
489 |
progress.echo("\nPHP daemon setup ...")
|
| 71053 | 490 |
|
| 72376 | 491 |
val phd_log_path = Isabelle_System.make_directory(Path.explode("/var/tmp/phd"))
|
| 71273 | 492 |
Isabelle_System.chown( |
493 |
"-R " + Bash.string(daemon_user) + ":" + Bash.string(daemon_user), phd_log_path) |
|
494 |
Isabelle_System.chmod("755", phd_log_path)
|
|
495 |
||
| 71053 | 496 |
config.execute("config set phd.user " + Bash.string(daemon_user))
|
| 71112 | 497 |
config.execute("config set phd.log-directory /var/tmp/phd/" +
|
498 |
isabelle_phabricator_name(name = name) + "/log") |
|
| 71053 | 499 |
|
|
71124
7dbadecdc118
just one isabelle-phabricator-phd service, which manages all processes uniformly (NB: "bin/phd stop" affects all installations);
wenzelm
parents:
71122
diff
changeset
|
500 |
val phd_name = isabelle_phabricator_name(name = "phd") |
| 71127 | 501 |
Linux.service_shutdown(phd_name) |
| 71282 | 502 |
val phd_command = command_setup(phd_name, body = """"$ROOT/phabricator/bin/phd" "$@" """) |
|
71128
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
503 |
try {
|
|
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
504 |
Linux.service_install(phd_name, |
| 71053 | 505 |
"""[Unit] |
|
71124
7dbadecdc118
just one isabelle-phabricator-phd service, which manages all processes uniformly (NB: "bin/phd stop" affects all installations);
wenzelm
parents:
71122
diff
changeset
|
506 |
Description=PHP daemon manager for Isabelle/Phabricator |
| 71053 | 507 |
After=syslog.target network.target apache2.service mysql.service |
508 |
||
509 |
[Service] |
|
510 |
Type=oneshot |
|
511 |
User=""" + daemon_user + """ |
|
512 |
Group=""" + daemon_user + """ |
|
513 |
Environment=PATH=/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin |
|
|
71124
7dbadecdc118
just one isabelle-phabricator-phd service, which manages all processes uniformly (NB: "bin/phd stop" affects all installations);
wenzelm
parents:
71122
diff
changeset
|
514 |
ExecStart=""" + phd_command.implode + """ start --force |
|
7dbadecdc118
just one isabelle-phabricator-phd service, which manages all processes uniformly (NB: "bin/phd stop" affects all installations);
wenzelm
parents:
71122
diff
changeset
|
515 |
ExecStop=""" + phd_command.implode + """ stop |
| 71053 | 516 |
RemainAfterExit=yes |
517 |
||
518 |
[Install] |
|
519 |
WantedBy=multi-user.target |
|
520 |
""") |
|
|
71128
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
521 |
} |
|
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
522 |
catch {
|
|
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
523 |
case ERROR(msg) => |
|
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
524 |
progress.bash("bin/phd status", cwd = config.home.file, echo = true).check
|
|
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
525 |
error(msg) |
|
f79006c533b0
clarified errors: PHP daemon can fail under odd circumstances;
wenzelm
parents:
71127
diff
changeset
|
526 |
} |
| 70967 | 527 |
} |
528 |
||
529 |
||
530 |
/* Isabelle tool wrapper */ |
|
531 |
||
| 71097 | 532 |
val isabelle_tool2 = |
| 70967 | 533 |
Isabelle_Tool("phabricator_setup", "setup Phabricator server on Ubuntu Linux", args =>
|
534 |
{
|
|
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
535 |
var mercurial_source = "" |
| 71047 | 536 |
var repo = "" |
537 |
var package_update = false |
|
| 71078 | 538 |
var name = default_name |
|
71422
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
539 |
var options = Options.init() |
| 70967 | 540 |
var root = "" |
541 |
||
542 |
val getopts = |
|
543 |
Getopts("""
|
|
| 71078 | 544 |
Usage: isabelle phabricator_setup [OPTIONS] |
| 70967 | 545 |
|
546 |
Options are: |
|
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
547 |
-M SOURCE install Mercurial from source: local PATH, or URL, or ":" for |
|
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
548 |
""" + standard_mercurial_source + """ |
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
549 |
-R DIR repository directory (default: """ + default_repo("NAME") + """)
|
| 71047 | 550 |
-U full update of system packages before installation |
| 71078 | 551 |
-n NAME Phabricator installation name (default: """ + quote(default_name) + """) |
|
71422
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
552 |
-o OPTION override Isabelle system OPTION (via NAME=VAL or NAME) |
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
553 |
-r DIR installation root directory (default: """ + default_root("NAME") + """)
|
| 70967 | 554 |
|
| 71103 | 555 |
Install Phabricator as LAMP application (Linux, Apache, MySQL, PHP). |
| 70967 | 556 |
|
| 71078 | 557 |
The installation name (default: """ + quote(default_name) + """) is mapped to a regular |
558 |
Unix user; this is relevant for public SSH access. |
|
| 70967 | 559 |
""", |
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
560 |
"M:" -> (arg => mercurial_source = (if (arg == ":") standard_mercurial_source else arg)), |
| 70967 | 561 |
"R:" -> (arg => repo = arg), |
| 71047 | 562 |
"U" -> (_ => package_update = true), |
| 71078 | 563 |
"n:" -> (arg => name = arg), |
|
71422
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
564 |
"o:" -> (arg => options = options + arg), |
| 70967 | 565 |
"r:" -> (arg => root = arg)) |
566 |
||
567 |
val more_args = getopts(args) |
|
| 71078 | 568 |
if (more_args.nonEmpty) getopts.usage() |
| 70967 | 569 |
|
570 |
val progress = new Console_Progress |
|
571 |
||
|
71422
5d5be87330b5
allow to override repository versions at runtime;
wenzelm
parents:
71421
diff
changeset
|
572 |
phabricator_setup(options, name = name, root = root, repo = repo, |
|
71280
5a2033fc8f3d
avoid odd (harmless) problem with Mercurial 4.5.3 provided by Ubuntu 18.04 on first push: "couldn't write revision branch cache names";
wenzelm
parents:
71277
diff
changeset
|
573 |
package_update = package_update, mercurial_source = mercurial_source, progress = progress) |
| 70967 | 574 |
}) |
575 |
||
576 |
||
577 |
||
| 71066 | 578 |
/** setup mail **/ |
| 70967 | 579 |
|
| 71072 | 580 |
val mailers_template: String = |
581 |
"""[ |
|
582 |
{
|
|
583 |
"key": "example.org", |
|
584 |
"type": "smtp", |
|
585 |
"options": {
|
|
586 |
"host": "mail.example.org", |
|
587 |
"port": 465, |
|
588 |
"user": "phabricator@example.org", |
|
589 |
"password": "********", |
|
590 |
"protocol": "ssl", |
|
591 |
"message-id": true |
|
592 |
} |
|
593 |
} |
|
594 |
]""" |
|
595 |
||
| 71066 | 596 |
def phabricator_setup_mail( |
597 |
name: String = default_name, |
|
598 |
config_file: Option[Path] = None, |
|
599 |
test_user: String = "", |
|
|
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71601
diff
changeset
|
600 |
progress: Progress = new Progress) |
| 70967 | 601 |
{
|
602 |
Linux.check_system_root() |
|
603 |
||
| 71066 | 604 |
val config = get_config(name) |
| 71073 | 605 |
val default_config_file = config.root + default_mailers |
| 71066 | 606 |
|
607 |
val mail_config = config_file getOrElse default_config_file |
|
608 |
||
609 |
def setup_mail |
|
610 |
{
|
|
611 |
progress.echo("Using mail configuration from " + mail_config)
|
|
612 |
config.execute("config set cluster.mailers --stdin < " + File.bash_path(mail_config))
|
|
613 |
||
614 |
if (test_user.nonEmpty) {
|
|
615 |
progress.echo("Sending test mail to " + quote(test_user))
|
|
616 |
progress.bash(cwd = config.home.file, echo = true, |
|
| 71102 | 617 |
script = """echo "Test from Phabricator ($(date))" | bin/mail send-test --subject "Test" --to """ + |
| 71066 | 618 |
Bash.string(test_user)).check |
619 |
} |
|
620 |
} |
|
621 |
||
622 |
if (config_file.isEmpty) {
|
|
| 71070 | 623 |
if (!default_config_file.is_file) {
|
624 |
File.write(default_config_file, mailers_template) |
|
| 71114 | 625 |
Isabelle_System.chmod("600", default_config_file)
|
| 71070 | 626 |
} |
| 71066 | 627 |
if (File.read(default_config_file) == mailers_template) {
|
| 71131 | 628 |
progress.echo("Please invoke the tool again, after providing details in\n " +
|
629 |
default_config_file.implode + "\n") |
|
| 71066 | 630 |
} |
631 |
else setup_mail |
|
632 |
} |
|
633 |
else setup_mail |
|
| 70967 | 634 |
} |
635 |
||
636 |
||
637 |
/* Isabelle tool wrapper */ |
|
638 |
||
| 71097 | 639 |
val isabelle_tool3 = |
| 71066 | 640 |
Isabelle_Tool("phabricator_setup_mail",
|
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
641 |
"setup mail for one Phabricator installation", args => |
| 70967 | 642 |
{
|
| 71066 | 643 |
var test_user = "" |
644 |
var name = default_name |
|
645 |
var config_file: Option[Path] = None |
|
646 |
||
| 70967 | 647 |
val getopts = |
648 |
Getopts("""
|
|
| 71066 | 649 |
Usage: isabelle phabricator_setup_mail [OPTIONS] |
650 |
||
651 |
Options are: |
|
652 |
-T USER send test mail to Phabricator user |
|
| 71103 | 653 |
-f FILE config file (default: """ + default_mailers + """ within Phabricator root) |
| 71066 | 654 |
-n NAME Phabricator installation name (default: """ + quote(default_name) + """) |
| 70967 | 655 |
|
| 71077 | 656 |
Provide mail configuration for existing Phabricator installation. |
| 71066 | 657 |
""", |
658 |
"T:" -> (arg => test_user = arg), |
|
659 |
"f:" -> (arg => config_file = Some(Path.explode(arg))), |
|
660 |
"n:" -> (arg => name = arg)) |
|
| 70967 | 661 |
|
662 |
val more_args = getopts(args) |
|
| 71066 | 663 |
if (more_args.nonEmpty) getopts.usage() |
| 70967 | 664 |
|
665 |
val progress = new Console_Progress |
|
666 |
||
| 71066 | 667 |
phabricator_setup_mail(name = name, config_file = config_file, |
668 |
test_user = test_user, progress = progress) |
|
| 70967 | 669 |
}) |
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
670 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
671 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
672 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
673 |
/** setup ssh **/ |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
674 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
675 |
/* sshd config */ |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
676 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
677 |
private val Port = """^\s*Port\s+(\d+)\s*$""".r |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
678 |
private val No_Port = """^#\s*Port\b.*$""".r |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
679 |
private val Any_Port = """^#?\s*Port\b.*$""".r |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
680 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
681 |
def conf_ssh_port(port: Int): String = |
| 71550 | 682 |
if (port == SSH.default_port) "#Port " + SSH.default_port else "Port " + port |
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
683 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
684 |
def read_ssh_port(conf: Path): Int = |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
685 |
{
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
686 |
val lines = split_lines(File.read(conf)) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
687 |
val ports = |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
688 |
lines.flatMap({
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
689 |
case Port(Value.Int(p)) => Some(p) |
| 71550 | 690 |
case No_Port() => Some(SSH.default_port) |
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
691 |
case _ => None |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
692 |
}) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
693 |
ports match {
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
694 |
case List(port) => port |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
695 |
case Nil => error("Missing Port specification in " + conf)
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
696 |
case _ => error("Multiple Port specifications in " + conf)
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
697 |
} |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
698 |
} |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
699 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
700 |
def write_ssh_port(conf: Path, port: Int): Boolean = |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
701 |
{
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
702 |
val old_port = read_ssh_port(conf) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
703 |
if (old_port == port) false |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
704 |
else {
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
705 |
val lines = split_lines(File.read(conf)) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
706 |
val lines1 = lines.map({ case Any_Port() => conf_ssh_port(port) case line => line })
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
707 |
File.write(conf, cat_lines(lines1)) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
708 |
true |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
709 |
} |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
710 |
} |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
711 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
712 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
713 |
/* phabricator_setup_ssh */ |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
714 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
715 |
def phabricator_setup_ssh( |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
716 |
server_port: Int = default_server_port, |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
717 |
system_port: Int = default_system_port, |
|
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71601
diff
changeset
|
718 |
progress: Progress = new Progress) |
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
719 |
{
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
720 |
Linux.check_system_root() |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
721 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
722 |
val configs = read_config() |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
723 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
724 |
if (server_port == system_port) {
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
725 |
error("Port for Phabricator sshd coincides with system port: " + system_port)
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
726 |
} |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
727 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
728 |
val sshd_conf_system = Path.explode("/etc/ssh/sshd_config")
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
729 |
val sshd_conf_server = sshd_conf_system.ext(isabelle_phabricator_name()) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
730 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
731 |
val ssh_name = isabelle_phabricator_name(name = "ssh") |
|
71111
cd166c3904dd
more robust: system ssh service is required for Phabricator ssh service;
wenzelm
parents:
71109
diff
changeset
|
732 |
Linux.service_shutdown(ssh_name) |
|
cd166c3904dd
more robust: system ssh service is required for Phabricator ssh service;
wenzelm
parents:
71109
diff
changeset
|
733 |
|
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
734 |
val old_system_port = read_ssh_port(sshd_conf_system) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
735 |
if (old_system_port != system_port) {
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
736 |
progress.echo("Reconfigurig system ssh service")
|
|
71111
cd166c3904dd
more robust: system ssh service is required for Phabricator ssh service;
wenzelm
parents:
71109
diff
changeset
|
737 |
Linux.service_shutdown("ssh")
|
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
738 |
write_ssh_port(sshd_conf_system, system_port) |
|
71111
cd166c3904dd
more robust: system ssh service is required for Phabricator ssh service;
wenzelm
parents:
71109
diff
changeset
|
739 |
Linux.service_start("ssh")
|
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
740 |
} |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
741 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
742 |
progress.echo("Configuring " + ssh_name + " service")
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
743 |
|
| 71282 | 744 |
val ssh_command = command_setup(ssh_name, body = |
| 71122 | 745 |
"""if [ "$1" = "$NAME" ] |
746 |
then |
|
747 |
exec "$ROOT/phabricator/bin/ssh-auth" "$@" |
|
| 71270 | 748 |
fi""", exit = "exit 1") |
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
749 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
750 |
File.write(sshd_conf_server, |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
751 |
"""# OpenBSD Secure Shell server for Isabelle/Phabricator |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
752 |
AuthorizedKeysCommand """ + ssh_command.implode + """ |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
753 |
AuthorizedKeysCommandUser """ + daemon_user + """ |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
754 |
AuthorizedKeysFile none |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
755 |
AllowUsers """ + configs.map(_.name).mkString(" ") + """
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
756 |
Port """ + server_port + """ |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
757 |
Protocol 2 |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
758 |
PermitRootLogin no |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
759 |
AllowAgentForwarding no |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
760 |
AllowTcpForwarding no |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
761 |
PrintMotd no |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
762 |
PrintLastLog no |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
763 |
PasswordAuthentication no |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
764 |
ChallengeResponseAuthentication no |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
765 |
PidFile /var/run/""" + ssh_name + """.pid |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
766 |
""") |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
767 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
768 |
Linux.service_install(ssh_name, |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
769 |
"""[Unit] |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
770 |
Description=OpenBSD Secure Shell server for Isabelle/Phabricator |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
771 |
After=network.target auditd.service |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
772 |
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
773 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
774 |
[Service] |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
775 |
EnvironmentFile=-/etc/default/ssh |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
776 |
ExecStartPre=/usr/sbin/sshd -f """ + sshd_conf_server.implode + """ -t |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
777 |
ExecStart=/usr/sbin/sshd -f """ + sshd_conf_server.implode + """ -D $SSHD_OPTS |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
778 |
ExecReload=/usr/sbin/sshd -f """ + sshd_conf_server.implode + """ -t |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
779 |
ExecReload=/bin/kill -HUP $MAINPID |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
780 |
KillMode=process |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
781 |
Restart=on-failure |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
782 |
RestartPreventExitStatus=255 |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
783 |
Type=notify |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
784 |
RuntimeDirectory=sshd-phabricator |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
785 |
RuntimeDirectoryMode=0755 |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
786 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
787 |
[Install] |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
788 |
WantedBy=multi-user.target |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
789 |
Alias=""" + ssh_name + """.service |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
790 |
""") |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
791 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
792 |
for (config <- configs) {
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
793 |
progress.echo("phabricator " + quote(config.name) + " port " + server_port)
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
794 |
config.execute("config set diffusion.ssh-port " + Bash.string(server_port.toString))
|
| 71550 | 795 |
if (server_port == SSH.default_port) config.execute("config delete diffusion.ssh-port")
|
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
796 |
} |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
797 |
} |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
798 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
799 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
800 |
/* Isabelle tool wrapper */ |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
801 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
802 |
val isabelle_tool4 = |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
803 |
Isabelle_Tool("phabricator_setup_ssh",
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
804 |
"setup ssh service for all Phabricator installations", args => |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
805 |
{
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
806 |
var server_port = default_server_port |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
807 |
var system_port = default_system_port |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
808 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
809 |
val getopts = |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
810 |
Getopts("""
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
811 |
Usage: isabelle phabricator_setup_ssh [OPTIONS] |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
812 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
813 |
Options are: |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
814 |
-p PORT sshd port for Phabricator servers (default: """ + default_server_port + """) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
815 |
-q PORT sshd port for the operating system (default: """ + default_system_port + """) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
816 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
817 |
Configure ssh service for all Phabricator installations: a separate sshd |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
818 |
is run in addition to the one of the operating system, and ports need to |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
819 |
be distinct. |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
820 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
821 |
A particular Phabricator installation is addressed by using its |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
822 |
name as the ssh user; the actual Phabricator user is determined via |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
823 |
stored ssh keys. |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
824 |
""", |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
825 |
"p:" -> (arg => server_port = Value.Int.parse(arg)), |
|
71295
6aadbd650280
eliminated pointless option -T: it merely tests ssh config of root, which is not required later;
wenzelm
parents:
71292
diff
changeset
|
826 |
"q:" -> (arg => system_port = Value.Int.parse(arg))) |
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
827 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
828 |
val more_args = getopts(args) |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
829 |
if (more_args.nonEmpty) getopts.usage() |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
830 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
831 |
val progress = new Console_Progress |
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
832 |
|
|
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
833 |
phabricator_setup_ssh( |
|
71295
6aadbd650280
eliminated pointless option -T: it merely tests ssh config of root, which is not required later;
wenzelm
parents:
71292
diff
changeset
|
834 |
server_port = server_port, system_port = system_port, progress = progress) |
|
71109
8c1c717a830b
configure SSH hosting via "isabelle phabricator_setup_ssh";
wenzelm
parents:
71103
diff
changeset
|
835 |
}) |
| 71299 | 836 |
|
837 |
||
838 |
||
839 |
/** conduit API **/ |
|
840 |
||
| 71314 | 841 |
object API |
| 71299 | 842 |
{
|
| 71332 | 843 |
/* user information */ |
844 |
||
845 |
sealed case class User( |
|
846 |
id: Long, |
|
847 |
phid: String, |
|
848 |
name: String, |
|
849 |
real_name: String, |
|
850 |
roles: List[String]) |
|
851 |
{
|
|
852 |
def is_valid: Boolean = |
|
853 |
roles.contains("verified") &&
|
|
854 |
roles.contains("approved") &&
|
|
855 |
roles.contains("activated")
|
|
856 |
def is_admin: Boolean = roles.contains("admin")
|
|
857 |
def is_regular: Boolean = !(roles.contains("bot") || roles.contains("list"))
|
|
858 |
} |
|
859 |
||
860 |
||
| 71314 | 861 |
/* repository information */ |
862 |
||
863 |
sealed case class Repository( |
|
864 |
vcs: VCS.Value, |
|
865 |
id: Long, |
|
866 |
phid: String, |
|
867 |
name: String, |
|
868 |
callsign: String, |
|
869 |
short_name: String, |
|
870 |
importing: Boolean, |
|
871 |
ssh_url: String) |
|
872 |
{
|
|
873 |
def is_hg: Boolean = vcs == VCS.hg |
|
874 |
} |
|
875 |
||
876 |
object VCS extends Enumeration |
|
877 |
{
|
|
878 |
val hg, git, svn = Value |
|
879 |
def read(s: String): Value = |
|
880 |
try { withName(s) }
|
|
881 |
catch { case _: java.util.NoSuchElementException => error("Unknown vcs type " + quote(s)) }
|
|
882 |
} |
|
883 |
||
884 |
def edits(typ: String, value: JSON.T): List[JSON.Object.T] = |
|
885 |
List(JSON.Object("type" -> typ, "value" -> value))
|
|
886 |
||
887 |
def opt_edits(typ: String, value: Option[JSON.T]): List[JSON.Object.T] = |
|
888 |
value.toList.flatMap(edits(typ, _)) |
|
889 |
||
890 |
||
891 |
/* result with optional error */ |
|
892 |
||
893 |
sealed case class Result(result: JSON.T, error: Option[String]) |
|
894 |
{
|
|
895 |
def ok: Boolean = error.isEmpty |
|
896 |
def get: JSON.T = if (ok) result else Exn.error(error.get) |
|
897 |
||
898 |
def get_value[A](unapply: JSON.T => Option[A]): A = |
|
899 |
unapply(get) getOrElse Exn.error("Bad JSON result: " + JSON.Format(result))
|
|
900 |
||
901 |
def get_string: String = get_value(JSON.Value.String.unapply) |
|
902 |
} |
|
903 |
||
904 |
def make_result(json: JSON.T): Result = |
|
905 |
{
|
|
906 |
val result = JSON.value(json, "result").getOrElse(JSON.Object.empty) |
|
907 |
val error_info = JSON.string(json, "error_info") |
|
908 |
val error_code = JSON.string(json, "error_code") |
|
909 |
Result(result, error_info orElse error_code) |
|
910 |
} |
|
911 |
||
912 |
||
913 |
/* context for operations */ |
|
914 |
||
| 71550 | 915 |
def apply(user: String, host: String, port: Int = SSH.default_port): API = |
| 71314 | 916 |
new API(user, host, port) |
| 71299 | 917 |
} |
918 |
||
| 71314 | 919 |
final class API private(ssh_user: String, ssh_host: String, ssh_port: Int) |
| 71299 | 920 |
{
|
921 |
/* connection */ |
|
922 |
||
923 |
require(ssh_host.nonEmpty && ssh_port >= 0) |
|
924 |
||
| 71550 | 925 |
private def ssh_user_prefix: String = SSH.user_prefix(ssh_user) |
926 |
private def ssh_port_suffix: String = SSH.port_suffix(ssh_port) |
|
| 71299 | 927 |
|
928 |
override def toString: String = ssh_user_prefix + ssh_host + ssh_port_suffix |
|
| 71308 | 929 |
def hg_url: String = "ssh://" + ssh_user_prefix + ssh_host + ssh_port_suffix |
| 71299 | 930 |
|
931 |
||
932 |
/* execute methods */ |
|
933 |
||
| 71300 | 934 |
def execute_raw(method: String, params: JSON.T = JSON.Object.empty): JSON.T = |
| 71299 | 935 |
{
|
| 71300 | 936 |
Isabelle_System.with_tmp_file("params", "json")(params_file =>
|
| 71299 | 937 |
{
|
| 71300 | 938 |
File.write(params_file, JSON.Format(JSON.Object("params" -> JSON.Format(params))))
|
| 71299 | 939 |
val result = |
940 |
Isabelle_System.bash( |
|
941 |
"ssh -p " + ssh_port + " " + Bash.string(ssh_user_prefix + ssh_host) + |
|
| 71300 | 942 |
" conduit " + Bash.string(method) + " < " + File.bash_path(params_file)).check |
| 71299 | 943 |
JSON.parse(result.out, strict = false) |
944 |
}) |
|
945 |
} |
|
946 |
||
| 71300 | 947 |
def execute(method: String, params: JSON.T = JSON.Object.empty): API.Result = |
948 |
API.make_result(execute_raw(method, params = params)) |
|
| 71299 | 949 |
|
| 71330 | 950 |
def execute_search[A]( |
951 |
method: String, params: JSON.Object.T, unapply: JSON.T => Option[A]): List[A] = |
|
952 |
{
|
|
953 |
val results = new mutable.ListBuffer[A] |
|
954 |
var after = "" |
|
955 |
||
956 |
do {
|
|
957 |
val result = |
|
958 |
execute(method, params = params ++ JSON.optional("after" -> proper_string(after)))
|
|
959 |
results ++= result.get_value(JSON.list(_, "data", unapply)) |
|
960 |
after = result.get_value(JSON.value(_, "cursor", JSON.string0(_, "after"))) |
|
961 |
} while (after.nonEmpty) |
|
962 |
||
963 |
results.toList |
|
964 |
} |
|
965 |
||
| 71332 | 966 |
def ping(): String = execute("conduit.ping").get_string
|
| 71299 | 967 |
|
968 |
||
| 71332 | 969 |
/* users */ |
| 71299 | 970 |
|
| 71300 | 971 |
lazy val user_phid: String = execute("user.whoami").get_value(JSON.string(_, "phid"))
|
972 |
lazy val user_name: String = execute("user.whoami").get_value(JSON.string(_, "userName"))
|
|
| 71301 | 973 |
|
| 71332 | 974 |
def get_users( |
975 |
all: Boolean = false, |
|
976 |
phid: String = "", |
|
977 |
name: String = ""): List[API.User] = |
|
978 |
{
|
|
979 |
val constraints: JSON.Object.T = |
|
980 |
(for { (key, value) <- List("phids" -> phid, "usernames" -> name) if value.nonEmpty }
|
|
981 |
yield (key, List(value))).toMap |
|
982 |
||
983 |
execute_search("user.search",
|
|
984 |
JSON.Object("queryKey" -> (if (all) "all" else "active"), "constraints" -> constraints),
|
|
985 |
data => JSON.value(data, "fields", fields => |
|
986 |
for {
|
|
987 |
id <- JSON.long(data, "id") |
|
988 |
phid <- JSON.string(data, "phid") |
|
989 |
name <- JSON.string(fields, "username") |
|
990 |
real_name <- JSON.string0(fields, "realName") |
|
991 |
roles <- JSON.strings(fields, "roles") |
|
992 |
} yield API.User(id, phid, name, real_name, roles))) |
|
993 |
} |
|
994 |
||
995 |
def the_user(phid: String): API.User = |
|
996 |
get_users(phid = phid) match {
|
|
997 |
case List(user) => user |
|
998 |
case _ => error("Bad user PHID " + quote(phid))
|
|
999 |
} |
|
1000 |
||
1001 |
||
1002 |
/* repositories */ |
|
1003 |
||
| 71306 | 1004 |
def get_repositories( |
| 71331 | 1005 |
all: Boolean = false, |
1006 |
phid: String = "", |
|
1007 |
callsign: String = "", |
|
1008 |
short_name: String = ""): List[API.Repository] = |
|
| 71306 | 1009 |
{
|
1010 |
val constraints: JSON.Object.T = |
|
1011 |
(for {
|
|
1012 |
(key, value) <- List("phids" -> phid, "callsigns" -> callsign, "shortNames" -> short_name)
|
|
1013 |
if value.nonEmpty |
|
1014 |
} yield (key, List(value))).toMap |
|
1015 |
||
| 71330 | 1016 |
execute_search("diffusion.repository.search",
|
| 71331 | 1017 |
JSON.Object("queryKey" -> (if (all) "all" else "active"), "constraints" -> constraints),
|
| 71330 | 1018 |
data => JSON.value(data, "fields", fields => |
1019 |
for {
|
|
1020 |
vcs_name <- JSON.string(fields, "vcs") |
|
1021 |
id <- JSON.long(data, "id") |
|
1022 |
phid <- JSON.string(data, "phid") |
|
1023 |
name <- JSON.string(fields, "name") |
|
1024 |
callsign <- JSON.string0(fields, "callsign") |
|
1025 |
short_name <- JSON.string0(fields, "shortName") |
|
1026 |
importing <- JSON.bool(fields, "isImporting") |
|
| 71306 | 1027 |
} |
| 71330 | 1028 |
yield {
|
1029 |
val vcs = API.VCS.read(vcs_name) |
|
1030 |
val url_path = |
|
1031 |
if (short_name.isEmpty) "/diffusion/" + id else "/source/" + short_name |
|
1032 |
val ssh_url = |
|
1033 |
vcs match {
|
|
1034 |
case API.VCS.hg => hg_url + url_path |
|
1035 |
case API.VCS.git => hg_url + url_path + ".git" |
|
1036 |
case API.VCS.svn => "" |
|
1037 |
} |
|
1038 |
API.Repository(vcs, id, phid, name, callsign, short_name, importing, ssh_url) |
|
1039 |
})) |
|
| 71306 | 1040 |
} |
| 71309 | 1041 |
|
| 71311 | 1042 |
def the_repository(phid: String): API.Repository = |
1043 |
get_repositories(phid = phid) match {
|
|
1044 |
case List(repo) => repo |
|
| 71314 | 1045 |
case _ => error("Bad repository PHID " + quote(phid))
|
| 71311 | 1046 |
} |
1047 |
||
| 71309 | 1048 |
def create_repository( |
1049 |
name: String, |
|
1050 |
callsign: String = "", // unique name, UPPERCASE |
|
1051 |
short_name: String = "", // unique name |
|
1052 |
description: String = "", |
|
1053 |
public: Boolean = false, |
|
| 71310 | 1054 |
vcs: API.VCS.Value = API.VCS.hg): API.Repository = |
| 71309 | 1055 |
{
|
1056 |
require(name.nonEmpty) |
|
1057 |
||
1058 |
val transactions = |
|
1059 |
API.edits("vcs", vcs.toString) :::
|
|
1060 |
API.edits("name", name) :::
|
|
1061 |
API.opt_edits("callsign", proper_string(callsign)) :::
|
|
1062 |
API.opt_edits("shortName", proper_string(short_name)) :::
|
|
1063 |
API.opt_edits("description", proper_string(description)) :::
|
|
1064 |
(if (public) Nil |
|
1065 |
else API.edits("view", user_phid) ::: API.edits("policy.push", user_phid)) :::
|
|
1066 |
API.edits("status", "active")
|
|
1067 |
||
| 71310 | 1068 |
val phid = |
| 71309 | 1069 |
execute("diffusion.repository.edit", params = JSON.Object("transactions" -> transactions))
|
1070 |
.get_value(JSON.value(_, "object", JSON.string(_, "phid"))) |
|
1071 |
||
| 71310 | 1072 |
execute("diffusion.looksoon", params = JSON.Object("repositories" -> List(phid))).get
|
| 71309 | 1073 |
|
| 71311 | 1074 |
the_repository(phid) |
| 71309 | 1075 |
} |
| 71299 | 1076 |
} |
| 70967 | 1077 |
} |