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 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-08 11:46:59 +01:00
1 parent 12534d3afd
commit 4d657656cd
2 files changed
+7 -6

No files matched your search

+6 -6
View File
@@ -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}