ircbot: Restart on failure, do not self-exec if running under systemd
This commit is contained in:
parent
ad4aae50ed
commit
d50a1c7c58
@ -22,7 +22,15 @@ connect() {
|
|||||||
echo "PRIVMSG $chan : $joinmsg" >> $inputf
|
echo "PRIVMSG $chan : $joinmsg" >> $inputf
|
||||||
}
|
}
|
||||||
reconnect() {
|
reconnect() {
|
||||||
|
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
|
exec $0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
delay() {
|
delay() {
|
||||||
while read line
|
while read line
|
||||||
|
@ -5,6 +5,7 @@ Description=Anarchyplanet IRC Bot
|
|||||||
User=nagios
|
User=nagios
|
||||||
Group=nagios
|
Group=nagios
|
||||||
ExecStart=/usr/local/bin/ircbot.sh
|
ExecStart=/usr/local/bin/ircbot.sh
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
Reference in New Issue
Block a user