commit 263db88c61de2ed322c8e211046eac864977acbe
parent 1fec157c3c35fd72563c2560db1ad72d0fa43222
Author: awy <awy@awy.one>
Date: Fri, 10 Apr 2026 23:26:49 +0300
useful scripts
Diffstat:
4 files changed, 122 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -30,6 +30,10 @@ COMPATSRC = \
BIN = \
stagit\
stagit-index
+SCRIPTS = \
+ stagit-gen-index\
+ stagit-newrepo\
+ stagit-rebuild-all
MAN1 = \
stagit.1\
stagit-index.1
@@ -80,6 +84,7 @@ install: all
# installing executable files.
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f ${BIN} ${DESTDIR}${PREFIX}/bin
+ cp -f ${SCRIPTS} ${DESTDIR}${PREFIX}/bin
for f in ${BIN}; do chmod 755 ${DESTDIR}${PREFIX}/bin/$$f; done
# installing example files.
mkdir -p ${DESTDIR}${DOCPREFIX}
@@ -98,6 +103,7 @@ install: all
uninstall:
# removing executable files.
for f in ${BIN}; do rm -f ${DESTDIR}${PREFIX}/bin/$$f; done
+ for f in ${SCRIPTS}; do rm -f ${DESTDIR}${PREFIX}/bin/$$f; done
# removing example files.
rm -f \
${DESTDIR}${DOCPREFIX}/style.css\
diff --git a/stagit-gen-index b/stagit-gen-index
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Author: Cale "poptart" Black
+# License: MIT
+
+set -eu
+. /home/git/config.rc
+stagit-index "$GIT_HOME"/*.git > "$WWW_HOME/index.html"
diff --git a/stagit-newrepo b/stagit-newrepo
@@ -0,0 +1,57 @@
+#!/bin/sh
+# Author: Cale "poptart" Black
+# License: MIT
+
+set -eu
+. /home/git/config.rc
+e_log() {
+ printf '%s\n' "$*"
+}
+
+e_err() {
+ printf '%s\n' "$*" >&2
+}
+
+e_exit() {
+ e_err "$*"
+ exit 1
+}
+
+DESC=""
+REPO=""
+
+if [ $# -gt 1 ]; then
+ DESC="$2"
+else
+ DESC="$DEFAULT_DESCRIPTION"
+fi
+
+if [ $# -gt 2 ]; then
+ BRANCH_NAME="$3"
+else
+ BRANCH_NAME="master"
+fi
+
+if [ $# -eq 0 ]; then
+ e_exit "not enough args"
+else
+ REPO="$(basename "$1")"
+fi
+
+git init --bare "$GIT_HOME/$REPO.git" -b "$BRANCH_NAME"
+cp "/home/git/hooks/post-receive" "$GIT_HOME/$REPO.git/hooks/post-receive"
+
+echo "$CLONE_URI/$REPO" > "$GIT_HOME/$REPO.git/url"
+echo "$DEFAULT_OWNER" > "$GIT_HOME/$REPO.git/owner"
+
+if [ -n "$DESC" ]; then
+ echo "$DESC" > "$GIT_HOME/$REPO.git/description"
+else
+ echo "this is a placeholder" > "$GIT_HOME/$REPO.git/description"
+fi
+
+chmod u+x "$GIT_HOME/$REPO.git/hooks/post-receive"
+
+mkdir "$WWW_HOME/$REPO"
+
+/usr/local/bin/stagit-gen-index
diff --git a/stagit-rebuild-all b/stagit-rebuild-all
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Author: awy
+# License: MIT
+
+. /home/git/config.rc
+
+echo "==> Starting stagit rebuild"
+echo " Repos: $GIT_HOME"
+echo " Output: $WWW_HOME"
+echo
+
+for repo in "$GIT_HOME"/*.git; do
+ [ -e "$repo" ] || continue
+
+ name=$(basename "$repo" .git)
+ outdir="$WWW_HOME/$name"
+
+ echo "==> Processing repo: $name"
+ echo " Source: $repo"
+ echo " Target: $outdir"
+
+ if [ ! -d "$outdir" ]; then
+ echo " Creating directory: $outdir"
+ if ! mkdir -p "$outdir"; then
+ echo " ERROR: failed to create $outdir" >&2
+ exit 1
+ fi
+ fi
+
+ echo " Running stagit..."
+ if (
+ cd "$outdir" &&
+ rm -rf "$outdir/*"
+ stagit "$repo" &&
+ ln -sf log.html index.html
+ ln -sf ../style.css style.css
+ ln -sf ../logo.png logo.png
+ ln -sf ../favicon.png favicon.png
+ ); then
+ echo " Done: $name"
+ else
+ echo " ERROR: stagit failed for $name" >&2
+ exit 1
+ fi
+
+ echo
+done
+
+echo "==> Updating index"
+stagit-gen-index
+
+echo "==> All repositories processed"