#! /bin/sh # # Copyright (c) 2013-2014, 2016 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # # # chkconfig: 2345 05 95 # ### BEGIN INIT INFO # Provides: hostwd # Required-Start: $null # Required-Stop: $null # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: host watchdog daemon ### END INIT INFO # echo "7:3:respawn:/usr/local/bin/hostwd" >> /etc/inittab CENTOS_FUNCTIONS="/etc/init.d/functions" DEBIAN_FUNCTIONS="/lib/lsb/init-functions" if [ ! -f ${CENTOS_FUNCTIONS} ] ; then . ${DEBIAN_FUNCTIONS} else . ${CENTOS_FUNCTIONS} fi DAEMON_NAME="hostwd" DAEMON_CENTOS_PATH="/usr/local/bin/${DAEMON_NAME}" DAEMON_DEBIAN_PATH="/usr/bin/${DAEMON_NAME}" if [ ! -f ${DAEMON_CENTOS_PATH} ] ; then DAEMON=${DAEMON_DEBIAN_PATH} else DAEMON=${DAEMON_CENTOS_PATH} fi IFACE="" if [ ! -e "$DAEMON" ] ; then logger "$DAEMON is missing" exit 1 fi RETVAL=0 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin export PATH case "$1" in start) echo -n "Starting $DAEMON_NAME: " # Prevent multipe starts if [ -n "`pidof ${DAEMON_NAME}`" ] ; then echo "OK" exit $RETVAL fi start-stop-daemon --start -b -x ${DAEMON} -- RETVAL=$? if [ $RETVAL -eq 0 ] ; then echo "OK" else echo "FAIL" fi ;; stop) echo -n "Stopping ${DAEMON_NAME}: " if [ -n "`pidof ${DAEMON_NAME}`" ] ; then killproc ${DAEMON_NAME} fi echo "OK" ;; restart) $0 stop $0 start ;; status) pid=`pidof ${DAEMON_NAME}` RETVAL=$? if [ ${RETVAL} -eq 0 ] ; then echo "${DAEMON_NAME} is running" else echo "${DAEMON_NAME} is NOT running" fi ;; condrestart) [ -f /var/lock/subsys/${DAEMON_NAME} ] && $0 restart ;; *) echo "usage: $0 { start | stop | status | restart | condrestart | status }" ;; esac exit $RETVAL