wildfired 1.88 KB
Newer Older
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
#!/bin/sh

# wildfired
#
# chkconfig: 2345 20 80
# description: Used to start and stop the wildfire XMPP server
# 
# Script used to start wildfire as daemon
# The script has currently been tested on Redhat Fedora Core 3,
# but should theoretically work on most UNIX like systems
#
# before running this script make sure $WILDFIRE_HOME/bin/wildfire is
# executable by the user you want to run wildfire as
# (chmod +x $WILDFIRE_HOME/bin/wildfire)
#
# This script should be copied into /etc/init.d and linked into
# your default runlevel directory.
# You can find your default runlevel directory by typing: 
# grep default /etc/inittab
#
# Link to the directory like follows
# cd /etc/rc<num>.d
# ln -s ../init.d/wildfired $90wildfired
#

# Set this to tell this script where wildfire lives
27
# If this is not set the script will look for /opt/wildfire, then /usr/local/wildfire
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
#export WILDFIRE_HOME=

# If there is a different user you would like to run this script as,
# change the following line
export WILDFIRE_USER=jive

# -----------------------------------------------------------------

# If a wildfire home variable has not been specified, try to determine it
if [ ! $WILDFIRE_HOME ]; then
	if [ -d "/opt/wildfire" ]; then
		WILDFIRE_HOME="/opt/wildfire"
	elif [ -d "/usr/local/wildfire" ]; then
		WILDFIRE_HOME="/usr/local/wildfire"
	else
		echo "Could not find Wildfire installation under /opt or /usr/local"
		echo "Please specify the Wildfire installation location in environment variable WILDFIRE_HOME"
		exit 1
	fi
fi


function execCommand() {
	OLD_PWD=`pwd`
	cd $WILDFIRE_HOME/bin
	CMD="./wildfire $1"
	su -c "$CMD" $WILDFIRE_USER &
	cd $OLD_PWD
}


start() {
	execCommand "start"
}

stop() {
	execCommand "stop"
}


case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	*)
		echo "Usage $0 {start|stop}"
		exit 1
esac

exit 0