author | wenzelm |
Thu, 07 Nov 2019 11:55:41 +0100 | |
changeset 71079 | e06852132c1d |
parent 71078 | 5bb2235d843d |
child 71097 | d3ededaa77b3 |
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 |
||
70969 | 14 |
import scala.util.matching.Regex |
15 |
||
16 |
||
70967 | 17 |
object Phabricator |
18 |
{ |
|
19 |
/** defaults **/ |
|
20 |
||
71049 | 21 |
/* required packages */ |
22 |
||
23 |
val packages: List[String] = |
|
24 |
Build_Docker.packages ::: |
|
25 |
List( |
|
26 |
// https://secure.phabricator.com/source/phabricator/browse/master/scripts/install/install_ubuntu.sh 15e6e2adea61 |
|
27 |
"git", "mysql-server", "apache2", "libapache2-mod-php", "php", "php-mysql", |
|
28 |
"php-gd", "php-curl", "php-apcu", "php-cli", "php-json", "php-mbstring", |
|
29 |
// more packages |
|
30 |
"php-zip", "python-pygments", "ssh") |
|
31 |
||
32 |
||
33 |
/* global system resources */ |
|
34 |
||
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
35 |
val www_user = "www-data" |
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
36 |
|
71049 | 37 |
val daemon_user = "phabricator" |
38 |
||
39 |
val ssh_standard = 22 |
|
40 |
val ssh_alternative1 = 222 |
|
41 |
val ssh_alternative2 = 2222 |
|
42 |
||
43 |
||
44 |
/* installation parameters */ |
|
45 |
||
70967 | 46 |
val default_name = "vcs" |
47 |
||
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
48 |
def phabricator_name(name: String = "", ext: String = ""): String = |
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
49 |
"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
|
50 |
|
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
51 |
def isabelle_phabricator_name(name: String = "", ext: String = ""): String = |
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
52 |
"isabelle-" + phabricator_name(name = name, ext = ext) |
70967 | 53 |
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
54 |
def default_root(name: String): Path = |
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
55 |
Path.explode("/var/www") + Path.basic(phabricator_name(name = name)) |
70967 | 56 |
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
57 |
def default_repo(name: String): Path = default_root(name) + Path.basic("repo") |
70967 | 58 |
|
71072 | 59 |
val default_mailers: Path = Path.explode("mailers.json") |
71066 | 60 |
|
70967 | 61 |
|
62 |
||
63 |
/** global configuration **/ |
|
64 |
||
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
65 |
val global_config = Path.explode("/etc/" + isabelle_phabricator_name(ext = "conf")) |
70967 | 66 |
|
67 |
sealed case class Config(name: String, root: Path) |
|
70968 | 68 |
{ |
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
69 |
def home: Path = root + Path.explode(phabricator_name()) |
70969 | 70 |
|
71 |
def execute(command: String): Process_Result = |
|
71074 | 72 |
Isabelle_System.bash("./bin/" + command, cwd = home.file, redirect = true).check |
70968 | 73 |
} |
70967 | 74 |
|
75 |
def read_config(): List[Config] = |
|
76 |
{ |
|
77 |
if (global_config.is_file) { |
|
78 |
for (entry <- Library.trim_split_lines(File.read(global_config)) if entry.nonEmpty) |
|
79 |
yield { |
|
80 |
space_explode(':', entry) match { |
|
81 |
case List(name, root) => Config(name, Path.explode(root)) |
|
82 |
case _ => error("Malformed config file " + global_config + "\nentry " + quote(entry)) |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
86 |
else Nil |
|
87 |
} |
|
88 |
||
89 |
def write_config(configs: List[Config]) |
|
90 |
{ |
|
91 |
File.write(global_config, |
|
92 |
configs.map(config => config.name + ":" + config.root.implode).mkString("", "\n", "\n")) |
|
93 |
} |
|
94 |
||
95 |
def get_config(name: String): Config = |
|
96 |
read_config().find(config => config.name == name) getOrElse |
|
97 |
error("Bad Isabelle/Phabricator installation " + quote(name)) |
|
98 |
||
99 |
||
100 |
||
101 |
/** setup **/ |
|
102 |
||
71049 | 103 |
def user_setup(name: String, description: String, ssh_setup: Boolean = false) |
104 |
{ |
|
105 |
if (!Linux.user_exists(name)) { |
|
71054
b64fc38327ae
prefer system user setup, e.g. avoid occurrence on login screen;
wenzelm
parents:
71053
diff
changeset
|
106 |
Linux.user_add(name, description = description, system = true, ssh_setup = ssh_setup) |
71049 | 107 |
} |
108 |
else if (Linux.user_description(name) != description) { |
|
109 |
error("User " + quote(name) + " already exists --" + |
|
110 |
" for Phabricator it should have the description:\n " + quote(description)) |
|
111 |
} |
|
112 |
} |
|
113 |
||
70967 | 114 |
def phabricator_setup( |
115 |
name: String = default_name, |
|
116 |
root: String = "", |
|
117 |
repo: String = "", |
|
71047 | 118 |
package_update: Boolean = false, |
70967 | 119 |
progress: Progress = No_Progress) |
120 |
{ |
|
121 |
/* system environment */ |
|
122 |
||
123 |
Linux.check_system_root() |
|
124 |
||
71079 | 125 |
progress.echo("System packages ...") |
126 |
||
71047 | 127 |
if (package_update) { |
128 |
Linux.package_update(progress = progress) |
|
129 |
Linux.check_reboot_required() |
|
130 |
} |
|
70967 | 131 |
|
132 |
Linux.package_install(packages, progress = progress) |
|
133 |
Linux.check_reboot_required() |
|
134 |
||
135 |
||
71049 | 136 |
/* users */ |
137 |
||
138 |
if (name == daemon_user) { |
|
139 |
error("Clash of installation name with daemon user " + quote(daemon_user)) |
|
140 |
} |
|
141 |
||
142 |
user_setup(daemon_user, "Phabricator Daemon User", ssh_setup = true) |
|
143 |
user_setup(name, "Phabricator SSH User") |
|
144 |
||
145 |
||
70967 | 146 |
/* basic installation */ |
147 |
||
71079 | 148 |
progress.echo("\nPhabricator installation ...") |
71076 | 149 |
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
150 |
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
|
151 |
val repo_path = if (repo.nonEmpty) Path.explode(repo) else default_repo(name) |
70967 | 152 |
|
153 |
val configs = read_config() |
|
154 |
||
155 |
for (config <- configs if config.name == name) { |
|
156 |
error("Duplicate Phabricator installation " + quote(name) + " in " + config.root) |
|
157 |
} |
|
158 |
||
159 |
if (!Isabelle_System.bash("mkdir -p " + File.bash_path(root_path)).ok) { |
|
160 |
error("Failed to create root directory " + root_path) |
|
161 |
} |
|
162 |
||
163 |
progress.bash(cwd = root_path.file, echo = true, |
|
164 |
script = """ |
|
165 |
set -e |
|
71050 | 166 |
chown """ + Bash.string(www_user) + ":" + Bash.string(www_user) + """ . |
70967 | 167 |
chmod 755 . |
168 |
||
169 |
git clone https://github.com/phacility/libphutil.git |
|
170 |
git clone https://github.com/phacility/arcanist.git |
|
171 |
git clone https://github.com/phacility/phabricator.git |
|
172 |
""").check |
|
173 |
||
174 |
val config = Config(name, root_path) |
|
175 |
write_config(configs ::: List(config)) |
|
70968 | 176 |
|
71051 | 177 |
config.execute("config set pygments.enabled true") |
178 |
||
70968 | 179 |
|
71050 | 180 |
/* local repository directory */ |
181 |
||
182 |
if (!Isabelle_System.bash("mkdir -p " + File.bash_path(repo_path)).ok) { |
|
183 |
error("Failed to create local repository directory " + repo_path) |
|
184 |
} |
|
185 |
||
186 |
Isabelle_System.bash(cwd = repo_path.file, |
|
187 |
script = """ |
|
188 |
set -e |
|
189 |
chown -R """ + Bash.string(daemon_user) + ":" + Bash.string(daemon_user) + """ . |
|
190 |
chmod 755 . |
|
191 |
""").check |
|
192 |
||
193 |
config.execute("config set repository.default-local-path " + File.bash_path(repo_path)) |
|
194 |
||
195 |
||
70969 | 196 |
/* MySQL setup */ |
197 |
||
71079 | 198 |
progress.echo("\nMySQL setup ...") |
70969 | 199 |
|
71055
27a998cdc0f4
back to plain name, to have it accepted my mysql;
wenzelm
parents:
71054
diff
changeset
|
200 |
File.write(Path.explode("/etc/mysql/mysql.conf.d/" + phabricator_name(ext = "cnf")), |
71051 | 201 |
"""[mysqld] |
202 |
max_allowed_packet = 32M |
|
203 |
innodb_buffer_pool_size = 1600M |
|
204 |
local_infile = 0 |
|
205 |
""") |
|
206 |
||
207 |
Linux.service_restart("mysql") |
|
208 |
||
209 |
||
70969 | 210 |
def mysql_conf(R: Regex): Option[String] = |
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
211 |
split_lines(File.read(Path.explode("/etc/mysql/debian.cnf"))).collectFirst({ case R(a) => a }) |
70969 | 212 |
|
213 |
for (user <- mysql_conf("""^user\s*=\s*(\S*)\s*$""".r)) { |
|
214 |
config.execute("config set mysql.user " + Bash.string(user)) |
|
215 |
} |
|
216 |
||
217 |
for (pass <- mysql_conf("""^password\s*=\s*(\S*)\s*$""".r)) { |
|
218 |
config.execute("config set mysql.pass " + Bash.string(pass)) |
|
219 |
} |
|
220 |
||
221 |
config.execute("config set storage.default-namespace " + |
|
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
222 |
Bash.string(phabricator_name(name = name).replace("-", "_"))) |
70969 | 223 |
|
71051 | 224 |
config.execute("config set storage.mysql-engine.max-size 8388608") |
225 |
||
71075
70205e023cb4
more messages -- expose potential database problems;
wenzelm
parents:
71074
diff
changeset
|
226 |
progress.bash("./bin/storage upgrade --force", cwd = config.home.file, echo = true).check |
70969 | 227 |
|
228 |
||
71049 | 229 |
/* SSH hosting */ |
230 |
||
71079 | 231 |
progress.echo("\nSSH hosting setup ...") |
71049 | 232 |
|
233 |
val ssh_port = ssh_alternative2 |
|
234 |
||
235 |
config.execute("config set diffusion.ssh-user " + Bash.string(name)) |
|
236 |
config.execute("config set diffusion.ssh-port " + ssh_port) |
|
237 |
||
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
238 |
val sudoers_file = Path.explode("/etc/sudoers.d") + Path.basic(isabelle_phabricator_name()) |
71049 | 239 |
File.write(sudoers_file, |
240 |
www_user + " ALL=(" + daemon_user + ") SETENV: NOPASSWD: /usr/bin/git, /usr/bin/hg, /usr/bin/ssh, /usr/bin/id\n" + |
|
241 |
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") |
|
242 |
||
243 |
Isabelle_System.bash("chmod 0440 " + File.bash_path(sudoers_file)).check |
|
244 |
||
245 |
||
71051 | 246 |
/* PHP setup */ |
247 |
||
248 |
val php_version = |
|
249 |
Isabelle_System.bash("""php --run 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION;'""") |
|
250 |
.check.out |
|
251 |
||
252 |
val php_conf = |
|
253 |
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
|
254 |
Path.explode("apache2/conf.d") + |
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
255 |
Path.basic(isabelle_phabricator_name(ext = "ini")) |
71051 | 256 |
|
257 |
File.write(php_conf, |
|
258 |
"post_max_size = 32M\n" + |
|
259 |
"opcache.validate_timestamps = 0\n" + |
|
260 |
"memory_limit = 512M\n") |
|
261 |
||
262 |
||
70968 | 263 |
/* Apache setup */ |
264 |
||
71079 | 265 |
progress.echo("Apache setup ...") |
70968 | 266 |
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
267 |
val apache_root = Path.explode("/etc/apache2") |
70968 | 268 |
val apache_sites = apache_root + Path.explode("sites-available") |
269 |
||
270 |
if (!apache_sites.is_dir) error("Bad Apache sites directory " + apache_sites) |
|
271 |
||
71058 | 272 |
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
|
273 |
val server_url = "http://" + server_name |
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
274 |
|
71058 | 275 |
File.write(apache_sites + Path.basic(isabelle_phabricator_name(name = name, ext = "conf")), |
70968 | 276 |
"""<VirtualHost *:80> |
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
277 |
ServerName """ + server_name + """ |
70968 | 278 |
ServerAdmin webmaster@localhost |
70969 | 279 |
DocumentRoot """ + config.home.implode + """/webroot |
70968 | 280 |
|
281 |
ErrorLog ${APACHE_LOG_DIR}/error.log |
|
282 |
RewriteEngine on |
|
283 |
RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA] |
|
284 |
</VirtualHost> |
|
285 |
||
286 |
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet |
|
287 |
""") |
|
288 |
||
71051 | 289 |
Isabelle_System.bash( """ |
70968 | 290 |
set -e |
291 |
a2enmod rewrite |
|
71058 | 292 |
a2ensite """ + Bash.string(isabelle_phabricator_name(name = name))).check |
71051 | 293 |
|
71057 | 294 |
config.execute("config set phabricator.base-uri " + Bash.string(server_url)) |
295 |
||
71051 | 296 |
Linux.service_restart("apache2") |
70968 | 297 |
|
71053 | 298 |
|
299 |
/* PHP daemon */ |
|
300 |
||
71079 | 301 |
progress.echo("PHP daemon setup ...") |
71053 | 302 |
|
303 |
config.execute("config set phd.user " + Bash.string(daemon_user)) |
|
304 |
||
71056
ee3c43eb79ae
proper service name (again): it is specific to each installation;
wenzelm
parents:
71055
diff
changeset
|
305 |
Linux.service_install(isabelle_phabricator_name(name = name), |
71053 | 306 |
"""[Unit] |
307 |
Description=PHP daemon for Isabelle/Phabricator """ + quote(name) + """ |
|
308 |
After=syslog.target network.target apache2.service mysql.service |
|
309 |
||
310 |
[Service] |
|
311 |
Type=oneshot |
|
312 |
User=""" + daemon_user + """ |
|
313 |
Group=""" + daemon_user + """ |
|
314 |
Environment=PATH=/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin |
|
315 |
ExecStart=""" + config.home.implode + """/bin/phd start |
|
316 |
ExecStop=""" + config.home.implode + """/bin/phd stop |
|
317 |
RemainAfterExit=yes |
|
318 |
||
319 |
[Install] |
|
320 |
WantedBy=multi-user.target |
|
321 |
""") |
|
322 |
||
323 |
||
71052
6bf53035baf0
clarified name prefixes: global config always uses "isabelle-phabricator";
wenzelm
parents:
71051
diff
changeset
|
324 |
progress.echo("\nDONE\nWeb configuration via " + server_url) |
70967 | 325 |
} |
326 |
||
327 |
||
328 |
/* Isabelle tool wrapper */ |
|
329 |
||
330 |
val isabelle_tool1 = |
|
331 |
Isabelle_Tool("phabricator_setup", "setup Phabricator server on Ubuntu Linux", args => |
|
332 |
{ |
|
71047 | 333 |
var repo = "" |
334 |
var package_update = false |
|
71078 | 335 |
var name = default_name |
70967 | 336 |
var root = "" |
337 |
||
338 |
val getopts = |
|
339 |
Getopts(""" |
|
71078 | 340 |
Usage: isabelle phabricator_setup [OPTIONS] |
70967 | 341 |
|
342 |
Options are: |
|
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
343 |
-R DIR repository directory (default: """ + default_repo("NAME") + """) |
71047 | 344 |
-U full update of system packages before installation |
71078 | 345 |
-n NAME Phabricator installation name (default: """ + quote(default_name) + """) |
71068
510b89906d86
discontinued somewhat pointless Isabelle options: setup implicitly assumes Ubuntu 18.04;
wenzelm
parents:
71066
diff
changeset
|
346 |
-r DIR installation root directory (default: """ + default_root("NAME") + """) |
70967 | 347 |
|
348 |
Install Phabricator as Ubuntu LAMP application (Linux, Apache, MySQL, PHP). |
|
349 |
||
350 |
Slogan: "Discuss. Plan. Code. Review. Test. |
|
351 |
Every application your project needs, all in one tool." |
|
352 |
||
71078 | 353 |
The installation name (default: """ + quote(default_name) + """) is mapped to a regular |
354 |
Unix user; this is relevant for public SSH access. |
|
70967 | 355 |
""", |
356 |
"R:" -> (arg => repo = arg), |
|
71047 | 357 |
"U" -> (_ => package_update = true), |
71078 | 358 |
"n:" -> (arg => name = arg), |
70967 | 359 |
"r:" -> (arg => root = arg)) |
360 |
||
361 |
val more_args = getopts(args) |
|
71078 | 362 |
if (more_args.nonEmpty) getopts.usage() |
70967 | 363 |
|
364 |
val progress = new Console_Progress |
|
365 |
||
71078 | 366 |
phabricator_setup(name = name, root = root, repo = repo, |
71047 | 367 |
package_update = package_update, progress = progress) |
70967 | 368 |
}) |
369 |
||
370 |
||
371 |
||
71066 | 372 |
/** setup mail **/ |
70967 | 373 |
|
71072 | 374 |
val mailers_template: String = |
375 |
"""[ |
|
376 |
{ |
|
377 |
"key": "example.org", |
|
378 |
"type": "smtp", |
|
379 |
"options": { |
|
380 |
"host": "mail.example.org", |
|
381 |
"port": 465, |
|
382 |
"user": "phabricator@example.org", |
|
383 |
"password": "********", |
|
384 |
"protocol": "ssl", |
|
385 |
"message-id": true |
|
386 |
} |
|
387 |
} |
|
388 |
]""" |
|
389 |
||
71066 | 390 |
def phabricator_setup_mail( |
391 |
name: String = default_name, |
|
392 |
config_file: Option[Path] = None, |
|
393 |
test_user: String = "", |
|
394 |
progress: Progress = No_Progress) |
|
70967 | 395 |
{ |
396 |
Linux.check_system_root() |
|
397 |
||
71066 | 398 |
val config = get_config(name) |
71073 | 399 |
val default_config_file = config.root + default_mailers |
71066 | 400 |
|
401 |
val mail_config = config_file getOrElse default_config_file |
|
402 |
||
403 |
def setup_mail |
|
404 |
{ |
|
405 |
progress.echo("Using mail configuration from " + mail_config) |
|
406 |
config.execute("config set cluster.mailers --stdin < " + File.bash_path(mail_config)) |
|
407 |
||
408 |
if (test_user.nonEmpty) { |
|
409 |
progress.echo("Sending test mail to " + quote(test_user)) |
|
410 |
progress.bash(cwd = config.home.file, echo = true, |
|
411 |
script = """echo "Test from Phabricator ($(date))" | ./bin/mail send-test --subject "Test" --to """ + |
|
412 |
Bash.string(test_user)).check |
|
413 |
} |
|
414 |
} |
|
415 |
||
416 |
if (config_file.isEmpty) { |
|
71070 | 417 |
if (!default_config_file.is_file) { |
418 |
File.write(default_config_file, mailers_template) |
|
419 |
Isabelle_System.bash("chmod 600 " + File.bash_path(default_config_file)).check |
|
420 |
} |
|
71066 | 421 |
if (File.read(default_config_file) == mailers_template) { |
422 |
progress.echo( |
|
71077 | 423 |
""" |
424 |
Please invoke the tool again, after providing details in |
|
425 |
""" + default_config_file.implode + """ |
|
426 |
||
427 |
See also section "Mailer: SMTP" in |
|
428 |
https://secure.phabricator.com/book/phabricator/article/configuring_outbound_email |
|
429 |
""") |
|
71066 | 430 |
} |
431 |
else setup_mail |
|
432 |
} |
|
433 |
else setup_mail |
|
70967 | 434 |
} |
435 |
||
436 |
||
437 |
/* Isabelle tool wrapper */ |
|
438 |
||
439 |
val isabelle_tool2 = |
|
71066 | 440 |
Isabelle_Tool("phabricator_setup_mail", |
441 |
"setup mail configuration for existing Phabricator server", args => |
|
70967 | 442 |
{ |
71066 | 443 |
var test_user = "" |
444 |
var name = default_name |
|
445 |
var config_file: Option[Path] = None |
|
446 |
||
70967 | 447 |
val getopts = |
448 |
Getopts(""" |
|
71066 | 449 |
Usage: isabelle phabricator_setup_mail [OPTIONS] |
450 |
||
451 |
Options are: |
|
452 |
-T USER send test mail to Phabricator user |
|
71073 | 453 |
-f FILE config file (default: """ + default_mailers + """ within installation root) |
71066 | 454 |
-n NAME Phabricator installation name (default: """ + quote(default_name) + """) |
70967 | 455 |
|
71077 | 456 |
Provide mail configuration for existing Phabricator installation. |
71066 | 457 |
""", |
458 |
"T:" -> (arg => test_user = arg), |
|
459 |
"f:" -> (arg => config_file = Some(Path.explode(arg))), |
|
460 |
"n:" -> (arg => name = arg)) |
|
70967 | 461 |
|
462 |
val more_args = getopts(args) |
|
71066 | 463 |
if (more_args.nonEmpty) getopts.usage() |
70967 | 464 |
|
465 |
val progress = new Console_Progress |
|
466 |
||
71066 | 467 |
phabricator_setup_mail(name = name, config_file = config_file, |
468 |
test_user = test_user, progress = progress) |
|
70967 | 469 |
}) |
470 |
} |