Initial import from FreeBSD RELENG_4:
[dragonfly.git] / etc / isdn / isdntel.sh
1 #!/bin/sh
2 #---------------------------------------------------------------------------
3 #
4 #       isdn telephone answering
5 #       -------------------------
6 #
7 # $FreeBSD: src/etc/isdn/isdntel.sh,v 1.4 1999/09/13 15:44:20 sheldonh Exp $
8 #
9 #       last edit-date: [Thu May 20 11:45:04 1999]
10 #
11 #---------------------------------------------------------------------------
12 #FreeBSD < 3.1, NetBSD, OpenBSD, BSD/OS
13 #LIBDIR=/usr/local/lib/isdn
14 #FreeBSD 3.1 and up
15 LIBDIR=/usr/share/isdn
16
17 VARDIR=/var/isdn
18 DEVICE=/dev/i4btel0
19
20 # sounds
21 MESSAGE=${LIBDIR}/msg.al
22 BEEP=${LIBDIR}/beep.al
23
24 # dd options
25 SKIP=25
26
27 # max message size
28 MAXMSIZ=100
29
30 # src and dst telephone numbers
31 src=
32 dst=
33
34 # current date
35 DATE=`date`
36
37 # check if directory exists
38 if [ ! -d "${VARDIR}" ]
39 then
40         mkdir ${VARDIR}
41 fi
42
43 # get options
44 if ! set -- `/usr/bin/getopt D:d:s: $*`; then
45         echo "usage2: play -D device -d <dest-telno> -s <src-telno>"
46         exit 1
47 fi
48
49 # process options
50 for i ; do
51         case $i in
52         -D)
53                 DEVICE=$2; shift; shift;
54                 ;;
55         -d)
56                 dst=$2; shift; shift;
57                 ;;
58         -s)
59                 src=$2; shift; shift;
60                 ;;
61         --)
62                 shift; break;
63                 ;;
64         esac
65 done
66
67 # this is a __MUST__ in order to use the fullscreen inteface !!!
68
69 FILEDATE=`date \+%y%m%d%H%M%S`
70
71 # echo message to phone
72 if [ -r "${MESSAGE}" ]; then
73         /bin/dd of=${DEVICE} if=${MESSAGE} bs=2k >/dev/null 2>&1
74 fi
75
76 # echo beep to phone
77 if [ -r "${BEEP}" ]; then
78         /bin/dd of=${DEVICE} if=${BEEP} bs=2k >/dev/null 2>&1
79 fi
80
81 # start time
82 START=`date \+%s`
83
84 # get message from caller
85 /bin/dd if=${DEVICE} of=${VARDIR}/${FILEDATE}-${dst}-${src} skip=${SKIP} bs=2k count=${MAXMSIZ} >/dev/null 2>&1
86
87 # end time
88 END=`date \+%s`
89
90 # duration
91 TIME=`expr ${END} - ${START}`
92
93 # save recorded message
94 if [ -r "${VARDIR}/${FILEDATE}-${dst}-${src}" ]; then
95         mv ${VARDIR}/${FILEDATE}-${dst}-${src} ${VARDIR}/${FILEDATE}-${dst}-${src}-${TIME}
96 fi
97
98 exit 0