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