| Crates.io | subsystemctl |
| lib.rs | subsystemctl |
| version | 0.2.0 |
| created_at | 2020-06-11 10:50:47.140292+00 |
| updated_at | 2021-10-04 01:07:08.78479+00 |
| description | Utility to run systemd in WSL2 with a Linux namespace |
| homepage | https://github.com/sorah/subsystemctl |
| repository | https://github.com/sorah/subsystemctl |
| max_upload_size | |
| id | 252700 |
| size | 41,803 |
Run systemd under Linux namespace in WSL2. Heavily inspired by arkane-systems/genie, but written in Rust.
Slightly following genie's behavior, but noted below...
--hostname, --hostname-suffix
/etc/hosts are not updated. Users are encouraged to use nss-myhostname.machinectl shell to launch a user shell; this allows running systemd user sessionunshare, daemonize, nsenter command line toolssystemd.conf drop-in, using DefaultEnvironment=/run/subsystemctl/systemd.pidPKGBUILD: https://github.com/sorah/arch.sorah.jp/tree/master/aur-sorah/PKGBUILDs/subsystemctl
(PKGBUILD originally submitted to AUR (https://aur.archlinux.org/packages/subsystemctl) was deleted as they unwelcomes WSL-exclusive packages.)
Refer to https://github.com/nkmideb/subsystemctl for debian source.
Pre-built package binaries available at https://github.com/nkmideb/subsystemctl/releases for your convenient.
cargo install subsystemctl
or from git source:
cargo build --release
install -m6755 -oroot -groot ./target/release/subsystemctl /usr/local/bin/subsystemctl
subsystemctl start: Start systemd environmentPS> wsl -u root -- subsystemctl start
subsystemctl shell: shell login to systemd-enabled environmentPS> wsl subsystemctl shell
Connected to the local host. Press ^] three times within 1s to exit session.
someone@hostname$ ...
PS> wsl -u root -- subsystemctl shell --uid=1000
Connected to the local host. Press ^] three times within 1s to exit session.
someone@hostname$ ...
PS> wsl -u root -d Arch -- subsystemctl shell --uid=1000 --start
[2021-06-27T16:32:20Z INFO subsystemctl] Starting systemd
Connected to the local host. Press ^] three times within 1s to exit session.
someone@hostname$ ...
subsystemctl exec: Raw nsenter like interfacePS> wsl subsystemctl exec id
uid=1000(sorah) gid=1000(sorah) groups=1000(sorah),116(admin)
PS> wsl -u root -- subsystemctl exec id
uid=0(root) gid=0(root) groups=0(root)
PS> wsl -u root -- subsystemctl exec --uid=1000 id
uid=1000(sorah) gid=1000(sorah) groups=1000(sorah),116(admin)
PS> wsl -u root -- subsystemctl exec --uid=1000 --gid=116 id
uid=1000(sorah) gid=116(admin) groups=116(admin)
subsystemctl is-running#!/bin/bash
if subsystemctl is-running; then
echo "running"
else
echo "not-running"
fi
subsystemctl is-inside#!/bin/bash
if subsystemctl is-inside; then
echo "inside"
else
echo "outside"
fi
otherwise /etc/resolv.conf might get overwritten to resolved stub-resolver.
Sorah Fukumori https://sorah.jp/
MIT