aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Rodrigues Lordello <[email protected]>2026-03-22 12:19:53 +0100
committerNicholas Rodrigues Lordello <[email protected]>2026-03-22 12:19:53 +0100
commit6ee7d7dff885f28589737e93143c5fc29fc965d1 (patch)
treee4319c34669a84b218579ba1f5d7a69319ddc878
parent9c52e2228d5d408645b49a264e16dc5943b12c8f (diff)
Enter and Run in a Devbox
You can now enter and run commands in a devbox.
-rwxr-xr-xdbx-create24
-rwxr-xr-xdbx-enter8
-rwxr-xr-xdbx-init16
-rwxr-xr-xdbx-run32
4 files changed, 64 insertions, 16 deletions
diff --git a/dbx-create b/dbx-create
index bce4f89..8a35097 100755
--- a/dbx-create
+++ b/dbx-create
@@ -4,15 +4,21 @@
set -euo pipefail
r="$HOME/.dbx"
+c="dbx"
d="$HOME/Developer/dbxroot"
+if podman container exists dbx; then
+ echo "already created"
+ exit
+fi
+
podman create \
- --hostname dbx \
- --label manager=dbx \
- --name dbx \
- --user root:root \
- --userns keep-id \
- --volume "$d:$d:z" \
- --volume "$r/dbx-init:/usr/local/bin/dbx-init:ro,z" \
- registry.fedoraproject.org/fedora-toolbox:43 \
- dbx-init
+ --hostname dbx \
+ --label manager=dbx \
+ --name "$c" \
+ --user root:root \
+ --userns keep-id \
+ --volume "$d:$d:z" \
+ --volume "$r/dbx-init:/usr/local/bin/dbx-init:ro,z" \
+ registry.fedoraproject.org/fedora-toolbox:43 \
+ dbx-init "$(id -u)" "$(id -g)"
diff --git a/dbx-enter b/dbx-enter
new file mode 100755
index 0000000..f4661d9
--- /dev/null
+++ b/dbx-enter
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: 0BSD
+
+set -euo pipefail
+
+r="$HOME/.dbx"
+
+"$r/dbx-run" fish --login
diff --git a/dbx-init b/dbx-init
index 21f8450..c2f9b54 100755
--- a/dbx-init
+++ b/dbx-init
@@ -4,10 +4,12 @@
set -euo pipefail
if [[ ! -f /run/.containerenv ]]; then
- echo "ERROR: not in a container." >&2
+ echo "ERROR: not in a container" >&2
fi
-h=/dbx
+h="/dbx"
+u="${1:-1000}"
+g="${2:-1000}"
dnf install -y \
fish \
@@ -16,16 +18,16 @@ dnf install -y \
ripgrep \
vim-enhanced
-if [[ ! -d $h ]]; then
+if [[ ! -d "$h" ]]; then
usermod \
- --home $h \
+ --home "$h" \
--groups wheel \
--password "" \
--shell $(command -v fish) \
- $(id -nu 1000)
+ $(id -nu "$u")
- mkdir --parents $h
- chown --recursive 1000:1000 $h
+ mkdir --parents "$h"
+ chown --recursive "$u:$g" "$h"
fi
touch /run/.dbxenv
diff --git a/dbx-run b/dbx-run
new file mode 100755
index 0000000..b8a2e52
--- /dev/null
+++ b/dbx-run
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: 0BSD
+
+set -euo pipefail
+
+if [[ $# -lt 1 ]]; then
+ echo "ERROR: missing command to run" >&2
+ exit 1
+fi
+
+c="dbx"
+d="$HOME/Developer/dbxroot"
+
+w="$(realpath "$PWD")"
+if [[ "$w" != "$d"* ]]; then
+ w="$d"
+fi
+
+tty="tty"
+if [[ ! -t 0 ]]; then
+ tty="tty=false"
+fi
+
+podman start "$c" >/dev/null
+exec podman exec \
+ --detach-keys "" \
+ --interactive \
+ --"$tty" \
+ --user "$(id -u):$(id -g)" \
+ --workdir "$w" \
+ dbx \
+ "$@"