SHA256
1
0
forked from pool/sanlock
sanlock/sanlock.init

74 lines
1.7 KiB
Bash

#!/bin/sh
### BEGIN INIT INFO
# Provides: sanlock
# Required-Start: $time $syslog wdmd $remote_fs
# Required-Stop: $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts and stops sanlock daemon
# Description: starts and stops sanlock daemon
### END INIT INFO
SANLOCK_BIN=/usr/sbin/sanlock
SANLOCK_PIDFILE=/var/run/sanlock/sanlock.pid
test -x $SANLOCK_BIN || { echo "$SANLOCK_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
[ -f /etc/sysconfig/sanlock ] && . /etc/sysconfig/sanlock
. /etc/rc.status
rc_reset
case "$1" in
start)
if [ -e $SANLOCK_PIDFILE ]; then
if checkproc $SANLOCK_BIN ; then
echo -n "sanlock is already running."
rc_status -v
exit
else
echo "Removing stale PID file $SANLOCK_PIDFILE."
rm -f $SANLOCK_PIDFILE
fi
fi
echo -n "Starting sanlock "
startproc $SANLOCK_BIN daemon $SANLOCKOPTS
rc_status -v
;;
stop)
echo -n "Shutting down sanlock "
killproc -TERM $SANLOCK_BIN > /dev/null 2>&1
rm -f $SANLOCK_PIDFILE
rc_status -v
;;
try-restart)
$0 status >/dev/null && $0 restart
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
reload)
killproc -HUP $SANLOCK_BIN
rc_status -v
;;
status)
echo -n "Checking status of sanlock "
checkproc $SANLOCK_BIN
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|reload|status}"
rc_failed 2
rc_exit
;;
esac
rc_exit