2007-11-27 12:53:18 +00:00
|
|
|
#!/bin/sh
|
2007-10-26 22:44:33 +00:00
|
|
|
# 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
|
2009-03-27 12:59:16 +00:00
|
|
|
# Required-Start: $network $syslog sshd
|
2009-04-08 22:38:16 +00:00
|
|
|
# Required-Stop:
|
2009-03-27 07:14:52 +00:00
|
|
|
# Should-Start: mysql
|
2007-10-26 22:44:33 +00:00
|
|
|
# Default-Start: 3 4 5
|
|
|
|
# Default-stop: 0 1 2 6
|
|
|
|
# Short-Description: xCATd
|
|
|
|
# Description: xCAT management service
|
|
|
|
### END INIT INFO
|
2008-05-03 11:25:22 +00:00
|
|
|
|
|
|
|
# This avoids the perl locale warnings
|
2008-05-06 13:53:48 +00:00
|
|
|
if [ -z $LC_ALL ]; then
|
|
|
|
export LC_ALL=C
|
2008-05-03 11:25:22 +00:00
|
|
|
fi
|
|
|
|
|
2008-01-25 15:07:53 +00:00
|
|
|
if [ -r /etc/sysconfig/xcat ]; then
|
|
|
|
. /etc/sysconfig/xcat
|
|
|
|
fi
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-06-26 14:45:51 +00:00
|
|
|
RHSuccess()
|
|
|
|
{
|
|
|
|
success
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
RHFailure()
|
|
|
|
{
|
|
|
|
failure
|
|
|
|
echo
|
|
|
|
}
|
2007-10-26 22:44:33 +00:00
|
|
|
MStatus()
|
|
|
|
{
|
2014-02-07 22:37:56 +00:00
|
|
|
PID=`cat /var/run/xcatd.pid`
|
|
|
|
if [ -z "$PID" ]; then
|
|
|
|
echo "xCAT service is not running"
|
|
|
|
return 3
|
|
|
|
fi
|
|
|
|
ps $PID|grep xcatd: > /dev/null 2>&1
|
2007-10-26 22:44:33 +00:00
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
RVAL=0
|
|
|
|
echo "xCAT service is running"
|
|
|
|
else
|
|
|
|
RVAL=3
|
|
|
|
echo "xCAT service is not running"
|
|
|
|
fi
|
|
|
|
return $RVAL
|
|
|
|
}
|
|
|
|
|
2008-06-24 19:46:23 +00:00
|
|
|
if [ -f /etc/init.d/functions ]; then
|
2008-05-03 11:25:22 +00:00
|
|
|
#echo RH
|
2007-10-26 22:44:33 +00:00
|
|
|
. /etc/init.d/functions
|
|
|
|
START_DAEMON=daemon
|
2008-03-19 14:13:13 +00:00
|
|
|
STATUS=MStatus
|
2008-06-26 14:45:51 +00:00
|
|
|
LOG_SUCCESS=RHSuccess
|
|
|
|
LOG_FAILURE=RHFailure
|
2007-10-26 22:44:33 +00:00
|
|
|
LOG_WARNING=passed
|
2008-06-24 19:46:23 +00:00
|
|
|
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
|
2007-10-26 22:44:33 +00:00
|
|
|
else
|
|
|
|
echo "Error, don't know how to start on this platform"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
restart)
|
2010-07-09 15:17:47 +00:00
|
|
|
echo -n "Restarting xCATd "
|
2010-10-14 19:55:18 +00:00
|
|
|
if [ -r /etc/profile.d/xcat.sh ]; then
|
|
|
|
. /etc/profile.d/xcat.sh
|
2010-07-09 15:17:47 +00:00
|
|
|
fi
|
|
|
|
xcatd -p /var/run/xcatd.pid && $LOG_SUCCESS || $LOG_FAILURE
|
2007-10-26 22:44:33 +00:00
|
|
|
;;
|
2009-03-02 15:32:34 +00:00
|
|
|
reload)
|
2010-07-09 15:17:47 +00:00
|
|
|
echo -n "Reloading xCATd "
|
2010-10-14 19:55:18 +00:00
|
|
|
if [ -r /etc/profile.d/xcat.sh ]; then
|
|
|
|
. /etc/profile.d/xcat.sh
|
|
|
|
fi
|
2009-03-02 15:32:34 +00:00
|
|
|
export XCATRELOAD=yes
|
2010-07-09 15:17:47 +00:00
|
|
|
xcatd -p /var/run/xcatd.pid && $LOG_SUCCESS || $LOG_FAILURE
|
2009-03-02 15:32:34 +00:00
|
|
|
;;
|
2007-10-26 22:44:33 +00:00
|
|
|
status)
|
|
|
|
$STATUS
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
echo -n "Stopping xCATd "
|
2011-08-17 19:42:11 +00:00
|
|
|
$STATUS > /dev/null 2>&1
|
2007-10-26 22:44:33 +00:00
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo -n "xCATd not running, not stopping "
|
|
|
|
$LOG_WARNING
|
2010-10-06 15:34:26 +00:00
|
|
|
exit 0
|
2007-10-26 22:44:33 +00:00
|
|
|
fi
|
|
|
|
kill -TERM -`cat /var/run/xcatd.pid`
|
2011-08-17 19:42:11 +00:00
|
|
|
i=0;
|
|
|
|
while $STATUS > /dev/null 2>&1 && [ $i -lt 15 ]; do
|
|
|
|
sleep .1
|
|
|
|
i=$((i+1))
|
2007-10-26 22:44:33 +00:00
|
|
|
done
|
2011-08-17 19:42:11 +00:00
|
|
|
$STATUS > /dev/null 2>&1
|
|
|
|
if [ "$?" = "0" ]; then
|
2007-10-26 22:44:33 +00:00
|
|
|
kill -KILL -`cat /var/run/xcatd.pid`
|
|
|
|
fi
|
2011-08-17 19:42:11 +00:00
|
|
|
sleep .1
|
|
|
|
$STATUS > /dev/null 2>&1
|
|
|
|
if [ "$?" = "0" ]; then
|
2007-10-26 22:44:33 +00:00
|
|
|
$LOG_FAILURE
|
2010-10-06 15:34:26 +00:00
|
|
|
exit 0
|
2007-10-26 22:44:33 +00:00
|
|
|
fi
|
|
|
|
$LOG_SUCCESS
|
|
|
|
rm /var/run/xcatd.pid
|
|
|
|
;;
|
|
|
|
start)
|
2011-08-17 19:42:11 +00:00
|
|
|
$STATUS > /dev/null 2>&1
|
|
|
|
if [ "$?" = "0" ]; then
|
2007-10-26 22:44:33 +00:00
|
|
|
echo -n "xCATd already running "
|
|
|
|
$LOG_WARNING
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
echo -n "Starting xCATd "
|
2012-11-29 06:35:36 +00:00
|
|
|
#/var/run/ is a symlink on /run and that's just a tmpfs mount created on boot on ubuntu.
|
|
|
|
#if there is not this directory, create first
|
|
|
|
if [ ! -d /var/run/xcat ];then
|
|
|
|
mkdir -p /var/run/xcat
|
|
|
|
fi
|
2008-02-08 21:53:41 +00:00
|
|
|
#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
|
2007-10-26 22:44:33 +00:00
|
|
|
xcatd -p /var/run/xcatd.pid && $LOG_SUCCESS || $LOG_FAILURE
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|