Skip to content

Commit 22f4812

Browse files
committed
fix: improve systemd detection to check if systemd is actually running
The previous implementation checked if systemctl command exists, but this fails in container environments where systemctl is installed but systemd is not running as PID 1. This caused the script to try using systemctl commands which would fail with 'System has not been booted with systemd'. Now we check for /run/systemd/system directory which only exists when systemd is actually running as the init system. Signed-off-by: Gajesh Bhat <gajeshbht@gmail.com>
1 parent 104ffc0 commit 22f4812

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

install.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ get_distribution() {
300300
# Check if systemd is available and running
301301
# Returns 0 if systemd is available, 1 otherwise
302302
has_systemd() {
303-
command_exists systemctl && systemctl --version >/dev/null 2>&1
303+
if [ -d /run/systemd/system ]; then
304+
return 0
305+
else
306+
return 1
307+
fi
304308
}
305309

306310
# Start and enable Docker daemon service after installation

0 commit comments

Comments
 (0)