aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Containerfile3
-rw-r--r--Makefile9
-rwxr-xr-xdbx-create45
-rwxr-xr-xdbx-enter2
-rwxr-xr-xdbx-proxy2
-rwxr-xr-xdbx-start6
-rw-r--r--ssh/config.in1
7 files changed, 25 insertions, 43 deletions
diff --git a/Containerfile b/Containerfile
index b808aab..84ba12e 100644
--- a/Containerfile
+++ b/Containerfile
@@ -30,6 +30,7 @@ RUN rm /etc/apt/apt.conf.d/docker-* && \
wget \
zip \
&& \
+ apt-get clean && \
rm -dr /var/lib/apt/lists/*
# Passwordless sudo
@@ -55,7 +56,9 @@ COPY --chmod=600 --chown=1000:1000 ssh/id_ed25519.pub /home/${USER}/.ssh/authori
COPY --chown=1000:1000 custom/ /home/${USER}/
RUN rm /home/${USER}/README.md
RUN if [ -f /home/${USER}/extra-packages ]; then \
+ apt-get update && \
apt-get install -y $(cat /home/${USER}/extra-packages | xargs) && \
+ apt-get clean && \
rm -dr /var/lib/apt/lists/* /home/${USER}/extra-packages; \
fi
RUN if [ -x /home/${USER}/post-install ]; then \
diff --git a/Makefile b/Makefile
index cacc8f8..c1da571 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,19 @@
.PHONY: all
-all: ssh/cofig .container;
- @ echo "install with 'make install'"
+all: .container ssh/config ;
.PHONY: install
install: all
mkdir -p $(HOME)/.local/bin
ln -s $(PWD)/dbx $(HOME)/.local/bin/dbx
+.container: Containerfile dbx-init ssh/id_ed25519.pub
+ container build --build-arg USER=$(USER) --pull --tag dbx .
+ touch $@
+
ssh/config: ssh/config.in ssh/id_ed25519.pub
cat $< \
| sed -e 's|$$PWD|$(PWD)|' \
> $@
-.container: ssh/id_ed25519.pub
-
ssh/id_% ssh/id_%.pub:
ssh-keygen -C "$$(id -un)@$$(hostname)" -f ssh/id_$* -N "" -t $*
diff --git a/dbx-create b/dbx-create
index 48b2633..18fb211 100755
--- a/dbx-create
+++ b/dbx-create
@@ -3,42 +3,15 @@
set -euo pipefail
-R="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
C="dbx"
-echo "TODO:"
-echo "- create temporary SSH key"
-echo "- generate SSH configuration for host and guest"
-echo "- create base container image"
-echo " - initialize user"
-echo " - add authorized keys for SSH login"
-echo " - install required packages (sshd and tini)"
-echo " - install nice to have packages (see toolbox image)"
-echo " - setup socket cleanup with sshd_config"
-echo "- magic encantation to create container"
+if ! container system status &>/dev/null; then
+ container system start
+fi
-#if ! id $DBX_USER &>/dev/null; then
-# useradd \
-# --comment "$DBX_USER_COMMENT" \
-# --create-home \
-# --groups sudo \
-# --shell /usr/bin/bash \
-# --uid 1000 \
-# --user-group \
-# $DBX_USER
-#fi
-# if container list --all | grep $C >/dev/null; then
-# echo "already created"
-# exit
-# fi
-# podman create \
-# --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)"
-# podman start "$c" >/dev/null
+if container list --all | grep $C >/dev/null; then
+ echo "already created"
+ exit
+fi
+
+container create --name $C --publish 4222:22 $C
diff --git a/dbx-enter b/dbx-enter
index 9ed911d..71d7d9a 100755
--- a/dbx-enter
+++ b/dbx-enter
@@ -6,5 +6,5 @@ set -euo pipefail
R="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
C="dbx"
-container start $C >/dev/null
+"$R/dbx-start"
exec ssh -F "$R/ssh/config" $C
diff --git a/dbx-proxy b/dbx-proxy
index 2eae026..b889f7f 100755
--- a/dbx-proxy
+++ b/dbx-proxy
@@ -12,5 +12,5 @@ R="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
C="dbx"
port="$1"
-container start "$C" >/dev/null
+"$R/dbx-start"
exec ssh -F "$R/ssh/config" -L "localhost:$port:localhost:$port" -N $C
diff --git a/dbx-start b/dbx-start
index b333fe7..4317345 100755
--- a/dbx-start
+++ b/dbx-start
@@ -5,4 +5,8 @@ set -euo pipefail
C="dbx"
-container start $C >/dev/null
+if ! container system status &>/dev/null; then
+ container system start
+fi
+
+container start $C
diff --git a/ssh/config.in b/ssh/config.in
index daf23b8..5184310 100644
--- a/ssh/config.in
+++ b/ssh/config.in
@@ -3,3 +3,4 @@ Host dbx
Port 4222
IdentitiesOnly yes
IdentityFile $PWD/ssh/id_ed25519
+ NoHostAuthenticationForLocalhost yes