c0facc5265
still needs some extra testing so it won't be connected to the builds just yet. diffs & good error reports welcome.
105 lines
2.0 KiB
Bash
105 lines
2.0 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $OpenBSD: openfirectl.template,v 1.1.1.1 2009/06/19 01:09:36 jolan Exp $
|
|
#
|
|
# openfirectl -- Stops and starts the Openfire XMPP service.
|
|
#
|
|
# Modified for OpenBSD by Jolan Luff <jolan@openbsd.org>
|
|
#
|
|
# This script manages the openfire daemon process. This script should
|
|
# only be run as root.
|
|
|
|
#####
|
|
# Begin setup work
|
|
#####
|
|
|
|
# Initialization
|
|
CMD=$1
|
|
PATH="/sbin:/bin:/usr/bin:/usr/sbin"
|
|
RETVAL=0
|
|
JAVA_HOME="__LOCALBASE__/jdk-1.7.0/jre"
|
|
JAVACMD="${JAVA_HOME}/bin/java"
|
|
|
|
OPENFIRE_HOME="__PREFIX__/openfire"
|
|
OPENFIRE_LOGDIR="${OPENFIRE_HOME}/logs"
|
|
OPENFIRE_LIB="${OPENFIRE_HOME}/lib"
|
|
OPENFIRE_USER="_openfire"
|
|
|
|
# Make sure we are running as root
|
|
set `/usr/bin/id`
|
|
if [ $1 != "uid=0(root)" ]; then
|
|
echo "$0: must be run as root"
|
|
exit 1
|
|
fi
|
|
|
|
# Prepare openfire command line
|
|
OPENFIRE_OPTS="${OPENFIRE_OPTS} -DopenfireHome=${OPENFIRE_HOME} -Dopenfire.lib.dir=${OPENFIRE_LIB}"
|
|
|
|
# Prepare local java class path
|
|
if [ -z "$LOCALCLASSPATH" ]; then
|
|
LOCALCLASSPATH="${OPENFIRE_LIB}/startup.jar"
|
|
else
|
|
LOCALCLASSPATH="${OPENFIRE_LIB}/startup.jar:${LOCALCLASSPATH}"
|
|
fi
|
|
|
|
# Export any necessary variables
|
|
export JAVA_HOME JAVACMD
|
|
|
|
# Lastly, prepare the full command that we are going to run.
|
|
OPENFIRE_RUN_CMD="${JAVACMD} -server ${OPENFIRE_OPTS} -classpath \"${LOCALCLASSPATH}\" -jar \"${OPENFIRE_LIB}/startup.jar\""
|
|
|
|
#####
|
|
# End setup work
|
|
#####
|
|
|
|
start() {
|
|
OLD_PWD=`pwd`
|
|
cd $OPENFIRE_HOME
|
|
|
|
# Start daemons.
|
|
echo "Starting openfire: $OPENFIRE_RUN_CMD \c"
|
|
|
|
PID=`su - $OPENFIRE_USER -c "nohup $OPENFIRE_RUN_CMD > $OPENFIRE_LOGDIR/nohup.out 2>&1 &"`
|
|
RETVAL=$?
|
|
echo "done."
|
|
|
|
sleep 1 # allows prompt to return
|
|
cd $OLD_PWD
|
|
}
|
|
|
|
stop_openfire() {
|
|
# Stop daemons.
|
|
echo "Shutting down openfire: \c"
|
|
|
|
kill `pgrep -f "/usr/local/openfire/lib/startup.jar"`
|
|
RETVAL=$?
|
|
echo "done."
|
|
}
|
|
|
|
restart() {
|
|
stop_openfire
|
|
sleep 10 # give it a few moments to shut down
|
|
start
|
|
}
|
|
|
|
# Handle how we were called.
|
|
case "$CMD" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop_openfire
|
|
;;
|
|
restart)
|
|
restart
|
|
;;
|
|
reload)
|
|
restart
|
|
;;
|
|
*)
|
|
echo "Usage $0 {start|stop|restart|reload}"
|
|
RETVAL=1
|
|
esac
|
|
|
|
exit $RETVAL
|