blob: 6933efc4d5297473f597fb7a04e4166ebd403b7f (
plain)
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
|
#!/sbin/runscript
VPNDIR="/etc/openvpn"
VPN="${myservice##*.}"
if [[ -n ${VPN} && ${myservice} != "openvpn" ]]; then
VPNPID="/var/run/openvpn.${VPN}.pid"
else
VPNPID="/var/run/openvpn.pid"
fi
VPNCONF="${VPNDIR}/${VPN}.conf"
depend() {
need net
}
checktundevice() {
if [[ ! -e /dev/net/tun ]]; then
if ! modprobe tun ; then
eerror "TUN/TAP support is not available in this kernel"
return 1
fi
fi
if [[ -h /dev/net/tun && -c /dev/misc/net/tun ]]; then
ebegin "Detected broken /dev/net/tun symlink, fixing..."
rm -f /dev/net/tun
ln -s /dev/misc/net/tun /dev/net/tun
eend $?
fi
}
start() {
ebegin "Starting ${myservice}"
checktundevice || return 1
if [[ ! -e "${VPNCONF}" ]]; then
eend 1 "${VPNCONF} does not exist"
return 1
fi
start-stop-daemon --start --exec /usr/sbin/openvpn --pidfile "${VPNPID}" \
-- --config "${VPNCONF}" --writepid "${VPNPID}" \
--daemon --cd "${VPNDIR}"
eend $? "Check your logs to see why startup failed"
}
stop() {
ebegin "Stopping ${myservice}"
start-stop-daemon --stop --exec /usr/sbin/openvpn --pidfile "${VPNPID}"
eend $?
}
# vim: ts=4
|