From e33ca1ec58ff64376c8bed968b92f2f30dfee153 Mon Sep 17 00:00:00 2001 From: chr0mag Date: Thu, 7 Mar 2019 01:10:21 -0800 Subject: [PATCH] [BOOT 5177] Simplify service filter & support multiple periods in names (#633) * Handle service names with multiple periods The current awk filter produces truncated output if the service name contains multiple periods. eg. dbus-org.freedesktop.resolve1.service and dbus-org.freedesktop.network1.service both appear as 'dbus-org' in the resulting service list. This change addresses this by filtering on '.service' instead. * Simplify systemd service filtering Added systemctl switches to filter the output based on enabled or running services. This removes the need for one of the awk statements. --- include/tests_boot_services | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/tests_boot_services b/include/tests_boot_services index 2de8d748..77d3cb47 100644 --- a/include/tests_boot_services +++ b/include/tests_boot_services @@ -564,7 +564,7 @@ LogText "Result: systemctl binary found, trying that to discover information" # Running services LogText "Searching for running services (systemctl services only)" - FIND=$(${SYSTEMCTLBINARY} --full --type=service | ${AWKBINARY} '{ if ($4=="running") { print $1 } }' | ${AWKBINARY} -F. '{ print $1 }') + FIND=$(${SYSTEMCTLBINARY} --no-legend --full --type=service --state=running | ${AWKBINARY} -F.service '{ print $1 }') COUNT=0 Report "running_service_tool=systemctl" for ITEM in ${FIND}; do @@ -579,7 +579,7 @@ # Services at boot LogText "Searching for enabled services (systemctl services only)" - FIND=$(${SYSTEMCTLBINARY} list-unit-files --type=service | ${SORTBINARY} -u | ${AWKBINARY} '{ if ($2=="enabled") { print $1 } }' | ${AWKBINARY} -F. '{ print $1 }') + FIND=$(${SYSTEMCTLBINARY} list-unit-files --no-legend --type=service --state=enabled | ${SORTBINARY} -u | ${AWKBINARY} -F.service '{ print $1 }') COUNT=0 Report "boot_service_tool=systemctl" for ITEM in ${FIND}; do