All pastes #49201 Raw Edit

dial

public text v1 · immutable
#49201 ·published 2006-04-12 18:30 UTC
rendered paste body
geo@time:~/ticpu.mech$ cat /etc/init.d/dial
#!/bin/bash

modprobe ppp_generic
modprobe pppoatm
modprobe br2684

fix_config()
{
  sed -i 's@gateway@# gateway@g' /etc/network/interfaces &&
  sed -i 's@dns@# dns@g' /etc/network/interfaces &&
  rm -f /etc/resolv.conf
}

start_modem()
{
  br2684ctl -b -c 0 -a 0.35
  sleep 3s
  ifconfig nas0 192.168.0.1 netmask 255.255.255.0 up
  pppd call speedtch
}

stop_modem()
{
  killall pppd
  ifconfig nas0 0
  killall br2684ctl
}

case $1 in
  start)
    SYNCHED=0
    fix_config
    for COUNT in $(seq 0 30)
    do
      stop_modem
      sleep 2s
      start_modem
      sleep 8s
      if [ ! -z $(pidof pppd) ]; then
        echo "ADSL is up and running."
        exit 0
      fi
    done
    cp -L /etc/ppp/resolv.conf /etc
  ;;

  stop)
    stop_modem
  ;;

  restart)
    $0 stop
    sleep 5s
    $0 start
  ;;

  status)
    BRIDGE="up"
    MODEM="up"
    [ -z $(pidof br2684ctl) ] && BRIDGE="down"
    [ -z $(pidof pppd) ] && MODEM="down"
    echo "Bridge is $BRIDGE and modem is $MODEM."
  ;;

  *)
    echo "Usage: $0 start|stop|restart|status"
  ;;
esac
geo@time:~/ticpu.mech$