]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/isdn/tell
$Id$ -> $FreeBSD$
[FreeBSD/FreeBSD.git] / etc / isdn / tell
1 #!/bin/sh
2 #---------------------------------------------------------------------------
3 #
4 #       tell called and calling numbers answer script for i4b isdnd
5 #       -----------------------------------------------------------
6 #
7 # $FreeBSD$
8 #
9 #       last edit-date: [Thu May 20 11:45:15 1999]
10 #
11 #---------------------------------------------------------------------------
12 VARDIR=/var/isdn
13
14 #FreeBSD < 3.1, NetBSD, OpenBSD, BSD/OS
15 #LIBDIR=/usr/local/lib/isdn
16 #FreeBSD 3.1 and up
17 LIBDIR=/usr/share/isdn
18
19 LOGFILE=/tmp/answer.log
20 NCALLFILE=$VARDIR/ncall
21 DATE=`date +%d%H`
22 DF=0
23 dF=0
24 sF=0
25
26 set -- `getopt D:d:s: $*`
27
28 if test $? != 0
29 then
30         echo 'Usage: answer -D device -d destination -s source'
31         exit 1
32 fi
33
34 for i
35 do
36         case "$i"
37         in
38                 -D)
39                         DEVICE=$2
40                         DF=1
41                         shift
42                         shift
43                         ;;
44                 -d)
45                         DEST=$2
46                         dF=1
47                         shift
48                         shift
49                         ;;
50                 -s)
51                         SRC=$2
52                         sF=1
53                         shift
54                         shift
55                         ;;
56                 --)
57                         shift
58                         break
59                         ;;
60         esac
61 done
62
63 echo "" >>$LOGFILE
64
65 if [ $DF -eq 0 -o $dF -eq 0 -o $sF -eq 0 ]
66 then
67         echo 'Usage: answer -D device -d destination -s source'
68         exit 1
69 fi      
70
71 echo "answer: device $DEVICE destination $DEST source $SRC " >>$LOGFILE
72
73 if [ -f $LIBDIR/beep.al ]
74 then
75         dd of=$DEVICE if=$LIBDIR/beep.al bs=2k >/dev/null 2>&1
76 fi
77
78 # tell the caller the number he is calling from
79
80 POS=1
81 LENGTH=`expr $SRC : '.*'`
82
83 while :
84 do
85         DIGIT=`echo $SRC | cut -c $POS`
86         /bin/dd of=$DEVICE if=$LIBDIR/$DIGIT.al bs=2k >/dev/null 2>&1
87         POS=`expr $POS + 1`
88         if [ $POS -gt $LENGTH ]
89         then
90                 break
91         fi
92 done
93
94 if [ -f $LIBDIR/beep.al ]
95 then
96         dd of=$DEVICE if=$LIBDIR/beep.al bs=2k >/dev/null 2>&1
97 fi