initial commit of file from CVS for e-smith-base on Thu 26 Oct 11:24:52 BST 2023
This commit is contained in:
83
root/etc/diald/scripts/isdn
Executable file
83
root/etc/diald/scripts/isdn
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
#exec > /tmp/isdn.log 2>&1
|
||||
#set -x
|
||||
|
||||
|
||||
end_dial() {
|
||||
for n in $PHONE
|
||||
do
|
||||
/usr/sbin/isdnctrl delphone "$DIALD_DEVICE" out "$n"
|
||||
done
|
||||
/usr/sbin/isdnctrl eaz "$DIALD_DEVICE" "$EAZ_IN"
|
||||
if [ $status -ne 0 ]; then
|
||||
# You should have specified "lock" in diald's config
|
||||
# otherwise if we try and dial out on a device that
|
||||
# is already connected we will hang it up.
|
||||
/usr/sbin/isdnctrl hangup "$DIALD_DEVICE"
|
||||
fi
|
||||
exit $status
|
||||
}
|
||||
|
||||
trap 'end_dial' 0
|
||||
|
||||
for n in $PHONE
|
||||
do
|
||||
/usr/sbin/isdnctrl addphone "$DIALD_DEVICE" out "$n"
|
||||
done
|
||||
/usr/sbin/isdnctrl eaz "$DIALD_DEVICE" "$EAZ_OUT"
|
||||
|
||||
/usr/sbin/isdnctrl dial "$DIALD_DEVICE"
|
||||
status=$?
|
||||
|
||||
if [ $status -eq 0 ]; then
|
||||
status=1
|
||||
while true
|
||||
do
|
||||
msg=`/sbin/ifconfig "$DIALD_DEVICE" 2>&1`
|
||||
if echo "$msg" | grep 'P-t-P:0.0.0.0' > /dev/null 2>&1
|
||||
then
|
||||
# no link yet...
|
||||
WAITTIME=`expr $WAITTIME - 1`
|
||||
if [ $WAITTIME -ge 0 ]; then
|
||||
# still waiting...
|
||||
sleep 1
|
||||
else
|
||||
echo "Timed out" 1>&2
|
||||
break
|
||||
fi
|
||||
elif echo "$msg" | grep 'P-t-P:\[NONE SET\]' > /dev/null 2>&1
|
||||
then
|
||||
# no link yet...
|
||||
WAITTIME=`expr $WAITTIME - 1`
|
||||
if [ $WAITTIME -ge 0 ]; then
|
||||
# still waiting...
|
||||
sleep 1
|
||||
else
|
||||
echo "Timed out" 1>&2
|
||||
break
|
||||
fi
|
||||
elif [ -n "$REMOTEIP" ]; then
|
||||
if echo "$msg" | grep "P-t-P:$REMOTEIP" > /dev/null 2>&1
|
||||
then
|
||||
echo "Interface up: remote host ok" 1>&2
|
||||
status=0
|
||||
break
|
||||
fi
|
||||
elif [ -z "$REMOTEIP" ]; then
|
||||
# The remote has a dynamic IP so we have no way
|
||||
# of knowing whether the dial succeeded or some
|
||||
# incoming connection was accepted. (If diald
|
||||
# is not using device locking we may even have
|
||||
# dialled somewhere else!)
|
||||
echo "Interface up: host indeterminate" 1>&2
|
||||
status=0
|
||||
break
|
||||
else
|
||||
# Dial failed and something else is using this link.
|
||||
echo "Interface up: wrong host - not my link" 1>&2
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
exit $status
|
Reference in New Issue
Block a user