summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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