commit 8391966e35ae627988856f47368ef5af73b2f25e
parent 5b20357641d0daf728b6e92896deca6f8ec7c981
Author: Christian Ermann <christianermann@gmail.com>
Date: Wed, 17 Apr 2024 21:12:16 -0400
Add scripts and license
Diffstat:
5 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2024 Christian Ermann
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/config.rc b/config.rc
@@ -0,0 +1,8 @@
+WWW_ROOT="/var/www/htdocs/git.christianermann.dev"
+GIT_ROOT="/home/git"
+CSS_PATH="/home/git/stagit/style.css"
+URI_BASE="git://git.christianermann.dev"
+
+DEFAULT_OWNER="Christian Ermann"
+DEFAULT_DESCRIPTION=""
+
diff --git a/install.sh b/install.sh
@@ -0,0 +1,5 @@
+chown root:wheel /home/git/config.rc
+
+ln -s repo-init.sh /usr/local/bin/repo-init
+ln -s repo-site.sh /usr/local/bin/repo-site
+ln -s config.rc /home/git/config.rc
diff --git a/repo-init.sh b/repo-init.sh
@@ -0,0 +1,15 @@
+#! /bin/sh
+
+CONFIG_PATH="/home/git/config.rc"
+. "${CONFIG_PATH}"
+
+REPO="$1"
+DESC="${2:-$DEFAULT_DESCRIPTION}"
+OWNER="${3:-$DEFAULT_OWNER}"
+
+REPO_PATH="${GIT_ROOT}/${REPO}"
+
+git init --bare "${REPO_PATH}"
+printf "%s\n" "${OWNER}" > "${REPO_PATH}/owner"
+printf "%s\n" "${DESC}" > "${REPO_PATH}/description"
+touch "${REPO_PATH}/git-daemon-export-ok"
diff --git a/repo-site.sh b/repo-site.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+
+CONFIG_PATH="/home/git/config.rc"
+. "${CONFIG_PATH}"
+
+# Build a list of all public repos. This is denoted by the existence of a
+# file named `git-daemon-export-ok`.
+repos=""
+repos_stripped=""
+printf "Publishing:\n"
+for repo in "${GIT_ROOT}"/*; do
+ if [ -f "${repo}/git-daemon-export-ok" ]; then
+ repo_stripped="${repo#"$GIT_ROOT/"}"
+ repos="$repo $repos"
+ repos_stripped="${repo_stripped} $repos_stripped"
+ printf " - %s\n" "${repo_stripped}"
+
+ # Add files to specify repo metadata
+ printf "%s/%s\n" "${URI_BASE}" "${repo_stripped}" > "${repo}/url"
+ fi
+done
+
+# Build 'repos' page.
+cd "${WWW_ROOT}"
+stagit-index $repos > index.html
+cp "${CSS_PATH}" style.css
+
+# Build pages for each repo.
+for repo in $repos_stripped; do
+ mkdir -p "${WWW_ROOT}/${repo}" && cd "${WWW_ROOT}/${repo}"
+ stagit "${GIT_ROOT}/${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
+done