Commit 47b14a86 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Committing updates to redhat scripts.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8120 b35dd754-fafc-0310-a699-88a17e54d16e
parent 91dad181
# Set this to the path where openfire lives
# If this is not set the script will look for /opt/openfire, then /usr/local/openfire
# Set this to the path where openfire lives.
# If this is not set the script will look for /opt/openfire, then
# /usr/local/openfire.
#OPENFIRE_HOME=""
# If there is a different user you would like to run openfire as,
# change the following line
#OPENFIRE_USER="jive"
# change the following line.
#OPENFIRE_USER="daemon"
# If you wish to change the location of the openfire pid file,
# change the following line
# change the following line.
#OPENFIRE_PIDFILE="/var/run/openfired.pid"
# If you wish to explictly specific the location of the log directory,
# you can set it here. Note that this applies to the logs generated outside
# openfire itself. If you want to change the location of openfire's own
# logs, see the system property 'log.directory'. If this is not set,
# it will default to $OPENFIRE_HOME/logs.
#OPENFIRE_LOGDIR="/some/where/logs"
# If you wish to override the auto-detected JAVA_HOME variable, uncomment
# and change the following line.
#JAVA_HOME=/usr/java/default
......@@ -9,58 +9,96 @@
# config: /etc/sysconfig/openfire
# pidfile: /var/run/openfire.pid
#
# This script has currently been tested on Redhat and CentOS based systems,
# but should theoretically work on most UNIX like systems
#
# Before running this script make sure $OPENFIRE_HOME/bin/openfire.sh is
# executable by the user you want to run openfire as
# (chmod +x $OPENFIRE_HOME/bin/openfire.sh)
#
# 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/openfired S99openfired
# This script has currently been tested on Redhat, CentOS, and Fedora based
# systems.
#
PATH=/sbin:/bin:/usr/bin:/usr/sbin
#####
# Begin setup work
#####
# Initialization
PATH="/sbin:/bin:/usr/bin:/usr/sbin"
RETVAL=0
PROG="openfire"
# Check that we are root ... so non-root users stop here
# Check that we are root ... so non-root users stop here.
[ "`id -u`" = 0 ] || exit 1
# Get config.
[ -f "/etc/sysconfig/$PROG" ] && . /etc/sysconfig/$PROG
# If openfire user is not set in sysconfig, set to jive.
[ -z "$OPENFIRE_USER" ] && OPENFIRE_USER=jive
# If openfire user is not set in sysconfig, set to daemon.
[ -z "$OPENFIRE_USER" ] && OPENFIRE_USER="daemon"
# If pid file path is not set in sysconfig, set to /var/run/openfired.pid.
[ -z "$OPENFIRE_PIDFILE" ] && OPENFIRE_PIDFILE=/var/run/$PROG.pid
[ -z "$OPENFIRE_PIDFILE" ] && OPENFIRE_PIDFILE="/var/run/${PROG}.pid"
# -----------------------------------------------------------------
# If a openfire home variable has not been specified, try to determine it
if [ -z "$OPENFIRE_HOME" ]; then
# If a openfire home variable has not been specified, try to determine it.
if [ -z "$OPENFIRE_HOME" -o ! -d "$OPENFIRE_HOME" ]; then
if [ -d "/opt/openfire" ]; then
OPENFIRE_HOME="/opt/openfire"
elif [ -d "/usr/local/openfire" ]; then
OPENFIRE_HOME="/usr/local/openfire"
else
echo "Could not find Openfire installation under /opt or /usr/local"
echo "Please specify the Openfire installation location in environment variable OPENFIRE_HOME"
echo "Could not find Openfire installation under /opt or /usr/local."
echo "Please specify the Openfire installation location as variable OPENFIRE_HOME"
echo "in /etc/sysconfig/$PROG."
exit 1
fi
fi
[ -z "$OPENFIRE_LOGDIR" ] && OPENFIRE_LOGDIR=$OPENFIRE_HOME/logs
# If log path is not set in sysconfig, set to $OPENFIRE_HOME/logs.
[ -z "$OPENFIRE_LOGDIR" ] && OPENFIRE_LOGDIR="${OPENFIRE_HOME}/logs"
# Attempt to locate java installation.
if [ -z "$JAVA_HOME" ]; then
if [ -d "${OPENFIRE_HOME}/jre" ]; then
JAVA_HOME="${OPENFIRE_HOME}/jre"
else
jdks=`ls -r1d /usr/java/j*`
for jdk in $jdks; do
if [ -f "${jdk}/bin/java" ]; then
JAVA_HOME="$jdk"
break
fi
done
fi
fi
JAVACMD="${JAVA_HOME}/bin/java"
if [ ! -d "$JAVA_HOME" -o ! -x "$JAVACMD" ]; then
echo "Error: JAVA_HOME is not defined correctly."
echo " Can not sure execute $JAVACMD."
exit 1
fi
# Prepare location of openfire libraries
OPENFIRE_LIB="${OPENFIRE_HOME}/lib"
# 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
#####
OPENFIRE_CMD="$OPENFIRE_HOME/bin/openfire.sh"
[ -f "$OPENFIRE_CMD" ] || exit 1
start() {
OLD_PWD=`pwd`
......@@ -69,7 +107,7 @@ start() {
# Start daemons.
echo -n "Starting $PROG: "
su -s /bin/sh -c "$OPENFIRE_CMD" $OPENFIRE_USER > nohup.out 2>&1 &
su -s /bin/sh -c "$OPENFIRE_RUN_CMD" $OPENFIRE_USER > nohup.out 2>&1 &
RETVAL=$?
if [ $RETVAL -eq 0 -a ! -z "$OPENFIRE_PIDFILE" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment