2024-06-07 00:26:49 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Check if the script is run with root privileges
|
|
|
|
#if [[ $EUID -ne 0 ]]; then
|
|
|
|
# echo "This script must be run as root"
|
|
|
|
# exit 1
|
|
|
|
#fi
|
|
|
|
|
|
|
|
# Function to get VPN password from Bitwarden
|
|
|
|
get_vpn_password() {
|
|
|
|
export BW_SESSION=$(bw unlock --raw)
|
|
|
|
bw get password com.azure.authenticator
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check the passed parameter
|
|
|
|
case "$1" in
|
|
|
|
up)
|
|
|
|
# Start the VPN connection
|
|
|
|
VPN_PASSWORD=$(get_vpn_password)
|
2024-09-27 20:49:21 +02:00
|
|
|
echo $VPN_PASSWORD | sudo openconnect --passwd-on-stdin --config $HOME/.config/openconnect/intersport.de.conf --servercert pin-sha256:ubN/pQqq4oHxnixTswjOlbVYf5qYf6DhbsuCLYndbvw=
|
2024-06-08 22:58:12 +02:00
|
|
|
#> /dev/null 2>/dev/null
|
2024-06-07 00:26:49 +02:00
|
|
|
;;
|
|
|
|
down)
|
|
|
|
# Terminate the VPN connection
|
|
|
|
sudo pkill -SIGINT openconnect
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {up|down}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|