diff --git a/ircbot.sh b/ircbot.sh index 8e46847..893cb3f 100755 --- a/ircbot.sh +++ b/ircbot.sh @@ -22,7 +22,15 @@ connect() { echo "PRIVMSG $chan : $joinmsg" >> $inputf } reconnect() { - exec $0 + if command -v systemctl >/dev/null; then + # NOTE: systemd is configured to restart the service, so simply dying + # with a non-zero exit code is enough to effectively reconnect. + exit 2 + else + # FIXME: We need to make sure we are only running one instance of the + # script at a time. This exec is therefore problematic. + exec $0 + fi } delay() { while read line diff --git a/services/systemd/ircbot.service b/services/systemd/ircbot.service index bb8fa5c..ed67aee 100644 --- a/services/systemd/ircbot.service +++ b/services/systemd/ircbot.service @@ -5,6 +5,7 @@ Description=Anarchyplanet IRC Bot User=nagios Group=nagios ExecStart=/usr/local/bin/ircbot.sh +Restart=on-failure [Install] WantedBy=multi-user.target