Created
June 13, 2023 16:00
-
-
Save Syakhisk/0f59179a5509adab1feedc7ddeaa8716 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
VPN_PATH="$HOME/VPNs/MYITS-OPENVPN" | |
VPN_CONFIG="$VPN_PATH/its-onefile-2.ovpn" | |
EXPIRED_FILE="$HOME/VPNs/expired.txt" | |
EXPIRED_DATE="$(cat "$EXPIRED_FILE" | grep "Expired:" | awk -F'Expired:' '{print $2}')" | |
if [ -n "$TMUX" ]; then | |
tmux rename-window "VPN" | |
fi | |
if ! $(node -e "(new Date('$EXPIRED_DATE').getTime() < new Date().getTime()) ? process.exit(1) : process.exit(0)"); then | |
echo "--Expired--" | |
exit 1 | |
fi | |
cd "$VPN_PATH" | |
if [[ "$1" == "no-route" ]]; then | |
echo "--Tunneling without route--" | |
sudo openvpn --config "$VPN_CONFIG" | |
exit 0 | |
fi | |
sudo openvpn \ | |
--config "$VPN_CONFIG" \ | |
--route-nopull \ | |
--route 10.15.40.0 255.255.255.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment