summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@jones.dk>2010-05-04 12:04:41 +0200
committerroot <root@jones.dk>2010-05-04 12:04:41 +0200
commitd50edb8d7bc4d5d34b93f6228f33b0d0b69a5f17 (patch)
tree5e69b563825bc397c5f86039822ac44106e7aa34
parentbd603ffdbf1fe23c901a4840a49fa1fbf3813e72 (diff)
Add sms- and Kannel-related script localsendgroupsms.
-rwxr-xr-xlocalsendgroupsms40
1 files changed, 40 insertions, 0 deletions
diff --git a/localsendgroupsms b/localsendgroupsms
new file mode 100755
index 0000000..81e2bee
--- /dev/null
+++ b/localsendgroupsms
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+set -e
+
+simpleword() {
+ echo "$1" | tr '[A-Z]' '[a-z]' | egrep '^[a-z][a-z0-9-]+$' || exit 1
+}
+
+uridecode() {
+ echo "$1" | perl -e 'use URI::Escape; print lc(uri_unescape(<STDIN>));'
+}
+
+urlencode() {
+ echo "$1" | perl -e 'use URI::URL; print URI::URL->new(<STDIN>)."\n";'
+}
+
+phone=`uridecode "$1" | sed -e 's/\+/ /g'`; shift
+set -- `uridecode "$@" | sed -e 's/\+/ /g'`
+app=`simpleword "$1"`; shift
+
+case "$app" in
+ wadmin|wall)
+ # coolsms dislikes leading + in phone number
+ SMS_PHONE=`echo "$SMS_PHONE" | sed 's/^%2b//i'`
+ origin="$1"; shift
+ i=
+ for p in $phone; do
+ case $p in
+ $origin)
+ ;;
+ *)
+ /usr/local/sbin/localsendsms "$p" "$@"
+ i=$((i+1))
+ ;;
+ esac
+ done
+ /usr/local/sbin/localsendsms "$origin" "Message \"$1 $2...\" sent to $i recipients."
+ ;;
+ *)
+esac