#!/bin/bash

# Source every per-location location.config file so the CFG_BACKUP_LOC_<idx>_*
# variables are available in the env. Called from the libreportal_configs
# scan path (see scripts/source/loading/scan_files.sh) so it runs at the
# same time as the rest of the config files.

sourceBackupLocations()
{
    local dir
    dir=$(backupLocationsDir)
    [[ ! -d "$dir" ]] && return 0

    local cfg
    while IFS= read -r -d '' cfg; do
        [[ -f "$cfg" ]] && source "$cfg"
    done < <(runFileOp find "$dir" -mindepth 2 -maxdepth 2 -name location.config -type f -print0 2>/dev/null)
}
