Skip to content

Commit

Permalink
Monitor for a restart loop that fails to connect to openvpn server
Browse files Browse the repository at this point in the history
  • Loading branch information
Fullaxx committed Dec 14, 2021
1 parent 0ec5ca7 commit debb1a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ bail()

if [ x"${OVPNCFG}" != "x" ]; then
/app/openvpn.sh || bail "openvpn startup failed!"
/app/monitor.sh &
if [ "${MONITOR}" == "1" ]; then
/app/monitor.sh &
/app/monitor_restarts.sh &
fi
fi

if [ -r /rtorrent/config/rtorrent.rc ]; then
Expand Down
14 changes: 14 additions & 0 deletions app/monitor_restarts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

RESTARTCOUNT=`grep 'Restart pause, 300 second(s)' /var/log/openvpn/openvpn.log | wc -l`
while [ "${RESTARTCOUNT}" -lt 3 ]; do
sleep 1
RESTARTCOUNT=`grep 'Restart pause, 300 second(s)' /var/log/openvpn/openvpn.log | wc -l`
done

if [ -n ${LOGFILE} ]; then
TIMESTAMP=`date "+%y%m%d-%H%M%S"`
echo "${TIMESTAMP}: RESTART MONITOR ACTIVATING KILLSWITCH" >> /rtorrent/session/${LOGFILE}
fi

/app/killswitch.sh

0 comments on commit debb1a7

Please sign in to comment.