Initial import from FreeBSD RELENG_4:
[games.git] / etc / isdn / unknown_incoming
1 #!/bin/sh
2 #---------------------------------------------------------------------------
3 #
4 #       unknown_incoming - script for isdnd
5 #       -----------------------------------
6 #
7 # $FreeBSD: src/etc/isdn/unknown_incoming,v 1.1.2.1 2001/08/01 20:34:38 obrien Exp $
8 #
9 #       last edit-date: [Wed Jan 10 13:40:36 2001]
10 #
11 #       This script may be configured to be called by isdnd when an 
12 #       unknown incoming call is received. In case the destination 
13 #       telephone number is available, it sends mail with the time,
14 #       source and destination numbers to a configurable address.
15 #
16 #       For this to work, and entry like this:
17 #
18 #               regexpr = "<unknown> incoming call from"
19 #               regprog = unknown_incoming
20 #
21 #       is needed in the system section of /etc/isdn/isdnd.rc.
22 #
23 #       This script has to be configured to the sites needs, look
24 #       for the comment lines start with "configure:"
25 #
26 #---------------------------------------------------------------------------
27 #
28 # configure: who shall receive the mail
29 mailaddr=root
30 #
31 from=`echo $* | awk '{print $6}'`
32 to=`echo $* | awk '{print $8}'`
33 test=`echo $* | awk '{print $9}'`
34 ctrl=`echo $* | awk '{print $10}'`
35 date=`date "+%b %d"`
36 time=`date "+%H:%M"`
37 mach=`hostname`
38
39 # configure: list of destination numbers to ignore
40 case "$from" in
41         "NotAvailable"  )       exit 0 ;;
42         "00401234567"* )        exit 0 ;;
43         "00407654321"   )       exit 0 ;;
44 esac
45
46 # configure: how to name the line on which this was received
47 if [ $test = "ctrl" ]
48 then
49         case "$ctrl" in
50                 "1")
51                         line="PBX 1"
52                         ;;
53                 "2")
54                         line="PBX 2"
55                         ;;
56                 *)
57                         line="controller is $ctrl"
58                         ;;
59         esac
60 else
61         line="test is $test, controller is $ctrl"
62 fi
63
64 cat << ENDOFDATA | mail -s "isdnd: unknown incoming telephone call" $mailaddr
65
66 Unknown incoming telephone call recognized:
67
68              Date: $date
69              Time: $time
70              Line: $line
71              From: $from
72                To: $to
73
74              Sincerly yours,
75                    the isdnd on $mach
76
77 ENDOFDATA
78  
79 exit 0