#!/bin/sh -eu set -eu DIR="/data/git" REPOS="$DIR/*.git" HOOKS="pre-receive" dir=`dirname $0` BASE=`realpath $dir` for hook in $HOOKS; do for git in $REPOS; do if [ -d "$git" ]; then cd $git name=`basename $git` simple=${name%.git} echo $name chown -R www:www . ln -sf $git $DIR/$simple find . -type f -print0 | xargs -0 chmod 660 find . -type d -print0 | xargs -0 chmod 770 ln -sf $BASE/$hook hooks/$hook git config core.sharedRepository=0660 || true git config receive.denyNonFastforwards=true || true touch git-daemon-export-ok fi done done