aboutsummaryrefslogtreecommitdiffstats
path: root/roles/obsd_git/files/git-shell-commands/create
blob: db389000b65864f611fdcbbfde3c2d6deafafd73 (plain) (blame)
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
#!/bin/sh
set -e

main() {
	repo="$1"
	desc="$2"
	if [ -z "$repo" ]; then
		echo "Usage: provide a repository name" >&2
		exit 1
	fi

	repo_name=$(basename "$repo" .git)
	repo_path="/var/www/pub/git/$repo_name.git"

	if [ ! -d "$repo_path" ]; then
		echo "Creating bare repository: $repo_name.git"
		git init --bare --initial-branch=main "$repo_path"
		chown -R git:git "$repo_path"

		if [ -n "$desc" ]; then
			# cgit will lookup the git repository description via the git config.
			git -C "$repo_path" config gitweb.description "$desc"
		fi
	fi
}

main "$@"