File enables-salt-minion-watchdog-on-init.d-script-for-sy.patch of Package salt.5440

From d95da9656d99321bcfd4ba20e3a622482b8b9c02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
 <psuarezhernandez@suse.com>
Date: Thu, 8 Jun 2017 16:23:02 +0100
Subject: [PATCH] Enables salt-minion watchdog on init.d script for sysV

---
 pkg/suse/salt-minion | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 pkg/suse/salt-minion

diff --git a/pkg/suse/salt-minion b/pkg/suse/salt-minion
old mode 100644
new mode 100755
index 0f04a13..2e41809
--- a/pkg/suse/salt-minion
+++ b/pkg/suse/salt-minion
@@ -51,8 +51,23 @@ SERVICE=salt-minion
 PROCESS=salt-minion
 
 RETVAL=0
+WATCHDOG_CRON="/etc/cron.d/salt-minion"
+
+set_watchdog() {
+    if [ ! -f $WATCHDOG_CRON ]; then
+        echo -e '* * * * * root /usr/bin/salt-daemon-watcher --with-init\n' > $WATCHDOG_CRON
+        # Kick the watcher for 1 minute immediately, because cron will wake up only afterwards
+        /usr/bin/salt-daemon-watcher --with-init & disown
+    fi
+}
+
+remove_watchdog() {
+    rm $WATCHDOG_CRON 2>/dev/null || true
+    kill -9 $(ps uax | grep [s]alt-daemon-watcher | awk '{print $2}') 2>/dev/null
+}
 
 start() {
+    set_watchdog;
     echo -n $"Starting salt-minion daemon: "
     if [ -f $SUSE_RELEASE ]; then
         startproc -p /var/run/$SERVICE.pid $SALTMINION -d $MINION_ARGS
@@ -80,6 +95,10 @@ start() {
 }
 
 stop() {
+    IS_RESTARTING=$1
+    if [ -z $IS_RESTARTING ]; then
+        remove_watchdog;
+    fi
     echo -n $"Stopping salt-minion daemon: "
     if [ -f $SUSE_RELEASE ]; then
         killproc -TERM $SALTMINION
@@ -101,8 +120,8 @@ stop() {
 }
 
 restart() {
-   stop
-   start
+   stop 1;
+   start;
 }
 
 # See how we were called.
-- 
2.10.1


openSUSE Build Service is sponsored by