From eb48e0cf22e239f8f3ae271d62765b98011b494a Mon Sep 17 00:00:00 2001 From: hael Date: Mon, 10 Jul 2023 13:58:27 +0000 Subject: [PATCH] wsl2-systemd script 2 --- entrypoint.sh | 2 +- install.sh | 27 +++++++++++++++------------ wsl2-systemd-script.sh | 4 ++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index d1ec083..09ac455 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -39,7 +39,7 @@ if [ "$ADDITIONALS" == "true" ]; then echo "Additional install has started" sh /additional_install.sh echo "Additional install has finished" -else if [ "$WSL2" == "true" ]; then +elif [ -n "$WSL_DISTRO_NAME" ]; then echo "WSL2 systemd script has started" sh /wsl2-systemd-script.sh #systemctl diff --git a/install.sh b/install.sh index 810888d..e87f433 100755 --- a/install.sh +++ b/install.sh @@ -648,19 +648,22 @@ if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ]; then registry.format.hu/installer-tool fi -# enable systemd support on current images -echo "Would you like to install and enable systemd support? (Y/n)"; -read -r ANSWER; -if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then +# running on WSL +if [ -n "$WSL_DISTRO_NAME" ]; then + # enable systemd support on current images + echo "Would you like to install and enable systemd support? (Y/n)"; + read -r ANSWER; + if [ "$ANSWER" == "y" ] || [ "$ANSWER" == "Y" ] || [ "$ANSWER" == "" ] ; then - # Run installer tool - $SUDO_CMD docker run \ - --env WSL2=true \ - --env SUDO_CMD=$SUDO_CMD \ - --volume $HOME/.ssh/installer:/root/.ssh/id_rsa \ - --volume /etc/user/:/etc/user/ \ - --volume /etc/system/:/etc/system/ \ - registry.format.hu/installer-tool + # Run installer tool + $SUDO_CMD docker run \ + --env WSL_DISTRO_NAME=$WSL_DISTRO_NAME \ + --env SUDO_CMD=$SUDO_CMD \ + --volume $HOME/.ssh/installer:/root/.ssh/id_rsa \ + --volume /etc/user/:/etc/user/ \ + --volume /etc/system/:/etc/system/ \ + registry.format.hu/installer-tool + fi; fi; shopt -s expand_aliases diff --git a/wsl2-systemd-script.sh b/wsl2-systemd-script.sh index d7ae7cb..cff9406 100755 --- a/wsl2-systemd-script.sh +++ b/wsl2-systemd-script.sh @@ -57,14 +57,14 @@ $SUDO_CMD apt-get update && $SUDO_CMD apt-get install -yqq daemonize dbus-user-s #$SUDO_CMD cp "$self_dir/enter-systemd-namespace" /enter-systemd-namespace $SUDO_CMD chmod +x /enter-systemd-namespace -$SUDO_CMD tee /etc/$SUDO_CMDers.d/systemd-namespace >/dev/null </dev/null </dev/null; then