]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
refactor check commands into func
authorBastian Dehn <hhaalo@arcor.de>
Tue, 4 Aug 2026 14:36:02 +0000 (16:36 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 4 Aug 2026 14:36:02 +0000 (16:36 +0200)
src/backup

index c257c3c36073bb4203ceb66160cd919d453bc301..6795768bb24ad8ce9777808599144d9fe15ebfec 100755 (executable)
@@ -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") \