summaryrefslogtreecommitdiff
path: root/install-repos
blob: c8792d22da4bc20d2bda01a6fa5577466cbf4edd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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 git-description ]; then
                        touch git-description
                fi

		# Add to cgit list
		(
			if [ -f cgit-repo-rc ]; then
			 	include=$git/cgit-repo-rc
			else
				desc=$(cat git-description)
				if [ -z "$desc" ]; then
					desc="$simple"
				fi
				echo "repo.url=$simple"
				echo "repo.path=$git"
				echo "repo.desc=$desc"
				echo "repo.owner=Stef"
			fi
			echo
		) >> $DIR/cgit-repo-rc
	fi
done