Skip to content

Commit

Permalink
Don't check /run for systemd if we're not starting the daemon (#853)
Browse files Browse the repository at this point in the history
* Don't check /run for systemd if we're not starting the daemon

* Add a note about start_daemon and checking /run/systemd/system
  • Loading branch information
Hoverbear committed Feb 23, 2024
1 parent 09ddc9b commit 4074042
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/action/common/configure_init_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 4074042

Please sign in to comment.