#!/bin/sh

if [[ $# -ne 1 ]]
then
  echo "$(basename $0) requires exactly one of: hard, medium, off"
  exit 1
else
  case $1 in
    "hard")
      PROFILE="2947fbbad4"
      ;;
    "medium")
      [[ $(hostname) == "DeathStar" ]] && PROFILE="OodDeathStar" || PROFILE="OodCanine"
      ;;
    "off")
      ;;
    *)
      echo "Wrong command, either hard, medium or off"
      exit 2
      ;;
  esac

  sudo systemctl stop openvpn@2947fbbad4.service
  sudo systemctl stop openvpn@OodCanine.service
  sleep 1s

  if [[ -n $PROFILE ]]
  then
    sudo systemctl start openvpn@$PROFILE.service
  fi
  echo "$PROFILE started"
fi