Debian Codegraph @

contrib/gsmsmsrequeue

raw symbols SCIP
1 #! /bin/bash
2 #
3 # /usr/bin/gsmsmsrequeue: Re-queues failed SMS
4 #
5 # written by Matthias Goebl <[email protected]>
6
7 SPOOLDIR=/var/spool/sms
8 PRIORITIES=3
9 SMSADMIN=root
10 SUBJECT="SMS delivery report:"
11
12 send_notify()
13 {
14 tmpfile="$SPOOLDIR/tmp/"`basename "$1"`
15 status="$2"
16 if mv "$1" "$tmpfile" 2>/dev/null; then
17 # extract the first tab-separated field after the phone number as
18 # email-address to send the notification to
19 mailto=` cat "$tmpfile" | sed -ne '1s/^[^ ]* \([^ ]*\).*/\1/p' `
20 test -z "$mailto" && mailto="$SMSADMIN"
21 cat "$tmpfile" | mail -s "$SUBJECT $status" "$mailto"
22 rm "$tmpfile"
23 fi
24 }
25 do_accounting()
26 {
27 true;
28 }
29
30 test -r /etc/default/gsm-utils && . /etc/default/gsm-utils
31
32 for p in `seq 1 $PRIORITIES`; do
33 ls "$SPOOLDIR/failed$p" | while read file; do
34 if expr "$file" : ".*rrrrrrrrrrrr" >/dev/null; then
35 send_notify "$SPOOLDIR/failed$p/$file" "failed"
36 else
37 # re-queue SMS
38 mv "$SPOOLDIR/failed$p/$file" "$SPOOLDIR/queue$p/${file}r" 2>/dev/null
39 fi
40 done
41 done
42
43 for p in `seq 1 $PRIORITIES`; do
44 ls "$SPOOLDIR/sent$p" | while read file; do
45 do_accounting "$SPOOLDIR/sent$p/$file" "sent"
46 send_notify "$SPOOLDIR/sent$p/$file" "sent"
47 done
48 done