From 6b19aab50dff057707a69dc5881efde8c53251f6 Mon Sep 17 00:00:00 2001 From: acidvegas Date: Tue, 27 Jun 2023 18:52:59 -0400 Subject: [PATCH] Updated post-recieve hook for full deployment --- assets/post-recieve | 48 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/assets/post-recieve b/assets/post-recieve index 34c55ef..db27fb7 100755 --- a/assets/post-recieve +++ b/assets/post-recieve @@ -1,40 +1,14 @@ #!/bin/sh -# stagit setup helper - developed by acidevegas (https://git.acid.vegas/stagit) -# sudo apt-get install libgit2-1.1 libmd4c* +# stagit post-recieve script - developed by acidevegas (https://git.acid.vegas/stagit) -BASE_URL="https://git.acid.vegas" -CLONE_URL="git://git.acid.vegas" -HTML_DIR="/home/acidvegas/dev/html/stagit/out" -REPOS="$(find $HOME/dev/git -type d -name mirror -prune -o -type d -name .git -print | sort | xargs echo)" +URL="git.acid.vegas" +PROTO="https" +CLONE_URL="git://$URL" +COMMIT_LIMIT=100 +HTML_DIR="/srv/http" -mkdir -p $HTML_DIR -cp favicon.png logo.png style.css $HTML_DIR -for dir in $(echo $REPOS); do - OWNER=$(basename $(dirname $(dirname $dir))) - REPO=$(basename $(dirname $dir)) - if [ -f $dir/description ]; then - REPO_DESC=$(cat $dir/description) - if [ "$REPO_DESC" = "Unnamed repository; edit this file 'description' to name the repository." ]; then - nano $dir/description - echo "[+] updated default 'description' file for '$REPO'" - fi - else - nano $dir/description - echo "[+] added missing 'description' file for '$REPO'" - fi - if [ ! -f $dir/owner ]; then - echo $OWNER > $dir/owner - echo "[+] added missing 'owner' file for '$REPO'" - fi - if [ ! -f $dir/url ]; then - echo "$CLONE_URL/$REPO.git" > $dir/url - echo "[+] added missing 'url' file for '$REPO'" - fi - echo "[~] processing '$REPO' repository..." - mkdir -p $HTML_DIR/$REPO && cd $HTML_DIR/$REPO && stagit -c ".cache" -u "$BASE_URL/$REPO" $dir - ln -sf log.html index.html && ln -sf ../style.css style.css && ln -sf ../logo.png logo.png && ln -sf ../favicon.png favicon.png - git --git-dir $dir archive HEAD -o "$HTML_DIR/$REPO/$REPO.zip" # TODO: can we do this with libgit2? -done -echo "[~] creating index..." -stagit-index "$REPOS" > $HTML_DIR/index.html -echo "[+] finished" \ No newline at end of file +DIR=$PWD +REPO=$(basename $DIR .git) +mkdir -p $HTML_DIR/$REPO && cd $HTML_DIR/$REPO && stagit -l $COMMIT_LIMIT -u "$PROTO://$URL/$REPO" $DIR +ln -sf log.html index.html +git --git-dir $DIR archive --format=tar.gz -o "$HTML_DIR/$REPO/$REPO.tar.gz" --prefix="$REPO/" HEAD