--- Begin Message ---
In LM 8.2 RC1 :

1) /usr/share/speedtouch/speedtouch.sh is not configured correctly.
you have to hack it

2)  /etc/ppp/peers/adsl is not configured correctly.
You have to specify VPI and VCI values
It would be good that connexion assistant (draknet) woult make it for 
us, for it claims for country... (why contry is fixed by default to 
Netherlands, and not according to locale ?)

c.devise
#!/bin/sh
#
# Script Name : adsl
#
# chkconfig:   345 91 35
# authors:      Edouard Gomez <[EMAIL PROTECTED]>
#               Bruno Bonfils <[EMAIL PROTECTED]>
# revision:    1.7
# description: This SysV script try to establish a connection with an ISP
#              using an Alcatel SpeedTouch USB and benoit papillault's driver
# usage: Depend on linux distro
#
# Return Values :
#  -1  argument unknown
#   0  success
#   1  kernel module loading failed
#   2  kernel module unloading failed
#   3  microcode file is missing
#   4  modem_run executable missing
#   5  modem_run failed to synchronise adsl line  
#   6  ppp executable missing
#   7  ppp connection failed
#   8  usbdevfs mounting failed
#   9  usbdevfs umounting failed
#  10  modprobe executable missing
#  11  mount  executable missing
#  12  umount executable missing
#  13  ifconfig executable missing
#  14  peer file missing
# 255  script not configured

#Set this to 1 if you have configured the script
CONFIGURED=1

# Includes function def
if [ -f /etc/debian_version ] ; then
  RHSTYLE=0
else
  RHSTYLE=1
fi

if [ $RHSTYLE -ne 0 ] ; then

. /etc/init.d/functions

# Check existence of the network file
[ ! -f /etc/sysconfig/network ] && exit 1

# Include network defs
. /etc/sysconfig/network

else
  NETWORKING="yes"
fi

[ ${NETWORKING} = "no" ] && exit 1


# SYTEM DEPENDANT STUFF
# All you have to configure is contained in this block
# You don't have to touch anything else outside of this block
  #Set them to 1 (== load) or 0 (== skip)
LOAD_USBCORE="0"
LOAD_USBINTERFACE="0"
LOAD_NHDLC="0"
 #Set the name of your default usb interface
 #usb-uhci, uhci or usb-ohci
DEFAULT_USBINTERFACE="usb-uhci"
  #Set the microcode path here
MICROCODE="/usr/share/speedtouch/mgmt.o"

# VARIABLES
MAX_LOOP=60
USBMODULE=$DEFAULT_USBINTERFACE
VERBOSE=1
PEER="adsl"


# Lock files
  # Red Hat & Mandrake
SYSCONF_FILE="/var/lock/subsys/adsl"
  # Specific for the Debian
MODEM_RUN_PID=/var/run/modem_run.pid

# Change PATH to be sure to include /usr/local/bin
PATH=$PATH:/usr/local/bin

#PROG NAMES
MODPROBE=$(which modprobe)
KILL=$(which killall)
PPP=$(which pppd)
MODEM_RUN=$(which modem_run)
MOUNT=$(which mount)
UMOUNT=$(which umount)
IFCONFIG=$(which ifconfig)

isconfigured()
{

  if [ $CONFIGURED -eq 0 ] ; then
    myecho_failure
    exit 255
  fi

}

myecho_success()
{

  if [ $RHSTYLE -ne 0 ] ; then
    echo_success
    echo
  else
    echo " Ok."
  fi

}

myecho_failure()
{

  if [ $RHSTYLE -ne 0 ] ; then
    echo_failure
    echo
  else
    echo " Echec."
  fi

}

load_kernel_module()
{

  if [ ! -x $MODPROBE ] ; then
    myecho_failure
    exit 10
  fi

  lsmod | grep -q $1
  RETURNED=$?
  [ $RETURNED -ne 0 ] && $MODPROBE -k $1

  RETURNED=$?

  if [ $RETURNED -ne 0 ] ; then
    myecho_failure
    exit 1
  fi

}

