#!/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 net.nas0 before ntp-client ntpd # There is more configuration required here, as mentioned at http://www.linux-usb.org/SpeedTouch/gentoo/index.html # /etc/init.d/net.nas0 needs to be set up, for the Ethernet interface, from the br2684ctl ebuild } 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 # Skip USB check, since the modem is not connected via USB. # PPPoE modules modprobe -q br2684 modprobe -q pppoe # 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 $? }