~ubuntu-branches/debian/jessie/ppp/jessie

« back to all changes in this revision

Viewing changes to scripts/redialer

  • Committer: Bazaar Package Importer
  • Author(s): Michael Beattie
  • Date: 2001-12-11 00:24:05 UTC
  • Revision ID: james.westby@ubuntu.com-20011211002405-gcsjlgalwyjf99m2
Tags: 2.4.1.uus-4
Use MAKEDEV in postinst, not mknod. (Closes: #122574)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
 
###################################################################
3
 
#
4
 
# These parameters control the attack dialing sequence.
5
 
#
6
 
# Maximum number of attempts to reach the telephone number(s)
7
 
MAX_ATTEMPTS=10
8
 
 
9
 
# Delay between each of the attempts. This is a parameter to sleep
10
 
# so use "15s" for 15 seconds, "1m" for 1 minute, etc.
11
 
SLEEP_DELAY=15s
12
 
 
13
 
###################################################################
14
 
#
15
 
# This is a list of telephone numbers. Add new numbers if you wish
16
 
# and see the function 'callall' below for the dial process.
17
 
PHONE1=555-1212
18
 
PHONE2=411
19
 
 
20
 
###################################################################
21
 
#
22
 
# If you use the ppp-on script, then these are passed to this routine
23
 
# automatically. There is no need to define them here. If not, then
24
 
# you will need to set the values.
25
 
#
26
 
ACCOUNT=my_account_name
27
 
PASSWORD=my_password
28
 
 
29
 
###################################################################
30
 
#
31
 
# Function to initialize the modem and ensure that it is in command
32
 
# state. This may not be needed, but it doesn't hurt.
33
 
#
34
 
function initialize
35
 
{
36
 
    chat -v TIMEOUT 3 '' AT 'OK-+++\c-OK'
37
 
    return
38
 
}
39
 
 
40
 
###################################################################
41
 
#
42
 
# Script to dial a telephone
43
 
#
44
 
function callnumber
45
 
{
46
 
chat -v                                                 \
47
 
        ABORT           '\nBUSY\r'                      \
48
 
        ABORT           '\nNO ANSWER\r'                 \
49
 
        ABORT           '\nRINGING\r\n\r\nRINGING\r'    \
50
 
        ''              ATDT$1                          \
51
 
        CONNECT         ''                              \
52
 
        ogin:--ogin:    $ACCOUNT                        \
53
 
        assword:        $PASSWORD
54
 
#
55
 
# If the connection was successful then end the whole script with a
56
 
# success.
57
 
#
58
 
    if [ "$?" = "0" ]; then
59
 
       exit 0
60
 
    fi
61
 
 
62
 
    return
63
 
}
64
 
 
65
 
###################################################################
66
 
#
67
 
# Script to dial any telephone number
68
 
#
69
 
function callall
70
 
{
71
 
#   echo "dialing attempt number: $1" >/dev/console
72
 
    callnumber $PHONE1
73
 
#    callnumber $PHONE2
74
 
}
75
 
 
76
 
###################################################################
77
 
#
78
 
# Initialize the modem to ensure that it is in the command state
79
 
#
80
 
initialize
81
 
if [ ! "$?" = "0" ]; then
82
 
   exit 1
83
 
fi
84
 
 
85
 
#
86
 
# Dial telephone numbers until one answers
87
 
#
 
2
#
 
3
# A chatscript that will attempt to dial multiple numbers in sequence, until
 
4
# you get connected.
 
5
#
 
6
# To use: edit /etc/peers/provider, and change the connect line to read:
 
7
# connect "/usr/local/bin/redialer"
 
8
#
 
9
# See below for configuration.
 
10
 
 
11
# This is a list of chatscripts to use to get connected, and (optional)
 
12
# telephone numbers to call for each of those chatscripts.
 
13
#
 
14
# Note that in the chatscripts, you may use #NUMBER#, this will be replaced
 
15
# with the number it is calling. You might want to use this to only have one
 
16
# chatscript that is used for all numbers, or you might need multiple
 
17
# chatscripts.
 
18
 
 
19
PHONE1=123456789
 
20
CHAT1=/etc/chatscripts/provider
 
21
 
 
22
PHONE2=912345678
 
23
CHAT2=/etc/chatscripts/provider
 
24
 
 
25
PHONE3=891234567
 
26
CHAT3=/etc/chatscripts/provider
 
27
 
 
28
PHONE4=789123456
 
29
CHAT4=/etc/chatscripts/provider
 
30
 
 
31
PHONE5=001234567
 
32
CHAT5=/etc/chatscripts/provider
 
33
 
 
34
# How long to sleep between retries:
 
35
#
 
36
# Note that this is a parameter to sleep so use "15s" for 15 seconds,
 
37
# "1m" for 1 minute, etc
 
38
SLEEP_DELAY=1s
 
39
 
 
40
# The code below does the dialing.
 
41
 
88
42
attempt=0
89
43
while : ; do
90
 
    attempt=`expr $attempt + 1`
91
 
    callall $attempt
92
 
    if [ "$attempt" = "$MAX_ATTEMPTS" ]; then
93
 
        exit 1
94
 
    fi  
95
 
    sleep "$SLEEP_DELAY"
 
44
        attempt=`expr $attempt + 1`
 
45
        NUMBER=`eval echo '$PHONE'$attempt`
 
46
        CHAT=`eval echo '$CHAT'$attempt`
 
47
        if [ ! "$CHAT" ]; then
 
48
                attempt=0
 
49
        else
 
50
                logger "Dialing attempt number: $attempt"
 
51
                sed s/#NUMBER#/$NUMBER/ $CHAT >/etc/chatscripts/tmpchat
 
52
                /usr/sbin/chat -v -f /etc/chatscripts/tmpchat
 
53
                rm -f /etc/chatscripts/tmpchat
 
54
                case $? in
 
55
                        0) logger Connection established ; exit 0;;
 
56
                        1) logger chat: exit 1, see manpage for details. ; exit 1;;
 
57
                        2) logger chat: exit 2, see manpage for details. ; exit 2;;
 
58
                        3) logger chat: exit 3, see manpage for details. ;;
 
59
                        4) logger Line busy. ;;
 
60
                        5) logger No Carrier. ;;
 
61
                        6) logger A call is coming. Exiting! ; exit 1;;
 
62
                        7) logger No dialtone. ;;
 
63
                        8) logger An error occured. Exiting! ; exit 1;;
 
64
                        *) logger chat: exit $?, see manpage for details. ;;
 
65
                esac
 
66
                logger "Waiting $SLEEP_DELAY seconds before next try."
 
67
                sleep $SLEEP_DELAY
 
68
        fi
96
69
done