stagit

static git page generator
git clone https://git.awy.one/stagit
Log | Files | Refs | README | LICENSE

stagit-newrepo (840B) - View raw


 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
#!/bin/sh
# Author: Cale "poptart" Black
# License: MIT

set -eu
. /var/git/config.rc
e_log() {
	printf '%s\n' "$*"
}

e_err() {
	printf '%s\n' "$*" >&2
}

e_exit() {
	e_err "$*"
	exit 1
}

DESC=""
REPO=""

if [ $# -gt 1 ]; then
	DESC="$2"
else
	DESC="$DEFAULT_DESCRIPTION"
fi

if [ $# -eq 0 ]; then
	e_exit "not enough args"
else
	REPO="$(basename "$1")"
fi

git init --bare "$GIT_HOME/$REPO.git"
cp "$GIT_HOME/template/post-receive" "$GIT_HOME/$REPO.git/hooks/post-receive"

echo "$CLONE_URI/$REPO" > "$GIT_HOME/$REPO.git/url"
echo "$DEFAULT_OWNER" > "$GIT_HOME/$REPO.git/owner"

if [ -n "$DESC" ]; then
	echo "$DESC" > "$GIT_HOME/$REPO.git/description"
else
	echo "this is a placeholder" > "$GIT_HOME/$REPO.git/description"
fi

chmod u+x "$GIT_HOME/$REPO.git/hooks/post-receive"

mkdir "$WWW_HOME/$REPO"

/usr/local/bin/stagit-gen-index