diff options
| author | Jan Sydänviita <jan@sydanviita.fi> | 2026-08-21 16:12:48 +0300 |
|---|---|---|
| committer | Jan Sydänviita <jan@sydanviita.fi> | 2026-08-21 16:12:48 +0300 |
| commit | 07b45bc892b636dd55472d0a4510c0b064418c01 (patch) | |
| tree | 0ba0470bbbd6e680a1eb8e396058d4b07a66f5ab /roles/jails/22_forge/files | |
| parent | 6f1ab23e5e4210e8167011e0fea1e1504fdd566e (diff) | |
Update forge
Diffstat (limited to 'roles/jails/22_forge/files')
| -rw-r--r-- | roles/jails/22_forge/files/footer.html | 5 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/help | 15 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/ls | 13 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/mirror | 75 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/mirror-from | 44 | ||||
| -rw-r--r-- | roles/jails/22_forge/files/git-shell-commands/mirror-to | 44 |
6 files changed, 98 insertions, 98 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> — 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" |
