Eventhandler can be used to create any functionality required. In the scripts directory of a package there are some samples.
Here is one more sample: in the global part of smsd.conf, define:
eventhandler = /usr/local/bin/smsd_eventhandler.shCreate this script file with suitable content, for example:
#!/bin/bash
if [ "$1" = "RECEIVED" ]; then
FROM=`formail -zx From: < $2`
TEXT=`sed -e '1,/^$/ d' < $2`
# List must start and end with space:
ALLOWED_NUMBERS=" 358401234567 358401234568 "
key=" $FROM "
if [[ $ALLOWED_NUMBERS == *$key* ]]; then
# Replace linefeeds with space:
TEXT=`echo "$TEXT" | tr "\n" " " | tr "\r" " "`
# Make an array of words:
words=($TEXT)
# First word is the key, make it uppercase:
key=${words[0]}
key=`echo $key | tr a-z A-Z`
if [ "x$key" = "xIGNORE" ]; then
key=${words[1]}
CONTROLFILE="/etc/postfix/control_sms_ignore_from"
if [ "x$key" = "x?" ]; then
FILE=`mktemp /tmp/send_XXXXXX`
echo "To: $FROM" >> $FILE
echo "" >> $FILE
echo "Ignore: " >> $FILE
cat "$CONTROLFILE" >> $FILE
FILE2=`mktemp /var/spool/sms/outgoing/send_XXXXXX`
mv $FILE $FILE2
else
if [ "x$key" != "x" ]; then
FILE=`mktemp /tmp/eventhandler_XXXXXX`
cp "$CONTROLFILE" $FILE
echo "$key" >> $FILE
chmod 644 $FILE
mv $FILE "$CONTROLFILE"
fi
fi
fi
fi
fi
exit 0
'bash' Syntax Highlight powered by GeSHi Make the script executable and restart smsd.
This sample script is used to add ignored sender addresses to the file which is used to determine is SMS notification is sent when a new e-mail is received. With SMS "ignore @somedomain.com" this domain is added to the list and with SMS "ignore ?" current list is sent back. There is also authorization by number used to control who can use this feature.