Skip to content

Commit

Permalink
Fix WSL systemd detection
Browse files Browse the repository at this point in the history
[NO NEW TESTS NEEDED]

Signed-off-by: Frederik Boster <[email protected]>
  • Loading branch information
Syquel committed Sep 28, 2023
1 parent 46a1e25 commit 5b990c3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/machine/wsl/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ chown [USER]:[USER] /home/[USER]/.config
const sudoers = `%wheel ALL=(ALL) NOPASSWD: ALL
`

const bootstrap = `#!/bin/bash
ps -ef | grep -v grep | grep -q systemd && exit 0
nohup unshare --kill-child --fork --pid --mount --mount-proc --propagation shared /lib/systemd/systemd >/dev/null 2>&1 &
sleep 0.1
`

const wslmotd = `
You will be automatically entered into a nested process namespace where
systemd is running. If you need to access the parent namespace, hit ctrl-d
or type exit. This also means to log out you need to exit twice.
`

const sysdpid = "SYSDPID=`ps -eo cmd,pid | grep -m 1 ^/lib/systemd/systemd | awk '{print $2}'`"
const sysdpid = "SYSDPID=`ps --no-headers -C systemd --format exe,pid | grep -m 1 ^/usr/lib/systemd/systemd | awk '{print $2}'`"

const bootstrap = "#!/bin/bash\n" + sysdpid + `
[ -n "$SYSDPID" ] && exit 0
nohup unshare --kill-child --fork --pid --mount --mount-proc --propagation shared /usr/lib/systemd/systemd >/dev/null 2>&1 &
sleep 0.1
`

const profile = sysdpid + `
if [ ! -z "$SYSDPID" ] && [ "$SYSDPID" != "1" ]; then
Expand Down

0 comments on commit 5b990c3

Please sign in to comment.