commit c4a6eb0fd7bd3d70b0a47994de64397b73719c28
parent 8eb7cc1cc3ce5329b73471b4bd3ccc9700f9ee16
Author: Erik Letson <hmagellan@tutamail.com>
Date: Fri, 3 Jul 2020 03:23:28 -0500
added initial upstagit script
Diffstat:
A | upstagit.sh | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 44 insertions(+), 0 deletions(-)
diff --git a/upstagit.sh b/upstagit.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# 'upsatgit.sh' - Script to update and format a stagit git web frontend
+# Intended for use with stagit: https://git.codemadness.org/stagit/file/README.html
+
+# Configure these values to match your web environment
+REPO_PATH="/srv/git"
+WEB_PATH="/var/www/html"
+WEB_URL="https://example.com"
+LOGO_URL="$WEBURL/example.jpg"
+STYLE_URL="$WEBURL/style.css"
+ICON_WIDTH="32"
+ICON_HEIGHT="32"
+STAGIT_COM="/usr/local/bin/stagit"
+STAGIT_INDEX_COM="$STAGIT_COM-index"
+
+# Update web frontend for each repo
+for i in $(ls $REPO_PATH); do
+ if [[ -d $WEB_PATH/$i ]]
+ then
+ cd $WEB_PATH/$i
+ rm -rd *
+ else
+ mkdir $WEB_PATH/$i
+ cd $WEB_PATH/$i
+ fi
+ $STAGIT_COM $REPO_PATH/$i
+done
+
+# Update index.html
+cd $WEB_PATH
+$STAGIT_INDEX_COM $REPO_PATH/* > $WEB_PATH/index.html
+
+# Update paths to stylesheets and logos in all web pages
+sed -i 's,class\=\"desc\">Repositories,class\=\"desc\"><h1>Repositories<\/h1>,g' "$WEB_PATH/index.html"
+sed -i 's,<td><b>Owner<\/b><\/td>,<td><\/td>,g' "$WEB_PATH/index.html"
+
+for j in $(ls $REPO_PATH); do
+ for k in $(ls -R -a1 $WEB_PATH/* | find $WEB_PATH | grep ".html$"); do
+ sed -i -E -e "s,\=\"(\.\.\/)*logo\.png\",\=\"$LOGO_URL\",g" "$k"
+ sed -i -E -e "s,\=\"(\.\.\/)*style\.css\",\=\"$STYLE_URL\",g" "$k"
+ sed -i "s,width\=\"32\" height\=\"32\",width\=\"$ICON_WIDTH\" height=\=\"$ICON_HEIGHT\",g" "$k"
+ done
+done