backup-db.sh: new utility to backup the chroot passwd/group files
[girocco.git] / hooks / post-receive
blob8e68da367ac2d1365837e66309c199c0fc02a5bc
1 #!/bin/sh
3 # Send notification through the taskd socket
5 # Beware, we MAY be running in a chroot!
7 set -e
9 sockpath=/etc/taskd.socket
10 reporoot=/@jailreporoot@
11 authuser="$LOGNAME"
12 cwd="$(pwd)"
13 if [ -x /usr/bin/perl ]; then
14 # Not in chroot...
15 . @basedir@/shlib.sh
17 sockpath="$cfg_chroot$sockpath"
18 reporoot="$cfg_reporoot"
20 # authuser needs to be set if not running in the chroot.
21 # Currently that can only be the case with https push in
22 # which case REMOTE_USER will contain the user name (possibly prefixed
23 # with "/UID=" and suffixed with "/dnQualifier=...").
24 # Fallback is the mirror_user if REMOTE_USER is not set.
25 authuser="${REMOTE_USER#/UID=}"
26 authuser="${authuser%/dnQualifier=*}"
27 [ -n authuser ] || authuser="$cfg_mirror_user"
28 else
29 # In chroot...
30 nc_openbsd() { /bin/nc.openbsd "$@"; }
32 projname="${cwd#$reporoot/}"
34 [ -S "$sockpath" ] || exit 0
36 while read line; do
37 echo "ref-change $authuser ${projname%.git} $line" | nc_openbsd -w 1 -U "$sockpath"
38 done
40 exit