From 9530cd413a265901f74f66bee31b1089e0a90d05 Mon Sep 17 00:00:00 2001 From: "J. Elfring (i)" Date: Thu, 15 Dec 2022 11:28:41 +0100 Subject: [PATCH] Add wdockerd --- simpleDots/bin/wdockerd | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 simpleDots/bin/wdockerd diff --git a/simpleDots/bin/wdockerd b/simpleDots/bin/wdockerd new file mode 100755 index 0000000..4a37d26 --- /dev/null +++ b/simpleDots/bin/wdockerd @@ -0,0 +1,26 @@ +#!/bin/bash +############################################################################ +## +# wdockerd +# Start dockerd inside a tmux session for use in WSL +# +# + +## Ask for sudo credentials +sudo --validate + +if ! $(sudo --non-interactive /bin/true) +then + echo "We cannot become root with sudo. Exiting." + exit 1 +fi + +## Check for a tmux session with docker fo:wqr root is already running +if $(sudo --non-interactive bash -c 'tmux has-session -t wdockerd') +then + echo "A wdockerd session is already running. Attaching." + sudo --non-interactive tmux attach -t wdockerd +else + echo "Starting a new dockerd tmux-session." + sudo --non-interactive tmux new-session -d -s wdockerd dockerd +fi