#!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # Kernel-space driver for Alcatel SpeedTouch modems (for >=2.6.10 kernels) get_ip_addr() { IP_ADDR=`ifconfig ppp0 2>/dev/null | grep -F "inet ad" | cut -f2 -d":" | cut -f1 -d" "` } depend() { need localmount modules before ntp-client ntpd } start() { ebegin "Starting SpeedTouch ADSL modem" if [ -e "/var/run/ppp0.pid" ]; then eend 1 "ppp0 is already running" return 1 fi # PEER is defined in /etc/conf.d/speedtouch if [ ! -f "/etc/ppp/peers/$PEER" ]; then eend 1 "/etc/ppp/peers/$PEER does not exist" return 1 fi # Check that the modem is plugged in local REVISION if [ -e /proc/bus/usb/devices ]; then REVISION=$(grep '^P: *Vendor=06b9 ProdID=4061 ' /proc/bus/usb/devices | sed -e 's/.*Rev= *\([^ ]*\)/\1/') if [ -z "${REVISION}" ]; then eend 1 "Plug in the SpeedTouch ADSL modem" return 1 fi else eend 1 "USB Device Filesystem (USB_DEVICEFS) is not enabled in the kernel" return 1 fi # PPPoA modules modprobe -q pppoatm modprobe -q speedtch # Reluctant pause, to stop the kernel driver from executing this script twice, # and populating /var/log/messages with errors like: # "connect(0.38): No such device". # There would normally be a pause of several seconds anyway, # For the firmware to load, and an initial connection made. sleep 8 # Check that the firmware is loading. local SYNC="" local i=0 while [ 1 ]; do SYNC=`dmesg | grep 'ADSL line is up'` if [ ! -z "${SYNC}" ]; then # Firmware is loading, so continue break fi if [ $i -ge ${FIRMWARE_TIMEOUT} ]; then # Timed out eend 1 "Timeout waiting for firmware loading" return 1 fi sleep 2 i=$[$i+2] done start-stop-daemon --start -p /var/run/ppp0.pid -x /usr/sbin/pppd call $PEER if [ ${WAIT_FOR_PPP} == "yes" ]; then # Assume failure until an IP address is seen local RETCODE=1 # Wait for an IP address i=0 while [ 1 ]; do get_ip_addr if [ ${IP_ADDR} ]; then # ppp0 has an IP address - success RETCODE=0 # Wait for the connection to settle sleep 4 break fi if [ $i -ge ${PPP_TIMEOUT} ]; then # Timed out break fi sleep 2 i=$[$i+2] done eend ${RETCODE} else eend $? fi } stop() { ebegin "Stopping SpeedTouch ADSL modem" start-stop-daemon --stop -p /var/run/ppp0.pid -n pppd eend $? }