6cd8940170
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
112 lines
2.4 KiB
Bash
Executable File
112 lines
2.4 KiB
Bash
Executable File
#! /bin/sh
|
|
#
|
|
# Copyright (c) 2013-2014 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
#
|
|
# chkconfig: 2345 95 95
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: fminit
|
|
# Default-Start: 3 5
|
|
# Default-Stop: 0 1 2 6
|
|
# Short-Description: Fault Manager
|
|
### END INIT INFO
|
|
|
|
. /etc/init.d/functions
|
|
|
|
FMMGR_NAME="fmManager"
|
|
FMMGR="/usr/local/bin/${FMMGR_NAME}"
|
|
PIDFILE=/var/run/${FMMGR_NAME}.pid
|
|
CONFIGFILE=/etc/fm.conf
|
|
|
|
|
|
# Linux Standard Base (LSB) Error Codes
|
|
RETVAL=0
|
|
GENERIC_ERROR=1
|
|
INVALID_ARGS=2
|
|
NOT_RUNNING=3
|
|
NOT_INSTALLED=5
|
|
|
|
if [ ! -e "$FMMGR" ] ; then
|
|
logger "$FMMGR is missing"
|
|
exit ${NOT_INSTALLED}
|
|
fi
|
|
|
|
|
|
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
|
|
export PATH
|
|
|
|
case "$1" in
|
|
start)
|
|
# The FMMGR runs on controller only
|
|
echo -n "Starting ${FMMGR_NAME}: "
|
|
if [ -n "`pidof ${FMMGR_NAME}`" ] ; then
|
|
echo -n "is already running "
|
|
RETVAL=0
|
|
else
|
|
start-stop-daemon --start -b --make-pidfile --pidfile $PIDFILE --chuid fm -x ${FMMGR} -- -c ${CONFIGFILE}
|
|
RETVAL=$?
|
|
fi
|
|
if [ ${RETVAL} -eq 0 ] ; then
|
|
pid=`pidof ${FMMGR_NAME}`
|
|
echo "OK"
|
|
logger "${FMMGR} (${pid})"
|
|
else
|
|
echo "FAIL"
|
|
RETVAL=${GENERIC_ERROR}
|
|
fi
|
|
|
|
|
|
;;
|
|
stop)
|
|
status ${FMMGR_NAME} >/dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "$FMMGR_NAME is not running"
|
|
RETVAL=0
|
|
else
|
|
echo -n "Stopping ${FMMGR_NAME}: "
|
|
killproc ${FMMGR_NAME}
|
|
if [ -n "`pidof ${FMMGR_NAME}`" ] ; then
|
|
logger "Going to SIGKILL ${FMMGR_NAME}"
|
|
killproc -KILL ${FMMGR_NAME}
|
|
fi
|
|
/bin/rm -rf $PIDFILE
|
|
status ${FMMGR_NAME} >/dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "Stopped"
|
|
RETVAL=0
|
|
else
|
|
echo "Failed"
|
|
RETVAL=${GENERIC_ERROR}
|
|
fi
|
|
fi
|
|
;;
|
|
restart)
|
|
$0 stop
|
|
sleep 1
|
|
$0 start
|
|
;;
|
|
|
|
status)
|
|
status ${FMMGR_NAME} >/dev/null
|
|
RETVAL=$?
|
|
if [ ! ${RETVAL} -eq 0 ] ; then
|
|
RETVAL=${NOT_RUNNING}
|
|
fi
|
|
|
|
;;
|
|
|
|
condrestart)
|
|
$0 restart
|
|
;;
|
|
|
|
*)
|
|
echo "usage: $0 { start | stop | status | restart | condrestart | status }"
|
|
;;
|
|
esac
|
|
|
|
exit $RETVAL
|