dotfiles/scripts/prefix/bin/vpn

44 lines
726 B
Text
Raw Normal View History

2016-03-18 17:59:50 +01:00
#!/bin/sh
2016-09-04 03:29:23 +02:00
HARDPROFILE="2947fbbad4"
if [[ $(hostname) == "DeathStar" ]]
then
OODPROFILE="OodDeathStar"
else
OODPROFILE="OodCanine"
fi
2016-03-18 17:59:50 +01:00
if [[ $# -ne 1 ]]
then
echo "$(basename $0) requires exactly one of: hard, medium, off"
exit 1
else
case $1 in
"hard")
2016-09-04 03:29:23 +02:00
PROFILE=$HARDPROFILE
2016-03-18 17:59:50 +01:00
;;
"medium")
2016-09-04 03:29:23 +02:00
PROFILE=$OODPROFILE
2016-03-18 17:59:50 +01:00
;;
"off")
;;
*)
echo "Wrong command, either hard, medium or off"
exit 2
;;
esac
2016-09-04 03:29:23 +02:00
sudo systemctl stop openvpn@$HARDPROFILE.service
sudo systemctl stop openvpn@$OODPROFILE.service
2016-03-18 17:59:50 +01:00
sleep 1s
if [[ -n $PROFILE ]]
then
sudo systemctl start openvpn@$PROFILE.service
2016-09-04 03:29:23 +02:00
echo "$PROFILE started"
else
echo "All stopped."
2016-03-18 17:59:50 +01:00
fi
fi