From e9dec6ff4041a8448ac2fd61451ea84623ccc997 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 4 Nov 2009 12:03:51 +0100 Subject: [PATCH] post-receive-hook: Introduce, sends ref-change messages to taskd --- README | 5 +++-- install.sh | 4 ++-- jailsetup.sh | 1 + post-receive-hook | 23 +++++++++++++++++++++++ update-hook | 4 +--- 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100755 post-receive-hook diff --git a/README b/README index 4d8d2f4..1d2f8ed 100644 --- a/README +++ b/README @@ -53,8 +53,9 @@ Requirements and setup You will need git pre-installed, or you can build and install one from the git.git subdirectory; normally, Girocco will use only gitweb from there. However, some bits of Girocco (e.g. the chroot setup) will rely on -/usr/bin/git regardless of cmd_git settings. You will need to add the right -users to the right groups (a dedicated Girocco user and the CGI user, +/usr/bin/git regardless of cmd_git settings; for chroot you will also need +/bin/nc.openbsd (netcat-openbsd debian package). You will need to add the +right users to the right groups (a dedicated Girocco user and the CGI user, at least); root access or root user cooperation will be probably essential unless you have good suexec setup. Girocco is designed to be run only with single instance within one system. If you want git protocol access, you will diff --git a/install.sh b/install.sh index e8e01f5..8ed31b1 100755 --- a/install.sh +++ b/install.sh @@ -17,14 +17,14 @@ perl -I. -M$GIROCCO_CONF -e '' echo "*** Setting up basedir..." rm -fr "$cfg_basedir" mkdir -p "$cfg_basedir" -cp -a Girocco jobd taskd gitweb html jobs toolbox apache.conf shlib.sh update-hook "$cfg_basedir" +cp -a Girocco jobd taskd gitweb html jobs toolbox apache.conf shlib.sh update-hook post-receive-hook "$cfg_basedir" # Put the correct Config in place [ "$GIROCCO_CONF" = "Girocco::Config" ] || cp "$(echo "$GIROCCO_CONF" | sed 's#::#/#g; s/$/.pm/')" "$cfg_basedir/Girocco/Config.pm" echo "*** Preprocessing scripts..." -perl -I. -M$GIROCCO_CONF -i -pe 's/\@basedir\@/"$Girocco::Config::basedir"/g' "$cfg_basedir"/jobs/*.sh "$cfg_basedir"/jobd/*.sh "$cfg_basedir"/taskd/*.sh "$cfg_basedir"/gitweb/*.sh "$cfg_basedir"/shlib.sh "$cfg_basedir"/update-hook +perl -I. -M$GIROCCO_CONF -i -pe 's/\@basedir\@/"$Girocco::Config::basedir"/g' "$cfg_basedir"/jobs/*.sh "$cfg_basedir"/jobd/*.sh "$cfg_basedir"/taskd/*.sh "$cfg_basedir"/gitweb/*.sh "$cfg_basedir"/shlib.sh "$cfg_basedir"/update-hook "$cfg_basedir"/post-receive-hook if [ -n "$cfg_mirror" ]; then diff --git a/jailsetup.sh b/jailsetup.sh index 9680b6d..397ccb0 100755 --- a/jailsetup.sh +++ b/jailsetup.sh @@ -104,6 +104,7 @@ pull_in_bin() { } pull_in_bin /bin/sh bin +pull_in_bin /bin/nc.openbsd bin pull_in_bin /usr/sbin/sshd sbin # ...and the bits of git we need. diff --git a/post-receive-hook b/post-receive-hook new file mode 100755 index 0000000..585ddde --- /dev/null +++ b/post-receive-hook @@ -0,0 +1,23 @@ +#!/bin/sh +# +# Send notification through the taskd socket +# +# Beware, we MAY be running in a chroot! + +set -e + +sockpath=/etc/taskd.socket +if [ -x /usr/bin/perl ]; then + # Not in chroot... + . @basedir@/shlib.sh + + sockpath="$cfg_chroot/$sockpath" +fi + +[ -S "$sockpath" ] || exit 0 + +while read line; do + echo "ref-change $line" +done | /bin/nc.openbsd -w 1 -U "$sockpath" >/dev/null + +exit diff --git a/update-hook b/update-hook index 41dc65c..249cc01 100755 --- a/update-hook +++ b/update-hook @@ -2,9 +2,7 @@ # # Currently, we just confine the mob user to the mob branch here. # -# TODO: CIA support. Mailing list notifications support. Generalized -# branches push permissions support. -# +# TODO: Generalized branches push permissions support. set -e -- 2.11.4.GIT