From 5d12f42bb6d8f339dbe76689a0fb2afa51f994d9 Mon Sep 17 00:00:00 2001 From: Wynn Wolf Arbor Date: Wed, 27 May 2020 21:48:14 +0200 Subject: cgit-chroot: Rename to skein-infra Be more clear about the purpose of this script and rename it to "skein-infra" since users might expect a program carrying "chroot" in its name to enter or otherwise manage a chroot. Additionally, use a consistent format for the environment variables controlling the locations of the cgit chroot and git repositories. --- Makefile | 4 ++-- README.md | 2 +- cgit-chroot | 77 ------------------------------------------------------------- skein-infra | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 80 deletions(-) delete mode 100755 cgit-chroot create mode 100755 skein-infra diff --git a/Makefile b/Makefile index 9c44387..02257a8 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,9 @@ LDFLAGS ?= -static cgit-about-filter: cgit-about-filter.c ${CC} -o $@ ${CFLAGS} ${LDFLAGS} $< -install: cgit-chroot cgit-about-filter - install -D -m 755 -t '${DESTDIR}${LIBEXECDIR}/skein' cgit-chroot +install: cgit-about-filter skein-infra install -D -m 755 -t '${DESTDIR}${LIBEXECDIR}/skein' cgit-about-filter + install -D -m 755 -t '${DESTDIR}${LIBEXECDIR}/skein' skein-infra clean: rm cgit-about-filter diff --git a/README.md b/README.md index a0cd413..ffa0751 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,6 @@ extensible deployment of cgit using OpenBSD's slowcgi(8). ## Utilities -- cgit-chroot - set up skein's cgit chroot environment +- skein-infra - set up skein's cgit chroot infrastructure - cgit-about-filter - a C implementation of a simple about-filter for cgit using mandoc(1) and lowdown(1). diff --git a/cgit-chroot b/cgit-chroot deleted file mode 100755 index 5d229db..0000000 --- a/cgit-chroot +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -set -e - -CGIT_CHROOT=${CGIT_CHROOT:-/srv/cgit} -CGIT_GIT_ROOT=${CGIT_GIT_ROOT:-/srv/git} - -usage() { - printf 'usage: cgit-chroot setup|teardown\n' >&2 - exit 1 -} - -log() { - printf ' %s %s\n' "$1" "$2" -} - -ladd() { - log + "$1" -} - -ldel() { - log - "$1" -} - -remove_prefix() { - printf "%s" "${1#$CGIT_CHROOT/*}" -} - -bind_mount() { - mkdir "$2" - mount --rbind "$1" "$2" - mount --make-rslave "$2" - ladd "$(remove_prefix "$2")" -} - -bind_umount() { - umount "$i" - rmdir "$i" - ldel "$(remove_prefix "$i")" -} - -setup() { - mkdir "$CGIT_CHROOT"/dev - mknod "$CGIT_CHROOT"/dev/null c 1 3 - chmod 666 "$CGIT_CHROOT"/dev/null - - for i in "$CGIT_CHROOT"/instances/*; do - test -d "$i" || continue - user=$(basename "$i") - id -ru "$user" >/dev/null || continue - - git_repo_dir="${CGIT_GIT_ROOT}/$user" - test -d "$git_repo_dir" || continue - - instance_repo_dir="$CGIT_CHROOT"/instances/$user/repos - - bind_mount "$git_repo_dir" "$instance_repo_dir" - chmod 0701 "$instance_repo_dir" - done -} - -teardown() { - rm "$CGIT_CHROOT"/dev/null - rmdir "$CGIT_CHROOT"/dev - - for i in "$CGIT_CHROOT"/instances/*/repos; do - bind_umount "$i" - done -} - -test $# -eq 1 || usage - -case $1 in - setup) setup;; - teardown) teardown;; - *) usage;; -esac diff --git a/skein-infra b/skein-infra new file mode 100755 index 0000000..44f55a5 --- /dev/null +++ b/skein-infra @@ -0,0 +1,77 @@ +#!/bin/sh + +set -e + +SKEIN_CGIT_ROOT=${SKEIN_CGIT_ROOT:-/srv/cgit} +SKEIN_GIT_ROOT=${SKEIN_GIT_ROOT:-/srv/git} + +usage() { + printf 'usage: skein-infra setup|teardown\n' >&2 + exit 1 +} + +log() { + printf ' %s %s\n' "$1" "$2" +} + +ladd() { + log + "$1" +} + +ldel() { + log - "$1" +} + +remove_prefix() { + printf "%s" "${1#$SKEIN_CGIT_ROOT/*}" +} + +bind_mount() { + mkdir "$2" + mount --rbind "$1" "$2" + mount --make-rslave "$2" + ladd "$(remove_prefix "$2")" +} + +bind_umount() { + umount "$i" + rmdir "$i" + ldel "$(remove_prefix "$i")" +} + +setup() { + mkdir "$SKEIN_CGIT_ROOT"/dev + mknod "$SKEIN_CGIT_ROOT"/dev/null c 1 3 + chmod 666 "$SKEIN_CGIT_ROOT"/dev/null + + for i in "$SKEIN_CGIT_ROOT"/instances/*; do + test -d "$i" || continue + user=$(basename "$i") + id -ru "$user" >/dev/null || continue + + git_repo_dir="${SKEIN_GIT_ROOT}/$user" + test -d "$git_repo_dir" || continue + + instance_repo_dir="$SKEIN_CGIT_ROOT"/instances/$user/repos + + bind_mount "$git_repo_dir" "$instance_repo_dir" + chmod 0701 "$instance_repo_dir" + done +} + +teardown() { + rm "$SKEIN_CGIT_ROOT"/dev/null + rmdir "$SKEIN_CGIT_ROOT"/dev + + for i in "$SKEIN_CGIT_ROOT"/instances/*/repos; do + bind_umount "$i" + done +} + +test $# -eq 1 || usage + +case $1 in + setup) setup;; + teardown) teardown;; + *) usage;; +esac -- cgit v1.2.3-2-gb3c3