Files
alpine-devcontainers/enter.sh
2025-10-28 08:46:30 +01:00

37 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# Check if a name argument was provided
if [ -z "$1" ]; then
echo "Usage: $0 <name>"
exit 1
fi
name="devc-$1"
tag="main"
command="/bin/bash"
# When container is not running or arguments are provided,
# recreate it.
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" != 'true' ]; then
echo "starting devcontainer..."
podman container rm -f -t 0 "$name" 1>/dev/null
podman run \
--security-opt label=disable \
--userns=keep-id \
--name $name \
--network host \
-e HOST_HOME=$HOME \
-e SSH_AUTH_SOCK='/tmp/ssh.sock' \
-e XDG_RUNTIME_DIR='/tmp/xdg' \
-e WAYLAND_DISPLAY=wayland-0 \
-v /run/user/$UID/bus:/tmp/dbus.sock \
-v /run/user/$UID/keyring/ssh:/tmp/ssh.sock \
-v /run/user/$UID/podman/podman.sock:/tmp/podman.sock \
-v /run/user/$UID/wayland-0:/tmp/xdg/wayland-0 \
-v $HOME/dev:/home/user/dev \
-v v-$name:/home/user:copy \
--rm -td git.plabble.org/maurice/$name:$tag
fi
podman exec --detach-keys "ctrl-@" -it "$name" ${command:-}