blob: ba579166240e302d4a0464290f41534d79953fb6 (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#!/bin/sh
#
# $FreeBSD
#
# PROVIDE: sonarqube
# REQUIRE: NETWORKING SERVERS
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable %%APP_NAME%%:
#
# %%APP_NAME%%_enable="YES"
#
. /etc/rc.subr
name=%%APP_NAME%%
rcvar=%%APP_NAME%%_enable
# set defaults
%%APP_NAME%%_enable=${%%APP_NAME%%_enable:-"NO"}
%%APP_NAME%%_supervised=${%%APP_NAME%%_supervised:-"YES"}
%%APP_NAME%%_user=${%%APP_NAME%%_user:-"sonarqube"}
%%APP_NAME%%_group=${%%APP_NAME%%_group:-"sonarqube"}
%%APP_NAME%%_parameters=${%%APP_NAME%%_parameters:-"-Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true"}
%%APP_NAME%%_logfile=${%%APP_NAME%%_logfile:-"%%LOG_DIR%%/daemon.log"}
%%APP_NAME%%_pidpath=${%%APP_NAME%%_pidpath:-"%%PID_DIR%%"}
sup_pidfile=${%%APP_NAME%%_pidpath}/%%APP_NAME%%_supervisor.pid
main_pidfile=${%%APP_NAME%%_pidpath}/%%APP_NAME%%.pid
if [ ! -d %%PID_DIR%% ]; then
mkdir -p %%PID_DIR%%
chown ${%%APP_NAME%%_user}:${%%APP_NAME%%_group} %%PID_DIR%%
fi
if [ ! -d %%LOG_DIR%% ]; then
mkdir -p %%LOG_DIR%%
chown ${%%APP_NAME%%_user}:${%%APP_NAME%%_group} %%LOG_DIR%%
fi
if test -n "${%%APP_NAME%%_java_version}" ; then
JAVA_HOME=$(JAVA_VERSION="${%%APP_NAME%%_java_version}" JAVAVM_DRYRUN=1 %%LOCALBASE%%/bin/java | grep JAVA_HOME | cut -d= -f2)
javaname=$(JAVA_VERSION="${%%APP_NAME%%_java_version}" JAVAVM_DRYRUN=1 %%LOCALBASE%%/bin/java | grep JAVAVM_PROG | cut -d= -f2)
else
JAVA_HOME=$(JAVAVM_DRYRUN=1 %%LOCALBASE%%/bin/java | grep JAVA_HOME | cut -d= -f2)
javaname=$(JAVAVM_DRYRUN=1 %%LOCALBASE%%/bin/java | grep JAVAVM_PROG | cut -d= -f2)
fi
export JAVA_HOME
jarname="%%PREFIX%%/%%APP_DIR%%/lib/sonar-application-%%JAR_VERSION%%.jar"
command="/usr/sbin/daemon"
required_files="%%PREFIX%%/%%APP_DIR%%/conf/sonar.properties"
load_rc_config ${name}
if checkyesno %%APP_NAME%%_supervised; then
# auto-restart on termination
pidfile=${sup_pidfile}
daemon_supervise_args="-r -P ${sup_pidfile}"
procname=daemon
else
# no restart on termination
pidfile=${main_pidfile}
damon_supervise_args=""
procname=${javaname}
fi
command_args="${daemon_supervise_args} -o ${%%APP_NAME%%_logfile} -p ${main_pidfile} ${javaname} ${%%APP_NAME%%_parameters} -jar ${jarname}"
run_rc_command "$1"
|