From e6359a9ceb5fba89ab0d152ce6ead2da7b8afa57 Mon Sep 17 00:00:00 2001 From: memdmp Date: Fri, 3 Jan 2025 01:03:27 +0100 Subject: feat: a sensible setup, for once --- contrib/build | 6 ++++++ contrib/launch | 4 ++++ contrib/setup-img | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100755 contrib/build create mode 100755 contrib/launch create mode 100755 contrib/setup-img (limited to 'contrib') diff --git a/contrib/build b/contrib/build new file mode 100755 index 0000000..f071a5d --- /dev/null +++ b/contrib/build @@ -0,0 +1,6 @@ +#!/bin/zsh +set -eax +IMG="${IMG:-"docker.io/memdmp/cgit:${TAG:-"local-build"}"}" +! podman container exists cgit >/dev/null 2>/dev/null || podman container rm cgit +! podman image exists "$IMG" >/dev/null 2>/dev/null || podman image rm "$IMG" +podman build -t "$IMG" . diff --git a/contrib/launch b/contrib/launch new file mode 100755 index 0000000..0124c70 --- /dev/null +++ b/contrib/launch @@ -0,0 +1,4 @@ +#!/bin/zsh +set -eax +podman container exists cgit || ("$(dirname "$(realpath "$0")")/setup-img" 2>&1 | tee /tmp/setup || (grep 'First launch: container is now shut down' /tmp/setup && rm /tmp/setup)) +podman start -ia cgit diff --git a/contrib/setup-img b/contrib/setup-img new file mode 100755 index 0000000..879f383 --- /dev/null +++ b/contrib/setup-img @@ -0,0 +1,38 @@ +#!/bin/zsh +set -eax + +__filename="$(realpath "$0")" +__dirname="$(dirname "${__filename})" +if [[ -f "$__dirname/.env" ]]; then + source "$__dirname/.env" +fi + +IMG="${IMG:-"docker.io/memdmp/cgit:${TAG:-"local-build"}"}" +SSH_DIR="${SSH_DIR:-"$HOME/.ssh"}" +SSH_KEY="${SSH_KEY:-"$(ls "$SSH_DIR/id_*.pub" | head -n 1)"}" +if [[ -f "$SSH_KEY" ]]; then + SSH_KEY="$(cat "$SSH_KEY")" +elif [[ -f "$SSH_DIR/$SSH_KEY.pub" ]]; then + SSH_KEY="$(cat "$SSH_DIR/$SSH_KEY.pub")" +elif [[ -f "$SSH_DIR/id_$SSH_KEY.pub" ]]; then + SSH_KEY="$(cat "$SSH_DIR/id_$SSH_KEY.pub")" +elif [[ -f "$SSH_DIR/$SSH_KEY" ]]; then + SSH_KEY="$(cat "$SSH_DIR/$SSH_KEY")" +elif [[ -f "$SSH_DIR/id_$SSH_KEY" ]]; then + SSH_KEY="$(cat "$SSH_DIR/id_$SSH_KEY")" +fi + +mkdir -p cgit/{ssh,git} +! podman container exists cgit >/dev/null 2>/dev/null || podman container rm cgit +! podman network exists cgit >/dev/null 2>/dev/null || podman network rm cgit +podman network create cgit +podman create \ + --name cgit \ + --network cgit \ + -v "$(pwd)/cgit/ssh:/etc/ssh:rw" \ + -v "$(pwd)/cgit/git:/var/lib/git:rw" \ + -p 127.0.0.1:18080:80 \ + -p 127.0.0.1:12222:22 \ + -e "SSH_KEY=${SSH_KEY}" \ + "$IMG" "$@" +podman start -ia cgit -- cgit v1.2.3