From d50edb8d7bc4d5d34b93f6228f33b0d0b69a5f17 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 4 May 2010 12:04:41 +0200 Subject: Add sms- and Kannel-related script localsendgroupsms. --- localsendgroupsms | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 localsendgroupsms (limited to 'localsendgroupsms') 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());' +} + +urlencode() { + echo "$1" | perl -e 'use URI::URL; print URI::URL->new()."\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 -- cgit v1.2.3