#!/bin/sh ### BEGIN INIT INFO # Provides: sysfence # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Should-Start: $network # Should-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Daemonized version of sysfence # Description: Starts the sysfence daemon # /etc/default/sysfence. ### END INIT INFO # Author: L. Sheed #The complete default command that is being run is: #sysfence " /etc/sysfence/sysfence.conf" #obviously this will change with your variables, #but the entire command is here for testing # uses /etc/default/sysfence NAME="sysfence" SYSFENCE_ENABLE=false DESC="sysfence Daemon" DAEMON=`which sysfence` DAEMON1="sffetch" DAEMON2="sfwatch" LOGFILE="/var/log/sysfence.log" test -x $DAEMON || exit 0 if [ ! -e "${LOGFILE}" ] then touch "${LOGFILE}" chmod 640 "${LOGFILE}" chown root:adm "${LOGFILE}" fi . /lib/lsb/init-functions if [ -f /etc/default/$NAME ]; then . /etc/default/$NAME case "x$SYSFENCE_ENABLE" in xtrue|x1|xyes) SYSFENCE_ENABLE=true ;; *) SYSFENCE_ENABLE=false exit 1; ;; esac fi case "$1" in start) PID=`ps aux | grep "$DAEMON1 " | grep -v grep | awk '{print $2}'` if [ "x$PID" != "x" ]; then echo `date` " * $NAME appears to be already running!" | tee -a $LOGFILE exit fi if $SYSFENCE_ENABLE; then echo "Starting $DESC" log_daemon_msg "Starting $DESC" "$NAME" $DAEMON $DAEMON_OPTS PID=`ps aux | grep "$DAEMON1 " | grep -v grep | awk '{print $2}'` echo " * $NAME PID is $PID" echo "Watching:" ps -ef | grep "$DAEMON2 " | grep "$PID" else log_warning_msg "Not starting $DESC $NAME, disabled via /etc/default/$NAME" fi ;; stop) if $SYSFENCE_ENABLE; then PID=`ps aux | grep "$DAEMON1 " | grep -v grep | awk '{print $2}'` if [ "x$PID" = "x" ]; then echo " * $NAME is not running" else echo " Stopping $NAME" log_daemon_msg "Stopping $DESC" "$NAME" kill $PID fi fi ;; status) PID=`ps aux | grep "$DAEMON1 " | grep -v grep | awk '{print $2}'` if [ "x$PID" = "x" ]; then echo " * $NAME is not running" else echo " * $NAME PID is $PID" echo "Watching:" ps -ef | grep "$DAEMON2 " | grep "$PID" fi ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|status}" >&2 exit 1 ;; esac exit 0;