-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvpn
More file actions
executable file
·68 lines (58 loc) · 922 Bytes
/
vpn
File metadata and controls
executable file
·68 lines (58 loc) · 922 Bytes
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
63
64
65
66
67
68
#!/bin/sh
# simple openconnect wrapper
if [ $# -ne 2 ]
then
echo "missing arg"
usage
fi
CUSTOMER=$1
cmd=$2
CMD_OPTS=
CUSTOMERCONF=~/.vpn/${CUSTOMER}.conf
PIDFILE=/run/openconnect.pid
[ -f $PIDFILE ] && PID=$(cat $PIDFILE)
usage()
{
echo "USAGE: sudo vpn <customer> up|down"
exit 1
}
vpn_up()
{
if [ -f $CUSTOMERCONF ]
then
while read line
do
CMD_OPTS="$CMD_OPTS $line"
# echo $CMD_OPTS
done < $CUSTOMERCONF
else
echo "$CUSTOMERCONF not found!"
exit 1
fi
if [ ! -f $PIDFILE ]
then
sudo openconnect --background --pid-file=$PIDFILE $CMD_OPTS
else
echo "openconnect process is already running... pid: $PID "
fi
# exit 0
}
vpn_down()
{
if [ -f "$PIDFILE" ]; then
sudo kill $PID
sudo rm $PIDFILE
else
echo "openconnect process not running."
fi
exit 0
}
case $cmd in
up)
vpn_up;;
down)
vpn_down;;
*)
usage
;;
esac