]> git.armaanb.net Git - stagit.git/blob - repo-gen.sh
Update date on manpages
[stagit.git] / repo-gen.sh
1 #!/bin/sh
2
3 fresh=false
4 unique=false
5
6 for arg in "$@"; do
7         [ "$unique" = true ]   && unique="$arg"
8         [ "$arg" = "--only" ]  && unique=true
9         [ "$arg" = "--fresh" ] && fresh=true
10 done
11
12 [ "$unique" = true ] && {
13         echo "Expected argument after \`--only\`.";
14         exit 1;
15 }
16
17 STAGIT=/var/www/git/stagit.out
18 [ ! -f "$STAGIT" ] && STAGIT=stagit
19
20 STAGIT_INDEX=/var/www/git/stagit-index.out
21 [ ! -f "$STAGIT_INDEX" ] && STAGIT_INDEX=stagit-index
22
23 build_html () {
24         repo="$1"
25         repo="$(basename "$repo" | sed 's/\.git$//g')"
26
27         [ "$fresh" = true ] && {
28                 echo "Deleting HTML for $repo.";
29                 rm -fr "/var/www/git/$repo";
30         }
31         mkdir -p "/var/www/git/$repo"
32         cd "/var/www/git/$repo" || { echo "Couldn't cd."; exit 1; }
33
34         [ ! -f style.css ]   && ln -s ../style.css ./
35         [ ! -f favicon.png ] && ln -s ../favicon.png ./
36         [ ! -f logo.png ]    && ln -s ../logo.png ./
37         [ ! -f highlight ]   && ln -s ../highlight ./
38         [ ! -f index.html ]  && ln -s log.html index.html
39
40         echo "git://git.knutsen.co/$repo" > "/srv/git/$repo.git/url"
41
42         COMMAND="$STAGIT -c ./cachefile /srv/git/$repo.git"
43         echo "Building web-page for $repo."
44         echo "$COMMAND"
45         $COMMAND
46 }
47
48 if [ "$unique" = false ]; then
49         for repo in /srv/git/*.git; do
50                 build_html "$repo"
51         done
52 else
53         build_html "$unique"
54 fi
55
56 echo "Generating index.html with \`$STAGIT_INDEX\`."
57 "$STAGIT_INDEX" /srv/git/*.git > /var/www/git/index.html
58
59 # Correct ownership of the web files.
60 chown git:www-data -R /var/www/git -f
61 chmod         g+rw -R /var/www/git -f