| 1 | #! /bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # |
| 3 | # /usr/bin/gsmsmsspool: Queues SMS for sending |
| 4 | # |
| 5 | # written by Matthias Goebl <[email protected]> |
| 6 | |
| 7 | SPOOLDIR=/var/spool/smsscip-shell filesystem . . `/var/spool/sms`. |
| 8 | PRIORITIES=3 |
| 9 | testscip-shell system . . test. -r /etc/default/gsm-utilsscip-shell filesystem . . `/etc/default/gsm-utils`. && . /etc/default/gsm-utilsscip-shell source . . `/etc/default/gsm-utils`. |
| 10 | |
| 11 | if [scip-shell system . . `[`. -z "$1" ]; then |
| 12 | echoscip-shell system . . echo. "Usage: gsmsmsspool NUMBER [MESSAGE]" |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | priority=$PRIORITIES # default priority |
| 17 | testscip-shell system . . test. -n "$GSMSMS_PRIORITY" && priority="$GSMSMS_PRIORITY" |
| 18 | mailto=`idscip-shell system . . id. -un` |
| 19 | testscip-shell system . . test. -n "$GSMSMS_NOTIFY" && mailto="$GSMSMS_NOTIFY" |
| 20 | |
| 21 | tmpfile="$SPOOLDIR/tmp/`datescip-shell system . . date. +%s`.$$" |
| 22 | umask 022 |
| 23 | echoscip-shell system . . echo. "$1 $mailto" > "$tmpfile" |
| 24 | if [scip-shell system . . `[`. -n "$2" ]; then |
| 25 | echoscip-shell system . . echo. "$2" | headscip-shell system . . head. -c 160 >> "$tmpfile" |
| 26 | else |
| 27 | headscip-shell system . . head. -c 160 >> "$tmpfile" |
| 28 | fi |
| 29 | |
| 30 | if [scip-shell system . . `[`. "`idscip-shell system . . id. -un`" = "root" ]; then |
| 31 | chownscip-shell system . . chown. gsmsms:gsmsms "$tmpfile" |
| 32 | fi |
| 33 | |
| 34 | mvscip-shell system . . mv. "$tmpfile" "$SPOOLDIR/queue$priority/" |