initial commit of file from CVS for e-smith-base on Thu 26 Oct 11:24:52 BST 2023
This commit is contained in:
14
root/etc/diald/device.conf
Normal file
14
root/etc/diald/device.conf
Normal file
@@ -0,0 +1,14 @@
|
||||
# This file is used by /usr/share/diald/connect to determine how
|
||||
# to establish a connection using the given device.
|
||||
#
|
||||
# First match is used. List specific device names before generic types.
|
||||
#
|
||||
# Device type Dial method
|
||||
# ----------- -----------
|
||||
/dev/ttyS0 modem/generic
|
||||
/dev/ttyS1 modem/generic
|
||||
/dev/ttyS2 modem/generic
|
||||
/dev/ttyS3 modem/generic
|
||||
modem modem/generic
|
||||
ippp isdn
|
||||
isdn isdn
|
130
root/etc/diald/scripts/connect
Executable file
130
root/etc/diald/scripts/connect
Executable file
@@ -0,0 +1,130 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $DIALD_LINK is the name of the link we are connecting.
|
||||
# $DIALD_DEVICE is the device we are calling out on.
|
||||
|
||||
#CFG_SCRIPTS='/usr/share/diald'
|
||||
CFG_SCRIPTS='/etc/diald/scripts'
|
||||
CFG_DEVICE='/etc/diald/device.conf'
|
||||
CFG_LINK="/etc/diald/link"
|
||||
CFG_SEQ='/var/run'
|
||||
|
||||
# $DIALD_DEVTYPE is a sanitized version of $DIALD_DEVICE.
|
||||
case "$DIALD_DEVICE" in
|
||||
ippp*) DIALD_DEVTYPE='isdn' ;;
|
||||
isdn*) DIALD_DEVTYPE='isdn' ;;
|
||||
*) DIALD_DEVTYPE='modem' ;;
|
||||
esac
|
||||
|
||||
|
||||
connect()
|
||||
{
|
||||
status=0
|
||||
|
||||
# If this device has a dial script we use it to bring up
|
||||
# the physical link.
|
||||
if [ -n "$dial_script" -a "$dial_script" != '-' ]; then
|
||||
"$CFG_SCRIPTS/$dial_script"
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
exit $status
|
||||
fi
|
||||
fi
|
||||
|
||||
# If we need to do some form of login when connecting this
|
||||
# link over this device, do it now.
|
||||
if [ -n "$LOGIN" -a "$LOGIN" != '-' ]; then
|
||||
"$CFG_SCRIPTS/login/$LOGIN"
|
||||
status=$?
|
||||
fi
|
||||
|
||||
# If everything worked we start from the beginning of the
|
||||
# list again next time
|
||||
if [ $status -eq 0 ]; then
|
||||
echo 1 > "$CFG_SEQ/dialdseq.$DIALD_LINK"
|
||||
fi
|
||||
|
||||
exit $status
|
||||
}
|
||||
|
||||
|
||||
# Save stdin, we need it later if we are dialling a modem.
|
||||
exec 9<&0
|
||||
|
||||
# Find out what dial script to use on this device.
|
||||
exec < "$CFG_DEVICE"
|
||||
gotdev=
|
||||
while read dev dial_script dial_args
|
||||
do
|
||||
# Ignore blank lines and comments.
|
||||
case "$dev" in
|
||||
'#'*|'')
|
||||
continue ;;
|
||||
esac
|
||||
|
||||
if [ "$dev" = "$DIALD_DEVICE" -o "$dev" = "$DIALD_DEVTYPE" ]; then
|
||||
gotdev=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$gotdev" ]; then
|
||||
echo "<3>No entry for $DIALD_DEVICE, type $DIALD_DEVTYPE in $CFG_DEVICE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
seq=0
|
||||
if [ -r "$CFG_SEQ/dialdseq.$DIALD_LINK" ]; then
|
||||
seq=`cat "$CFG_SEQ/dialdseq.$DIALD_LINK"`
|
||||
fi
|
||||
seq=`expr $seq + 1`
|
||||
echo $seq > "$CFG_SEQ/dialdseq.$DIALD_LINK"
|
||||
|
||||
|
||||
passes=2
|
||||
while [ $passes -gt 0 ]; do
|
||||
passes=`expr $passes - 1`
|
||||
|
||||
exec < "$CFG_LINK"
|
||||
dev_type=
|
||||
link_params=
|
||||
base_params=
|
||||
counted=0
|
||||
while read dev_type link_params
|
||||
do
|
||||
# Ignore blank lines and comments.
|
||||
case "$dev_type" in
|
||||
'#'*|'')
|
||||
continue ;;
|
||||
esac
|
||||
|
||||
if [ "$dev_type" = '=' ]; then
|
||||
base_params="$link_params"
|
||||
elif [ "$dev_type" = '+' ]; then
|
||||
base_params="$base_params $link_params"
|
||||
elif [ "$dev_type" = "$DIALD_DEVICE" \
|
||||
-o "$dev_type" = "$DIALD_DEVTYPE" ]; then
|
||||
counted=`expr $counted + 1`
|
||||
seq=`expr $seq - 1`
|
||||
if [ $seq -eq 0 ]; then
|
||||
passes=0
|
||||
exec 0<&9
|
||||
eval "$dial_args $base_params $link_params connect"
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# If no entries match there is a problem
|
||||
if [ $counted -eq 0 ]; then
|
||||
echo "<3>No entry for $DIALD_DEVICE, type $DIALD_DEVTYPE in $CFG_LINK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# One or more entries exists, we have just run off the end
|
||||
# of the list so we have to start again from the top.
|
||||
echo 1 > "$CFG_SEQ/dialdseq.$DIALD_LINK"
|
||||
seq=1
|
||||
done
|
||||
|
||||
exit 1
|
106
root/etc/diald/scripts/disconnect
Executable file
106
root/etc/diald/scripts/disconnect
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $DIALD_LINK is the name of the link we are disconnecting.
|
||||
# $DIALD_DEVICE is the device we are called out on.
|
||||
|
||||
#CFG_SCRIPTS='/usr/share/diald'
|
||||
CFG_SCRIPTS='/etc/diald/scripts'
|
||||
CFG_DEVICE='/etc/diald/device.conf'
|
||||
CFG_LINK="/etc/diald/link"
|
||||
CFG_SEQ='/var/run'
|
||||
|
||||
# $DIALD_DEVTYPE is a sanitized version of $DIALD_DEVICE.
|
||||
case "$DIALD_DEVICE" in
|
||||
ippp*) DIALD_DEVTYPE='isdn' ;;
|
||||
isdn*) DIALD_DEVTYPE='isdn' ;;
|
||||
*) DIALD_DEVTYPE='modem' ;;
|
||||
esac
|
||||
|
||||
|
||||
disconnect()
|
||||
{
|
||||
status=0
|
||||
|
||||
# If this device has a hangup script we use it to hang up
|
||||
# the physical link.
|
||||
if [ -n "$dial_script" -a "$dial_script" != '-' \
|
||||
-a -x "$CFG_SCRIPTS/$dial_script.hangup" ]; then
|
||||
"$CFG_SCRIPTS/$dial_script.hangup"
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
exit $status
|
||||
fi
|
||||
fi
|
||||
|
||||
exit $status
|
||||
}
|
||||
|
||||
|
||||
# Save stdin, we need it later if we are dialling a modem.
|
||||
exec 9<&0
|
||||
|
||||
# Find out what dial script to use on this device.
|
||||
exec < "$CFG_DEVICE"
|
||||
gotdev=
|
||||
while read dev dial_script dial_args
|
||||
do
|
||||
# Ignore blank lines and comments.
|
||||
case "$dev" in
|
||||
'#'*|'')
|
||||
continue ;;
|
||||
esac
|
||||
|
||||
if [ "$dev" = "$DIALD_DEVICE" -o "$dev" = "$DIALD_DEVTYPE" ]; then
|
||||
gotdev=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$gotdev" ]; then
|
||||
echo "<3>No entry for $DIALD_DEVICE, type $DIALD_DEVTYPE in $CFG_DEVICE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
seq=1
|
||||
if [ -r "$CFG_SEQ/dialdseq.$DIALD_LINK" ]; then
|
||||
seq=`cat "$CFG_SEQ/dialdseq.$DIALD_LINK"`
|
||||
fi
|
||||
|
||||
|
||||
exec < "$CFG_LINK"
|
||||
dev_type=
|
||||
link_params=
|
||||
base_params=
|
||||
counted=0
|
||||
while read dev_type link_params
|
||||
do
|
||||
# Ignore blank lines and comments.
|
||||
case "$dev_type" in
|
||||
'#'*|'')
|
||||
continue ;;
|
||||
esac
|
||||
|
||||
if [ "$dev_type" = '=' ]; then
|
||||
base_params="$link_params"
|
||||
elif [ "$dev_type" = '+' ]; then
|
||||
base_params="$base_params $link_params"
|
||||
elif [ "$dev_type" = "$DIALD_DEVICE" \
|
||||
-o "$dev_type" = "$DIALD_DEVTYPE" ]; then
|
||||
seq=`expr $seq - 1`
|
||||
counted=`expr $counted + 1`
|
||||
if [ $seq -eq 0 ]; then
|
||||
exec 0<&9
|
||||
eval "$dial_args $base_params $link_params disconnect"
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# If no entries match there is a problem
|
||||
if [ $counted -eq 0 ]; then
|
||||
echo "<3>No entry for $DIALD_DEVICE, type $DIALD_DEVTYPE in $CFG_LINK"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "<3>Did not find entry matching sequence number $seq for $DIALD_DEVICE, type $DIALD_DEVTYPE in $CFG_LINK"
|
||||
exit 1
|
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
|
37
root/etc/diald/scripts/isdn.hangup
Executable file
37
root/etc/diald/scripts/isdn.hangup
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
/usr/sbin/isdnctrl eaz "$DIALD_DEVICE" "$EAZ_IN"
|
||||
/usr/sbin/isdnctrl hangup "$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:' > /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 - link still up" 1>&2
|
||||
break
|
||||
fi
|
||||
else
|
||||
echo "Link is down" 1>&2
|
||||
status=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Error return $status from isdnctrl hangup command" 2>&1
|
||||
fi
|
||||
|
||||
# Set fake IPs for ippp0 device, to help diald
|
||||
/sbin/ifconfig "$DIALD_DEVICE" \
|
||||
$(/sbin/e-smith/db configuration get LocalIP) pointopoint 0.0.0.0 \
|
||||
|| echo "Error ($?) while forcing ippp0 device down" 2>&1
|
||||
exit $status
|
Reference in New Issue
Block a user