init.d/fence_sanlockd | 186 ++++++++++++------------------------------ init.d/fence_sanlockd.service | 6 +- init.d/fence_sanlockd.tmpfile | 2 + init.d/sanlk-resetd | 95 +++++++++++++++++++++ init.d/sanlock | 119 ++++++++++----------------- init.d/sanlock.service.native | 4 +- init.d/sanlock.tmpfile | 1 + init.d/wdmd | 116 ++++++++++---------------- init.d/wdmd.module | 1 + init.d/wdmd.service.native | 6 +- init.d/wdmd.tmpfile | 1 + reset/Makefile | 4 +- 12 files changed, 247 insertions(+), 294 deletions(-) diff --git a/init.d/fence_sanlockd b/init.d/fence_sanlockd index 99041b5..d4574a1 100755 --- a/init.d/fence_sanlockd +++ b/init.d/fence_sanlockd @@ -2,143 +2,56 @@ # # fence_sanlockd - daemon for fence_sanlock agent # -# chkconfig: 2345 20 80 +# chkconfig: 345 98 03 # description: starts and stops fence_sanlockd # ### BEGIN INIT INFO # Provides: fence_sanlockd -# Required-Start: $time $syslog +# Required-Start: $time $syslog wdmd sanlock # Required-Stop: $syslog # Should-Start: # Should-Stop: -# Default-Start: 2 3 4 5 +# Default-Start: 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts and stops fence_sanlockd # Description: starts and stops fence_sanlockd ### END INIT INFO -. /etc/rc.d/init.d/functions +# Do not load RH compatibility interface. +WITHOUT_RC_COMPAT=1 -prog="fence_sanlockd" -agent="fence_sanlock" -runfile="/run/$prog/$prog.pid" -fifofile="/run/$prog/$prog.fifo" -lockfile="/var/lock/subsys/$prog" -exec="/usr/sbin/$prog" +# Source function library. +. /etc/init.d/functions -FENCESANLOCKDOPTS="-w" - -[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog - -start() { - [ -x $exec ] || exit 5 - - # start wdmd and sanlock daemons if they aren't running - - service wdmd status > /dev/null 2>&1 || service wdmd start +SERVICE=fence_sanlockd +AGENT=fence_sanlock +PIDFILE=/run/$SERVICE/$SERVICE.pid +FIFOFILE=/run/$SERVICE/$SERVICE.fifo +LOCKFILE=/run/lock/subsys/$SERVICE - service sanlock status > /dev/null 2>&1 || service sanlock start - - [ ! -d /run/$prog ] && install -d -m 775 /run/$prog - - [ ! -d /run/$agent ] && install -d -m 775 /run/$agent +FENCESANLOCKDOPTS="-w" - [ -n "$(which restorecon)" ] && \ - [ -x "$(which restorecon)" ] && \ - restorecon /run/$prog +# Source config. +SourceIfNotEmpty /etc/sysconfig/$SERVICE - [ -n "$(which restorecon)" ] && \ - [ -x "$(which restorecon)" ] && \ - restorecon /run/$agent +RETVAL=0 - echo -n $"Starting $prog: " - daemon $prog $FENCESANLOCKDOPTS - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval +start() { + start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $SERVICE $FENCESANLOCKDOPTS + RETVAL=$? + return $RETVAL } stop() { - agent_ps="$(ps ax -o pid,args | grep fence_sanlock | grep -v grep | grep -v fence_sanlockd)" - - [ -n "$agent_ps" ] && { - agent_pid="$(echo $agent_ps | awk '{print $1}')" - echo -n "cannot stop while $agent $agent_pid is running" - failure; echo - return 1 - } - - # Ideally, we'd like a general way to check if anything - # needs fencing to continue running, but without that, - # check what we know, which is that dlm requires it. - - if [ -d /sys/kernel/dlm/ ]; then - count="$(ls -A /sys/kernel/dlm/ | wc -l)" - if [ $count -ne 0 ]; then - echo -n "cannot stop while dlm lockspaces exist" - failure; echo - return 1 - fi - fi - - if [ -d /sys/kernel/config/dlm/cluster ]; then - # this dir exists while dlm_controld is running - echo -n "cannot stop while dlm is running" - failure; echo - return 1 - fi - - PID=$(pidofproc -p $runfile $prog) - - # We have to use SIGHUP to mean stop because sanlock - # uses SIGTERM to mean that the lockspace failed. - - echo -n $"Sending stop signal $prog ($PID): " - killproc -p $runfile $prog -HUP - retval=$? - echo - - if [ $retval -ne 0 ]; then - return $retval - fi - - # fence_sanlockd won't see the SIGHUP if it's - # still waiting for config from the fifo, so - # send invalid config to the fifo to make it fail. - - if [ -p $fifofile ]; then - echo "" > $fifofile - fi - - echo -n $"Waiting for $prog ($PID) to stop:" - - timeout=10 - while checkpid $PID; do - sleep 1 - timeout=$((timeout - 1)) - if [ "$timeout" -le 0 ]; then - failure; echo - return 1 - fi - done - - success; echo - rm -f $lockfile - - # stop wdmd and sanlock daemons if they are running - - service sanlock status > /dev/null 2>&1 && service sanlock stop - - service wdmd status > /dev/null 2>&1 && service wdmd stop - - return $retval + stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $SERVICE + RETVAL=$? + return $RETVAL } restart() { - rh_status_q && stop + stop start } @@ -146,42 +59,43 @@ reload() { restart } -rh_status() { - status $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - +# See how we were called. case "$1" in start) - rh_status_q && exit 0 - $1 + start ;; stop) - rh_status_q || exit 0 - $1 + stop + ;; + status) + status --pidfile "$PIDFILE" --expect-user root -- $SERVICE + RETVAL=$? ;; restart) - $1 + restart ;; reload) - rh_status_q || exit 7 - $1 + reload ;; - force-reload) - force_reload + condstop) + if [ -e "$LOCKFILE" ]; then + stop + fi ;; - status) - rh_status + condreload) + if [ -e "$LOCKFILE" ]; then + reload + fi ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart + condrestart) + if [ -e "$LOCKFILE" ]; then + restart + fi ;; *) - echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 + msg_usage "${0##*/} {start|stop|status|reload|restart|condstop|condrestart|condreload}" + RETVAL=1 esac -exit $? + +exit $RETVAL + diff --git a/init.d/fence_sanlockd.service b/init.d/fence_sanlockd.service index f2d655b..194ad97 100644 --- a/init.d/fence_sanlockd.service +++ b/init.d/fence_sanlockd.service @@ -1,12 +1,12 @@ [Unit] Description=daemon for fence_sanlock agent -After=syslog.target wdmd.service sanlock.service +After=wdmd.service sanlock.service Before=corosync.service [Service] Type=forking -ExecStart=/lib/systemd/systemd-fence_sanlockd start -ExecStop=/lib/systemd/systemd-fence_sanlockd stop +EnvironmentFile=-/etc/sysconfig/fence_sanlockd +ExecStart=/usr/sbin/fence_sanlockd [Install] WantedBy=multi-user.target diff --git a/init.d/fence_sanlockd.tmpfile b/init.d/fence_sanlockd.tmpfile new file mode 100644 index 0000000..390f787 --- /dev/null +++ b/init.d/fence_sanlockd.tmpfile @@ -0,0 +1,2 @@ +d /run/fence_sanlockd 775 root root +d /run/fence_sanlock 775 root root diff --git a/init.d/sanlk-resetd b/init.d/sanlk-resetd new file mode 100644 index 0000000..ce1879c --- /dev/null +++ b/init.d/sanlk-resetd @@ -0,0 +1,95 @@ +#!/bin/bash +# +# sanlk-resetd - daemon gets events from specified sanlock lockspaces +# +# chkconfig: - 98 03 +# description: The sanlk-resetd daemon gets events from specified sanlock lockspaces. +# + +### BEGIN INIT INFO +# Provides: sanlk-resetd +# Required-Start: $time $syslog wdmd sanlock +# Required-Stop: $syslog +# Should-Start: +# Should-Stop: +# Default-Start: 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts and stops sanlk-resetd +# Description: starts and stops sanlk-resetd +### END INIT INFO + +# Do not load RH compatibility interface. +WITHOUT_RC_COMPAT=1 + +# Source function library. +. /etc/init.d/functions + +SERVICE=sanlk-resetd +LOCKFILE=/run/lock/subsys/$SERVICE + +# Source config. +SourceIfNotEmpty /etc/sysconfig/$SERVICE + +RETVAL=0 + +start() { + start_daemon --lockfile "$LOCKFILE" --expect-user root -- $SERVICE $RESETD_OPTIONS + RETVAL=$? + return $RETVAL +} + +stop() { + stop_daemon --lockfile "$LOCKFILE" --expect-user root -- $SERVICE + RETVAL=$? + return $RETVAL +} + +restart() { + stop + start +} + +reload() { + restart +} + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status --expect-user root -- $SERVICE + RETVAL=$? + ;; + restart) + restart + ;; + reload) + reload + ;; + condstop) + if [ -e "$LOCKFILE" ]; then + stop + fi + ;; + condreload) + if [ -e "$LOCKFILE" ]; then + reload + fi + ;; + condrestart) + if [ -e "$LOCKFILE" ]; then + restart + fi + ;; + *) + msg_usage "${0##*/} {start|stop|status|reload|restart|condstop|condrestart|condreload}" + RETVAL=1 +esac + +exit $RETVAL + diff --git a/init.d/sanlock b/init.d/sanlock index bc1c330..9d01e34 100644 --- a/init.d/sanlock +++ b/init.d/sanlock @@ -2,7 +2,7 @@ # # sanlock - SAN-based lock manager # -# chkconfig: 2345 97 03 +# chkconfig: 345 97 03 # description: starts and stops sanlock daemon # @@ -13,71 +13,42 @@ # Required-Stop: $syslog # Should-Start: # Should-Stop: -# Default-Start: 2 3 4 5 +# Default-Start: 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts and stops sanlock daemon # Description: starts and stops sanlock daemon ### END INIT INFO -. /etc/rc.d/init.d/functions +# Do not load RH compatibility interface. +WITHOUT_RC_COMPAT=1 -prog="sanlock" -runfile="/run/$prog/$prog.pid" -lockfile="/var/lock/subsys/$prog" -exec="/usr/sbin/$prog" +# Source function library. +. /etc/init.d/functions -SANLOCKUSER="sanlock" -SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER" +SERVICE=sanlock +PIDFILE=/run/$SERVICE/$SERVICE.pid +LOCKFILE=/run/lock/subsys/$SERVICE -[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog +# Source config. +SourceIfNotEmpty /etc/sysconfig/$SERVICE -start() { - [ -x $exec ] || exit 5 +RETVAL=0 - if [ ! -d /run/$prog ]; then - install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 /run/$prog - [ -x /sbin/restorecon ] && restorecon /run/$prog - fi - echo -n $"Starting $prog: " - daemon $prog daemon $SANLOCKOPTS - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval +start() { + start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user sanlock -- $SERVICE daemon $SANLOCKOPTS + RETVAL=$? + return $RETVAL } stop() { - PID=$(pidofproc -p $runfile $prog) - - echo -n $"Sending stop signal $prog ($PID): " - killproc -p $runfile $prog -TERM - retval=$? - echo - - if [ $retval -ne 0 ]; then - return $retval - fi - - echo -n $"Waiting for $prog ($PID) to stop:" - - timeout=10 - while checkpid $PID; do - sleep 1 - timeout=$((timeout - 1)) - if [ "$timeout" -le 0 ]; then - failure; echo - return 1 - fi - done - - success; echo - rm -f $lockfile - return $retval + stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user sanlock -- $SERVICE + RETVAL=$? + return $RETVAL } restart() { - rh_status_q && stop + stop start } @@ -85,42 +56,42 @@ reload() { restart } -rh_status() { - status $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - +# See how we were called. case "$1" in start) - rh_status_q && exit 0 - $1 + start ;; stop) - rh_status_q || exit 0 - $1 + stop + ;; + status) + status --pidfile "$PIDFILE" --expect-user sanlock -- $SERVICE + RETVAL=$? ;; restart) - $1 + restart ;; reload) - rh_status_q || exit 7 - $1 + reload ;; - force-reload) - force_reload + condstop) + if [ -e "$LOCKFILE" ]; then + stop + fi ;; - status) - rh_status + condreload) + if [ -e "$LOCKFILE" ]; then + reload + fi ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart + condrestart) + if [ -e "$LOCKFILE" ]; then + restart + fi ;; *) - echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - exit 2 + msg_usage "${0##*/} {start|stop|status|reload|restart|condstop|condrestart|condreload}" + RETVAL=1 esac -exit $? + +exit $RETVAL diff --git a/init.d/sanlock.service.native b/init.d/sanlock.service.native index f14eccd..9819cba 100644 --- a/init.d/sanlock.service.native +++ b/init.d/sanlock.service.native @@ -1,11 +1,11 @@ [Unit] Description=Shared Storage Lease Manager -After=syslog.target Wants=wdmd.service [Service] Type=forking -ExecStart=/usr/sbin/sanlock daemon +EnvironmentFile=-/etc/sysconfig/sanlock +ExecStart=/usr/sbin/sanlock daemon $SANLOCKOPTS SendSIGKILL=no LimitNOFILE=2048 diff --git a/init.d/sanlock.tmpfile b/init.d/sanlock.tmpfile new file mode 100644 index 0000000..f0eb6a0 --- /dev/null +++ b/init.d/sanlock.tmpfile @@ -0,0 +1 @@ +d /run/sanlock 775 sanlock sanlock diff --git a/init.d/wdmd b/init.d/wdmd index b6a2a79..efc4efd 100644 --- a/init.d/wdmd +++ b/init.d/wdmd @@ -2,7 +2,7 @@ # # wdmd - watchdog multiplexing daemon # -# chkconfig: 2345 97 03 +# chkconfig: 345 96 03 # description: starts and stops wdmd daemon # @@ -13,23 +13,26 @@ # Required-Stop: $syslog # Should-Start: # Should-Stop: -# Default-Start: 2 3 4 5 +# Default-Start: 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts and stops wdmd daemon # Description: starts and stops wdmd daemon ### END INIT INFO -. /etc/rc.d/init.d/functions +# Do not load RH compatibility interface. +WITHOUT_RC_COMPAT=1 -prog="wdmd" -runfile="/run/$prog/$prog.pid" -lockfile="/var/lock/subsys/$prog" -exec="/usr/sbin/$prog" +# Source function library. +. /etc/init.d/functions -WDMDGROUP="sanlock" -WDMDOPTS="-G $WDMDGROUP" +SERVICE=wdmd +PIDFILE=/run/$SERVICE/$SERVICE.pid +LOCKFILE=/run/lock/subsys/$SERVICE -[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog +# Source config. +SourceIfNotEmpty /etc/sysconfig/$SERVICE + +RETVAL=0 watchdog_probe() { $exec --probe > /dev/null 2>&1 @@ -57,53 +60,19 @@ watchdog_check() { start() { watchdog_check - - [ -x $exec ] || exit 5 - - if [ ! -d /run/$prog ]; then - install -d -g $WDMDGROUP -m 775 /run/$prog - [ -x /sbin/restorecon ] && restorecon /run/$prog - fi - - echo -n $"Starting $prog: " - daemon $prog $WDMDOPTS - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval + start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $SERVICE $WDMDOPTS + RETVAL=$? + return $RETVAL } stop() { - PID=$(pidofproc -p $runfile $prog) - - echo -n $"Sending stop signal $prog ($PID): " - killproc -p $runfile $prog -TERM - retval=$? - echo - - if [ $retval -ne 0 ]; then - return $retval - fi - - echo -n $"Waiting for $prog ($PID) to stop:" - - timeout=10 - while checkpid $PID; do - sleep 1 - timeout=$((timeout - 1)) - if [ "$timeout" -le 0 ]; then - failure; echo - return 1 - fi - done - - success; echo - rm -f $lockfile - return $retval + stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $SERVICE + RETVAL=$? + return $RETVAL } restart() { - rh_status_q && stop + stop start } @@ -111,45 +80,44 @@ reload() { restart } -rh_status() { - status $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - +# See how we were called. case "$1" in start) - rh_status_q && exit 0 - $1 + start ;; stop) - rh_status_q || exit 0 - $1 + stop + ;; + status) + status --pidfile "$PIDFILE" --expect-user root -- $SERVICE + RETVAL=$? ;; restart) - $1 + restart ;; reload) - rh_status_q || exit 7 - $1 + reload ;; watchdog-check) watchdog_check ;; - force-reload) - force_reload + condstop) + if [ -e "$LOCKFILE" ]; then + stop + fi ;; - status) - rh_status + condreload) + if [ -e "$LOCKFILE" ]; then + reload + fi ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart + condrestart) + if [ -e "$LOCKFILE" ]; then + restart + fi ;; *) - echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|watchdog-check}" exit 2 esac exit $? diff --git a/init.d/wdmd.module b/init.d/wdmd.module new file mode 100644 index 0000000..6711610 --- /dev/null +++ b/init.d/wdmd.module @@ -0,0 +1 @@ +softdog diff --git a/init.d/wdmd.service.native b/init.d/wdmd.service.native index ab0828e..33c0892 100644 --- a/init.d/wdmd.service.native +++ b/init.d/wdmd.service.native @@ -1,11 +1,11 @@ [Unit] Description=Watchdog Multiplexing Daemon -After=syslog.target [Service] Type=forking -ExecStartPre=/lib/systemd/systemd-wdmd watchdog-check -ExecStart=/usr/sbin/wdmd +EnvironmentFile=-/etc/sysconfig/wdmd +ExecStartPre=/etc/rc.d/init.d/wdmd watchdog-check +ExecStart=/usr/sbin/wdmd $WDMDOPTS SendSIGKILL=no [Install] diff --git a/init.d/wdmd.tmpfile b/init.d/wdmd.tmpfile new file mode 100644 index 0000000..893137a --- /dev/null +++ b/init.d/wdmd.tmpfile @@ -0,0 +1 @@ +d /run/wdmd 775 root sanlock diff --git a/reset/Makefile b/reset/Makefile index 004dbb6..baea832 100644 --- a/reset/Makefile +++ b/reset/Makefile @@ -18,10 +18,10 @@ LDADD = -lsanlock -lwdmd all: $(TARGET1) $(TARGET2) $(TARGET1): $(SOURCE1) - $(CC) $(CFLAGS) $(LDFLAGS) $(SOURCE1) $(LDADD) -o $@ -L. -L../src -L../wdmd + $(CC) $(CFLAGS) $(LDFLAGS) $(SOURCE1) -o $@ -L. -L../src -L../wdmd $(LDADD) $(TARGET2): $(SOURCE2) - $(CC) $(CFLAGS) $(LDFLAGS) $(SOURCE2) $(LDADD) -o $@ -L. -L../src -L../wdmd + $(CC) $(CFLAGS) $(LDFLAGS) $(SOURCE2) -o $@ -L. -L../src -L../wdmd $(LDADD) clean: rm -f *.o *.so *.so.* $(TARGET1) $(TARGET2)