unload_kernel_module()
{

  if [ ! -x $MODPROBE ] ; then
    myecho_failure
    exit 10
  fi

  lsmod | grep -q $1
  RETURNED=$?
  [ $RETURNED -eq 0 ] && $MODPROBE -r $1

  RETURNED=$?

  if [ $RETURNED -ne 0 ] ; then
    myecho_failure
    exit 2
  fi

}

kill_process()
{

  ps ax | grep -q $1
  RETURNED=$?
  [ $RETURNED -eq 0 ] && ($KILL $1 >/dev/null 1>&2)

}

connect_adsl_line()
{

  #Launch the modem_run driver
  if [ ! -f $MICROCODE ] ; then
    myecho_failure
    exit 3
  fi

  if [ ! -x $MODEM_RUN ] ; then
    myecho_failure
    exit 4
  fi

  if [ $RHSTYLE -eq 0 ] ; then
        start-stop-daemon --start --pidfile $MODEM_RUN_PID --make-pidfile \
                --exec $MODEM_RUN -- -v $VERBOSE -m -f $MICROCODE
  else
        $MODEM_RUN -v $VERBOSE -m -f $MICROCODE
  fi

  RETURNED=$?

  if [ $RETURNED -ne 0 ] ; then
    myecho_failure
    exit 5
  fi

}

connect_ppp()
{

  #Launch ppp daemon
  if [ ! -x $PPP ] ; then
    myecho_failure
    exit 6
  fi

  if [ ! -f "/etc/ppp/peers/$PEER" ] ; then
    myecho_failure
    exit 14
  fi

  if [ ! -x $IFCONFIG ] ; then
    myecho_failure
    exit 13
  fi

  if [ $RHSTYLE -eq 0 ] ; then
        start-stop-daemon --start \
                --exec $PPP -- call $PEER > /dev/null 2>&1
  else
        $PPP call $PEER >/dev/null 2>&1
  fi 
  RETURNED=1
  LOOPS=0

  # Loop until connection has been established with the ISP
  # or the transaction has failed
  while [ $RETURNED -ne 0 ] && [ $LOOPS -le $MAX_LOOP ] ; do
    $IFCONFIG | grep -q 'ppp'
    RETURNED=$?
    LOOPS=`expr $LOOPS + 1`
    sleep 1
  done

  if [ $LOOPS -gt $MAX_LOOP ] && [ $RETURNED -ne 0 ] ; then
    myecho_failure
    exit 7
  fi

}

mount_usb()
{

  if [ ! -x $MOUNT ] ; then
    echo_failure
    exit 11
  fi

  $MOUNT | grep -q usbdevfs
  RETURNED=$?

  if [ $RETURNED -ne 0 ] ; then 
    $MOUNT none /proc/bus/usb -t usbdevfs

    RETURNED=$?

    if [ $RETURNED -ne 0 ] ; then
      myecho_failure
      exit 8
    fi

  fi

}

umount_usb()
{

  if [ ! -x $MOUNT ] ; then
    echo_failure
    exit 11
  fi

  if [ ! -x $UMOUNT ] ; then
    echo_failure
    exit 12
  fi

  $MOUNT | grep -q usbdevfs
  RETURNED=$?

  if [ $RETURNED -eq 0 ] ; then
    $UMOUNT /proc/bus/usb

    RETURNED=$?

    if [ $RETURNED -ne 0 ] ; then
      myecho_failure
      exit 9
    fi

  fi

}

get_usb_module()
{

  MODULE_CONF="/etc/modules.conf"
  [ -f /etc/conf.modules ] && MODULE_CONF="/etc/conf.modules"
  [ -f /etc/modules.conf ] && MODULE_CONF="/etc/modules.conf"

  USBMODULE=$(grep "usb-interface" ${MODULE_CONF} | awk '{ print $3 }')
  RETURNED=$?
  [ $RETURNED -ne 0 ] || [ "$USBMODULE" = "" ] && USBMODULE=${DEFAULT_USBINTERFACE}

}


###############################################################################
#
#                          Beginning of the script
#
###############################################################################

