From: Simon Tatham Date: Fri, 18 Dec 2015 17:23:59 +0000 (+0000) Subject: New notification mechanism 'userv'. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a7b661486ddf65ef92f42941eec4d03e3be78875;p=post-pizza-notify.git New notification mechanism 'userv'. This makes an ssh connection to a specified host, and then invokes a specified userv service provided by a specified user. The recipient configuration is of the form 'userv SSH_HOST_ARG USERV_USER SERVICE', e.g. I've been testing it myself with the line userv sgtatham@chiark sgtatham post-pizza which causes the first argument 'sgtatham@chiark' to be passed to ssh, and then the service command 'userv sgtatham post-pizza' to be invoked on the target host. The notification message is passed to the userv service via standard input, because that seemed slightly easier than doing it as a command-line argument (the latter would be easy enough to get through userv uncorrupted, but less easy to get through the ssh command line mechanism). The userv service is invoked with a 2-second timeout, so if it needs to do anything potentially long (like trying to make a network connection over a maybe-not-up-yet secnet tunnel) then it should close file descriptors and fork. --- diff --git a/via-userv b/via-userv new file mode 100755 index 0000000..dbfd8b9 --- /dev/null +++ b/via-userv @@ -0,0 +1,15 @@ +#!/usr/bin/perl -w +# +# recipient format: +# userv HOST USER SERVICE + +use strict; +die unless @ARGV==4; +our ($msg,$host,$user,$service) = @ARGV; + +if (open PIPE, "|-", "ssh", $host, "userv", "-t", "2", $user, $service) { + print PIPE "$msg\n"; + close PIPE; +} + +die $! if $? != 0;