]> git.phdru.name Git - git-scripts.git/blob - publish2web
c66a6940b2c4655887789aa6f5e5946f237d03cd
[git-scripts.git] / publish2web
1 #! /bin/sh
2
3 if [ -z "$1" ]; then
4    echo "Usage: $0 repoistory [directories]" >&2
5    exit 1
6 fi
7
8 umask 022 &&
9 cd "$1" && source_dir="`pwd`" &&
10
11 if [ ! -d ".git" ]; then
12    echo "$source_dir is not a repoistory (.git isn't found)" >&2
13    exit 1
14 fi &&
15
16 cd "$HOME"/tmp &&
17 dest_dir="`basename \"$source_dir\"`".git &&
18 git clone --mirror --config core.sharedRepository=0644 "$source_dir" "$dest_dir" &&
19
20 cd "$dest_dir" &&
21 git repack -a -d -f --depth=250 --window=250 &&
22 git fsck --strict &&
23 cp -p hooks/post-update.sample hooks/post-update && hooks/post-update &&
24 cp -p "$HOME"/Internet/WWW/htdocs/git.phdru.name/phdru.name/phdru.name.git/git-daemon-export-ok . &&
25 if [ "`cat \"$source_dir\"/.git/description`" = \
26    "Unnamed repository; edit this file 'description' to name the repository." ]
27 then
28    "${VISUAL:-${EDITOR:-vi}}" "$source_dir"/.git/description description
29 else
30    cp -p "$source_dir"/.git/description . && chmod a+r description
31 fi &&
32 if [ -f "$source_dir"/README.html ]; then
33    cp -p "$source_dir"/README.html . && chmod a+r README.html
34 fi &&
35
36 cd "$HOME"/Internet/WWW/htdocs/git.phdru.name &&
37 directories="$2" &&
38 if [ -n "$directories" ]; then
39    mkdir -p "$directories"
40 fi &&
41
42 cd "$HOME"/tmp &&
43 mv "$dest_dir" "$HOME"/Internet/WWW/htdocs/git.phdru.name/"$directories" &&
44
45 umask 077 &&
46 cd "$source_dir" &&
47 if [ -n "$directories" ]; then
48    dest_dir="$directories/$dest_dir"
49 fi &&
50 exec git remote add --mirror=push web "$HOME"/Internet/WWW/htdocs/git.phdru.name/"$dest_dir"