Created
July 16, 2015 16:10
-
-
Save moonwatcher/063a010497705ccdd0c1 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
alias vpn.portodelgato.stop="close.vpn portodelgato" | |
alias vpn.portodelgato.start="open.vpn portodelgato" | |
alias vpn.portodelgato.restart="restart.vpn portodelgato" | |
alias vpn.portodelgato.log="cat /usr/local/var/log/openvpn.portodelgato.log|tail -n 100" | |
show.vpn() { | |
if [ -n "$1" ]; then | |
PROCESS="org.openvpn.$1" | |
sudo launchctl list $PROCESS | |
else | |
echo 'Must provide VPN tunnel name' | |
fi | |
} | |
restart.vpn() { | |
close.vpn $1 | |
open.vpn $1 | |
} | |
open.vpn() { | |
if [ -n "$1" ]; then | |
PLIST="/Library/LaunchDaemons/org.openvpn."$1".plist" | |
if [ -f $PLIST ]; then | |
echo "Starting up OpenVPN tunnel $1" | |
sudo launchctl load -w $PLIST | |
else | |
echo 'No such VPN tunnel defined' | |
fi | |
else | |
echo 'Must provide VPN tunnel name' | |
fi | |
} | |
close.vpn() { | |
if [ -n "$1" ]; then | |
PLIST="/Library/LaunchDaemons/org.openvpn."$1".plist" | |
if [ -f $PLIST ]; then | |
echo "Shutting down OpenVPN tunnel $1" | |
sudo launchctl unload -w $PLIST | |
else | |
echo 'No such VPN tunnel defined' | |
fi | |
else | |
echo 'Must provide VPN tunnel name' | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment