Don't check /run for systemd if we're not starting the daemon (#853)

* Don't check /run for systemd if we're not starting the daemon

* Add a note about start_daemon and checking /run/systemd/system
This commit is contained in:
Ana Hobden 2024-02-23 08:41:41 -08:00 committed by GitHub
parent 09ddc9be6b
commit 40740423ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,10 +79,14 @@ impl ConfigureInitService {
},
#[cfg(target_os = "linux")]
InitSystem::Systemd => {
// If /run/systemd/system exists, we can be reasonably sure the machine is booted
// with systemd: https://www.freedesktop.org/software/systemd/man/sd_booted.html
if !Path::new("/run/systemd/system").exists() {
return Err(Self::error(ActionErrorKind::SystemdMissing));
// If `no_start_daemon` is set, then we don't require a running systemd,
// so we don't need to check if `/run/systemd/system` exists.
if start_daemon {
// If /run/systemd/system exists, we can be reasonably sure the machine is booted
// with systemd: https://www.freedesktop.org/software/systemd/man/sd_booted.html
if !Path::new("/run/systemd/system").exists() {
return Err(Self::error(ActionErrorKind::SystemdMissing));
}
}
if which::which("systemctl").is_err() {