Blame SOURCES/0001-avoid-running-checks-if-conditions-aren-t-met.patch

9242a4
From 2c0ac48ec6fd620816da4e240d9a2310922786d6 Mon Sep 17 00:00:00 2001
9242a4
From: Antonio Murdaca <runcom@linux.com>
9242a4
Date: Thu, 8 Sep 2022 14:20:30 +0200
9242a4
Subject: [PATCH] avoid running checks if conditions aren't met
9242a4
9242a4
Signed-off-by: Antonio Murdaca <runcom@linux.com>
9242a4
---
9242a4
 .../greenboot/check/required.d/01_repository_dns_check.sh    | 5 +++++
9242a4
 usr/lib/greenboot/check/required.d/02_watchdog.sh            | 5 +++++
9242a4
 2 files changed, 10 insertions(+)
9242a4
9242a4
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
9242a4
index f661dcd..51e52b3 100644
9242a4
--- a/usr/lib/greenboot/check/required.d/01_repository_dns_check.sh
9242a4
+++ b/usr/lib/greenboot/check/required.d/01_repository_dns_check.sh
9242a4
@@ -44,6 +44,11 @@ if [[ ! -d $REPOS_DIRECTORY ]]; then
9242a4
     exit 1
9242a4
 fi
9242a4
 
9242a4
+if [ -z "$(ls -A $REPOS_DIRECTORY)" ]; then
9242a4
+   echo "${REPOS_DIRECTORY} is empty, skipping check"
9242a4
+   exit 0
9242a4
+fi
9242a4
+
9242a4
 get_domain_names_from_platform_urls
9242a4
 if [[ -n $DOMAIN_NAMES ]]; then
9242a4
     get_dns_resolution_from_domain_names
9242a4
diff --git a/usr/lib/greenboot/check/required.d/02_watchdog.sh b/usr/lib/greenboot/check/required.d/02_watchdog.sh
9242a4
index 101750d..b072288 100644
9242a4
--- a/usr/lib/greenboot/check/required.d/02_watchdog.sh
9242a4
+++ b/usr/lib/greenboot/check/required.d/02_watchdog.sh
9242a4
@@ -41,6 +41,11 @@ check_if_current_boot_is_wd_triggered() {
9242a4
     fi
9242a4
 }
9242a4
 
9242a4
+if ! check_if_there_is_a_watchdog ; then
9242a4
+  echo "No watchdog on the system, skipping check"
9242a4
+  exit 0
9242a4
+fi
9242a4
+
9242a4
 # This is in order to test check_if_current_boot_is_wd_triggered
9242a4
 # function within a container
9242a4
 if [ "${1}" != "--source-only" ]; then
9242a4
-- 
9242a4
2.37.3
9242a4