freebsd-nq/etc/isdn/unknown_incoming
2004-06-06 11:46:29 +00:00

80 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
#---------------------------------------------------------------------------
#
# unknown_incoming - script for isdnd
# -----------------------------------
#
# $FreeBSD$
#
# last edit-date: [Wed Jan 10 13:40:36 2001]
#
# This script may be configured to be called by isdnd when an
# unknown incoming call is received. In case the destination
# telephone number is available, it sends mail with the time,
# source and destination numbers to a configurable address.
#
# For this to work, and entry like this:
#
# regexpr = "<unknown> incoming call from"
# regprog = unknown_incoming
#
# is needed in the system section of /etc/isdn/isdnd.rc.
#
# This script has to be configured to the sites needs, look
# for the comment lines start with "configure:"
#
#---------------------------------------------------------------------------
#
# configure: who shall receive the mail
mailaddr=root
#
from=`echo $* | awk '{print $6}'`
to=`echo $* | awk '{print $8}'`
test=`echo $* | awk '{print $9}'`
ctrl=`echo $* | awk '{print $10}'`
date=`date "+%b %d"`
time=`date "+%H:%M"`
mach=`hostname`
# configure: list of destination numbers to ignore
case "$from" in
"NotAvailable" ) exit 0 ;;
"00401234567"* ) exit 0 ;;
"00407654321" ) exit 0 ;;
esac
# configure: how to name the line on which this was received
if [ $test = "ctrl" ]
then
case "$ctrl" in
"1")
line="PBX 1"
;;
"2")
line="PBX 2"
;;
*)
line="controller is $ctrl"
;;
esac
else
line="test is $test, controller is $ctrl"
fi
cat << ENDOFDATA | mail -s "isdnd: unknown incoming telephone call" $mailaddr
Unknown incoming telephone call recognized:
Date: $date
Time: $time
Line: $line
From: $from
To: $to
Sincerly yours,
the isdnd on $mach
ENDOFDATA
exit 0