Blob Blame History Raw
From 2c0ac48ec6fd620816da4e240d9a2310922786d6 Mon Sep 17 00:00:00 2001
From: Antonio Murdaca <runcom@linux.com>
Date: Thu, 8 Sep 2022 14:20:30 +0200
Subject: [PATCH] avoid running checks if conditions aren't met

Signed-off-by: Antonio Murdaca <runcom@linux.com>
---
 .../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