git-serv

All-in-one Git hosting container

git clone git://git.janzachar.dev/git-serv.git


0#!/bin/sh
1
2
3#shellcheck source=config/env
4. "/srv/config/env"
5
6usage() {
7	echo "usage: init <name>"
8	echo "  initializes a new repo with the given name"
9	echo "  example: init test"
10	exit 1
11}
12
13[ $# -ne 1 ] && usage
14
15REPO="/repos/${1}.git"
16
17[ -d "$REPO" ] && {
18	echo "'${1}' already exists!"
19	exit 1
20}
21
22git init -q --bare --initial-branch=main "$REPO"
23touch "$REPO"/git-daemon-export-ok # Repos are public by default
24
25cat<< EOF > "$REPO"/hooks/post-update 
26#!/bin/sh
27
28git show-ref --heads 2>&1
29
30SRC=/repos \
31BUILD=/srv/pages \
32python3 /srv/spgit/src/main.py >> /log/spgit 2>> /log/spgit
33EOF
34chmod +x "$REPO"/hooks/post-update
35
36
37echo "repo created! Clone it with"
38echo "  git clone $(./git-shell-commands/link "$1")"
39
40