blob: 53e5f62fa201ca1cbf77b7f77d3a438ec479cac7 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#!/sbin/openrc-run
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/vpnc/files/vpnc-3.init,v 1.2 2010/08/13 08:39:48 fauli Exp $
VPNDIR="/etc/vpnc"
VPN="${SVCNAME#*.}"
if [ -n ${VPN} ] && [ ${SVCNAME} != "vpnc" ]; then
mkdir -p /var/run/vpnc
VPNPID="/var/run/vpnc/${VPN}.pid"
else
VPNPID="/var/run/vpnc.pid"
fi
VPNCONF="${VPNDIR}/${VPN}.conf"
VPNSCRIPTDIR="${VPNDIR}/scripts.d"
PREUPSCRIPT="${VPNSCRIPTDIR}/${VPN}-preup.sh"
PREDOWNSCRIPT="${VPNSCRIPTDIR}/${VPN}-predown.sh"
POSTUPSCRIPT="${VPNSCRIPTDIR}/${VPN}-postup.sh"
POSTDOWNSCRIPT="${VPNSCRIPTDIR}/${VPN}-postdown.sh"
# We should source this file to avoid problems when init script
# name differs from the default name
. /etc/conf.d/vpnc
depend() {
need net
before netmount
}
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
}
screenoutput() {
if [ "${VPNCOUTPUT}" = "yes" ]; then
export SCREEN_OUTPUT="/dev/stdout"
else
export SCREEN_OUTPUT="/dev/null"
fi
}
start() {
ebegin "Starting VPNC: ${VPN}"
checktundevice || return 1
screenoutput
if [ ! -e "${VPNCONF}" ]; then
eend 1 "${VPNCONF} does not exist"
return 1
fi
local args=""
if [ -x "${PREUPSCRIPT}" ] ; then
"${PREUPSCRIPT}" > ${SCREEN_OUTPUT}
fi
start-stop-daemon --start --pidfile "${VPNPID}" --exec /usr/sbin/vpnc \
-- --pid-file "${VPNPID}" "${VPNCONF}" > ${SCREEN_OUTPUT}
local retval=$?
if [ ! ${retval} -eq 0 ]; then
eend ${retval}
return ${retval}
fi
if [ -x "${POSTUPSCRIPT}" ] ; then
"${POSTUPSCRIPT}" > ${SCREEN_OUTPUT}
fi
eend $?
}
stop() {
ebegin "Stopping VPNC: ${VPN}"
screenoutput
if [ -x "${PREDOWNSCRIPT}" ] ; then
"${PREDOWNSCRIPT}" > ${SCREEN_OUTPUT}
fi
start-stop-daemon --stop --pidfile "${VPNPID}"
local retval=$?
if [ ! ${retval} -eq 0 ]; then
eend ${retval}
return ${retval}
fi
if [ -x "${POSTDOWNSCRIPT}" ] ; then
"${POSTDOWNSCRIPT}" > ${SCREEN_OUTPUT}
fi
eend $?
}
|