]> git.phdru.name Git - git-scripts.git/blob - publish2web
Allow additional subdirectories
[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 gc --aggressive && git fsck --strict &&
22 cp -p hooks/post-update.sample hooks/post-update && hooks/post-update &&
23 cp -p "$HOME"/Internet/WWW/htdocs/git.phdru.name/phdru.name/phdru.name.git/git-daemon-export-ok . &&
24 if [ "`cat \"$source_dir\"/.git/description`" = \
25    "Unnamed repository; edit this file 'description' to name the repository." ]
26 then
27    "${VISUAL:-${EDITOR:-vi}}" "$source_dir"/.git/description description
28 else
29    cp -p "$source_dir"/.git/description . && chmod a+r description
30 fi &&
31 if [ -f "$source_dir"/README.html ]; then
32    cp -p "$source_dir"/README.html . && chmod a+r README.html
33 fi &&
34
35 cd "$HOME"/Internet/WWW/htdocs/git.phdru.name &&
36 directories="$2" &&
37 if [ -n "$directories" ]; then
38    mkdir -p "$directories"
39 fi &&
40
41 cd "$HOME"/tmp &&
42 mv "$dest_dir" "$HOME"/Internet/WWW/htdocs/git.phdru.name/"$directories" &&
43
44 umask 077 &&
45 cd "$source_dir" &&
46 if [ -n "$directories" ]; then
47    dest_dir="$directories/$dest_dir"
48 fi &&
49 exec git remote add --mirror=push web "$HOME"/Internet/WWW/htdocs/git.phdru.name/"$dest_dir"