Merge pull request #1296 from konstruktoid/issue1286

use systemctl get-default instead of following link
This commit is contained in:
Michael Boelen 2024-05-14 14:30:11 +02:00 committed by GitHub
commit 1773db0bef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 26 deletions

View File

@ -41,28 +41,17 @@
if [ ${SKIPTEST} -eq 0 ]; then if [ ${SKIPTEST} -eq 0 ]; then
# Checking if we can find the systemd default target # Checking if we can find the systemd default target
LogText "Test: Checking for systemd default.target" LogText "Test: Checking for systemd default.target"
if [ -L ${ROOTDIR}etc/systemd/system/default.target ]; then if [ $(${SYSTEMCTLBINARY} get-default) ]; then
LogText "Result: symlink found" FIND=$(${SYSTEMCTLBINARY} get-default)
if HasData "${READLINKBINARY}"; then FIND2=$(${ECHOCMD} ${FIND} | ${EGREPBINARY} "runlevel5|graphical")
FIND=$(${READLINKBINARY} ${ROOTDIR}etc/systemd/system/default.target) if HasData "${FIND2}"; then
if ! HasData "${FIND}"; then LogText "Result: Found match on runlevel5/graphical"
LogText "Exception: can't find the target of the symlink of /etc/systemd/system/default.target" Display --indent 2 --text "- Checking default runlevel" --result "runlevel 5" --color GREEN
ReportException "${TEST_NO}:01" Report "linux_default_runlevel=5"
else
FIND2=$(${ECHOCMD} ${FIND} | ${GREPBINARY} -E "runlevel5|graphical")
if HasData "${FIND2}"; then
LogText "Result: Found match on runlevel5/graphical"
Display --indent 2 --text "- Checking default runlevel" --result "runlevel 5" --color GREEN
Report "linux_default_runlevel=5"
else
LogText "Result: No match found on runlevel, defaulting to runlevel 3"
Display --indent 2 --text "- Checking default runlevel" --result "runlevel 3" --color GREEN
Report "linux_default_runlevel=3"
fi
fi
else else
LogText "Result: No readlink binary, can't determine where symlink is pointing to" LogText "Result: No match found on runlevel, defaulting to runlevel 3"
Display --indent 2 --text "- Checking default run level" --result "${STATUS_UNKNOWN}" --color YELLOW Display --indent 2 --text "- Checking default runlevel" --result "runlevel 3" --color GREEN
Report "linux_default_runlevel=3"
fi fi
else else
LogText "Result: no systemd found, so trying inittab" LogText "Result: no systemd found, so trying inittab"
@ -912,7 +901,6 @@
LogText "Result: Did not get output from 'uname -v'. Skipping test." LogText "Result: Did not get output from 'uname -v'. Skipping test."
fi fi
else else
LogText "Result: /var/cache/apt/archives/ does not exist" LogText "Result: /var/cache/apt/archives/ does not exist"
fi fi