blob: 881ee55a24390b000a2f4b99bcff64abbedc6e55 (
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
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
|
#! /usr/bin/env bash
# Usage examples
#
# Init private repository and mirror it to github.
# ./init-git-repo.sh --private --mirror repo.git
private=0
mirror=0
repo=""
while [[ $# -gt 0 ]]; do
case $1 in
-p|--private)
private=1
shift
;;
-m|--mirror)
mirror=1
shift
;;
-*|--*)
echo "Unknown option $1" 1>&2
exit 1
;;
*)
repo=$1
shift
;;
esac
done
if [ -z $repo ]; then
echo "Provide repository name!" 1>&2
exit 1
fi
mkdir $repo
cd $repo
git init --bare
if [ $private -eq 0 ]; then
touch git-daemon-export-ok
fi
if [ $mirror -eq 1 ]; then
git remote add --mirror github git@github.com:ilvokhin/$repo
cat > hooks/post-receive <<EOF
#! /bin/sh
git push --quiet github &
EOF
chmod +x hooks/post-receive
fi
cd ..
|