From ae08ea3211d8cc1b9e9c3a185cb39a49a53454b5 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Mon, 11 Mar 2019 14:12:45 +0000 Subject: [PATCH] scripts: Add helper function to collect script Add a `have_service()` helper function to the data collection script to simplify the code. Signed-off-by: James O. D. Hunt --- data/kata-collect-data.sh.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/data/kata-collect-data.sh.in b/data/kata-collect-data.sh.in index 28281b2112..38d712705b 100644 --- a/data/kata-collect-data.sh.in +++ b/data/kata-collect-data.sh.in @@ -141,6 +141,13 @@ have_cmd() [ $ret -eq 0 ] } +have_service() +{ + local service="$1" + + systemctl status "${service}" >/dev/null 2>&1 +} + show_quoted_text() { local language="$1" @@ -593,7 +600,7 @@ show_throttler_details() "kata-vc-throttler" \ "vc-throttler" do - systemctl status "${unit}" >/dev/null 2>&1 && \ + have_service "${unit}" && \ run_cmd_and_show_quoted_output "" "systemctl show ${unit}" done }