summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2016-12-05 17:01:08 +0000
committerRay Strode <rstrode@redhat.com>2016-12-05 17:33:19 +0000
commitbabc11dd0dea9d621458dd701cd6ab83637358f0 (patch)
treeab54a8aeec45176419f29425c3c64d1698bbb33c
parent37477ad97f7793515881b58c65cf625a8adbf5fa (diff)
set-up-post-receive-hooks: scripts to set up post-receive hooks to mirror
-rwxr-xr-xset-up-all-post-receive-hooks.sh10
-rwxr-xr-xset-up-post-receive-hooks.sh26
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