Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Fixed the script by chaging installation location #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion start-systemd-namespace
Original file line number Diff line number Diff line change
Expand Up @@ -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 /ubuntu-wsl2-systemd-script/enter-systemd-namespace "$BASH_EXECUTION_STRING"
fi
if [ -n "$PRE_NAMESPACE_PATH" ]; then
export PATH="$PRE_NAMESPACE_PATH"
Expand Down
10 changes: 4 additions & 6 deletions ubuntu-wsl2-systemd-script.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ "$1" != "--force" ]; then
if [ -f /usr/sbin/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
Expand Down Expand Up @@ -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" /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 chmod +x /ubuntu-wsl2-systemd-script/enter-systemd-namespace

sudo tee /etc/sudoers.d/systemd-namespace >/dev/null <<EOF
Defaults env_keep += WSLPATH
Expand All @@ -64,11 +62,11 @@ Defaults env_keep += WSL_INTEROP
Defaults env_keep += WSL_DISTRO_NAME
Defaults env_keep += PRE_NAMESPACE_PATH
Defaults env_keep += PRE_NAMESPACE_PWD
%sudo ALL=(ALL) NOPASSWD: /usr/sbin/enter-systemd-namespace
%sudo ALL=(ALL) NOPASSWD: /ubuntu-wsl2-systemd-script/enter-systemd-namespace
EOF

if ! grep 'start-systemd-namespace' /etc/bash.bashrc >/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 /ubuntu-wsl2-systemd-script/start-systemd-namespace\n" /etc/bash.bashrc
fi

sudo rm -f /etc/systemd/user/sockets.target.wants/dirmngr.socket
Expand Down