From 816f83d78d350cb1c860ccc68ca2be027c21e47a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 1 Oct 2016 16:28:32 +0100 Subject: [PATCH] Remove the irc watchdog --- src/freedombone-app-irc | 11 ++--------- src/freedombone-utils-watchdog | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/freedombone-app-irc b/src/freedombone-app-irc index e5f19269..c5e027c7 100755 --- a/src/freedombone-app-irc +++ b/src/freedombone-app-irc @@ -144,6 +144,7 @@ function remove_irc { if [[ $(app_is_installed irc) == "0" ]]; then return fi + remove_watchdog_daemon ngircd systemctl stop ngircd apt-get -y remove --purge ngircd apt-get -y remove --purge irssi @@ -263,15 +264,7 @@ function install_irc_server { systemctl restart ngircd - # keep the daemon running - echo '' >> /usr/bin/$WATCHDOG_SCRIPT_NAME - echo '# keep irc daemon running' >> /usr/bin/$WATCHDOG_SCRIPT_NAME - echo 'IRC_RUNNING=$(pgrep ngircd > /dev/null && echo Running)' >> /usr/bin/$WATCHDOG_SCRIPT_NAME - echo 'if [ ! $IRC_RUNNING ]; then' >> /usr/bin/$WATCHDOG_SCRIPT_NAME - echo ' systemctl start ngircd' >> /usr/bin/$WATCHDOG_SCRIPT_NAME - echo ' echo -n $CURRENT_DATE >> $LOGFILE' >> /usr/bin/$WATCHDOG_SCRIPT_NAME - echo ' echo " IRC daemon restarted" >> $LOGFILE' >> /usr/bin/$WATCHDOG_SCRIPT_NAME - echo 'fi' >> /usr/bin/$WATCHDOG_SCRIPT_NAME + add_watchdog_daemon ngircd if ! grep -q $"IRC Server" /home/$MY_USERNAME/README; then echo '' >> /home/$MY_USERNAME/README diff --git a/src/freedombone-utils-watchdog b/src/freedombone-utils-watchdog index e629bec9..025957f9 100755 --- a/src/freedombone-utils-watchdog +++ b/src/freedombone-utils-watchdog @@ -9,7 +9,8 @@ # Freedom in the Cloud # # Watchdog functions to keep systems running even if they crash -# systemd itself may be able to handle this to a large extent +# systemd itself can handle this, but some debian packages are in +# twilight world where they still use the older init scripts # # License # ======= @@ -48,4 +49,24 @@ function install_watchdog_script { echo 'install_watchdog_script' >> $COMPLETION_FILE } +function add_watchdog_daemon { + daemon_name=$1 + + echo '' >> /usr/bin/$WATCHDOG_SCRIPT_NAME + echo "# keep ${daemon_name} daemon running" >> /usr/bin/$WATCHDOG_SCRIPT_NAME + echo "RUNNING=$(pgrep ${daemon_name} > /dev/null && echo Running)" >> /usr/bin/$WATCHDOG_SCRIPT_NAME + echo 'if [ ! $RUNNING ]; then' >> /usr/bin/$WATCHDOG_SCRIPT_NAME + echo " systemctl start ${daemon_name}" >> /usr/bin/$WATCHDOG_SCRIPT_NAME + echo ' echo -n $CURRENT_DATE >> $LOGFILE' >> /usr/bin/$WATCHDOG_SCRIPT_NAME + echo " echo \"${daemon_name} daemon restarted\" >> \$LOGFILE" >> /usr/bin/$WATCHDOG_SCRIPT_NAME + echo 'fi' >> /usr/bin/$WATCHDOG_SCRIPT_NAME + echo "# End of ${daemon_name}" >> /usr/bin/$WATCHDOG_SCRIPT_NAME +} + +function remove_watchdog_daemon { + daemon_name=$1 + + sed -i "/# keep ${daemon_name} daemon running/,/# End of ${daemon_name}/d" /usr/bin/$WATCHDOG_SCRIPT_NAME +} + # NOTE: deliberately no exit 0