commit 1861cb01d7360cbcc096ed5df7c43393eaed766c
parent f051663b1783033f8fe0a279f454990775fbf912
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Sat, 11 Jul 2020 22:16:05 +0200

make-public and make-private now also configure website

Diffstat:
Mgit-shell-commands/make-private | 23+++++++++++++++++++----
Mgit-shell-commands/make-public | 46++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/git-shell-commands/make-private b/git-shell-commands/make-private @@ -1,12 +1,27 @@ #!/bin/sh +# path must be absolute +reposdir="/srv/git" +webdir="/srv/git/html" + # Check number of params [ $# -ne 1 ] && echo "Usage: make-private <project.git>" && exit 1 # Set the project name, adding .git if necessary -p=$(echo "$1" | sed 's/\.git$\|$/.git/i') +dir="$(echo "$1" | sed 's/\.git$\|$/.git/i')" +web="/srv/git/html/$(basename "$dir" ".git")" + +[ ! -d "$dir" ] && echo "$dir not found." + +[ ! -f "$dir/git-daemon-export-ok" ] && echo "$dir is already private." && exit + +rm "$dir/git-daemon-export-ok" +rm -rf "$web" -[ ! -d "$p" ] && echo "$p not found." +repos="" +for d in "$reposdir/"*.git/; do + [ -f "$d/git-daemon-export-ok" ] && repos="$repos $d" +done -[ ! -f "$p/git-daemon-export-ok" ] && echo "$p is already private." && exit -rm "$p/git-daemon-export-ok" && echo "$p is now private." +echo "$repos" | xargs stagit-index > "$webdir/index.html" +echo "$dir is now private." diff --git a/git-shell-commands/make-public b/git-shell-commands/make-public @@ -1,12 +1,50 @@ #!/bin/sh +# path must be absolute +reposdir="/srv/git" +webdir="/srv/git/html" +defaultdir="/usr/local/share/doc/stagit" + # Check number of params [ $# -ne 1 ] && echo "Usage: make-public <project.git>" && exit 1 # Set the project name, adding .git if necessary -p=$(echo "$1" | sed 's/\.git$\|$/.git/i') +dir=$(echo "$1" | sed 's/\.git$\|$/.git/i') + +[ ! -d "$dir" ] && echo "$dir not found." + +[ -f "$dir/git-daemon-export-ok" ] && echo "$dir is already public." && exit + +touch "$dir/git-daemon-export-ok" +git -C "$dir" update-server-info + +mkdir -p "$webdir" || exit 1 + +# set assets if not already there +ln -s "$defaultdir/style.css" "$webdir/style.css" 2> /dev/null +ln -s "$defaultdir/logo.png" "$webdir/logo.png" 2> /dev/null +ln -s "$defaultdir/favicon.ico" "$webdir/favicon.ico" 2> /dev/null + +# strip .git suffix +r=$(basename "$dir") +d=$(basename "$dir" ".git") +printf "%s... " "$d" + +mkdir -p "$webdir/$d" +cd "$webdir/$d" || continue +stagit -c ".stagit-build-cache" "$reposdir/$r" + +# symlinks +ln -sf log.html index.html +ln -sf "$reposdir/$r" ".git" + +echo "done" -[ ! -d "$p" ] && echo "$p not found." +# make index +repos="" +for d in "$reposdir/"*.git/; do + [ -f "$d/git-daemon-export-ok" ] && repos="$repos $d" +done +echo "$repos" | xargs stagit-index > "$webdir/index.html" -[ -f "$p/git-daemon-export-ok" ] && echo "$p is already public." && exit -touch "$p/git-daemon-export-ok" && echo "$p is now public." +echo "$dir is now public."