diff --git a/src/freedombone-app-xmpp b/src/freedombone-app-xmpp index 4f97a86b..88a46cab 100755 --- a/src/freedombone-app-xmpp +++ b/src/freedombone-app-xmpp @@ -414,10 +414,16 @@ function prosody_daemon_restart_script { # On rare occasions the daemon appears to get stuck # i.e. still active, but not accepting connections # This ensures that it will unstick itself at least once per day - if [ ! -f /etc/cron.daily/prosody ]; then - echo '#!/bin/bash' > /etc/cron.daily/prosody - echo 'systemctl restart prosody' >> /etc/cron.daily/prosody - chmod +x /etc/cron.daily/prosody + if [ -f /etc/cron.daily/prosody ]; then + rm /etc/cron.daily/prosody + fi + if [ ! -f /etc/cron.hourly/prosody ]; then + { '#!/bin/bash'; + "is_active=\$(systemctl is-active prosody)"; + "if [[ \"\$is_active\" != 'active' ]]; then"; + ' systemctl restart prosody' + 'fi'; } > /etc/cron.hourly/prosody + chmod +x /etc/cron.hourly/prosody fi }