blob: e306665d92aa386e50b3256b12c81b31301746d1 (
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
|
#!/usr/bin/env bash
playbook_add() {
case "${BASHTARD_PLATFORM[distro]}" in
gentoo)
mkdir -pv "/etc/portage/package.use"
printf "acct-user/git gitolite" > /etc/portage/package.use/bashtard-gitolite
;;
*)
notice "$BASHTARD_PLAYBOOK" "Creating user 'git'"
useradd \
--home-dir "$(config "git.repodir")" \
--create-home \
--shell "$(config "fs.bindir")/git-shell" \
git
;;
esac
notice "$BASHTARD_PLAYBOOK" "Installing packages"
pkg install \
"$(config "pkg.gitolite")"
playbook_sync
}
playbook_sync() {
notice "$BASHTARD_PLAYBOOK" "Ensuring all desired repositories exist"
while read -r repo
do
local name="$(config "git.repos.$repo.name" "$repo")"
local path="$(config "git.repodir")/$(config "git.repos.$repo.path" "$name")"
info "$BASHTARD_PLAYBOOK" "Ensuring $name exists ($repo)"
if [[ ! -d "$path" ]]
then
notice "$BASHTARD_PLAYBOOK" "Creating bare repository at $path"
mkdir -pv -- "$path"
git -C "$path" --bare init
fi
printf "$(config "git.repos.$repo.description" "Nondescript")\n" > "$path/description"
done < <(config_subkeys "git.repos")
}
playbook_del() {
notice "$BASHTARD_PLAYBOOK" "Removing packages"
pkg uninstall \
"$(config "pkg.gitolite")"
notice "$BASHTARD_PLAYBOOK" "Cleaning up srv directory"
rm -frv --one-file-system -- "$(config "git.repodir")"
}
|