Remove the irc watchdog

This commit is contained in:
Bob Mottram 2016-10-01 16:28:32 +01:00
parent d37b69bf50
commit 816f83d78d
2 changed files with 24 additions and 10 deletions

View File

@ -144,6 +144,7 @@ function remove_irc {
if [[ $(app_is_installed irc) == "0" ]]; then if [[ $(app_is_installed irc) == "0" ]]; then
return return
fi fi
remove_watchdog_daemon ngircd
systemctl stop ngircd systemctl stop ngircd
apt-get -y remove --purge ngircd apt-get -y remove --purge ngircd
apt-get -y remove --purge irssi apt-get -y remove --purge irssi
@ -263,15 +264,7 @@ function install_irc_server {
systemctl restart ngircd systemctl restart ngircd
# keep the daemon running add_watchdog_daemon ngircd
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
if ! grep -q $"IRC Server" /home/$MY_USERNAME/README; then if ! grep -q $"IRC Server" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README echo '' >> /home/$MY_USERNAME/README

View File

@ -9,7 +9,8 @@
# Freedom in the Cloud # Freedom in the Cloud
# #
# Watchdog functions to keep systems running even if they crash # 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 # License
# ======= # =======
@ -48,4 +49,24 @@ function install_watchdog_script {
echo 'install_watchdog_script' >> $COMPLETION_FILE 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 # NOTE: deliberately no exit 0