#!/bin/bash

# Reconcile each application's config ($containers_dir/<app>/<app>.config) against
# its freshly-cloned template ($install_containers_dir). See reconcileConfigFile.
checkApplicationsConfigFilesMissingVariables()
{
    local live app remote
    while IFS= read -r live; do
        app=$(basename "$live" .config)
        remote="$install_containers_dir$app/$app.config"
        reconcileConfigFile "$live" "$remote"
    # 2>/dev/null on the find: app data dirs (e.g. invidious/postgresdata,
    # nextcloud/html) are owned by container sub-UIDs that the manager user
    # can't read into, and they're harmless permission-denied chatter — find
    # at this maxdepth doesn't need to enter them to satisfy -name '*.config'
    # at depth 2. Keep the noise out of CLI/log output.
    done < <(runFileOp find "$containers_dir" -maxdepth 2 -type f -name '*.config' ! -name '*.bak' 2>/dev/null)

    isSuccessful "Application config reconciliation completed."
}
