#!/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 command= $rc_pid | awk '{print $1 }'` 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"