diff --git a/SOURCES/0001-avoid-running-checks-if-conditions-aren-t-met.patch b/SOURCES/0001-avoid-running-checks-if-conditions-aren-t-met.patch new file mode 100644 index 0000000..b8f50e0 --- /dev/null +++ b/SOURCES/0001-avoid-running-checks-if-conditions-aren-t-met.patch @@ -0,0 +1,46 @@ +From 2c0ac48ec6fd620816da4e240d9a2310922786d6 Mon Sep 17 00:00:00 2001 +From: Antonio Murdaca +Date: Thu, 8 Sep 2022 14:20:30 +0200 +Subject: [PATCH] avoid running checks if conditions aren't met + +Signed-off-by: Antonio Murdaca +--- + .../greenboot/check/required.d/01_repository_dns_check.sh | 5 +++++ + usr/lib/greenboot/check/required.d/02_watchdog.sh | 5 +++++ + 2 files changed, 10 insertions(+) + +diff --git a/usr/lib/greenboot/check/required.d/01_repository_dns_check.sh b/usr/lib/greenboot/check/required.d/01_repository_dns_check.sh +index f661dcd..51e52b3 100644 +--- a/usr/lib/greenboot/check/required.d/01_repository_dns_check.sh ++++ b/usr/lib/greenboot/check/required.d/01_repository_dns_check.sh +@@ -44,6 +44,11 @@ if [[ ! -d $REPOS_DIRECTORY ]]; then + exit 1 + fi + ++if [ -z "$(ls -A $REPOS_DIRECTORY)" ]; then ++ echo "${REPOS_DIRECTORY} is empty, skipping check" ++ exit 0 ++fi ++ + get_domain_names_from_platform_urls + if [[ -n $DOMAIN_NAMES ]]; then + get_dns_resolution_from_domain_names +diff --git a/usr/lib/greenboot/check/required.d/02_watchdog.sh b/usr/lib/greenboot/check/required.d/02_watchdog.sh +index 101750d..b072288 100644 +--- a/usr/lib/greenboot/check/required.d/02_watchdog.sh ++++ b/usr/lib/greenboot/check/required.d/02_watchdog.sh +@@ -41,6 +41,11 @@ check_if_current_boot_is_wd_triggered() { + fi + } + ++if ! check_if_there_is_a_watchdog ; then ++ echo "No watchdog on the system, skipping check" ++ exit 0 ++fi ++ + # This is in order to test check_if_current_boot_is_wd_triggered + # function within a container + if [ "${1}" != "--source-only" ]; then +-- +2.37.3 + diff --git a/SPECS/greenboot.spec b/SPECS/greenboot.spec index 8caf859..d5bee3d 100644 --- a/SPECS/greenboot.spec +++ b/SPECS/greenboot.spec @@ -2,7 +2,7 @@ Name: greenboot Version: 0.15.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Generic Health Check Framework for systemd License: LGPLv2+ @@ -13,6 +13,7 @@ License: LGPLv2+ URL: https://github.com/%{repo_owner}/%{repo_name} Source0: https://github.com/%{repo_owner}/%{repo_name}/archive/%{repo_tag}.tar.g#/%{name}-%{version}.tar.gz Patch0: 0001-disable-DefaultDependencies-to-fix-cycle-error.patch +Patch1: 0001-avoid-running-checks-if-conditions-aren-t-met.patch ExcludeArch: s390x BuildRequires: systemd-rpm-macros @@ -172,6 +173,9 @@ install -DpZm 0644 etc/greenboot/greenboot.conf %{buildroot}%{_sysconfdir}/%{nam %{_prefix}/lib/%{name}/check/required.d/02_watchdog.sh %changelog +* Thu Sep 08 2022 Peter Robinson - 0.15.1-3 +- Avoid running health checks if conditions aren't met + * Wed Aug 31 2022 Peter Robinson - 0.15.1-2 - disable DefaultDependencies to fix cycle error