1999-01-10 14:30:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# tell called and calling numbers answer script for i4b isdnd
|
|
|
|
# -----------------------------------------------------------
|
|
|
|
#
|
1999-08-27 23:37:10 +00:00
|
|
|
# $FreeBSD$
|
1999-01-10 14:30:53 +00:00
|
|
|
#
|
1999-05-20 10:14:57 +00:00
|
|
|
# last edit-date: [Thu May 20 11:45:15 1999]
|
1999-01-10 14:30:53 +00:00
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
VARDIR=/var/isdn
|
1999-05-20 10:14:57 +00:00
|
|
|
|
|
|
|
#FreeBSD < 3.1, NetBSD, OpenBSD, BSD/OS
|
|
|
|
#LIBDIR=/usr/local/lib/isdn
|
|
|
|
#FreeBSD 3.1 and up
|
|
|
|
LIBDIR=/usr/share/isdn
|
|
|
|
|
1999-01-10 14:30:53 +00:00
|
|
|
LOGFILE=/tmp/answer.log
|
1999-09-13 15:44:20 +00:00
|
|
|
NCALLFILE=${VARDIR}/ncall
|
1999-01-10 14:30:53 +00:00
|
|
|
DATE=`date +%d%H`
|
|
|
|
DF=0
|
|
|
|
dF=0
|
|
|
|
sF=0
|
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
if ! set -- `getopt D:d:s: $*`; then
|
1999-01-10 14:30:53 +00:00
|
|
|
echo 'Usage: answer -D device -d destination -s source'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
for i ; do
|
|
|
|
case ${i} in
|
|
|
|
-D)
|
|
|
|
DEVICE=$2
|
|
|
|
DF=1
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-d)
|
|
|
|
DEST=$2
|
|
|
|
dF=1
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-s)
|
|
|
|
SRC=$2
|
|
|
|
sF=1
|
|
|
|
shift
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
1999-01-10 14:30:53 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
echo "" >>${LOGFILE}
|
1999-01-10 14:30:53 +00:00
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
if [ "${DF}" -eq 0 -o "${dF}" -eq 0 -o "${sF}" -eq 0 ]; then
|
1999-01-10 14:30:53 +00:00
|
|
|
echo 'Usage: answer -D device -d destination -s source'
|
|
|
|
exit 1
|
1999-09-13 15:44:20 +00:00
|
|
|
fi
|
1999-01-10 14:30:53 +00:00
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
echo "answer: device ${DEVICE} destination ${DEST} source ${SRC} " >>${LOGFILE}
|
1999-01-10 14:30:53 +00:00
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
if [ -r "${LIBDIR}/beep.al" ]; then
|
|
|
|
dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k >/dev/null 2>&1
|
1999-01-10 14:30:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# tell the caller the number he is calling from
|
|
|
|
|
|
|
|
POS=1
|
1999-09-13 15:44:20 +00:00
|
|
|
LENGTH=`expr ${SRC} : '.*'`
|
1999-01-10 14:30:53 +00:00
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
while : ; do
|
|
|
|
DIGIT=`echo ${SRC} | cut -c ${POS}`
|
|
|
|
/bin/dd of=${DEVICE} if=${LIBDIR}/${DIGIT}.al bs=2k >/dev/null 2>&1
|
|
|
|
POS=`expr ${POS} + 1`
|
|
|
|
if [ "${POS}" -gt "${LENGTH}" ]; then
|
1999-01-10 14:30:53 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
if [ -r "${LIBDIR}/beep.al" ]; then
|
|
|
|
dd of=${DEVICE} if=${LIBDIR}/beep.al bs=2k >/dev/null 2>&1
|
1999-01-10 14:30:53 +00:00
|
|
|
fi
|