From 184ab5c150110471f2c0271b83e64754b09b8cee Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Tue, 4 Aug 2026 16:36:02 +0200 Subject: [PATCH] refactor check commands into func --- src/backup | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/backup b/src/backup index c257c3c..6795768 100755 --- a/src/backup +++ b/src/backup @@ -9,6 +9,22 @@ errlog() return $lastexit } +exists_needed_commands() +{ + command -v yq > /dev/null \ + || errlog "command yq not found" \ + || return $? + command -v jq > /dev/null \ + || errlog "command jq not found" \ + || return $? + command -v rsync > /dev/null \ + || errlog "command rsync not found" \ + || return $? + command -v ssh > /dev/null \ + || errlog "command ssh not found" \ + || return $? +} + exists_config_file() { local config_file="$1" @@ -56,20 +72,8 @@ main() local CONFIG_FILE=${CONFIG_FILE:="config.yaml"} echo "⭐ START: backup" - command -v yq > /dev/null \ - || errlog "command yq not found" \ - || return $? - command -v jq > /dev/null \ - || errlog "command jq not found" \ - || return $? - command -v rsync > /dev/null \ - || errlog "command rsync not found" \ - || return $? - command -v ssh > /dev/null \ - || errlog "command ssh not found" \ - || return $? - exists_config_file "$CONFIG_FILE" \ - || return $? + exists_needed_commands || return $? + exists_config_file "$CONFIG_FILE" || return $? local config= config=$(yq '.' "$CONFIG_FILE") \ -- 2.47.3