LibrePortal/scripts/config/password/password_update_all.sh
librelad 5ceef2df6a refactor(de-sudo): config/password processors off raw sudo
scanConfigsForRandomPassword iterates $configs_dir (manager-owned), so the
placeholder grep/sed/awk on the config file -> runInstallOp. The bcrypt export
log ($containers_dir/bcrypt.txt) is docker-install-owned, so its touch/chmod/
sed/grep/append -> runFileOp/runFileWrite (NOT runInstallOp). Covers all
password_replace*/password_user_replace/password_update_all and bcrypt/*.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-24 17:30:25 +01:00

22 lines
795 B
Bash
Executable File

#!/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
}