From: Ian Jackson Date: Fri, 11 Apr 2014 16:16:20 +0000 (+0100) Subject: wip, nearly working X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2689e819b1a05da21194be0ef7c5180a193400ea;p=post-pizza-notify.git wip, nearly working --- diff --git a/notify b/notify old mode 100644 new mode 100755 index 597877e..833d46e --- a/notify +++ b/notify @@ -2,12 +2,25 @@ set -e case "$#.$1" in -2.[^-]*) ;; -*) echo >&2 "usage: ./notify recipientsfile 'message'"; exit 1;; +3.[^-]*) ;; +*) echo >&2 "usage: ./notify senderfile recipientsfile 'message'" + exit 1 ;; esac -rcpts="$1" -msg="$2" +senderinfo="$1" +rcpts="$2" +msg="$3" + +exec <"$senderinfo" +while read settingname value; do + case "$settingname" in + #*|'') continue;; + *) vn=PIZZANOTIFY_$settingname + eval "$vn=\"\$value\"" + export $vn + ;; + esac +done exec <"$rcpts" line=0 @@ -16,15 +29,20 @@ while read method data; do case "$method" in #*|'') continue ;; [^a-z]*) echo >&2 "huh ? $rcpts:$line: $method"; continue ;; + esac log=log-$method-$line.txt exec >$log set +e - printf >&2 "sms" - ./"via-$method" $data 2>&1 + printf >&2 "$method" + exec 3>&2 2>&1 + set -x + ./"via-$method" $data "$msg" 2>&1 rc=$? + set +x + exec 2>&3 3>&- set -e if [ $rc != 0 ]; then - printf >&2 "-FAIL:%s\n" $log + printf >&2 -- "-FAIL:%s\n" $log else printf >&2 " " fi diff --git a/via-email b/via-email old mode 100644 new mode 100755 index f08d110..2f1bd46 --- a/via-email +++ b/via-email @@ -4,4 +4,10 @@ msg="$2" ssh -vt ijackson@tunnel.chiark.greenend.org.uk \ /usr/lib/sendmail -oem -odb -oi -t <