diff options
Diffstat (limited to 'debian/postinst')
| -rw-r--r-- | debian/postinst | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..f47ea01 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,54 @@ +#!/bin/bash +set -e +case "$1" in + configure) + # Create system user/group + if ! getent passwd witryna >/dev/null; then + adduser --system --group --no-create-home --home /var/lib/witryna witryna + fi + # Create data + log directories + install -d -o witryna -g witryna -m 0755 /var/lib/witryna + install -d -o witryna -g witryna -m 0755 /var/lib/witryna/clones + install -d -o witryna -g witryna -m 0755 /var/lib/witryna/builds + install -d -o witryna -g witryna -m 0755 /var/lib/witryna/cache + install -d -o witryna -g witryna -m 0755 /var/log/witryna + # Config file is installed by dpkg from the asset. + # Fix ownership so the witryna service can read it (Group=witryna in unit). + chown root:witryna /etc/witryna/witryna.toml + chmod 640 /etc/witryna/witryna.toml + # Auto-detect and configure container runtime + if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then + # Docker: add to docker group + install override + if getent group docker >/dev/null; then + usermod -aG docker witryna || true + fi + mkdir -p /etc/systemd/system/witryna.service.d + cp /usr/share/doc/witryna/examples/systemd/docker.conf \ + /etc/systemd/system/witryna.service.d/10-runtime.conf + chmod 644 /etc/systemd/system/witryna.service.d/10-runtime.conf + systemctl daemon-reload >/dev/null 2>&1 || true + echo "witryna: Docker detected and configured." + elif command -v podman >/dev/null 2>&1 && podman info >/dev/null 2>&1; then + # Podman: subuids + lingering + override + if ! grep -q "^witryna:" /etc/subuid 2>/dev/null; then + usermod --add-subuids 100000-165535 witryna || true + fi + if ! grep -q "^witryna:" /etc/subgid 2>/dev/null; then + usermod --add-subgids 100000-165535 witryna || true + fi + loginctl enable-linger witryna >/dev/null 2>&1 || true + mkdir -p /etc/systemd/system/witryna.service.d + cp /usr/share/doc/witryna/examples/systemd/podman.conf \ + /etc/systemd/system/witryna.service.d/10-runtime.conf + chmod 644 /etc/systemd/system/witryna.service.d/10-runtime.conf + systemctl daemon-reload >/dev/null 2>&1 || true + echo "witryna: Podman detected and configured." + else + echo "witryna: WARNING — no container runtime (docker/podman) detected." + echo " Install one, then reinstall this package or copy an override from" + echo " /usr/share/doc/witryna/examples/systemd/ manually." + fi + ;; +esac +#DEBHELPER# +exit 0 |
