-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvpnc-wrapper
executable file
·52 lines (45 loc) · 1.29 KB
/
vpnc-wrapper
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
#!/bin/bash
#
# XXX - this is mostly untested/legacy
# i no longer really use or have access to a working cisco vpn...
#
whoami | grep -q ^root$ || {
echo "please run this as root (via sudo)"
exit 1
}
# required programs
reqprogs="vpnc openvpn"
# sleep time for pauses
sleeptime="5"
# vpn tun/tap device
vpnif="tun0"
# check for required programs
for reqprog in ${reqprogs} ; do
which "${reqprog}" >/dev/null 2>&1 || {
echo "${i}: required program not found"
exit 1
}
done
# make our runtime directory
test -e /var/run/vpnc || mkdir -p /var/run/vpnc
# check shill to see if we already have an interface override in place
# XXX - this should check for .*$IF.* and _append_ if not found
# from shill_main.cc, this should be a comma-separated list
tr \\0 \\n < /proc/$(pgrep shill)/environ | \
grep -q "^BLOCKED_DEVICES=${vpnif}$" || {
echo "adding ${vpnif} to shill BLOCKED_DEVICES"
echo "restarting shill"
stop shill
sleep ${sleeptime}
start shill BLOCKED_DEVICES="${vpnif}"
}
sleep ${sleeptime}
# check for and create our vpn device
ifconfig -a | grep -q "^${vpnif}" || {
echo "adding tunnel device ${vpnif} with openvpn"
openvpn --mktun --dev "${vpnif}"
}
sleep ${sleeptime}
# finally run vpnc
echo "attempting to connect to private network via vpnc"
vpnc --ifname="${vpnif}"