case "$1" in
    start)
          echo -n "D�marrage connexion ADSL:"
          isconfigured

          # At least but not at last, Mandrake dependant USB daemon
          [ -x /usr/sbin/usbd ] && usbd -k 1>&2 >/dev/null

          # Load usb core if needed
          if [ $LOAD_USBCORE -ne 0 ] ; then
            load_kernel_module "usbcore"
          fi

          # If one of usb modules has been loaded, mount the usbdevfs
          if [ $LOAD_USBCORE -ne 0 ] || [ $LOAD_USBINTERFACE -ne 0 ] ; then
            mount_usb
            sleep 2
          fi

          # Load usb-interface module described in /etc/modules.conf
          if [ $LOAD_USBCORE -ne 0 ] || [ $LOAD_USBINTERFACE -ne 0 ] ; then
            get_usb_module
            sleep 1
            load_kernel_module "$USBMODULE"
            sleep 3
          fi

          # ADSL synchro
          connect_adsl_line
          sleep 1

          # Load n_hdlc line discipline
          if [ $LOAD_NHDLC -ne 0 ] ; then
            load_kernel_module "n_hdlc"
          fi

          # ISP connection
          connect_ppp

          # Load ppp module
          load_kernel_module "ppp"

          # Report success
          myecho_success

          if [ $RHSTYLE -ne 0 ] ; then
            touch $SYSCONF_FILE
          fi
          ;;
    stop)
          echo -n "Arr�t connexion ADSL:"
          isconfigured

          # Kill pppd to break ppp connection
          if [ $RHSTYLE -eq 0 ] ; then
                start-stop-daemon --stop --pidfile /var/run/ppp0.pid pppd
                sleep 2
                start-stop-daemon --stop --pidfile $MODEM_RUN_PID modem_run
          else
                kill_process pppd
                sleep 2
                kill_process modem_run
          fi

          # Unload HDLC line discipline
          if [ $LOAD_NHDLC -ne 0 ] ; then
            unload_kernel_module "n_hdlc"
          fi


          # At least but not at last, Mandrake dependant USB daemon
          [ -x /usr/sbin/usbd ] && (usbd -k 1>&2 >/dev/null)

          # Unload modules
          if [ $LOAD_USBCORE -ne 0 ] || [ $LOAD_USBINTERFACE -ne 0 ] ; then

            kill_process khubd
            sleep 1

            get_usb_module

            unload_kernel_module "$USBMODULE"
            sleep 2

            umount_usb
            sleep 2

            if [ $LOAD_USBCORE -ne 0 ] ; then
              unload_kernel_module "usbcore"
              sleep 1
            fi

          fi

          # Report success
          myecho_success

          # Remove lock file
          if [ $RHSTYLE -ne 0 ] ; then
            rm -f $SYSCONF_FILE
          fi
          ;;
    restart|force-reload)
          echo -n "Red�marrage connexion:"
          isconfigured

          if [ $LOAD_USBCORE -ne 0 ] || [ $LOAD_USBINTERFACE -ne 0 ] ; then

            $0 stop  >/dev/null

            RETURNED=$?

            if [ $RETURNED -ne 0 ] ; then
              myecho_failure
              exit $RETURNED
            fi

            $0 start >/dev/null

            RETURNED=$?

            if [ $RETURNED -ne 0 ] ; then
              myecho_failure
              exit $RETURNED
            fi

          else

            $0 reload >/dev/null

            RETURNED=$?

            if [ $RETURNED -ne 0 ] ; then
              myecho_failure
              exit $RETURNED
            fi

          fi

          myecho_success
          ;;
    reload)
          echo -n "Rechargement connexion ADSL:"
          isconfigured

          # Kills pppd to break ppp connection
          if [ $RHSTYLE -eq 0 ] ; then
                start-stop-daemon --stop --pidfile /var/run/ppp0.pid pppd
          else
                kill_process pppd
          fi

          sleep 2
          connect_ppp

          myecho_success
          ;;
    status)
          exit 0
          ;;
    *)
          if [ $RHSTYLE -ne 0 ] ; then
            echo "Usage : $0 [start|stop|restart|reload|status]"
          else
            echo "Usage : $0 {start|stop|restart|force-reload}"
          fi
          exit -1

esac

exit 0
--- End Message ---

Reply via email to