/
gerrit.in
60 lines (48 loc) · 1.21 KB
/
gerrit.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: gerrit
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable the Gerrit daeamon:
#
# gerrit_enable="YES"
#
. /etc/rc.subr
name="gerrit"
rcvar=`set_rcvar`
load_rc_config "${name}"
: ${gerrit_enable="NO"}
: ${gerrit_home="%%GERRIT_HOME%%"}
: ${gerrit_args=""}
: ${gerrit_java_home="%%JAVA_HOME%%"}
: ${gerrit_user="%%GERRIT_USER%%"}
: ${gerrit_group="%%GERRIT_GROUP%%"}
: ${gerrit_site="%%GERRIT_HOME%%/%%GERRIT_SITE%%"}
command="${gerrit_site}/bin/gerrit.sh"
java_cmd="${gerrit_java_home}/bin/java"
procname="GerritCodeReview"
required_files="${java_cmd}"
start_precmd="gerrit_prestart"
start_cmd="gerrit_start"
stop_cmd="gerrit_stop"
PATH="${PATH}:/usr/local/bin"
gerrit_prestart() {
if [ ! -d "${gerrit_home}" ]; then
install -d -o "${gerrit_user}" -g "${gerrit_group}" -m 750 "${gerrit_home}"
fi
# initialize Gerrit if the site directory is missing
if [ ! -d "${gerrit_site}" ]; then
echo "No Gerrit site found. Will initialize Gerrit first..."
/usr/bin/su - ${gerrit_user} -c "${java_cmd} -jar %%DATADIR%%/gerrit.war init -d ${gerrit_site}"
fi
}
gerrit_start() {
${command} start
}
gerrit_stop() {
${command} stop
}
run_rc_command "$1"