better vpn commands

This commit is contained in:
Martin Potier 2016-09-04 03:29:23 +02:00
parent f21d7e7f11
commit 9f931911e3
1 changed files with 15 additions and 5 deletions

View File

@ -1,5 +1,13 @@
#!/bin/sh #!/bin/sh
HARDPROFILE="2947fbbad4"
if [[ $(hostname) == "DeathStar" ]]
then
OODPROFILE="OodDeathStar"
else
OODPROFILE="OodCanine"
fi
if [[ $# -ne 1 ]] if [[ $# -ne 1 ]]
then then
echo "$(basename $0) requires exactly one of: hard, medium, off" echo "$(basename $0) requires exactly one of: hard, medium, off"
@ -7,10 +15,10 @@ then
else else
case $1 in case $1 in
"hard") "hard")
PROFILE="2947fbbad4" PROFILE=$HARDPROFILE
;; ;;
"medium") "medium")
[[ $(hostname) == "DeathStar" ]] && PROFILE="OodDeathStar" || PROFILE="OodCanine" PROFILE=$OODPROFILE
;; ;;
"off") "off")
;; ;;
@ -20,14 +28,16 @@ else
;; ;;
esac esac
sudo systemctl stop openvpn@2947fbbad4.service sudo systemctl stop openvpn@$HARDPROFILE.service
sudo systemctl stop openvpn@OodCanine.service sudo systemctl stop openvpn@$OODPROFILE.service
sleep 1s sleep 1s
if [[ -n $PROFILE ]] if [[ -n $PROFILE ]]
then then
sudo systemctl start openvpn@$PROFILE.service sudo systemctl start openvpn@$PROFILE.service
echo "$PROFILE started"
else
echo "All stopped."
fi fi
echo "$PROFILE started"
fi fi