diff --git a/0001-fix-systemd-service-files.patch b/0001-fix-systemd-service-files.patch new file mode 100644 index 0000000..11044c4 --- /dev/null +++ b/0001-fix-systemd-service-files.patch @@ -0,0 +1,57 @@ +From 337c30353d650bd02bd1203b7859124926dfef71 Mon Sep 17 00:00:00 2001 +From: David Teigland +Date: Mon, 5 Nov 2012 15:53:40 -0600 +Subject: [PATCH] fix systemd service files + +add [Unit] and disable the cgroup stuff to avoid +the set_scheduler failures + +Signed-off-by: David Teigland +--- + init.d/fence_sanlockd.service | 1 + + init.d/sanlock.service | 2 ++ + init.d/wdmd.service | 2 ++ + 3 files changed, 5 insertions(+) + +diff --git a/init.d/fence_sanlockd.service b/init.d/fence_sanlockd.service +index 873da59..f2d655b 100644 +--- a/init.d/fence_sanlockd.service ++++ b/init.d/fence_sanlockd.service +@@ -1,3 +1,4 @@ ++[Unit] + Description=daemon for fence_sanlock agent + After=syslog.target wdmd.service sanlock.service + Before=corosync.service +diff --git a/init.d/sanlock.service b/init.d/sanlock.service +index ff4a3e7..f026fe0 100644 +--- a/init.d/sanlock.service ++++ b/init.d/sanlock.service +@@ -1,8 +1,10 @@ ++[Unit] + Description=Shared Storage Lease Manager + After=syslog.target wdmd.service + + [Service] + Type=forking ++ControlGroup=cpu:/ + ExecStart=/lib/systemd/systemd-sanlock start + ExecStop=/lib/systemd/systemd-sanlock stop + +diff --git a/init.d/wdmd.service b/init.d/wdmd.service +index 88d00b6..efe46bf 100644 +--- a/init.d/wdmd.service ++++ b/init.d/wdmd.service +@@ -1,8 +1,10 @@ ++[Unit] + Description=Watchdog Multiplexing Daemon + After=syslog.target + + [Service] + Type=forking ++ControlGroup=cpu:/ + ExecStart=/lib/systemd/systemd-wdmd start + ExecStop=/lib/systemd/systemd-wdmd stop + +-- +1.7.10.1.362.g242cab3 + diff --git a/fence_sanlockd.init b/fence_sanlockd.init new file mode 100644 index 0000000..75e8492 --- /dev/null +++ b/fence_sanlockd.init @@ -0,0 +1,160 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: fence_sanlockd +# Required-Start: $time $syslog $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 fence_sanlockd +# Description: Starts and stops fence_sanlockd. See fence_sanlockd(8). +### END INIT INFO +PROG=fence_sanlockd +FENCE_SANLOCKD_BIN=/usr/sbin/$PROG +FENCE_SANLOCKD_RUNDIR=/var/run/$PROG +FENCE_SANLOCKD_PIDFILE=$FENCE_SANLOCKD_RUNDIR/$PROG.pid +FENCE_SANLOCKD_FIFOFILE=$FENCE_SANLOCKD_RUNDIR/$PROG.fifo +FENCESANLOCKDOPTS="-w" + +FENCE_SANLOCK_AGENT_RUNDIR=/var/run/fence_sanlock + +test -x $FENCE_SANLOCKD_BIN || { echo "$FENCE_SANLOCKD_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + +. /etc/rc.status +rc_reset + + + +case "$1" in + start) + # start wdmd and sanlock daemons if they aren't running + service wdmd status > /dev/null 2>&1 || service wdmd start + service sanlock status > /dev/null 2>&1 || service sanlock start + + [ ! -d $FENCE_SANLOCKD_RUNDIR ] && \ + install -d -m 775 $FENCE_SANLOCKD_RUNDIR + + [ ! -d $FENCE_SANLOCK_AGENT_RUNDIR ] && \ + install -d -m 775 $FENCE_SANLOCK_AGENT_RUNDIR + + [ -n "$(which restorecon)" ] && \ + [ -x "$(which restorecon)" ] && \ + restorecon $FENCE_SANLOCKD_RUNDIR + + [ -n "$(which restorecon)" ] && \ + [ -x "$(which restorecon)" ] && \ + restorecon $FENCE_SANLOCK_AGENT_RUNDIR + + if [ -e $FENCE_SANLOCKD_PIDFILE ]; then + if checkproc $FENCE_SANLOCKD_BIN ; then + echo -n "$PROG is already running." + rc_status -v + rc_exit + else + echo "Removing stale PID file $FENCE_SANLOCKD_PIDFILE." + rm -f $FENCE_SANLOCKD_PIDFILE + fi + fi + echo -n "Starting $PROG " + startproc $FENCE_SANLOCKD_BIN $FENCESANLOCKDOPTS + rc_status -v + ;; + stop) + echo -n "Shutting down $PROG " + 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 fence_sanlock $agent_pid is running" + rc_failed 1 + rc_status -v + rc_exit + } + + # 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" + rc_failed 1 + rc_status -v + rc_exit + 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" + rc_failed 1 + rc_status -v + rc_exit + fi + + PID=$(pidofproc -p $FENCE_SANLOCKD_PIDFILE $PROG) + + # We have to use SIGHUP to mean stop because sanlock + # uses SIGTERM to mean that the lockspace failed. + killproc -p $FENCE_SANLOCKD_PIDFILE $PROG -HUP > /dev/null 2>&1 + retval=$? + if [ $retval -ne 0 ]; then + rc_failed 1 + rc_status -v + rc_exit + 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 $FENCE_SANLOCKD_FIFOFILE ]; then + echo "" > $FENCE_SANLOCKD_FIFOFILE + fi + + timeout=10 + while checkpid $PID; do + sleep 1 + timeout=$((timeout - 1)) + if [ "$timeout" -le 0 ]; then + echo -n "failed waiting for $PROG ($PID) to stop" + rc_failed 1 + rc_status -v + rc_exit + fi + done + + # 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 + + rc_status -v + ;; + try-restart) + $0 status >/dev/null && $0 restart + rc_status + ;; + restart) + $0 stop + $0 start + rc_status + ;; + reload) + killproc -HUP $FENCE_SANLOCKD_BIN + rc_status -v + ;; + status) + echo -n "Checking status of $PROG " + checkproc $FENCE_SANLOCKD_BIN + rc_status -v + ;; + *) + echo "Usage: $0 {start|stop|restart|try-restart|reload|status}" + rc_failed 2 + rc_exit + ;; +esac +rc_exit diff --git a/sanlock-2.1.tar.bz2 b/sanlock-2.1.tar.bz2 deleted file mode 100644 index dd0c252..0000000 --- a/sanlock-2.1.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:66564cb6df008fff298940561c75ace172dcda55266a47049d766c7e7bd56521 -size 97614 diff --git a/sanlock-2.6.tar.bz2 b/sanlock-2.6.tar.bz2 new file mode 100644 index 0000000..dcad72c --- /dev/null +++ b/sanlock-2.6.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29272ccbf4f93f70afa08abd3036e449a75271115132745039dc74fe539ffef9 +size 109332 diff --git a/sanlock-SCHED_RESET_ON_FORK-undefined.patch b/sanlock-SCHED_RESET_ON_FORK-undefined.patch index 21c1273..b47a135 100644 --- a/sanlock-SCHED_RESET_ON_FORK-undefined.patch +++ b/sanlock-SCHED_RESET_ON_FORK-undefined.patch @@ -2,9 +2,9 @@ Index: src/main.c =================================================================== --- src/main.c.orig +++ src/main.c -@@ -52,6 +52,10 @@ +@@ -56,6 +56,10 @@ - #define RELEASE_VERSION "2.1" + #define SIGRUNPATH 100 /* anything that's not SIGTERM/SIGKILL */ +#ifndef SCHED_RESET_ON_FORK +#define SCHED_RESET_ON_FORK 0 @@ -17,14 +17,14 @@ Index: wdmd/main.c =================================================================== --- wdmd/main.c.orig +++ wdmd/main.c -@@ -43,6 +43,10 @@ - - #define RELEASE_VERSION "2.1" +@@ -41,6 +41,10 @@ + #define GNUC_UNUSED __attribute__((__unused__)) + #endif +#ifndef SCHED_RESET_ON_FORK +#define SCHED_RESET_ON_FORK 0 +#endif + #define DEFAULT_TEST_INTERVAL 10 + #define RECOVER_TEST_INTERVAL 1 #define DEFAULT_FIRE_TIMEOUT 60 - #define DEFAULT_HIGH_PRIORITY 1 diff --git a/sanlock-old_blkid.patch b/sanlock-old_blkid.patch index d4883ab..ab980ee 100644 --- a/sanlock-old_blkid.patch +++ b/sanlock-old_blkid.patch @@ -10,7 +10,7 @@ Index: src/diskio.c blkid_probe probe; blkid_topology topo; uint32_t sector_size, ss_logical, ss_physical; -@@ -64,7 +65,10 @@ static int set_disk_properties(struct sy +@@ -62,7 +63,10 @@ static int set_disk_properties(struct sy ss_physical, disk->path); return -1; } diff --git a/sanlock.changes b/sanlock.changes index 9bf4f89..af734ff 100644 --- a/sanlock.changes +++ b/sanlock.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Dec 3 15:09:22 MST 2012 - jfehlig@suse.com + +- Update to sanlock 2.6 + - Add fence_sanlock, a fence agent that uses /dev/watchdog to + reset hosts (currently disabled) + - Various bug fixes and improvements + ------------------------------------------------------------------- Tue Mar 13 12:04:11 MDT 2012 - jfehlig@suse.com diff --git a/sanlock.init b/sanlock.init index 1f99db5..0b48bf6 100644 --- a/sanlock.init +++ b/sanlock.init @@ -6,15 +6,19 @@ # Required-Stop: $syslog # Should-Start: # Should-Stop: -# Default-Start: 3 5 -# Default-Stop: 0 1 2 6 +# Default-Start: 2 3 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"; +SANLOCKBIN=/usr/sbin/sanlock +SANLOCKRUNDIR=/var/run/sanlock +SANLOCKPIDFILE=$SANLOCKRUNDIR/sanlock.pid +SANLOCKUSER="sanlock" +SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER" + +test -x $SANLOCKBIN || { echo "$SANLOCKBIN not installed"; if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; } @@ -26,24 +30,28 @@ rc_reset case "$1" in start) - if [ -e $SANLOCK_PIDFILE ]; then - if checkproc $SANLOCK_BIN ; then + if [ ! -d $SANLOCKRUNDIR ]; then + install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 $SANLOCKRUNDIR + [ -x /sbin/restorecon ] && restorecon $SANLOCKRUNDIR + fi + if [ -e $SANLOCKPIDFILE ]; then + if checkproc $SANLOCKBIN ; then echo -n "sanlock is already running." rc_status -v exit else - echo "Removing stale PID file $SANLOCK_PIDFILE." - rm -f $SANLOCK_PIDFILE + echo "Removing stale PID file $SANLOCKPIDFILE." + rm -f $SANLOCKPIDFILE fi fi echo -n "Starting sanlock " - startproc $SANLOCK_BIN daemon $SANLOCK_OPTS + startproc $SANLOCKBIN daemon $SANLOCKOPTS rc_status -v ;; stop) echo -n "Shutting down sanlock " - killproc -TERM $SANLOCK_BIN > /dev/null 2>&1 - rm -f $SANLOCK_PIDFILE + killproc -TERM $SANLOCKBIN > /dev/null 2>&1 + rm -f $SANLOCKPIDFILE rc_status -v ;; try-restart) @@ -56,12 +64,12 @@ case "$1" in rc_status ;; reload) - killproc -HUP $SANLOCK_BIN + killproc -HUP $SANLOCKBIN rc_status -v ;; status) echo -n "Checking status of sanlock " - checkproc $SANLOCK_BIN + checkproc $SANLOCKBIN rc_status -v ;; *) diff --git a/sanlock.spec b/sanlock.spec index 38267df..7af6929 100644 --- a/sanlock.spec +++ b/sanlock.spec @@ -16,13 +16,15 @@ # -%define with_systemd 0 +%define with_systemd 0 +%define with_fence_sanlockd 0 + %if 0%{?suse_version} > 1140 -%define with_systemd 1 +%define with_systemd 1 %endif Name: sanlock -Version: 2.1 +Version: 2.6 Release: 1%{?dist} Summary: A shared disk lock manager License: GPL-2.0 ; GPL-2.0+ ; LGPL-2.1+ @@ -40,17 +42,23 @@ BuildRequires: systemd %endif Requires(pre): %insserv_prereq %fillup_prereq Requires: %{name}-lib = %{version}-%{release} +Recommends: logrotate # Latest version available at # https://fedorahosted.org/releases/s/a/sanlock/ Source0: %{name}-%{version}.tar.bz2 Source1: sanlock.init -Source2: wdmd.init -Source3: sysconfig.sanlock -Patch0: sanlock-SCHED_RESET_ON_FORK-undefined.patch -Patch1: sanlock-python-prefix.patch -Patch2: sanlock-old_blkid.patch -Patch3: suse-systemd.patch -Patch4: suse-no-date-time.patch +Source2: sysconfig.sanlock +Source3: wdmd.init +Source4: sysconfig.wdmd +Source5: fence_sanlockd.init +# Upstream patches +Patch0: 0001-fix-systemd-service-files.patch +# SUSE patches +Patch100: sanlock-SCHED_RESET_ON_FORK-undefined.patch +Patch101: sanlock-python-prefix.patch +Patch102: sanlock-old_blkid.patch +Patch103: suse-systemd.patch +Patch104: suse-no-date-time.patch %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} @@ -61,11 +69,12 @@ access to the shared disks. %prep %setup -q -%patch0 -%patch1 -%patch2 -%patch3 -p1 -%patch4 -p1 +%patch0 -p1 +%patch100 +%patch101 +%patch102 +%patch103 -p1 +%patch104 -p1 %build # upstream does not require configure @@ -73,6 +82,9 @@ access to the shared disks. CFLAGS=$RPM_OPT_FLAGS make -C wdmd CFLAGS=$RPM_OPT_FLAGS make -C src CFLAGS=$RPM_OPT_FLAGS make -C python +%if %{with_fence_sanlockd} +CFLAGS=$RPM_OPT_FLAGS make -C fence_sanlock +%endif %install make -C src \ @@ -84,20 +96,42 @@ make -C wdmd \ make -C python \ install LIBDIR=%{_libdir} \ DESTDIR=$RPM_BUILD_ROOT PREFIX=%_prefix +%if %{with_fence_sanlockd} +make -C fence_sanlock \ + install LIBDIR=%{_libdir} \ + DESTDIR=$RPM_BUILD_ROOT +%endif install -D -m 755 %SOURCE1 $RPM_BUILD_ROOT/etc/init.d/sanlock ln -s /etc/init.d/sanlock $RPM_BUILD_ROOT%{_sbindir}/rcsanlock -install -D -m 755 %SOURCE3 $RPM_BUILD_ROOT/%{_localstatedir}/adm/fillup-templates/sysconfig.sanlock -install -D -m 755 %SOURCE2 $RPM_BUILD_ROOT/etc/init.d/wdmd +install -D -m 755 %SOURCE2 $RPM_BUILD_ROOT/%{_localstatedir}/adm/fillup-templates/sysconfig.sanlock +install -D -m 755 %SOURCE3 $RPM_BUILD_ROOT/etc/init.d/wdmd ln -s /etc/init.d/wdmd $RPM_BUILD_ROOT%{_sbindir}/rcwdmd +install -D -m 755 %SOURCE4 $RPM_BUILD_ROOT/%{_localstatedir}/adm/fillup-templates/sysconfig.wdmd +%if %{with_fence_sanlockd} +install -D -m 755 %SOURCE5 $RPM_BUILD_ROOT/%{_initddir}/fence_sanlockd +ln -s /etc/init.d/fence_sanlockd $RPM_BUILD_ROOT%{_sbindir}/rcfence_sanlockd +%endif %if %{with_systemd} install -D -m 755 init.d/sanlock.service $RPM_BUILD_ROOT/%{_unitdir}/sanlock.service install -D -m 755 init.d/wdmd.service $RPM_BUILD_ROOT/%{_unitdir}/wdmd.service +%if %{with_fence_sanlockd} +install -D -m 0755 init.d/fence_sanlockd $RPM_BUILD_ROOT/lib/systemd/systemd-fence_sanlockd +install -D -m 0644 init.d/fence_sanlockd.service $RPM_BUILD_ROOT/%{_unitdir}/fence_sanlockd.service %endif +%endif + +install -Dm 0644 src/logrotate.sanlock \ + $RPM_BUILD_ROOT/etc/logrotate.d/sanlock %clean rm -rf $RPM_BUILD_ROOT %pre +%{_bindir}/getent group sanlock > /dev/null || %{_sbindir}/groupadd \ + -g 179 sanlock +%{_bindir}/getent passwd sanlock > /dev/null || %{_sbindir}/useradd \ + -u 179 -c "sanlock" -s /sbin/nologin -r \ + -g 179 -G disk -d /var/run/sanlock sanlock %if %{with_systemd} %service_add_pre wdmd.service %service_add_pre sanlock.service @@ -107,6 +141,7 @@ rm -rf $RPM_BUILD_ROOT %if %{with_systemd} %service_add_post wdmd.service sanlock.service %endif +%fillup_only -n wdmd %fillup_only -n sanlock %restart_on_update wdmd %restart_on_update sanlock @@ -131,6 +166,7 @@ rm -rf $RPM_BUILD_ROOT %{_localstatedir}/adm/fillup-templates/sysconfig.sanlock /etc/init.d/wdmd %{_sbindir}/rcwdmd +%{_localstatedir}/adm/fillup-templates/sysconfig.wdmd %if %{with_systemd} %{_unitdir}/sanlock.service %{_unitdir}/wdmd.service @@ -139,6 +175,7 @@ rm -rf $RPM_BUILD_ROOT %{_sbindir}/wdmd %{_mandir}/man8/wdmd* %{_mandir}/man8/sanlock* +%config(noreplace) %{_sysconfdir}/logrotate.d/sanlock %package -n libsanlock1 Provides: sanlock-lib @@ -198,4 +235,47 @@ developing applications that use %{name}. %{_includedir}/sanlock_resource.h %{_includedir}/sanlock_direct.h +%if %{with_fence_sanlockd} +%package -n fence-sanlock +Summary: Fence agent using sanlock and wdmd +Group: System Environment/Base +Requires: sanlock = %{version}-%{release} + +%description -n fence-sanlock +The fence-sanlock package contains the fence agent and +daemon for using sanlock and wdmd as a cluster fence agent. + +%files -n fence-sanlock +%defattr(-,root,root,-) +/etc/init.d/fence_sanlockd +%{_sbindir}/fence_sanlockd +%if %{with_systemd} +/lib/systemd/systemd-fence_sanlockd +%{_unitdir}/fence_sanlockd.service +%endif +%{_sbindir}/fence_sanlock +%{_sbindir}/fence_sanlockd +%{_mandir}/man8/fence_sanlock* + +%post -n fence-sanlock +%if %{with_systemd} +%service_add_post fence_sanlockd.service +%endif +%restart_on_update fence_sanlockd +#if [ $1 -eq 1 ] ; then +#ccs_update_schema > /dev/null 2>&1 ||: +#fi + +%preun -n fence-sanlock +%if %{with_systemd} +%service_del_preun fence_sanlockd.service +%endif +%stop_on_removal fence_sanlockd + +%postun -n fence-sanlock +%if %{with_systemd} +%service_del_postun fence_sanlockd.service +%endif +%endif + %changelog diff --git a/suse-no-date-time.patch b/suse-no-date-time.patch index 181006d..bdaba75 100644 --- a/suse-no-date-time.patch +++ b/suse-no-date-time.patch @@ -1,14 +1,15 @@ -Index: sanlock-2.1/src/main.c +Index: sanlock-2.6/src/main.c =================================================================== ---- sanlock-2.1.orig/src/main.c -+++ sanlock-2.1/src/main.c -@@ -1439,8 +1439,7 @@ static int read_command_line(int argc, c +--- sanlock-2.6.orig/src/main.c ++++ sanlock-2.6/src/main.c +@@ -1841,8 +1841,8 @@ static int read_command_line(int argc, c if (!strcmp(arg1, "version") || !strcmp(arg1, "--version") || !strcmp(arg1, "-V")) { - printf("%s %s (built %s %s)\n", -- argv[0], RELEASE_VERSION, __DATE__, __TIME__); -+ printf("%s %s\n", argv[0], RELEASE_VERSION); +- argv[0], VERSION, __DATE__, __TIME__); ++ printf("%s %s\n", ++ argv[0], VERSION); exit(EXIT_SUCCESS); } diff --git a/suse-systemd.patch b/suse-systemd.patch index 95987a9..295d6bf 100644 --- a/suse-systemd.patch +++ b/suse-systemd.patch @@ -1,30 +1,33 @@ -Index: sanlock-2.1/init.d/sanlock.service +Index: sanlock-2.6/init.d/sanlock.service =================================================================== ---- sanlock-2.1.orig/init.d/sanlock.service -+++ sanlock-2.1/init.d/sanlock.service -@@ -3,8 +3,9 @@ After=syslog.target wdmd.service - +--- sanlock-2.6.orig/init.d/sanlock.service ++++ sanlock-2.6/init.d/sanlock.service +@@ -5,8 +5,10 @@ After=syslog.target wdmd.service [Service] Type=forking + ControlGroup=cpu:/ -ExecStart=/lib/systemd/systemd-sanlock start -ExecStop=/lib/systemd/systemd-sanlock stop +EnvironmentFile=-/etc/sysconfig/sanlock +ExecStart=/usr/sbin/sanlock daemon $SANLOCKOPTS ++ExecStop=/bin/kill -TERM $MAINPID +ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target -Index: sanlock-2.1/init.d/wdmd.service +Index: sanlock-2.6/init.d/wdmd.service =================================================================== ---- sanlock-2.1.orig/init.d/wdmd.service -+++ sanlock-2.1/init.d/wdmd.service -@@ -3,8 +3,8 @@ After=syslog.target - +--- sanlock-2.6.orig/init.d/wdmd.service ++++ sanlock-2.6/init.d/wdmd.service +@@ -5,8 +5,10 @@ After=syslog.target [Service] Type=forking + ControlGroup=cpu:/ -ExecStart=/lib/systemd/systemd-wdmd start -ExecStop=/lib/systemd/systemd-wdmd stop -+ExecStart=/usr/sbin/wdmd ++EnvironmentFile=-/etc/sysconfig/wdmd ++ExecStart=/usr/sbin/wdmd $WDMDOPTS ++ExecStop=/bin/kill -TERM $MAINPID +ExecReload=/bin/kill -HUP $MAINPID [Install] diff --git a/sysconfig.sanlock b/sysconfig.sanlock index 80bb2a4..465d51d 100644 --- a/sysconfig.sanlock +++ b/sysconfig.sanlock @@ -1,10 +1,13 @@ ## Path: System/Virtualization/sanlock ## Type: string -## Default: "" -# Options passed to sanlock daemon, see man sanlock(8) -# E.g. to use sanlock without the watchdog multiplexing -# daemon set SANLOCK_OPTS as follows +## Default: "-U sanlock -G sanlock" +# Options passed to sanlock daemon, see man sanlock(8). # -# SANLOCK_OPTS="-w 0" -SANLOCK_OPTS="" \ No newline at end of file +# E.g. to use sanlock without the watchdog multiplexing +# daemon set SANLOCKOPTS as follows +#SANLOCKOPTS="-U sanlock -G sanlock -w 0" +# +# To disable use of watchdog via wdmd and disable high priority features +#SANLOCKOPTS="-U sanlock -G sanlock -w 0 -h 0" +SANLOCKOPTS="-U sanlock -G sanlock" \ No newline at end of file diff --git a/sysconfig.wdmd b/sysconfig.wdmd new file mode 100644 index 0000000..4f20639 --- /dev/null +++ b/sysconfig.wdmd @@ -0,0 +1,9 @@ +## Path: System/Virtualization/wdmd + +## Type: string +## Default: "-G sanlock" +# Options passed to wdmd daemon, see man wdmd(8). +# +# E.g. to enable use of test scripts +#WDMDOPTS="-G sanlock -S 1" +WDMDOPTS="-G sanlock" \ No newline at end of file diff --git a/wdmd.init b/wdmd.init index ce79cd2..6a7c5a9 100644 --- a/wdmd.init +++ b/wdmd.init @@ -12,46 +12,63 @@ # Description: starts and stops wdmd daemon ### END INIT INFO -WDMD_BIN=/usr/sbin/wdmd -WDMD_PIDFILE=/var/run/wdmd/wdmd.pid +WDMDBIN=/usr/sbin/wdmd +WDMDRUNDIR=/var/run/wdmd +WDMDPIDFILE=$WDMDRUNDIR/wdmd.pid WDMDGROUP="sanlock" WDMDOPTS="-G $WDMDGROUP" -test -x $WDMD_BIN || { echo "$WDMD_BIN not installed"; +test -x $WDMDBIN || { echo "$WDMDBIN not installed"; if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; } -[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog +[ -f /etc/sysconfig/wdmd ] && . /etc/sysconfig/wdmd . /etc/rc.status rc_reset +watchdog_check() { + if [ ! -c /dev/watchdog ]; then + echo -n "Loading the softdog kernel module " + modprobe softdog && udevadm settle + if [ ! -c /dev/watchdog ]; then + rc_failed 1 + rc_status -v + rc_exit + fi + rc_status -v + fi +} + case "$1" in start) - if [ ! -d /var/run/$prog ]; then - mkdir -p /var/run/$prog + watchdog_check + + if [ ! -d $WDMDRUNDIR ]; then + install -d -g $WDMDGROUP -m 775 $WDMDRUNDIR + [ -x /sbin/restorecon ] && restorecon $WDMDRUNDIR fi - if [ -e $WDMD_PIDFILE ]; then - if checkproc $WDMD_BIN ; then + if [ -e $WDMDPIDFILE ]; then + if checkproc $WDMDBIN; then echo -n "wdmd is already running." rc_status -v - exit + rc_exit else - echo "Removing stale PID file $WDMD_PIDFILE." - rm -f $WDMD_PIDFILE + echo "Removing stale PID file $WDMDPIDFILE." + rm -f $WDMDPIDFILE fi fi echo -n "Starting wdmd " - startproc $WDMD_BIN $WDMDOPTS + startproc $WDMDBIN $WDMDOPTS rc_status -v ;; stop) echo -n "Shutting down wdmd " - killproc -TERM $WDMD_BIN > /dev/null 2>&1 - rm -f $WDMD_PIDFILE + killproc -TERM $WDMDBIN > /dev/null 2>&1 + rm -f $WDMDPIDFILE rc_status -v ;; try-restart) @@ -64,12 +81,12 @@ case "$1" in rc_status ;; reload) - killproc -HUP $WDMD_BIN + killproc -HUP $WDMDBIN rc_status -v ;; status) echo -n "Checking status of wdmd " - checkproc $WDMD_BIN + checkproc $WDMDBIN rc_status -v ;; *)