#!/bin/sh # # echo "ppp-on-dialer gestartet">/dev/console # # file: /etc/ppp/redialer # # This script is based on the script "redialer" found at # ftp://sunsite.unc.edu/pub/Linux/system/Network/serial/ppp/ppp-2.2.0f.tar.gz # It should work with previous versions of chat too # ################################################################### # # These parameters control the attack dialing sequence. # # Maximum number of attempts to reach the telephone number(s) MAX_ATTEMPTS=2 # Delay between each of the attempts (in seconds). SLEEP_DELAY=5 # Terminal to echo output, exported from "ppp-on" if [ "w$TERMINAL" = "w" ]; then # TERMINAL=/dev/ttyI0 TERMINAL=/dev/console fi ################################################################### # # This is a list of telephone numbers. PHONE1=$TELEPHONE #PHONE1=006332979290 #PHONE2=31420920 #PHONE3=31420988 #PHONE4=39991099 numbers=1 ################################################################### # #ACCOUNT=ppp #PASSWORD=OpenSesame # ################################################################### # # Script to dial a telephone # You probably have to change the initialization string # Check your modem manual function callnumber { #echo "$ACCOUNT">$TERMINAL #echo "$PASSWORD">$TERMINAL #echo "$1">$TERMINAL /usr/sbin/chat -v \ TIMEOUT 10 \ ABORT '\nBUSY\r' \ ABORT '\nNO CARRIER\r' \ ABORT '\nRING\r\n\r\nRING\r' \ ABORT '\nNO DIALTONE\r' \ ABORT '\nERROR\r' \ '' '+++ATZ' \ OK 'AT&E40' \ TIMEOUT 15 \ OK ATD$1 \ 'CONNECT 64000/X.75' '' \ TIMEOUT 10 \ ogin:--ogin: $ACCOUNT \ assword: $PASSWORD \ Starting PPP '' # assword: $PASSWORD # # decide what to do depending on exitcode of chat # case $? in 0) echo Connection established > $TERMINAL; exit 0;; 1) echo chat: exit 1, see manpage for details. > $TERMINAL; exit 1;; 2) echo chat: exit 2, see manpage for details. > $TERMINAL; exit 2;; 3) echo chat: exit 3, see manpage for details. > $TERMINAL; exit 3;; 4) echo Line busy. > $TERMINAL;; 5) echo No Carrier. > $TERMINAL;; 6) echo A call is coming. Exiting! > $TERMINAL; exit 1;; 7) echo No dialtone. > $TERMINAL;; 8) echo An error occured. Exiting! > $TERMINAL; exit 1;; esac return } ################################################################### # # Function, that displays the rest of time before the next number # is dialed function sleeping { REST=$SLEEP_DELAY while [ $REST -ne 0 ]; do echo -ne Next trial in $REST seconds. "\r" > $TERMINAL sleep 1s REST=`expr $REST - 1` done echo "Next trial now. " "\r" > $TERMINAL return } ################################################################### # # Dial telephone numbers until one answers attempt=0 while : ; do echo -e "\n" > $TERMINAL attempt=`expr $attempt + 1` echo "Dialing attempt number: $attempt" > $TERMINAL n=`expr $attempt % $numbers` if [ $n -eq 0 ]; then n=$numbers fi NUMBER=`eval echo '$PHONE'$n` callnumber $NUMBER if [ $attempt -eq $MAX_ATTEMPTS ]; then exit 1 fi sleeping done