aboutsummaryrefslogtreecommitdiff
path: root/net-im/openfire/files/wildfire.in
blob: 3d0894cf2906a8031a2dcc115230a554f516fe07 (plain) (blame)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh

# PROVIDE: wildfire
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# wildfire_enable (bool):   Set to NO by default.
#               Set it to YES to enable wildfire.

. %%RC_SUBR%%

name="wildfire"
rcvar=${name}_enable
# Set defaults
: ${wildfire_enable:=NO}
: ${wildfire_user:=${name}}
: ${wildfire_group:=${name}}

pidfile=/var/run/${name}.pid

required_files="%%PREFIX%%/etc/wildfire/wildfire.xml"
java_options=" 	-server -jar \
		-Dwildfire.lib.dir=%%JAVAJARDIR%% \
		-DwildfireHome=%%DATADIR%%"

java_command="	%%LOCALBASE%%/bin/java ${java_options} \
		%%JAVAJARDIR%%/startup.jar"

# Subvert the check_pid_file procname check.
if [ -f $pidfile ]; then
	read rc_pid junk < $pidfile
	if [ ! -z "$rc_pid" ]; then
		procname=`ps -o ucomm= $rc_pid`
	fi
fi

command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} ${java_command}"
start_precmd="wildfire_precmd"
status_cmd="wildfire_status"
stop_cmd="wildfire_stop"
load_rc_config $name

wildfire_precmd() {
        touch ${pidfile}
        chown ${wildfire_user}:${wildfire_group} ${pidfile}
}

wildfire_status() {
	rc_pid=$(check_pidfile $pidfile *$procname*)

        if [ -z "$rc_pid" ]; then
                [ -n "$rc_fast" ] && return 0
                if [ -n "$pidfile" ]; then
                        echo "${name} not running? (check $pidfile)."
                else
                        echo "${name} not running?"
                fi
                return 1
        fi
	echo "$name is running as pid ${rc_pid}"
}


wildfire_stop() {
        rc_pid=$(check_pidfile $pidfile *$procname*)

        if [ -z "$rc_pid" ]; then
                [ -n "$rc_fast" ] && return 0
                if [ -n "$pidfile" ]; then
                        echo "${name} not running? (check $pidfile)."
                else
                        echo "${name} not running?"
                fi
                return 1
        fi

        echo "Stopping ${name}."
        kill ${rc_pid} 
	wait_for_pids ${rc_pid}
	rm ${pidfile}
}

run_rc_command "$1"