├── README.md └── wslsystemd.sh /README.md: -------------------------------------------------------------------------------- 1 | # wslsystemd 2 | Make systemd's PID 1 using Linux namespace 3 | 4 | ## How to use 5 | Just run the script with WHO variable specified 6 | ```bash 7 | WHO=`whoami` sudo -E ./wslsystemd.sh 8 | ``` 9 | -------------------------------------------------------------------------------- /wslsystemd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | systemd_pid= 4 | 5 | if [ -z $(pidof systemd) ]; then 6 | daemonize /usr/bin/unshare -fp --propagation shared --mount-proc systemd 7 | fi 8 | 9 | while [ -z $systemd_pid ] 10 | do 11 | for pid in $(pidof systemd) 12 | do 13 | systemd_pid=$pid 14 | done 15 | done 16 | 17 | if [ -z $WHO ]; then 18 | WHO=root 19 | WD=/ 20 | else 21 | WD=/home/$WHO 22 | fi 23 | 24 | nsenter -t $systemd_pid -m -p --wd=$WD runuser -m -p -u $WHO zsh 25 | --------------------------------------------------------------------------------