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