From 214f4bab8b852e9b66d909bc22e5f9119da7dfb5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 29 Dec 2025 18:28:13 +0800 Subject: initial commit --- start_container.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 start_container.sh (limited to 'start_container.sh') diff --git a/start_container.sh b/start_container.sh new file mode 100755 index 0000000..bf1c167 --- /dev/null +++ b/start_container.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +# Load config +source "$(dirname "$0")/config.env" + +# Create network if not exists +if ! podman network exists ${NETWORK}; then + echo "Creating network: ${NETWORK} (subnet: ${PRIVATE_SUBNET})" + podman network create --subnet=${PRIVATE_SUBNET} ${NETWORK} +else + echo "Network exists: ${NETWORK}" +fi + +# Stop existing container if running +podman stop ${CONTAINER_NAME} 2>/dev/null || true +podman rm ${CONTAINER_NAME} 2>/dev/null || true +ip route del ${PUBLIC_IP}/32 2>/dev/null || true + +# Run container +podman run -d \ + --name ${CONTAINER_NAME} \ + --network ${NETWORK} \ + --ip ${PRIVATE_IP} \ + --cap-add=NET_ADMIN \ + --env-file "$(dirname "$0")/config.env" \ + -v ${CONTAINER_NAME}_data:/data \ + -v /git:/git \ + localhost/cgit-caddy + +# Setup public IP +sleep 2 +IFACE=$(podman exec ${CONTAINER_NAME} sh -c "ip -o link | grep -v lo | head -1 | cut -d: -f2 | tr -d ' ' | cut -d@ -f1") +podman exec ${CONTAINER_NAME} ip addr add ${PUBLIC_IP}/32 dev ${IFACE} +ip route add ${PUBLIC_IP}/32 via ${PRIVATE_IP} + +echo "Running at https://${DOMAIN}/" -- cgit