3
# /usr/bin/gsmsmsrequeue: Re-queues failed SMS
5
# written by Matthias Goebl <matthias@goebl.net>
7
SPOOLDIR=/var/spool/sms
10
SUBJECT="SMS delivery report:"
12
function send_notify {
13
tmpfile="$SPOOLDIR/tmp/"`basename "$1"`
15
if mv "$1" "$tmpfile" 2>/dev/null; then
16
# extract the first tab-separated field after the phone number as
17
# email-address to send the notification to
18
mailto=` cat "$tmpfile" | sed -ne '1s/^[^ ]* \([^ ]*\).*/\1/p' `
19
test -z "$mailto" && mailto="$SMSADMIN"
20
cat "$tmpfile" | mail -s "$SUBJECT $status" "$mailto"
24
function do_accounting { true; }
26
test -r /etc/default/gsm-utils && . /etc/default/gsm-utils
28
for p in `seq 1 $PRIORITIES`; do
29
ls "$SPOOLDIR/failed$p" | while read file; do
30
if expr "$file" : ".*rrrrrrrrrrrr" >/dev/null; then
31
send_notify "$SPOOLDIR/failed$p/$file" "failed"
34
mv "$SPOOLDIR/failed$p/$file" "$SPOOLDIR/queue$p/${file}r" 2>/dev/null
39
for p in `seq 1 $PRIORITIES`; do
40
ls "$SPOOLDIR/sent$p" | while read file; do
41
do_accounting "$SPOOLDIR/sent$p/$file" "sent"
42
send_notify "$SPOOLDIR/sent$p/$file" "sent"