1999-01-10 14:30:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# isdn telephone answering
|
|
|
|
# -------------------------
|
|
|
|
#
|
1999-08-28 00:37:10 +01:00
|
|
|
# $FreeBSD$
|
1999-01-10 14:30:53 +00:00
|
|
|
#
|
1999-05-20 11:14:57 +01:00
|
|
|
# last edit-date: [Thu May 20 11:45:04 1999]
|
1999-01-10 14:30:53 +00:00
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------------
|
1999-05-20 11:14:57 +01: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
|
|
|
VARDIR=/var/isdn
|
|
|
|
DEVICE=/dev/i4btel0
|
|
|
|
|
1999-09-13 16:44:20 +01:00
|
|
|
# sounds
|
|
|
|
MESSAGE=${LIBDIR}/msg.al
|
|
|
|
BEEP=${LIBDIR}/beep.al
|
1999-01-10 14:30:53 +00:00
|
|
|
|
|
|
|
# dd options
|
|
|
|
SKIP=25
|
|
|
|
|
|
|
|
# max message size
|
|
|
|
MAXMSIZ=100
|
|
|
|
|
|
|
|
# src and dst telephone numbers
|
|
|
|
src=
|
|
|
|
dst=
|
|
|
|
|
|
|
|
# current date
|
|
|
|
DATE=`date`
|
|
|
|
|
|
|
|
# check if directory exists
|
1999-09-13 16:44:20 +01:00
|
|
|
if [ ! -d "${VARDIR}" ]
|
1999-01-10 14:30:53 +00:00
|
|
|
then
|
1999-09-13 16:44:20 +01:00
|
|
|
mkdir ${VARDIR}
|
1999-01-10 14:30:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# get options
|
1999-09-13 16:44:20 +01:00
|
|
|
if ! set -- `/usr/bin/getopt D:d:s: $*`; then
|
1999-01-10 14:30:53 +00:00
|
|
|
echo "usage2: play -D device -d <dest-telno> -s <src-telno>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# process options
|
1999-09-13 16:44:20 +01:00
|
|
|
for i ; do
|
1999-01-10 14:30:53 +00:00
|
|
|
case $i in
|
1999-09-13 16:44:20 +01:00
|
|
|
-D)
|
|
|
|
DEVICE=$2; shift; shift;
|
|
|
|
;;
|
|
|
|
-d)
|
|
|
|
dst=$2; shift; shift;
|
|
|
|
;;
|
|
|
|
-s)
|
|
|
|
src=$2; shift; shift;
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
shift; break;
|
|
|
|
;;
|
1999-01-10 14:30:53 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# this is a __MUST__ in order to use the fullscreen inteface !!!
|
|
|
|
|
|
|
|
FILEDATE=`date \+%y%m%d%H%M%S`
|
|
|
|
|
|
|
|
# echo message to phone
|
1999-09-13 16:44:20 +01:00
|
|
|
if [ -r "${MESSAGE}" ]; then
|
|
|
|
/bin/dd of=${DEVICE} if=${MESSAGE} bs=2k >/dev/null 2>&1
|
1999-01-10 14:30:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# echo beep to phone
|
1999-09-13 16:44:20 +01:00
|
|
|
if [ -r "${BEEP}" ]; then
|
|
|
|
/bin/dd of=${DEVICE} if=${BEEP} bs=2k >/dev/null 2>&1
|
1999-01-10 14:30:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# start time
|
|
|
|
START=`date \+%s`
|
|
|
|
|
|
|
|
# get message from caller
|
1999-09-13 16:44:20 +01:00
|
|
|
/bin/dd if=${DEVICE} of=${VARDIR}/${FILEDATE}-${dst}-${src} skip=${SKIP} bs=2k count=${MAXMSIZ} >/dev/null 2>&1
|
1999-01-10 14:30:53 +00:00
|
|
|
|
|
|
|
# end time
|
|
|
|
END=`date \+%s`
|
|
|
|
|
|
|
|
# duration
|
1999-09-13 16:44:20 +01:00
|
|
|
TIME=`expr ${END} - ${START}`
|
1999-01-10 14:30:53 +00:00
|
|
|
|
|
|
|
# save recorded message
|
1999-09-13 16:44:20 +01:00
|
|
|
if [ -r "${VARDIR}/${FILEDATE}-${dst}-${src}" ]; then
|
|
|
|
mv ${VARDIR}/${FILEDATE}-${dst}-${src} ${VARDIR}/${FILEDATE}-${dst}-${src}-${TIME}
|
1999-01-10 14:30:53 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|