From ce5011b5d3e8e193f873f8c461ac9149922a634d Mon Sep 17 00:00:00 2001 From: Namyts <35004248+Namyts@users.noreply.github.com> Date: Mon, 23 Nov 2020 15:32:13 +0000 Subject: [PATCH 1/2] changed install location to /, which fixes the bug preventing this script from working. --- start-systemd-namespace | 2 +- ubuntu-wsl2-systemd-script.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/start-systemd-namespace b/start-systemd-namespace index 6218ef7..2cac5a8 100755 --- a/start-systemd-namespace +++ b/start-systemd-namespace @@ -10,7 +10,7 @@ OSTYPE|PATH|PIPESTATUS|POSIXLY_CORRECT|PPID|PS1|PS4|\ SHELL|SHELLOPTS|SHLVL|SYSTEMD_PID|UID|USER|_)(=|\$)" > "$HOME/.systemd-env" export PRE_NAMESPACE_PATH="$PATH" export PRE_NAMESPACE_PWD="$(pwd)" - exec sudo /usr/sbin/enter-systemd-namespace "$BASH_EXECUTION_STRING" + exec sudo /enter-systemd-namespace "$BASH_EXECUTION_STRING" fi if [ -n "$PRE_NAMESPACE_PATH" ]; then export PATH="$PRE_NAMESPACE_PATH" diff --git a/ubuntu-wsl2-systemd-script.sh b/ubuntu-wsl2-systemd-script.sh index 5c32f2a..6a225d4 100755 --- a/ubuntu-wsl2-systemd-script.sh +++ b/ubuntu-wsl2-systemd-script.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ "$1" != "--force" ]; then - if [ -f /usr/sbin/start-systemd-namespace ]; then + if [ -f /start-systemd-namespace ]; then echo "It appears you have already installed the systemd hack." echo "To forcibly reinstall, run this script with the \`--force\` parameter." exit @@ -53,9 +53,9 @@ function sysdrive_prefix { sudo hwclock -s sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig -sudo cp "$self_dir/start-systemd-namespace" /usr/sbin/start-systemd-namespace -sudo cp "$self_dir/enter-systemd-namespace" /usr/sbin/enter-systemd-namespace -sudo chmod +x /usr/sbin/enter-systemd-namespace +sudo cp "$self_dir/start-systemd-namespace" /start-systemd-namespace +sudo cp "$self_dir/enter-systemd-namespace" /enter-systemd-namespace +sudo chmod +x /enter-systemd-namespace sudo tee /etc/sudoers.d/systemd-namespace >/dev/null </dev/null; then - sudo sed -i 2a"# Start or enter a PID namespace in WSL2\nsource /usr/sbin/start-systemd-namespace\n" /etc/bash.bashrc + sudo sed -i 2a"# Start or enter a PID namespace in WSL2\nsource /start-systemd-namespace\n" /etc/bash.bashrc fi sudo rm -f /etc/systemd/user/sockets.target.wants/dirmngr.socket From e9c0a58c36c90c043b7465594bd898a7bcd15ea6 Mon Sep 17 00:00:00 2001 From: Namyts <35004248+Namyts@users.noreply.github.com> Date: Mon, 23 Nov 2020 15:46:45 +0000 Subject: [PATCH 2/2] changed location to /ubuntu-wsl2-systemd-script which is the repo name. this allows for "updates" using git pull. updated README --- README.md | 1 + start-systemd-namespace | 2 +- ubuntu-wsl2-systemd-script.sh | 10 ++++------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9b3772e..b123334 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ sudo apt install git to do so. ### Run the script and commands ```sh +cd / git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git cd ubuntu-wsl2-systemd-script/ bash ubuntu-wsl2-systemd-script.sh diff --git a/start-systemd-namespace b/start-systemd-namespace index 2cac5a8..e027cc0 100755 --- a/start-systemd-namespace +++ b/start-systemd-namespace @@ -10,7 +10,7 @@ OSTYPE|PATH|PIPESTATUS|POSIXLY_CORRECT|PPID|PS1|PS4|\ SHELL|SHELLOPTS|SHLVL|SYSTEMD_PID|UID|USER|_)(=|\$)" > "$HOME/.systemd-env" export PRE_NAMESPACE_PATH="$PATH" export PRE_NAMESPACE_PWD="$(pwd)" - exec sudo /enter-systemd-namespace "$BASH_EXECUTION_STRING" + exec sudo /ubuntu-wsl2-systemd-script/enter-systemd-namespace "$BASH_EXECUTION_STRING" fi if [ -n "$PRE_NAMESPACE_PATH" ]; then export PATH="$PRE_NAMESPACE_PATH" diff --git a/ubuntu-wsl2-systemd-script.sh b/ubuntu-wsl2-systemd-script.sh index 6a225d4..41af8dd 100755 --- a/ubuntu-wsl2-systemd-script.sh +++ b/ubuntu-wsl2-systemd-script.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ "$1" != "--force" ]; then - if [ -f /start-systemd-namespace ]; then + if [ -f /ubuntu-wsl2-systemd-script/start-systemd-namespace ]; then echo "It appears you have already installed the systemd hack." echo "To forcibly reinstall, run this script with the \`--force\` parameter." exit @@ -53,9 +53,7 @@ function sysdrive_prefix { sudo hwclock -s sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig -sudo cp "$self_dir/start-systemd-namespace" /start-systemd-namespace -sudo cp "$self_dir/enter-systemd-namespace" /enter-systemd-namespace -sudo chmod +x /enter-systemd-namespace +sudo chmod +x /ubuntu-wsl2-systemd-script/enter-systemd-namespace sudo tee /etc/sudoers.d/systemd-namespace >/dev/null </dev/null; then - sudo sed -i 2a"# Start or enter a PID namespace in WSL2\nsource /start-systemd-namespace\n" /etc/bash.bashrc + sudo sed -i 2a"# Start or enter a PID namespace in WSL2\nsource /ubuntu-wsl2-systemd-script/start-systemd-namespace\n" /etc/bash.bashrc fi sudo rm -f /etc/systemd/user/sockets.target.wants/dirmngr.socket