9a70aa89b9
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7765 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
151 lines
3.1 KiB
Bash
Executable File
151 lines
3.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
# chkconfig: 345 85 60
|
|
# description: xCAT management service
|
|
# processname: xcatd
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: xcatd
|
|
# Required-Start: $network $syslog sshd
|
|
# Required-Stop:
|
|
# Should-Start: mysql
|
|
# Default-Start: 3 4 5
|
|
# Default-stop: 0 1 2 6
|
|
# Short-Description: xCATd
|
|
# Description: xCAT management service
|
|
### END INIT INFO
|
|
|
|
# This avoids the perl locale warnings
|
|
if [ -z $LC_ALL ]; then
|
|
export LC_ALL=C
|
|
fi
|
|
|
|
if [ -r /etc/sysconfig/xcat ]; then
|
|
. /etc/sysconfig/xcat
|
|
fi
|
|
|
|
RHSuccess()
|
|
{
|
|
success
|
|
echo
|
|
}
|
|
|
|
RHFailure()
|
|
{
|
|
failure
|
|
echo
|
|
}
|
|
MStatus()
|
|
{
|
|
ps ax|grep -v grep|grep xcatd: >& /dev/null
|
|
if [ "$?" = "0" ]; then
|
|
RVAL=0
|
|
echo "xCAT service is running"
|
|
else
|
|
RVAL=3
|
|
echo "xCAT service is not running"
|
|
fi
|
|
return $RVAL
|
|
}
|
|
|
|
if [ -f /etc/init.d/functions ]; then
|
|
#echo RH
|
|
. /etc/init.d/functions
|
|
START_DAEMON=daemon
|
|
STATUS=MStatus
|
|
LOG_SUCCESS=RHSuccess
|
|
LOG_FAILURE=RHFailure
|
|
LOG_WARNING=passed
|
|
elif [ -f /lib/lsb/init-functions ]; then
|
|
. /lib/lsb/init-functions
|
|
START_DAEMON=start_daemon
|
|
STATUS=MStatus
|
|
LOG_SUCCESS=log_success_msg
|
|
LOG_FAILURE=log_failure_msg
|
|
LOG_WARNING=log_warning_msg
|
|
else
|
|
echo "Error, don't know how to start on this platform"
|
|
exit 1
|
|
fi
|
|
|
|
case $1 in
|
|
restart)
|
|
echo -n "Restarting xCATd "
|
|
$STATUS >& /dev/null
|
|
if [ "$?" == "0" ]; then
|
|
if ! nodels --version |grep 'Version 2.6'; #upgrade or downgrade from another major release, stop it just in case
|
|
$0 stop
|
|
fi
|
|
fi
|
|
if [ -r /etc/profile.d/xcat.sh ]; then
|
|
. /etc/profile.d/xcat.sh
|
|
fi
|
|
xcatd -p /var/run/xcatd.pid && $LOG_SUCCESS || $LOG_FAILURE
|
|
;;
|
|
reload)
|
|
echo -n "Reloading xCATd "
|
|
$STATUS >& /dev/null
|
|
if [ "$?" == "0" ]; then
|
|
if ! nodels --version |grep 'Version 2.6'; #upgrade or downgrade from another major release, stop it just in case
|
|
$0 stop
|
|
fi
|
|
fi
|
|
export XCATRELOAD=yes
|
|
if [ -r /etc/profile.d/xcat.sh ]; then
|
|
. /etc/profile.d/xcat.sh
|
|
fi
|
|
xcatd -p /var/run/xcatd.pid && $LOG_SUCCESS || $LOG_FAILURE
|
|
;;
|
|
status)
|
|
$STATUS
|
|
;;
|
|
stop)
|
|
echo -n "Stopping xCATd "
|
|
$STATUS >& /dev/null
|
|
if [ "$?" != "0" ]; then
|
|
echo -n "xCATd not running, not stopping "
|
|
$LOG_WARNING
|
|
exit 0
|
|
fi
|
|
kill -TERM -`cat /var/run/xcatd.pid`
|
|
let i=0;
|
|
while $STATUS >& /dev/null && [ $i -lt 15 ]; do
|
|
usleep 100000
|
|
let i=i+1
|
|
done
|
|
$STATUS >& /dev/null
|
|
if [ "$?" == "0" ]; then
|
|
kill -KILL -`cat /var/run/xcatd.pid`
|
|
fi
|
|
usleep 100000
|
|
$STATUS >& /dev/null
|
|
if [ "$?" == "0" ]; then
|
|
$LOG_FAILURE
|
|
exit 0
|
|
fi
|
|
$LOG_SUCCESS
|
|
rm /var/run/xcatd.pid
|
|
;;
|
|
start)
|
|
$STATUS >& /dev/null
|
|
if [ "$?" == "0" ]; then
|
|
echo -n "xCATd already running "
|
|
$LOG_WARNING
|
|
exit
|
|
fi
|
|
echo -n "Starting xCATd "
|
|
#xcatroot=`head -n1 /etc/profile.d/xcat.sh`
|
|
#export $xcatroot
|
|
# When this script is invoked via the service cmd on RH, it doesn't have PATH
|
|
# set either, so we run our profile entry to get everything set up properly.
|
|
if [ -r /etc/profile.d/xcat.sh ]; then
|
|
. /etc/profile.d/xcat.sh
|
|
fi
|
|
xcatd -p /var/run/xcatd.pid && $LOG_SUCCESS || $LOG_FAILURE
|
|
;;
|
|
esac
|
|
|
|
|
|
|
|
|