#!/bin/sh -eu set -eu DIR="/data/git" REPOS="$DIR/*.git" HOOKS="pre-receive" dir=`dirname $0` BASE=`realpath $dir` echo "# This file is auto-generated" > $DIR/cgit-repo-rc for git in $REPOS; do if [ -d "$git" ]; then cd $git name=`basename $git` simple=${name%.git} echo $name # Prepare the repository chown -R root:wheel . ln -sf $git $DIR/$simple find . -type f -print0 | xargs -0 chmod 664 find . -type d -print0 | xargs -0 chmod 775 # Install hooks for hook in $HOOKS; do ln -sf $BASE/$hook hooks/$hook done # Repository settings git config core.sharedRepository=0664 || true git config receive.denyNonFastforwards=true || true touch git-daemon-export-ok if [ ! -f git-receive-allow ]; then touch git-receive-allow fi if [ ! -f cgit-repo-rc ]; then ( echo "repo.desc=$simple" echo "repo.owner=" ) > cgit-repo-rc fi # Add to cgit list ( echo "repo.url=$simple" echo "repo.path=$git" echo "include=$git/cgit-repo-rc" ) >> $DIR/cgit-repo-rc fi done