linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* hotplug support for USB DSL modems
@ 2008-07-29  1:42 Marco d'Itri
  0 siblings, 0 replies; only message in thread
From: Marco d'Itri @ 2008-07-29  1:42 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 643 bytes --]

This script automatically starts a network connection when an USB DSL
modem is plugged and initialized.

I do not think it's worth distributing it with udev, but I am posting it
in the hope that other distributions will finally provide decent support
for these devices.

SUBSYSTEM=="atm", RUN+="dsl-modem.agent"


# from the Debian hotplug.functions:
wait_for_file() {
  local file=$1
  local timeout=$2
  [ "$timeout" ] || timeout=120

  local count=$timeout
  while [ $count != 0 ]; do
    [ -e "$file" ] && return 0
    sleep 1
    count=$(($count - 1))
  done

  mesg "$file did not appear before the timeout!"
  exit 1
}

-- 
ciao,
Marco

[-- Attachment #2: dsl-modem.agent --]
[-- Type: text/plain, Size: 2274 bytes --]

#!/bin/sh -e 
#
# Copyright 2008 Marco d'Itri <md@Linux.IT>
#
# This script automatically starts networking when a DSL modem is connected
# and its ATM interface is ready.
#
#
# For PPPoE you can set PROTOCOL=2684bridged and then add something like
# this to /etc/network/interfaces:
#
# allow-hotplug nas0
# iface nas0 inet manual
#        pre-up          ip link set up $IFACE
#        up              pppd persist call dsl-provider
#
#
# Support for CLIP (Classical IP over ATM, RFC 1577) may be incomplete.
#

# defaults
[ "$IP_INTERFACE" ] || IP_INTERFACE='nas0'
[ "$VP" ] || VP='8'
[ "$VC" ] || VC='35'

if [ -e /etc/default/dsl-modem.agent ]; then
  . /etc/default/dsl-modem.agent
fi

# just exit unless a protocol is configured
[ "$PROTOCOL" ] || exit 0

##############################################################################
wait_and_run_pppd() {
  # this guarantees that everything pppd needs to work is ready
  wait_for_file /dev/log

  exec pppd persist call ${PPP_PEER:-dsl-provider}
}

wait_and_run_br2684ctl() {
  wait_for_file /dev/log

  exec br2684ctl $BR2684_ARGS -b -c ${IP_INTERFACE#nas} \
    -a ${ATM_INTERFACE}.${VP}.${VC}
}

wait_and_run_atmarp() {
  wait_for_file /var/run/atmarpd.table

  # create the IP interface
  atmarp -c ${IP_INTERFACE:-atm0}
  # setup the VC
#  atmarp -s 192.0.2.254 ${ATM_INTERFACE}.${VP}.${VC}
  exec ifup ${IP_INTERFACE:-atm0} # XXX
}

##############################################################################
ATM_DRIVER=${NAME%%[0-9]*}
ATM_INTERFACE=${NAME##$ATM_DRIVER}

# is this a DSL modem?
case "$ATM_DRIVER" in
cxacru|speedtch|ueagle-atm|xusbatm|UNICORN) ;;
*) exit 0 ;;
esac

cd /lib/udev/
. ./hotplug.functions

##############################################################################
case "$ACTION" in
add)
  case "$PROTOCOL" in
  pppoa)	wait_and_run_pppd & ;;
  2684bridged)	wait_and_run_br2684ctl & ;;
  clip)		wait_and_run_atmarp & ;;
  esac
  ;;

remove)
  case "$PROTOCOL" in
  pppoa)
    # pppd will terminate automatically
    ;;
  2684bridged)
    PIDFILE="/var/run/$IP_INTERFACE.pid"
    if [ -e $PIDFILE ]; then
      kill $(cat $PIDFILE)
      rm -f $PIDFILE
    fi
    ;;
  clip)
    ifdown ${IP_INTERFACE:-atm0} # XXX
#    atmarp -d 192.0.2.254
    ;;
  esac
  ;;
esac

exit 0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-07-29  1:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-29  1:42 hotplug support for USB DSL modems Marco d'Itri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).