fault/fm-mgr/sources/fminit
Marcela Rosales 7c535566af Add Required-Start and Required-Stop to fminit header
It is required for the fminit header to be compliant with LSB in
order to build on OBS infrastructure.

Story: 2003736
Task: 31057

Change-Id: I70555ce7b1245c940d56a04aa98bd1a5c17dc04e
Signed-off-by: Marcela Rosales <marcela.a.rosales.jimenez@intel.com>
2019-05-16 11:14:57 -05:00

113 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
# Required-Start:
# Required-Stop:
# 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/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