aboutsummaryrefslogtreecommitdiff
path: root/lib/subcommands/sync.bash
diff options
context:
space:
mode:
Diffstat (limited to 'lib/subcommands/sync.bash')
-rw-r--r--lib/subcommands/sync.bash24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/subcommands/sync.bash b/lib/subcommands/sync.bash
index 1ae2aae..8f5e2cd 100644
--- a/lib/subcommands/sync.bash
+++ b/lib/subcommands/sync.bash
@@ -29,6 +29,7 @@ subcommand()
sync_playbook()
{
local playbook_base="$BASHTARD_ETCDIR/playbooks.d/$BASHTARD_PLAYBOOK"
+ local missing_vars=0
notice "bashtard/sync" "Running sync for $BASHTARD_PLAYBOOK"
@@ -47,5 +48,28 @@ sync_playbook()
# shellcheck disable=SC1090,SC1091
. "$playbook_base/playbook.bash"
+ debug "bashtard/sync" "Checking for \$BASHTARD_PLAYBOOK_VARS"
+
+ # Ensure all required vars are non-empty
+ for key in "${!BASHTARD_PLAYBOOK_VARS[@]}"
+ do
+ # shellcheck disable=SC2086
+ in_args "required" ${BASHTARD_PLAYBOOK_VARS[$key]} || continue
+
+ debug "bashtard/sync" "Checking \$BASHTARD_PLAYBOOK_VARS[$key]"
+
+ if [[ "$(config "$key")" == "" ]]
+ then
+ missing_vars=$(( missing_vars + 1))
+ fi
+ done
+
+ if (( 0 < missing_vars ))
+ then
+ emerg "bashtard/sync" "One or more required variables are unset"
+ return 3
+ fi
+
+ # Run the playbook
playbook_sync
}