-
Notifications
You must be signed in to change notification settings - Fork 1
/
anyconnect-manager
62 lines (51 loc) · 1.15 KB
/
anyconnect-manager
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
56
57
58
59
60
61
62
#!/bin/bash
function usage {
echo "Usage:
-n Name for the running instance of anyconnect
-d Stop the running instance of anyconnect
Examples:
(start) $ sudo anyconnect-manager -n example
(stop) $ sudo anyconnect-manager -n example -d"
exit
}
function launch {
CONTAINER_NAME=anyconnect-client
if [ -v CONNECTION_NAME ]; then
CONTAINER_NAME+="-${CONNECTION_NAME}"
fi
# TODO: Detect if the container is already running.
# TODO: check for available ports for binding.
su -c "docker run --detach --cap-add=NET_ADMIN --cap-add=SYS_ADMIN --device /dev/net/tun -p 5900:5900 -p 1080:1080 -p 5901:5901 --name ${CONTAINER_NAME} --rm anyconnect-client"
}
function tear_down {
CONTAINER_NAME=anyconnect-client
if [ -v CONNECTION_NAME ]; then
CONTAINER_NAME+="-${CONNECTION_NAME}"
fi
su -c "docker stop ${CONTAINER_NAME}"
}
VPN_SUBNETS=()
while getopts :hn:d options; do
case ${options} in
h)
usage
;;
n)
CONNECTION_NAME="${OPTARG}"
;;
d)
TEAR_DOWN=true
;;
:)
usage
;;
?)
usage
;;
esac
done
if [ -v TEAR_DOWN ]; then
tear_down
exit
fi
launch