#!/bin/sh # # gsc-post-receive — Git post-receive hook to do gsc poking # # Copyright © 2014 martin f. krafft # Released under the terms of the Artistic Licence 2.0 # set -eu TEMPDIR=$(mktemp -d gsc.XXXXXXXXXX) TRAPSIGNALS="0 1 2 3 4 5 6 7 8 10 11 12 13 14 15" cleanup() { rm -rf "$TEMPDIR"; trap - $TRAPSIGNALS; } trap cleanup $TRAPSIGNALS if ! git show HEAD:.gsc/pokehosts 2>/dev/null > $TEMPDIR/pokehosts; then exit 0 fi git show HEAD:.gsc/poke-key > $TEMPDIR/poke-key git show HEAD:.gsc/ssh_known_hosts > $TEMPDIR/ssh_known_hosts poke_host() { echo >&2 "*** Poking $1..." ssh -T -o ConnectTimeout=10 \ -o ForwardAgent=no -o ForwardX11=no \ -o PreferredAuthentications=publickey \ -o IdentitiesOnly=yes \ -o IdentityFile="$TEMPDIR/poke-key" \ -o StrictHostKeyChecking=yes \ -o UserKnownHostsFile=$TEMPDIR/ssh_known_hosts \ $1 &2 echo >&2 "*** Done poking $1." } while read target remainder; do # reserve the use of $remainder for now poke_host $target done < $TEMPDIR/pokehosts