ha/service-mgmt/sm-common/scripts/sm-watchdog
Erich Cordoba 44f220a3b8 Remove version from sm-common folder
The sm-common component had the 1.0.0 version in the folder name, this
change removes that version and updates the centos_pkg_dirs.

Story: 2006623
Task: 36828

Change-Id: I0e998a3e2482bc06f3a91f9494a3e5d21faa28e7
Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-09-26 12:00:43 -05:00

132 lines
2.7 KiB
Bash
Executable File

#! /bin/sh
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# chkconfig: - 87 87
# processname: sm-watchdog
# description: Service Management Watchdog
#
### BEGIN INIT INFO
# Description: sm-watchdog
#
# Short-Description: Service Management Watchdog
# Provides: sm-watchdog
# Required-Start: $network
# Should-Start: $syslog
# Required-Stop: $network
# Default-Start: 3 5
# Default-Stop: 0 6
### END INIT INFO
. /etc/init.d/functions
RETVAL=0
SM_WATCHDOG_NAME="sm-watchdog"
SM_WATCHDOG="/usr/bin/${SM_WATCHDOG_NAME}"
SM_WATCHDOG_PIDFILE="/var/run/${SM_WATCHDOG_NAME}.pid"
if [ ! -e "${SM_WATCHDOG}" ]
then
logger "${SM_WATCHDOG} is missing"
exit 5
fi
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
case "$1" in
start)
echo -n "Starting ${SM_WATCHDOG_NAME}: "
if [ -n "`pidof ${SM_WATCHDOG}`" ]
then
# PMOND might have restarted SM-WATCHDOG already.
RETVAL=0
else
start-stop-daemon --start -b -x ${SM_WATCHDOG}
RETVAL=$?
fi
if [ ${RETVAL} -eq 0 ]
then
echo "OK"
else
echo "FAIL"
RETVAL=1
fi
;;
stop)
echo -n "Stopping ${SM_WATCHDOG_NAME}: "
if [ -n "`pidof ${SM_WATCHDOG}`" ]
then
killproc ${SM_WATCHDOG}
fi
SHUTDOWN_TIMEOUT=5
count=0
while [ ${count} -lt ${SHUTDOWN_TIMEOUT} ]
do
pidof ${SM_WATCHDOG} &> /dev/null
rc=$?
if [ ${rc} -eq 1 ]
then
echo "OK"
break
fi
count=`expr ${count} + 1`
sleep 1
done
pidof ${SM_WATCHDOG} &> /dev/null
rc=$?
if [ ${rc} -eq 0 ]
then
echo "FAIL"
RETVAL=7
fi
rm -f ${SM_WATCHDOG_PIDFILE}
;;
status)
pid=`cat ${SM_WATCHDOG_PIDFILE} 2>/dev/null`
if [ -n "${pid}" ]
then
if ps -p ${pid} &>/dev/null
then
echo "${SM_WATCHDOG_NAME} is running"
RETVAL=0
else
echo "${SM_WATCHDOG_NAME} is not running but has pid file"
RETVAL=1
fi
else
echo "${SM_WATCHDOG_NAME} is not running"
RETVAL=3
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
reload)
echo "${SM_WATCHDOG_NAME} reload"
$0 restart
;;
force-reload)
echo "${SM_WATCHDOG_NAME} force-reload"
$0 restart
;;
*)
echo "usage: $0 { start | stop | status | restart | reload | force-reload }"
;;
esac
exit ${RETVAL}