Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# |
4 |
# PROVIDE: %%PORTNAME%% |
5 |
# REQUIRE: LOGIN |
6 |
# KEYWORD: shutdown |
7 |
|
8 |
# Add the following lines to /etc/rc.conf to enable %%PORTNAME%% |
9 |
# %%PORTNAME%%_enable="YES" |
10 |
# |
11 |
# %%PORTNAME%%_enable (bool): Set to YES to enable %%PORTNAME%% |
12 |
# Default: NO |
13 |
# %%PORTNAME%%_conf (str): %%PORTNAME%% configration file |
14 |
# Default: %%PREFIX%%/etc/%%PORTNAME%%.conf |
15 |
# %%PORTNAME%%_user (str): %%PORTNAME%% daemon user |
16 |
# Default: %%METABASE_USER%% |
17 |
# %%PORTNAME%%_group (str): %%PORTNAME%% daemon group |
18 |
# Default: %%METABASE_GROUP%% |
19 |
|
20 |
. /etc/rc.subr |
21 |
|
22 |
name="%%PORTNAME%%" |
23 |
rcvar=%%PORTNAME%%_enable |
24 |
load_rc_config $name |
25 |
|
26 |
: ${%%PORTNAME%%_enable:="NO"} |
27 |
: ${%%PORTNAME%%_user:="%%METABASE_USER%%"} |
28 |
: ${%%PORTNAME%%_group:="%%METABASE_GROUP%%"} |
29 |
: ${%%PORTNAME%%_flags=""} |
30 |
: ${%%PORTNAME%%_java_opts=""} |
31 |
: ${%%PORTNAME%%_java_home="%%JAVA_HOME%%"} |
32 |
: ${%%PORTNAME%%_conf:="%%PREFIX%%/etc/${name}.conf"} |
33 |
: ${%%PORTNAME%%_log:="/var/log/${name}.log"} |
34 |
: ${%%PORTNAME%%_pidfile:="/var/run/${name}.pid"} |
35 |
: ${%%PORTNAME%%_datadir:="%%METABASEDATADIR%%"} |
36 |
|
37 |
required_files=${%%PORTNAME%%_conf} |
38 |
java_command="${%%PORTNAME%%_java_home}/bin/java" |
39 |
procname="${java_command}" |
40 |
pidfile=${%%PORTNAME%%_pidfile} |
41 |
command=/usr/sbin/daemon |
42 |
command_args="-f -t ${name} -p ${pidfile} -o ${%%PORTNAME%%_log} ${java_command} ${%%PORTNAME%%_java_opts} -jar %%PREFIX%%/bin/%%PORTNAME%%.jar ${%%PORTNAME%%_flags}" |
43 |
start_precmd="%%PORTNAME%%_precmd" |
44 |
|
45 |
%%PORTNAME%%_chdir=${%%PORTNAME%%_datadir} |
46 |
|
47 |
%%PORTNAME%%_precmd() |
48 |
{ |
49 |
if [ ! -d "${%%PORTNAME%%_datadir}/." ]; then |
50 |
%%PORTNAME%%_create_datadir || return 1 |
51 |
fi |
52 |
|
53 |
install -o ${%%PORTNAME%%_user} /dev/null ${%%PORTNAME%%_pidfile} |
54 |
|
55 |
if [ ! -f "${%%PORTNAME%%_log}" ]; then |
56 |
touch "${%%PORTNAME%%_log}" |
57 |
chown "${%%PORTNAME%%_user}:${%%PORTNAME%%_group}" "${%%PORTNAME%%_log}" |
58 |
chmod 640 "${%%PORTNAME%%_log}" |
59 |
fi |
60 |
|
61 |
# Loads the configuration file variables and exports them. |
62 |
set -a |
63 |
. ${%%PORTNAME%%_conf} |
64 |
set +a |
65 |
} |
66 |
|
67 |
%%PORTNAME%%_create_datadir() |
68 |
{ |
69 |
echo "Creating data directory" |
70 |
eval mkdir -p ${%%PORTNAME%%_datadir} |
71 |
[ $? -eq 0 ] && chown -R ${%%PORTNAME%%_user}:${%%PORTNAME%%_group} ${%%PORTNAME%%_datadir} |
72 |
} |
73 |
|
74 |
run_rc_command "$1" |