From 9f9077c52b7e69c5c2fa6652051080822d569a9d Mon Sep 17 00:00:00 2001 From: Florian Beisel Date: Fri, 7 Jun 2024 00:26:49 +0200 Subject: [PATCH] Add .local/bin/vpn --- private_dot_local/bin/executable_vpn | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 private_dot_local/bin/executable_vpn diff --git a/private_dot_local/bin/executable_vpn b/private_dot_local/bin/executable_vpn new file mode 100644 index 0000000..69d178c --- /dev/null +++ b/private_dot_local/bin/executable_vpn @@ -0,0 +1,31 @@ +#!/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) + echo $VPN_PASSWORD | sudo openconnect --passwd-on-stdin --config .config/openconnect/intersport.de.conf + ;; + down) + # Terminate the VPN connection + sudo pkill -SIGINT openconnect + ;; + *) + echo "Usage: $0 {up|down}" + exit 1 + ;; +esac +