#!/bin/bash

scanConfigsForRandomPassword()
{
    if [[ "$CFG_REQUIREMENT_PASSWORDS" == "true" ]]; then
        isHeader "Randomizing Config Passwords"

        local passplaceholder="RANDOMIZEDPASSWORD"
        local bcryptplaceholder="RANDOMIZEDBCRYPTPASSWORD"

        # Find all config files in subdirectories (excluding .category files)
        find "$configs_dir" -type f ! -name "*.category" -print0 | while IFS= read -r -d '' scanned_config_file; do
            # Check for placeholders in the file
            if runInstallOp grep -qE "$passplaceholder|$bcryptplaceholder" "$scanned_config_file"; then
                scanFileForRandomPasswordKeysUsers "$scanned_config_file"
            fi
        done

        isSuccessful "Random password generation and update completed."
    fi
}
