xcat-core/xCAT-server-2.0/xcatd.rc

91 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/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
# Default-Start: 3 4 5
# Default-stop: 0 1 2 6
# Short-Description: xCATd
# Description: xCAT management service
### END INIT INFO
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 /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_message
elif [ -f /etc/init.d/functions ]; then
echo RH
. /etc/init.d/functions
START_DAEMON=daemon
STATUS=status
LOG_SUCCESS=success
LOG_FAILURE=failure
LOG_WARNING=passed
else
echo "Error, don't know how to start on this platform"
exit 1
fi
case $1 in
status)
$STATUS
;;
stop)
echo -n "Stopping xCATD"
$STATUS >& /dev/null
if [ "$?" != "0" ]; then
echo -n "xCATd not running, not stopping"
$LOG_WARNING
exit 1
fi
kill -TERM -`cat /var/run/xcatd.pid`
usleep 100000
$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 1
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"
xcatd -p /var/run/xcatd.pid && $LOG_SUCCESS || $LOG_FAILURE
;;
esac