aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jails
diff options
context:
space:
mode:
authorJan Sydänviita <jan@sydanviita.fi>2026-08-21 16:12:48 +0300
committerJan Sydänviita <jan@sydanviita.fi>2026-08-21 16:12:48 +0300
commit07b45bc892b636dd55472d0a4510c0b064418c01 (patch)
tree0ba0470bbbd6e680a1eb8e396058d4b07a66f5ab /roles/jails
parent6f1ab23e5e4210e8167011e0fea1e1504fdd566e (diff)
Update forge
Diffstat (limited to 'roles/jails')
-rw-r--r--roles/jails/22_forge/files/footer.html5
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/help15
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/ls13
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/mirror75
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/mirror-from44
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/mirror-to44
-rw-r--r--roles/jails/22_forge/tasks/main.yml26
-rw-r--r--roles/jails/22_forge/templates/usr_local_etc_cgitrc.j21
8 files changed, 108 insertions, 115 deletions
diff --git a/roles/jails/22_forge/files/footer.html b/roles/jails/22_forge/files/footer.html
new file mode 100644
index 0000000..2774ace
--- /dev/null
+++ b/roles/jails/22_forge/files/footer.html
@@ -0,0 +1,5 @@
+<div class="footer">
+ <p>Want to contribute? Host your changes somewhere and send me the link: jan (at) sydanviita.fi. Also, check out my <a href="https://jan.systems" target="_blank">website</a>.</p>
+ <br>
+ <a href="https://forge.jan.systems">forge.jan.systems</a> &mdash; powered by <a href="https://git.zx2c4.com/cgit/">cgit</a>
+</div>
diff --git a/roles/jails/22_forge/files/git-shell-commands/help b/roles/jails/22_forge/files/git-shell-commands/help
index acd24a9..0494ae3 100644
--- a/roles/jails/22_forge/files/git-shell-commands/help
+++ b/roles/jails/22_forge/files/git-shell-commands/help
@@ -2,12 +2,13 @@
cat <<EOF
Available commands:
- new [REPO_NAME] create a new bare repository
- ls list repositories
- describe [REPO_NAME] [DESCRIPTION] set repository description
- rename [OLD_NAME] [NEW_NAME] rename a repository
- delete [REPO_NAME] delete a repository
- mirror-to [REPO_NAME] [GIT_URL] set up hourly mirror to a remote git URL
- mirror-from [REPO_NAME] [GIT_URL] set up hourly fetch from a remote git URL
+ new [REPO_NAME] create a new bare repository
+ ls list repositories
+ describe [REPO_NAME] [DESCRIPTION] set repository description
+ rename [OLD_NAME] [NEW_NAME] rename a repository
+ delete [REPO_NAME] delete a repository
+ mirror [REPO_NAME] to [GIT_URL] set up hourly push mirror to a remote
+ from [GIT_URL] set up hourly fetch mirror from a remote
+ delete remove mirror
EOF
diff --git a/roles/jails/22_forge/files/git-shell-commands/ls b/roles/jails/22_forge/files/git-shell-commands/ls
index ef5d3e5..d72fa9a 100644
--- a/roles/jails/22_forge/files/git-shell-commands/ls
+++ b/roles/jails/22_forge/files/git-shell-commands/ls
@@ -1,4 +1,11 @@
#!/bin/sh
-find . -maxdepth 1 -type d -name "*.git" | while read repo; do
- basename "$repo" .git
-done | sort
+find . -maxdepth 1 -type d -name "*.git" | sort | while read repo; do
+ name="$(basename "$repo" .git)"
+ desc="$(cat "$repo/description" 2>/dev/null)"
+ mirror_to="$(git -C "$repo" remote get-url mirror-to 2>/dev/null)"
+ mirror_from="$(git -C "$repo" remote get-url mirror-from 2>/dev/null)"
+
+ printf "%-30s %s\n" "$name" "$desc"
+ [ -n "$mirror_to" ] && printf " %-28s -> %s\n" "" "$mirror_to"
+ [ -n "$mirror_from" ] && printf " %-28s <- %s\n" "" "$mirror_from"
+done
diff --git a/roles/jails/22_forge/files/git-shell-commands/mirror b/roles/jails/22_forge/files/git-shell-commands/mirror
new file mode 100644
index 0000000..30237af
--- /dev/null
+++ b/roles/jails/22_forge/files/git-shell-commands/mirror
@@ -0,0 +1,75 @@
+#!/bin/sh
+# mirror [REPO] to [URL] - set up hourly push mirror
+# mirror [REPO] from [URL] - set up hourly fetch mirror
+# mirror [REPO] delete - remove any mirror
+
+_usage() {
+ echo "Usage:"
+ echo " mirror [REPO] to [URL] set up hourly push mirror"
+ echo " mirror [REPO] from [URL] set up hourly fetch mirror"
+ echo " mirror [REPO] delete remove any mirror"
+ exit "${1:-0}"
+}
+
+[ -z "$1" ] && _usage
+[ -z "$2" ] && _usage
+
+REPO="$1"
+CMD="$2"
+ARG="$3"
+REPO_PATH="$HOME/$REPO.git"
+
+if [ ! -d "$REPO_PATH" ]; then
+ echo "Repository $REPO does not exist"
+ exit 1
+fi
+
+cd "$REPO_PATH" || exit 1
+
+case "$CMD" in
+to)
+ [ -z "$ARG" ] && _usage 1
+ if git remote get-url mirror-from >/dev/null 2>&1; then
+ echo "Error: $REPO already has a mirror-from. Remove it first with: mirror $REPO delete"
+ exit 1
+ fi
+ if git remote get-url mirror-to >/dev/null 2>&1; then
+ git remote set-url mirror-to "$ARG"
+ else
+ git remote add mirror-to "$ARG"
+ fi
+ echo "Configured $REPO to mirror to $ARG"
+ echo "Runs hourly. Logs: /var/log/git-mirrors.log"
+ ;;
+from)
+ [ -z "$ARG" ] && _usage 1
+ if git remote get-url mirror-to >/dev/null 2>&1; then
+ echo "Error: $REPO already has a mirror-to. Remove it first with: mirror $REPO delete"
+ exit 1
+ fi
+ if git remote get-url mirror-from >/dev/null 2>&1; then
+ git remote set-url mirror-from "$ARG"
+ else
+ git remote add mirror-from "$ARG"
+ fi
+ echo "Configured $REPO to mirror from $ARG"
+ echo "Runs hourly. Logs: /var/log/git-mirrors.log"
+ ;;
+delete)
+ removed=0
+ if git remote get-url mirror-to >/dev/null 2>&1; then
+ git remote remove mirror-to
+ echo "Removed mirror-to for $REPO"
+ removed=1
+ fi
+ if git remote get-url mirror-from >/dev/null 2>&1; then
+ git remote remove mirror-from
+ echo "Removed mirror-from for $REPO"
+ removed=1
+ fi
+ [ "$removed" -eq 0 ] && echo "No mirror configured for $REPO"
+ ;;
+*)
+ _usage 1
+ ;;
+esac
diff --git a/roles/jails/22_forge/files/git-shell-commands/mirror-from b/roles/jails/22_forge/files/git-shell-commands/mirror-from
deleted file mode 100644
index 2666cac..0000000
--- a/roles/jails/22_forge/files/git-shell-commands/mirror-from
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-# mirror-from [REPO_NAME] [GIT_URL]
-# Configures a repo to pull updates from a remote git URL hourly.
-# Pass empty URL to remove the mirror source.
-# Example: mirror-from myrepo https://github.com/user/myrepo.git
-if [ -z "$1" ]; then
- echo "Usage: mirror-from [REPO_NAME] [GIT_URL]"
- echo " mirror-from [REPO_NAME] - remove mirror source"
- exit 1
-fi
-if [ ! -d "$1.git" ]; then
- echo "Repository $1 does not exist"
- exit 1
-fi
-
-REPO="$1"
-REMOTE="$2"
-REPO_PATH="$HOME/$REPO.git"
-
-cd "$REPO_PATH" || exit 1
-
-if [ -z "$REMOTE" ]; then
- if git remote get-url mirror-from >/dev/null 2>&1; then
- git remote remove mirror-from
- echo "Removed mirror source for $REPO"
- else
- echo "No mirror source configured for $REPO"
- fi
- exit 0
-fi
-
-if git remote get-url mirror-to >/dev/null 2>&1; then
- echo "Error: $REPO already has a mirror-to configured. Remove it first with: mirror-to $REPO"
- exit 1
-fi
-
-if git remote get-url mirror-from >/dev/null 2>&1; then
- git remote set-url mirror-from "$REMOTE"
-else
- git remote add mirror-from "$REMOTE"
-fi
-
-echo "Configured $REPO to mirror from $REMOTE"
-echo "Mirrors run hourly. Logs: /var/log/git-mirrors.log"
diff --git a/roles/jails/22_forge/files/git-shell-commands/mirror-to b/roles/jails/22_forge/files/git-shell-commands/mirror-to
deleted file mode 100644
index 6a0c20e..0000000
--- a/roles/jails/22_forge/files/git-shell-commands/mirror-to
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-# mirror-to [REPO_NAME] [GIT_URL]
-# Configures a repo to be mirrored hourly to a remote git URL.
-# Example: mirror-to myrepo git@example.com:user/myrepo.git
-if [ -z "$1" ]; then
- echo "Usage: mirror-to [REPO_NAME] [GIT_URL]"
- echo " mirror-to [REPO_NAME] - remove mirror"
- echo "Example: mirror-to myrepo git@example.com:user/myrepo.git"
- exit 1
-fi
-if [ ! -d "$1.git" ]; then
- echo "Repository $1 does not exist"
- exit 1
-fi
-
-REPO="$1"
-REMOTE="$2"
-REPO_PATH="$HOME/$REPO.git"
-
-cd "$REPO_PATH" || exit 1
-
-if [ -z "$REMOTE" ]; then
- if git remote get-url mirror-to >/dev/null 2>&1; then
- git remote remove mirror-to
- echo "Removed mirror for $REPO"
- else
- echo "No mirror configured for $REPO"
- fi
- exit 0
-fi
-
-if git remote get-url mirror-from >/dev/null 2>&1; then
- echo "Error: $REPO already has a mirror-from configured. Remove it first with: mirror-from $REPO"
- exit 1
-fi
-
-if git remote get-url mirror-to >/dev/null 2>&1; then
- git remote set-url mirror-to "$REMOTE"
-else
- git remote add mirror-to "$REMOTE"
-fi
-
-echo "Configured $REPO to mirror to $REMOTE"
-echo "Mirrors run hourly. Logs: /var/log/git-mirrors.log"
diff --git a/roles/jails/22_forge/tasks/main.yml b/roles/jails/22_forge/tasks/main.yml
index e837d72..24fe362 100644
--- a/roles/jails/22_forge/tasks/main.yml
+++ b/roles/jails/22_forge/tasks/main.yml
@@ -26,23 +26,7 @@
- delete
- rename
- describe
- - mirror-to
- - mirror-from
-
-# --- Remove legacy git user ---
-
-- name: Remove legacy git user
- user:
- name: git
- state: absent
- remove: false
- ignore_errors: true
-
-- name: Remove legacy git group
- group:
- name: git
- state: absent
- ignore_errors: true
+ - mirror
# --- Forge users ---
@@ -202,6 +186,14 @@
group: wheel
mode: "0644"
+- name: Deploy cgit footer
+ copy:
+ src: "{{ jail_role_dir }}/files/footer.html"
+ dest: /usr/local/etc/cgit/footer.html
+ owner: root
+ group: wheel
+ mode: "0644"
+
- name: Deploy custom cgit.css
copy:
src: "{{ jail_role_dir }}/files/cgit.css"
diff --git a/roles/jails/22_forge/templates/usr_local_etc_cgitrc.j2 b/roles/jails/22_forge/templates/usr_local_etc_cgitrc.j2
index 7a0e040..a1e7c9e 100644
--- a/roles/jails/22_forge/templates/usr_local_etc_cgitrc.j2
+++ b/roles/jails/22_forge/templates/usr_local_etc_cgitrc.j2
@@ -2,6 +2,7 @@ css=/cgit.css
logo=/cgit.png
favicon=/favicon.ico
head-include=/usr/local/etc/cgit/head-include.html
+footer=/usr/local/etc/cgit/footer.html
virtual-root=/