Browse Source

Only restart prosody if the daemon isn't running

Bob Mottram 7 years ago
parent
commit
b8eaf17ee0
1 changed files with 10 additions and 4 deletions
  1. 10
    4
      src/freedombone-app-xmpp

+ 10
- 4
src/freedombone-app-xmpp View File

@@ -414,10 +414,16 @@ function prosody_daemon_restart_script {
414 414
     # On rare occasions the daemon appears to get stuck
415 415
     # i.e. still active, but not accepting connections
416 416
     # This ensures that it will unstick itself at least once per day
417
-    if [ ! -f /etc/cron.daily/prosody ]; then
418
-        echo '#!/bin/bash' > /etc/cron.daily/prosody
419
-        echo 'systemctl restart prosody' >> /etc/cron.daily/prosody
420
-        chmod +x /etc/cron.daily/prosody
417
+    if [ -f /etc/cron.daily/prosody ]; then
418
+        rm /etc/cron.daily/prosody
419
+    fi
420
+    if [ ! -f /etc/cron.hourly/prosody ]; then
421
+        { '#!/bin/bash';
422
+          "is_active=\$(systemctl is-active prosody)";
423
+          "if [[ \"\$is_active\" != 'active' ]]; then";
424
+          '  systemctl restart prosody'
425
+          'fi'; } > /etc/cron.hourly/prosody
426
+        chmod +x /etc/cron.hourly/prosody
421 427
     fi
422 428
 }
423 429