2022-05-14 02:43:48 +08:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2022-05-14 02:43:52 +08:00
|
|
|
# A chatscript that will attempt to dial multiple numbers in sequence, until
|
|
|
|
# you get connected.
|
2022-05-14 02:43:48 +08:00
|
|
|
#
|
2022-05-14 02:43:52 +08:00
|
|
|
# To use: edit /etc/peers/provider, and change the connect line to read:
|
|
|
|
# connect "/usr/local/bin/redialer"
|
2022-05-14 02:43:48 +08:00
|
|
|
#
|
2022-05-14 02:43:52 +08:00
|
|
|
# See below for configuration.
|
2022-05-14 02:43:48 +08:00
|
|
|
|
2022-05-14 02:43:52 +08:00
|
|
|
# This is a list of chatscripts to use to get connected, and (optional)
|
|
|
|
# telephone numbers to call for each of those chatscripts.
|
2022-05-14 02:43:48 +08:00
|
|
|
#
|
2022-05-14 02:43:52 +08:00
|
|
|
# Note that in the chatscripts, you may use #NUMBER#, this will be replaced
|
|
|
|
# with the number it is calling. You might want to use this to only have one
|
|
|
|
# chatscript that is used for all numbers, or you might need multiple
|
|
|
|
# chatscripts.
|
2022-05-14 02:43:48 +08:00
|
|
|
|
2022-05-14 02:43:52 +08:00
|
|
|
PHONE1=123456789
|
|
|
|
CHAT1=/etc/chatscripts/provider
|
2022-05-14 02:43:48 +08:00
|
|
|
|
2022-05-14 02:43:52 +08:00
|
|
|
PHONE2=912345678
|
|
|
|
CHAT2=/etc/chatscripts/provider
|
2022-05-14 02:43:48 +08:00
|
|
|
|
2022-05-14 02:43:52 +08:00
|
|
|
PHONE3=891234567
|
|
|
|
CHAT3=/etc/chatscripts/provider
|
2022-05-14 02:43:48 +08:00
|
|
|
|
2022-05-14 02:43:52 +08:00
|
|
|
PHONE4=789123456
|
|
|
|
CHAT4=/etc/chatscripts/provider
|
2022-05-14 02:43:48 +08:00
|
|
|
|
2022-05-14 02:43:52 +08:00
|
|
|
PHONE5=001234567
|
|
|
|
CHAT5=/etc/chatscripts/provider
|
2022-05-14 02:43:48 +08:00
|
|
|
|
2022-05-14 02:43:52 +08:00
|
|
|
# How long to sleep between retries:
|
2022-05-14 02:43:48 +08:00
|
|
|
#
|
2022-05-14 02:43:52 +08:00
|
|
|
# Note that this is a parameter to sleep so use "15s" for 15 seconds,
|
|
|
|
# "1m" for 1 minute, etc
|
|
|
|
SLEEP_DELAY=1s
|
|
|
|
|
|
|
|
# The code below does the dialing.
|
|
|
|
|
2022-05-14 02:43:48 +08:00
|
|
|
attempt=0
|
|
|
|
while : ; do
|
2022-05-14 02:43:52 +08:00
|
|
|
attempt=`expr $attempt + 1`
|
|
|
|
NUMBER=`eval echo '$PHONE'$attempt`
|
|
|
|
CHAT=`eval echo '$CHAT'$attempt`
|
|
|
|
if [ ! "$CHAT" ]; then
|
|
|
|
attempt=0
|
|
|
|
else
|
|
|
|
logger "Dialing attempt number: $attempt"
|
|
|
|
sed s/#NUMBER#/$NUMBER/ $CHAT >/etc/chatscripts/tmpchat
|
|
|
|
/usr/sbin/chat -v -f /etc/chatscripts/tmpchat
|
|
|
|
rm -f /etc/chatscripts/tmpchat
|
|
|
|
case $? in
|
|
|
|
0) logger Connection established ; exit 0;;
|
|
|
|
1) logger chat: exit 1, see manpage for details. ; exit 1;;
|
|
|
|
2) logger chat: exit 2, see manpage for details. ; exit 2;;
|
|
|
|
3) logger chat: exit 3, see manpage for details. ;;
|
|
|
|
4) logger Line busy. ;;
|
|
|
|
5) logger No Carrier. ;;
|
|
|
|
6) logger A call is coming. Exiting! ; exit 1;;
|
|
|
|
7) logger No dialtone. ;;
|
|
|
|
8) logger An error occured. Exiting! ; exit 1;;
|
|
|
|
*) logger chat: exit $?, see manpage for details. ;;
|
|
|
|
esac
|
|
|
|
logger "Waiting $SLEEP_DELAY seconds before next try."
|
|
|
|
sleep $SLEEP_DELAY
|
|
|
|
fi
|
2022-05-14 02:43:48 +08:00
|
|
|
done
|