#!/sbin/runscript # Copyright 1999-2004 Gentoo Technologies, Inc. # 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.4 2004/03/06 03:29:17 vapier Exp $ opts="start stop status" VPNCLIENT="/usr/bin/vpnclient" VPNDEV="cipsec0" VPNMOD="cisco_ipsec" ID="`which id`" if [ "$?" != "0" ]; then eerror "Failed: Unable to determine access level (can't find $HILITE id $NORMAL in \$PATH)." unset ID exit 1 fi WHOAMI="`$ID -u`" depend() { need net } start() { 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/`uname -r`/CiscoVPN fi if [ -d $PC ] ; then /sbin/insmod ${PC}/${VPNMOD} >/dev/null 2>&1 if [ "$?" != "0" ] ; then eerror "Failed to load module ${VPNMOD}" exit 1 fi else eerror "module directory $PC not found." exit 1 fi case "`uname -r`" in 2.6.*) ;; 2.5.*) ;; 2.4.*) ;; 2.2.*) ;; 2.0.*) # # 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 ;; *) eerror "Failed (unsupported Linux version)." /sbin/rmmod ${VPNMOD} exit 1 ;; esac eend $? } stop() { ebegin "Stopping Cisco VPN Client" if [ -x $VPNCLIENT ]; then $VPNCLIENT disconnect > /dev/null 2>&1 fi /sbin/lsmod | grep -q "${VPNMOD}" if [ "$?" != "0" ] ; then eerror "Failed: module ${VPNMOD} is not running." exit 1 fi /sbin/ifconfig $VPNDEV down if [ "$?" != "0" ] ; then eerror "Failed (ifconfig)." exit 1 fi /sbin/rmmod ${VPNMOD} if [ "$?" != "0" ] ; then eerror "Failed (rmmod)." exit 1 fi eend $? } status() { /sbin/lsmod | egrep 'Module' /sbin/lsmod | egrep "${VPNMOD}" if [ "$?" != "0" ] ; then echo eerror "Failed (lsmod ${VPNMOD}): the VPN module is not loaded." exit 1 fi echo /sbin/ifconfig $VPNDEV if [ "$?" != "0" ] ; then echo eerror "Failed (ifconfig ${VPNDEV}): the virtual interface is not present." exit 1 fi }