From: short <> Date: Tue, 10 Jul 2001 18:34:30 +0000 (+0000) Subject: k332.feld.cvut.cz:STEP start/stop script invoked from mail X-Git-Tag: rh71~63 X-Git-Url: http://git.jankratochvil.net/?p=nethome.git;a=commitdiff_plain;h=30ca3ac2b25e7ebea4ef96af4b86b4c153100cc0;hp=828bbc0d8ccc569d3c88d8d3987a21409214a17f k332.feld.cvut.cz:STEP start/stop script invoked from mail --- diff --git a/bin/step.sh b/bin/step.sh new file mode 100755 index 0000000..7aec497 --- /dev/null +++ b/bin/step.sh @@ -0,0 +1,37 @@ +#!/bin/sh +NUM=0603431329 +MAILTO=+42$NUM@sms.paegas.cz +SAFE="tr -cd 'a-zA-Z0-9\040.:\042\043\044\055/<>(){}'" +t=/tmp/short.step.$$ +cd + +sendmail() { + (echo -n "\ +From: Step-activator +To: $MAILTO +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + +$1" + if [ -f $t ];then + echo -n "&" + head -n $hd $t|grep "^From:" + fi + )|/usr/sbin/sendmail "$MAILTO" + rm -f $t* + exit; + } + +k332cmd () { + echo "$1;true"|ssh -o "BatchMode yes" k332.feld.cvut.cz sh &>$t.e || \ + sendmail "ssh execute fail:`cat $t.e|$SAFE`" + } + +cat >$t +hd="$[`sed -n -e '/^\$/=' -e '/^\$/q' <$t`+1]" +id="`tail +$hd $t|head -n 1|$SAFE`" +[ "$id" != 0 -a "$id" != 1 ] && \ + sendmail "Command syntax:ID=$id" +k332cmd "killall httpsd postmaster" +if [ "$id" = 1 ];then k332cmd ". .profile &>/dev/null;./step/pgsql/bin/postmaster.run&./step/httpsd";fi +sendmail "Ran, last res <`cat $t.e|$SAFE`>"