diff options
author | Ray Strode <rstrode@redhat.com> | 2016-12-05 17:01:08 +0000 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2016-12-05 17:33:19 +0000 |
commit | babc11dd0dea9d621458dd701cd6ab83637358f0 (patch) | |
tree | ab54a8aeec45176419f29425c3c64d1698bbb33c | |
parent | 37477ad97f7793515881b58c65cf625a8adbf5fa (diff) |
set-up-post-receive-hooks: scripts to set up post-receive hooks to mirror
-rwxr-xr-x | set-up-all-post-receive-hooks.sh | 10 | ||||
-rwxr-xr-x | set-up-post-receive-hooks.sh | 26 |
2 files changed, 36 insertions, 0 deletions
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 <<EOF > 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 |