blob: 32cb0b850bb1e6cad138c917c6b37b259c73e8b2 (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#! /usr/bin/env bash
# Create remote git repository (on the server). You must run this script from
# the "repositories root" (e.g., /var/scm) where you want the repository to be
# created (including any subdirectories). If the repository is public, also
# add it to the manifest file (used for mirroring), together with an optional
# remote URL where the repository must additionally be mirrored to.
#
# --private
# make the repository private
#
# Note: <name> can be without the .git suffix.
#
usage="usage: $0 [--private] <name> [<remote-mirror-url>]"
owd="$(pwd)"
trap "{ cd '$owd'; exit 1; }" ERR
set -o errtrace # Trap in functions.
function info () { echo "$*" 1>&2; }
function error () { info "$*"; exit 1; }
public="y"
while [ "$#" -gt 0 ]; do
case "$1" in
--private)
public="n"
shift
;;
-*)
error "unknown option: $1"
;;
*)
break
;;
esac
done
if [ -z "$1" ]; then
error "repository name expected"
fi
r="$1"
shift
if [ "$(basename "$r")" = "$(basename --suffix=.git "$r")" ]; then
r="$r.git"
fi
u=
if [ -n "$1" ]; then
if [ "$public" = "n" ]; then
error "private repository cannot be mirrored"
fi
u="$1"
fi
gr='scm'
mkdir -p "$r"
chgrp "$gr" "$r"
git --bare init --shared=all "$r"
info "Enter project description (one line; or edit $r/description later)"
info "Hit Ctrl-D when done"
cat >"$r/description"
chgrp -R "$gr" "$r"
if [ "$public" = "y" ]; then
f="$r/git-daemon-export-ok"
touch "$f"
chgrp "$gr" "$f"
chmod g+w "$f"
else
# Disable raw HTTP access to this directory.
#
echo "deny from all" >"$r/.htaccess"
fi
mv "$r/hooks/post-update.sample" "$r/hooks/post-update"
if [ "$public" = "y" ]; then
l="$r"
if [ -n "$u" ]; then
l="$l $u"
fi
echo "$l" >>manifest
fi
|