-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcisco-vpn-connect.sh
More file actions
executable file
·55 lines (47 loc) · 1.24 KB
/
cisco-vpn-connect.sh
File metadata and controls
executable file
·55 lines (47 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
ARGUMENTS=$(getopt -o s:dc --long server:,disconnect,connect -n 'vpn-script' -- "$@")
# shellcheck disable=SC2181
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
eval set -- "$ARGUMENTS"
VPN_SERVER=""
ACTION="connect" # default action
while true ; do
case "$1" in
-s|--server)
VPN_SERVER="$2"
shift 2
;;
-d|--disconnect)
ACTION="disconnect"
shift
;;
-c|--connect)
ACTION="connect"
shift
;;
--)
shift
break
;;
*)
echo "Error: Unsupported argument '$1'" >&2
exit 1
;;
esac
done
# Handle disconnect action
if [ "$ACTION" = "disconnect" ]; then
echo "Disconnecting VPN..."
pkexec killall openconnect
exit 0
fi
# Check if required server argument is provided for connect
if [ -z "$VPN_SERVER" ]; then
echo "Error: --server argument is required for connection" >&2
exit 1
fi
echo "Switching to Python 3.12..."
pyenv shell 3.12
echo "Activating OpenConnect Virtual Environment..."
source "${HOME}/.local/share/openconnect/venv/bin/activate"
openconnect-sso --server="$VPN_SERVER"