chiark / gitweb /
wip, nearly working
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 11 Apr 2014 16:16:20 +0000 (17:16 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 11 Apr 2014 16:16:20 +0000 (17:16 +0100)
notify [changed mode: 0644->0755]
via-email [changed mode: 0644->0755]

diff --git a/notify b/notify
old mode 100644 (file)
new mode 100755 (executable)
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
old mode 100644 (file)
new mode 100755 (executable)
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 <<END
 To: $rcpt
-Subject: Post-pizza: $msg
+Subject: $msg
+
+$msg
+
+-- 
+$PIZZANOTIFY_name using the post-pizza notify.git script
+END