summaryrefslogtreecommitdiff
path: root/localsendgroupsms
blob: 81e2bee4897b1155826359c45fcd076983bbc19c (plain)
  1. #!/bin/sh
  2. set -e
  3. simpleword() {
  4. echo "$1" | tr '[A-Z]' '[a-z]' | egrep '^[a-z][a-z0-9-]+$' || exit 1
  5. }
  6. uridecode() {
  7. echo "$1" | perl -e 'use URI::Escape; print lc(uri_unescape(<STDIN>));'
  8. }
  9. urlencode() {
  10. echo "$1" | perl -e 'use URI::URL; print URI::URL->new(<STDIN>)."\n";'
  11. }
  12. phone=`uridecode "$1" | sed -e 's/\+/ /g'`; shift
  13. set -- `uridecode "$@" | sed -e 's/\+/ /g'`
  14. app=`simpleword "$1"`; shift
  15. case "$app" in
  16. wadmin|wall)
  17. # coolsms dislikes leading + in phone number
  18. SMS_PHONE=`echo "$SMS_PHONE" | sed 's/^%2b//i'`
  19. origin="$1"; shift
  20. i=
  21. for p in $phone; do
  22. case $p in
  23. $origin)
  24. ;;
  25. *)
  26. /usr/local/sbin/localsendsms "$p" "$@"
  27. i=$((i+1))
  28. ;;
  29. esac
  30. done
  31. /usr/local/sbin/localsendsms "$origin" "Message \"$1 $2...\" sent to $i recipients."
  32. ;;
  33. *)
  34. esac