From babc11dd0dea9d621458dd701cd6ab83637358f0 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Mon, 5 Dec 2016 17:01:08 +0000 Subject: set-up-post-receive-hooks: scripts to set up post-receive hooks to mirror --- set-up-all-post-receive-hooks.sh | 10 ++++++++++ set-up-post-receive-hooks.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 set-up-all-post-receive-hooks.sh create mode 100755 set-up-post-receive-hooks.sh diff --git a/set-up-all-post-receive-hooks.sh b/set-up-all-post-receive-hooks.sh new file mode 100755 index 0000000..8d3e26a --- /dev/null +++ b/set-up-all-post-receive-hooks.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -x +cd /git +find -path './users' -prune -o -name config -print | while read repo_config; do + dir="$(dirname $repo_config)" + if [ -e $dir/git-daemon-export-ok -a -e $dir/HEAD -a -e $dir/$(awk '{ print $2 }' $dir/HEAD) ]; then + sh -x /git/bin/set-up-post-receive-hooks.sh "$(dirname $repo_config)" + fi + +done diff --git a/set-up-post-receive-hooks.sh b/set-up-post-receive-hooks.sh new file mode 100755 index 0000000..936df41 --- /dev/null +++ b/set-up-post-receive-hooks.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +cd /git/$1 +if [ ! -e git-daemon-export-ok -o ! -e HEAD -o ! -e $(awk '{ print $2 }' HEAD) ]; then + exit +fi + +[ -e hooks/post-receive.d ] && exit + +mkdir hooks/post-receive.d +cat < hooks/post-receive-new-$$ +#!/bin/sh + +set -e + +for f in hooks/post-receive.d/*; do + [ -x \$f ] && \$f "\$@" +done + +EOF + +[ -e hooks/post-receive ] && mv hooks/post-receive hooks/post-receive.d/00-post-receive +ln -s /git/bin/post-receive-mirror-github hooks/post-receive.d/01-github + +mv hooks/post-receive-new-$$ hooks/post-receive +chmod +x hooks/post-receive -- cgit v1.2.3