mirror of
https://github.com/MarkusMcNugen/docker-qBittorrentvpn
synced 2024-11-14 22:55:11 +00:00
Have container shut down if VPN or qbittorrent dies
This commit is contained in:
parent
00bce09f7f
commit
bf8b282876
@ -18,7 +18,7 @@ RUN apt-get update \
|
||||
&& apt-get install -y software-properties-common \
|
||||
&& add-apt-repository ppa:qbittorrent-team/qbittorrent-stable \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y jq traceroute qbittorrent-nox openvpn curl moreutils net-tools dos2unix kmod iptables ipcalc unrar \
|
||||
&& apt-get install -y iputils-ping jq traceroute qbittorrent-nox openvpn curl moreutils net-tools dos2unix kmod iptables ipcalc unrar \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# Add configuration and scripts
|
||||
|
@ -84,12 +84,28 @@ if [ -e /proc/$qbpid ]; then
|
||||
chmod 775 /config/qBittorrent/data/logs/qbittorrent.log
|
||||
if [[ $PFWD == "yes" ]]; then
|
||||
echo "[info] PIA Port forwarding configured, calling pia_port_forwarding.sh"
|
||||
/bin/bash /etc/openvpn/pia_port_forwarding.sh
|
||||
/bin/bash /etc/openvpn/pia_port_forwarding.sh &
|
||||
else
|
||||
echo "[info] PIA Port forwarding not enabled"
|
||||
fi
|
||||
fi
|
||||
sleep infinity
|
||||
while true; do
|
||||
sleep 60 #check once per minute if VPN is up
|
||||
ping -I tun0 -c 1 8.8.8.8 > /dev/null && VPNUP=true || VPNUP=false
|
||||
if [[ $VPNUP == false ]]; then
|
||||
echo "[crit] VPN down, shutting down docker (turn on auto restart to reconnect)" | ts '%Y-%m-%d %H:%M:%.S'
|
||||
exit 5
|
||||
fi
|
||||
pidof qbittorrent-nox >& /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
sleep 10 #check again after 10 secs.. maybe we were just restarting service to get new port forward
|
||||
pidof qbittorrent-nox >& /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "[crit] qbittorrent stopped, shutting down docker (turn on auto restart to reconnect)" | ts '%Y-%m-%d %H:%M:%.S'
|
||||
exit 6
|
||||
fi
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "qBittorrent failed to start!"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user