]>
Commit | Line | Data |
---|---|---|
1d058f32 | 1 | #!/bin/sh |
2 | ########################################################################## | |
3 | # Copyright (c) 2001, Cisco Systems, All Rights Reserved | |
4 | ########################################################################### | |
5 | # | |
6 | # File: vpnclient_init | |
7 | # Date: 04/23/2001 | |
8 | # | |
9 | ########################################################################### | |
10 | # | |
11 | # chkconfig: 345 85 85 | |
12 | # description: Startup script for the vpn client. Version 4.6.00 (0045) | |
13 | # | |
14 | ########################################################################### | |
15 | # Source function library. | |
16 | VPNCLIENT="/opt/cisco-vpnclient/bin/vpnclient" | |
17 | VPNDEV="cipsec0" | |
18 | VPNMOD=cisco_ipsec | |
1d058f32 | 19 | WHOAMI=`id | sed -e 's/(.*//'` |
20 | ||
21 | # See how we were called. | |
22 | case "$1" in | |
23 | start) | |
24 | echo -n "Starting ${VPNCLIENT}: " | |
25 | if [ "$WHOAMI" != "uid=0" ] ; then | |
26 | echo "Failed (super user access required)" | |
27 | exit 1 | |
28 | fi | |
29 | /sbin/lsmod | grep -q "${VPNMOD}" | |
f489cb6a | 30 | if [ "$?" = "0" ] ; then |
1d058f32 | 31 | echo "module ${VPNMOD} is already running. Use restart instead." |
32 | exit 1 | |
33 | fi | |
34 | ||
35 | if [ -f /etc/resolv.conf.vpnbackup ]; then | |
36 | echo "restoring /etc/resolv.conf" | |
37 | mv /etc/resolv.conf.vpnbackup /etc/resolv.conf | |
38 | fi | |
8331e13b AG |
39 | /sbin/modprobe ${VPNMOD} |
40 | if [ "$?" != "0" ] ; then | |
41 | echo "Failed (insmod)" | |
42 | exit 1 | |
1d058f32 | 43 | fi |
1d058f32 | 44 | case "`uname -r`" in |
45 | 2.6.*) | |
46 | ;; | |
47 | 2.5.*) | |
48 | ;; | |
49 | 2.4.*) | |
50 | ;; | |
51 | 2.2.*) | |
52 | ;; | |
53 | 2.0.*) | |
54 | # | |
55 | # This is only needed due to a bug in 2.0.x kernels that affects | |
56 | # arp lookups. | |
57 | # | |
58 | ifconfig $VPNDEV 222.222.222.222 ; | |
59 | if [ "$?" != "0" ] ; then | |
60 | echo "Failed (ifconfig)" | |
61 | /sbin/rmmod ${VPNMOD} | |
62 | exit 1 | |
63 | fi | |
64 | ;; | |
65 | *) | |
66 | echo "Failed (unsupported Linux version)" | |
67 | /sbin/rmmod ${VPNMOD} | |
68 | exit 1 | |
69 | ;; | |
70 | esac | |
1d058f32 | 71 | echo "Done" |
72 | ;; | |
73 | stop) | |
74 | echo -n "Shutting down ${VPNCLIENT}: " | |
75 | if [ "$WHOAMI" != "uid=0" ] ; then | |
76 | echo "Failed (super user access required)" | |
77 | exit 1 | |
78 | fi | |
79 | killall cvpnd > /dev/null 2>&1 | |
80 | ||
81 | /sbin/lsmod | grep -q "${VPNMOD}" | |
f489cb6a | 82 | if [ "$?" != "0" ] ; then |
1d058f32 | 83 | echo "module ${VPNMOD} is not running." |
84 | exit 1 | |
85 | fi | |
86 | /sbin/ifconfig $VPNDEV down | |
87 | if [ "$?" != "0" ] ; then | |
88 | echo "Failed (ifconfig)" | |
89 | exit 1 | |
90 | fi | |
91 | /sbin/rmmod ${VPNMOD} | |
92 | if [ "$?" != "0" ] ; then | |
93 | echo "Failed (rmmod)" | |
94 | exit 1 | |
95 | fi | |
96 | echo "Done" | |
97 | ;; | |
98 | status) | |
99 | /sbin/lsmod | egrep 'Module' | |
100 | /sbin/lsmod | egrep "${VPNMOD}" | |
101 | if [ "$?" != "0" ] ; then | |
102 | echo | |
103 | echo "Status Failed (lsmod ${VPNMOD}) - The VPN module is not loaded." | |
104 | fi | |
105 | echo | |
106 | /sbin/ifconfig $VPNDEV | |
107 | if [ "$?" != "0" ] ; then | |
108 | echo | |
109 | echo "Status Failed (ifconfig ${VPNDEV}) - The virtual interface is not present." | |
110 | exit 1 | |
111 | fi | |
112 | ;; | |
113 | restart|reload) | |
114 | $0 stop | |
115 | $0 start | |
116 | ;; | |
117 | *) | |
118 | echo "Usage: $0 {start|stop|restart|reload|status}" | |
119 | exit 1 | |
120 | esac | |
121 | ||
122 | exit 0 |