]> git.madduck.net Git - code/gsc.git/blob - gsc-post-receive

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Initial checkin
[code/gsc.git] / gsc-post-receive
1 #!/bin/sh
2 #
3 # gsc-post-receive — Git post-receive hook to do gsc poking
4 #
5 # Copyright © 2014 martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
7 #
8 set -eu
9
10 TEMPDIR=$(mktemp -d gsc.XXXXXXXXXX)
11 TRAPSIGNALS="0 1 2 3 4 5 6 7 8 10 11 12 13 14 15"
12 cleanup() { rm -rf "$TEMPDIR"; trap - $TRAPSIGNALS; }
13 trap cleanup $TRAPSIGNALS
14
15 if ! git show HEAD:.gsc/pokehosts 2>/dev/null > $TEMPDIR/pokehosts; then
16   exit 0
17 fi
18 git show HEAD:.gsc/poke-key > $TEMPDIR/poke-key
19 git show HEAD:.gsc/ssh_known_hosts > $TEMPDIR/ssh_known_hosts
20
21 poke_host() {
22   echo >&2 "*** Poking $1..."
23
24   ssh -T -o ConnectTimeout=10 \
25     -o ForwardAgent=no -o ForwardX11=no \
26     -o PreferredAuthentications=publickey \
27     -o IdentitiesOnly=yes \
28     -o IdentityFile="$TEMPDIR/poke-key" \
29     -o StrictHostKeyChecking=yes \
30     -o UserKnownHostsFile=$TEMPDIR/ssh_known_hosts \
31     $2 $1 </dev/null | sed 's,^,    ,' >&2
32
33   echo >&2 "*** Done poking $1."
34 }
35
36 while read target ssh_opts; do
37   poke_host $target $ssh_opts
38 done < $TEMPDIR/pokehosts