blob: 0a1ae4a4c6a18703ca9d222c4fc81fd2b070dd2f (
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
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/cisco-vpnclient-3des/files/vpnclient.rc,v 1.6 2004/08/25 00:04:32 vapier Exp $
opts="start stop status"
VPNCLIENT="/usr/bin/vpnclient"
VPNDEV="cipsec0"
depend() {
need net
}
checkconfig() {
export KV="$(uname -r)"
export VPNMOD="cisco_ipsec"
case "${KV}" in
2.6.*|2.5.*) VPNMOD_FILE="${VPNMOD}.ko";;
2.4.*|2.2.*|2.0.*) VPNMOD_FILE="${VPNMOD}.o";;
*)
eerror "Kernel version '${KV}' is not supported"
return 1;;
esac
export VPNMOD_FILE
return 0
}
start() {
checkconfig || return 1
local PC=""
ebegin "Starting Cisco VPN Client"
if [ -f /etc/resolv.conf.vpnbackup ]; then
einfo "restoring /etc/resolv.conf"
mv /etc/resolv.conf.vpnbackup /etc/resolv.conf
fi
if [ -d /lib/modules/preferred ]; then
PC="/lib/modules/preferred/CiscoVPN"
else
PC="/lib/modules/${KV}/CiscoVPN"
fi
if [ -d "${PC}" ] ; then
/sbin/insmod ${PC}/${VPNMOD_FILE} >/dev/null 2>&1
if [ "$?" != "0" ] ; then
eend 1 "Failed to load module '${VPNMOD}'"
return 1
fi
else
eend 1 "module directory '$PC' not found"
return 1
fi
if [ "${KV:0:3}" == "2.0" ] ; then
# This is only needed due to a bug in 2.0.x kernels that affects
# arp lookups.
ifconfig $VPNDEV 222.222.222.222 ;
if [ "$?" != "0" ] ; then
eerror "Failed (ifconfig)"
/sbin/rmmod ${VPNMOD}
exit 1
fi
fi
eend 0
}
stop() {
checkconfig || return 1
ebegin "Stopping Cisco VPN Client"
if [ -x $VPNCLIENT ]; then
$VPNCLIENT disconnect > /dev/null 2>&1
fi
/sbin/lsmod | grep -q "${VPNMOD}"
if [ "$?" != "0" ] ; then
eend 1 "Failed: module ${VPNMOD} is not running"
return 1
fi
/sbin/ifconfig $VPNDEV down
if [ "$?" != "0" ] ; then
eend 1 "Failed (ifconfig)"
return 1
fi
/sbin/rmmod ${VPNMOD}
if [ "$?" != "0" ] ; then
eend 1 "Failed (rmmod)"
return 1
fi
eend 0
}
status() {
checkconfig || return 1
/sbin/lsmod | egrep "${VPNMOD}"
if [ "$?" != "0" ] ; then
eerror "Failed (lsmod ${VPNMOD}): the VPN module is not loaded"
return 1
fi
echo
/sbin/ifconfig $VPNDEV
if [ "$?" != "0" ] ; then
echo
eerror "Failed (ifconfig ${VPNDEV}): the virtual interface is not present"
return 1
fi
}
|