aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/setup-img
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-01-03 01:03:27 +0100
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-01-03 01:03:27 +0100
commite6359a9ceb5fba89ab0d152ce6ead2da7b8afa57 (patch)
tree0751a2a4b358f850dac8c83a4ee74a155c6c6e59 /contrib/setup-img
parenta912704a1fdc06622466c9887051e1e0b2f5d42f (diff)
downloadcgit-oci-e6359a9ceb5fba89ab0d152ce6ead2da7b8afa57.tar.gz
cgit-oci-e6359a9ceb5fba89ab0d152ce6ead2da7b8afa57.tar.bz2
cgit-oci-e6359a9ceb5fba89ab0d152ce6ead2da7b8afa57.tar.lz
cgit-oci-e6359a9ceb5fba89ab0d152ce6ead2da7b8afa57.zip

feat: a sensible setup, for once

Diffstat (limited to 'contrib/setup-img')
-rwxr-xr-xcontrib/setup-img38
1 files changed, 38 insertions, 0 deletions
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