Closed DiMiTriFrog closed 3 years ago
Other than a missing semi-colon after true
, and dropping the redirection and backgrounding, this works for me in a container.
I'm going to close this issue, though, since it's not really within the scope of this project.
Other than a missing semi-colon after
true
, and dropping the redirection and backgrounding, this works for me in a container.I'm going to close this issue, though, since it's not really within the scope of this project. Thanks for your answering! Any code example? I can't understand an for me is not working
From a shell in the container, this worked: while true; do protonvpn refresh; protonvpn $PVPN_CMD_ARGS; sleep 10; echo "DISCONNECTING!"; protonvpn disconnect; done
It works for me!
#!/bin/sh
PVDIR=/root/.pvpn-cli
if [ -z "$PVPN_USERNAME" ] || [ -z "$PVPN_PASSWORD" ]; then
echo "PVPN_USERNAME and/or PVPN_PASSWORD not set!"
exit 1
fi
# Initialize config
if [ ! -f $PVDIR/pvpn-cli.cfg ]; then
cp $PVDIR/pvpn-cli.cfg.clean $PVDIR/pvpn-cli.cfg
sed -i \
-e "s/PVPN_USERNAME/$PVPN_USERNAME/" \
-e "s/PVPN_PROTOCOL/$PVPN_PROTOCOL/" \
-e "s/PVPN_TIER/$PVPN_TIER/" \
$PVDIR/pvpn-cli.cfg
fi
echo "$PVPN_USERNAME" > $PVDIR/pvpnpass
echo "$PVPN_PASSWORD" >> $PVDIR/pvpnpass
chmod 0600 $PVDIR/pvpnpass
# Connect to ProtonVPN
protonvpn refresh
protonvpn c -r
if ! ip link show proton0 > /dev/null; then
echo "Failed to bring up VPN :("
exit 1
fi
if [ -n "$DNS_SERVERS_OVERRIDE" ]; then
# This needs to run at this point, because ProtonVPN will have changed the
# DNS servers in /etc/resolv.conf.
cp /etc/resolv.conf /etc/resolv.conf.bak
echo "$DNS_SERVERS_OVERRIDE" | sed -e 's/^/nameserver /' -e 's/,/\nnameserver /' > /etc/resolv.conf
fi
# Setup route for host network
if [ -n "$HOST_NETWORK" ]; then
gw=$(ip route | awk '$1 == "default" { print $3 }')
ip route add "$HOST_NETWORK" via "$gw"
fi
# Start Privoxy
exec privoxy --no-daemon &
while true; do protonvpn refresh; protonvpn c -r; sleep 10; echo "DISCONNECTING!"; protonvpn disconnect; done
I'm trying to configure the run file for connect and disconnect periodically, but doesn't works.. Like ->
while true do protonvpn refresh; protonvpn $PVPN_CMD_ARGS; sleep 100; protonvpn disconnect; done </dev/null &>/dev/null &