From 4d657656cd286624126359bade680a56b49eee3d Mon Sep 17 00:00:00 2001 From: Job79 Date: Sun, 8 Nov 2026 11:31:37 +0100 Subject: [PATCH] refactor(devc): harden entry script - Resolve config.sh relative to the real script path (works via symlink). - Don't silently swallow errors from config.sh. - Default DEVC_REGISTRY to git.plabble.org/job79. - Add -no-pull to start without contacting the registry. - Host wrappers explain how to enable host-spawn instead of failing obscurely. Co-Authored-By: Claude Opus 5.5 --- bin/devc | 12 ++++++------ containers/base/bin/host | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/devc b/bin/devc index f7f2dc9..01fd319 100755 --- a/bin/devc +++ b/bin/devc @@ -1,6 +1,6 @@ #!/bin/bash # =============================================== # -# devc.sh v2.1; job79, maurice # +# devc.sh v2.2; job79, maurice # # Dev container entry script. # # =============================================== # set -euo pipefail @@ -23,11 +23,11 @@ default_args() { # Desktop integration (Wayland, SSH). [[ -e "/run/user/$UID/wayland-0" ]] && run_opts+=("-v" "/run/user/$UID/wayland-0:/run/user/1000/wayland-0") - [[ -e "${SSH_AUTH_SOCK:-}" ]] && run_opts+=("-v" "$SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock" "-e" "SSH_AUTH_SOCK=/run/user/1000/ssh-auth-sock") + [[ -e "${SSH_AUTH_SOCK:-}" ]] && run_opts+=("-v" "$SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock") # Load custom container config. - local config_file="${BASH_SOURCE[0]%/*}/../containers/$name/config.sh" - [[ -f "$config_file" ]] && source "$config_file" || true + local config_file="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/../containers/$name/config.sh" + [[ ! -f "$config_file" ]] || source "$config_file" } # param_args parses CLI arguments into podman run options. @@ -35,6 +35,7 @@ param_args() { while (($# > 0)); do case "$1" in -gpu) run_opts+=("--device" "/dev/dri") ;; + -no-pull) run_opts+=("--pull=never") ;; -host-spawn) run_opts+=("-v" "/run/user/$UID/bus:/tmp/bus" "-e" "HOST_HOME=$HOME") ;; -container-sock) run_opts+=("-v" "$XDG_RUNTIME_DIR/podman/podman.sock:/var/run/docker.sock") ;; -x11) run_opts+=("-v" "/tmp/.X11-unix:/tmp/.X11-unix" "-v" "$XAUTHORITY:/run/user/1000/.Xauthority:ro" "-e" "DISPLAY=$DISPLAY" "-e" "XAUTHORITY=/run/user/1000/.Xauthority") ;; @@ -68,8 +69,7 @@ main() { default_args param_args "$@" - [[ -n "${DEVC_REGISTRY:-}" ]] || die "registry unknown; set the DEVC_REGISTRY environment variable" - podman run --replace --stop-timeout 0 -td "${run_opts[@]}" "$DEVC_REGISTRY/$image" + podman run --replace --stop-timeout 0 -td "${run_opts[@]}" "${DEVC_REGISTRY:-git.plabble.org/job79}/$image" fi exec podman exec --detach-keys "ctrl-@,ctrl-@" -it "$name" ${DEVC_COMMAND:-bash -l} diff --git a/containers/base/bin/host b/containers/base/bin/host index f66d0aa..ac9a198 100755 --- a/containers/base/bin/host +++ b/containers/base/bin/host @@ -1,5 +1,6 @@ #!/bin/bash export DBUS_SESSION_BUS_ADDRESS="unix:path=/tmp/bus" +[[ -S /tmp/bus ]] || { echo "host-spawn unavailable: restart with 'devc -host-spawn'" >&2; exit 1; } cmd="${0##*/}" [[ "$cmd" == "host" ]] && unset cmd