diff --git a/scripts/config/password/bcrypt/password_export_bcrypt.sh b/scripts/config/password/bcrypt/password_export_bcrypt.sh index a46a239..0bf3571 100755 --- a/scripts/config/password/bcrypt/password_export_bcrypt.sh +++ b/scripts/config/password/bcrypt/password_export_bcrypt.sh @@ -9,26 +9,26 @@ exportBcryptPassword() local file="$4" # File where the placeholder was found local log_file="$containers_dir/bcrypt.txt" - # Ensure log file exists + # bcrypt.txt lives under containers_dir (docker-install-owned) -> runFileOp. if [ ! -f "$log_file" ]; then - local result=$(sudo touch "$log_file") + local result=$(runFileOp touch "$log_file") checkSuccess "Created bcrypt.txt file." - local result=$(sudo chmod 600 "$log_file") + local result=$(runFileOp chmod 600 "$log_file") checkSuccess "Adjusted bcrypt.txt file permissions." fi # Extract the correct variable name (e.g., PASSWORD_HASH) before the placeholder local variable_name - variable_name=$(sudo awk -F= '/'"$placeholder"'/ { gsub(/^[ \t-]+/, "", $1); print $1; exit }' "$file") + variable_name=$(runInstallOp awk -F= '/'"$placeholder"'/ { gsub(/^[ \t-]+/, "", $1); print $1; exit }' "$file") if [ -n "$variable_name" ]; then # Remove old password entries for this app & variable - local result=$(sudo sed -i "/^$app_name $variable_name /d" "$log_file") + local result=$(runFileOp sed -i "/^$app_name $variable_name /d" "$log_file") checkSuccess "Removed existing entry for $app_name $variable_name from bcrypt.txt." # Log new password - local result=$(echo "$app_name $variable_name $raw_password" | sudo tee -a "$log_file" > /dev/null) + local result=$(echo "$app_name $variable_name $raw_password" | runFileWrite -a "$log_file" > /dev/null) checkSuccess "Logged $app_name $variable_name in bcrypt.txt." else checkSuccess "Could not extract a variable name before $placeholder in $file." diff --git a/scripts/config/password/bcrypt/password_process_bcrypt.sh b/scripts/config/password/bcrypt/password_process_bcrypt.sh index f303234..776017d 100755 --- a/scripts/config/password/bcrypt/password_process_bcrypt.sh +++ b/scripts/config/password/bcrypt/password_process_bcrypt.sh @@ -8,7 +8,7 @@ processBcryptPassword() # Extract the variable name before the placeholder local variable_name - variable_name=$(sudo awk -F= '/'"$placeholder"'/ { gsub(/^[ \t-]+/, "", $1); print $1; exit }' "$file") + variable_name=$(runInstallOp awk -F= '/'"$placeholder"'/ { gsub(/^[ \t-]+/, "", $1); print $1; exit }' "$file") if [ -z "$variable_name" ]; then isError " Could not extract variable name before $placeholder." @@ -35,11 +35,11 @@ processBcryptPassword() # Remove any single quotes from the bcrypt hash bcrypt_password=$(echo "$bcrypt_password" | tr -d "'") - local result=$(sudo sed -i -E "s#$placeholder#$bcrypt_password#g" "$file") + local result=$(runInstallOp sed -i -E "s#$placeholder#$bcrypt_password#g" "$file") checkSuccess "Use sed to replace placeholder with bcrypt hash" # Verify replacement - if sudo grep -q "$bcrypt_password" "$file"; then + if runInstallOp grep -q "$bcrypt_password" "$file"; then isSuccessful "Updated $variable_name in $(basename "$file")." else isError "ERROR: sed failed to replace $placeholder in $file." diff --git a/scripts/config/password/bcrypt/password_replace_bcrypt.sh b/scripts/config/password/bcrypt/password_replace_bcrypt.sh index 08181bc..3440024 100755 --- a/scripts/config/password/bcrypt/password_replace_bcrypt.sh +++ b/scripts/config/password/bcrypt/password_replace_bcrypt.sh @@ -7,7 +7,7 @@ replaceBcryptPasswords() app_name=$(basename "$(dirname "$file")") # Only scan for bcrypt placeholders that actually exist in the file - local existing_placeholders=$(sudo grep -oE 'RANDOMIZEDBCRYPTPASSWORD[0-9]*' "$file" 2>/dev/null | sort -u) + local existing_placeholders=$(runInstallOp grep -oE 'RANDOMIZEDBCRYPTPASSWORD[0-9]*' "$file" 2>/dev/null | sort -u) if [[ -n "$existing_placeholders" ]]; then while IFS= read -r placeholder; do diff --git a/scripts/config/password/bcrypt/password_retreive_bcrypt.sh b/scripts/config/password/bcrypt/password_retreive_bcrypt.sh index c2fc4be..079368d 100755 --- a/scripts/config/password/bcrypt/password_retreive_bcrypt.sh +++ b/scripts/config/password/bcrypt/password_retreive_bcrypt.sh @@ -7,7 +7,7 @@ getStoredPassword() local log_file="$containers_dir/bcrypt.txt" if [ -f "$log_file" ]; then - sudo grep "^$app_name $variable_name " "$log_file" | awk '{print $3}' | tail -n 1 + runFileOp grep "^$app_name $variable_name " "$log_file" | awk '{print $3}' | tail -n 1 else echo "" fi diff --git a/scripts/config/password/password_replace hex.sh b/scripts/config/password/password_replace hex.sh index 6c84295..de15d9b 100755 --- a/scripts/config/password/password_replace hex.sh +++ b/scripts/config/password/password_replace hex.sh @@ -5,7 +5,7 @@ replaceHexKeys() local file="$1" # Only scan for hex placeholders that actually exist in the file - local existing_placeholders=$(sudo grep -oE 'RANDOMIZEDHEX[0-9]*' "$file" 2>/dev/null | sort -u) + local existing_placeholders=$(runInstallOp grep -oE 'RANDOMIZEDHEX[0-9]*' "$file" 2>/dev/null | sort -u) if [[ -n "$existing_placeholders" ]]; then while IFS= read -r placeholder; do @@ -13,7 +13,7 @@ replaceHexKeys() local hex_key hex_key=$(openssl rand -hex 32) - sudo sed -i "s/${placeholder}/${hex_key}/g" "$file" + runInstallOp sed -i "s/${placeholder}/${hex_key}/g" "$file" checkSuccess "Updated ${placeholder} in $(basename "$file") with a new hex key." fi done <<< "$existing_placeholders" diff --git a/scripts/config/password/password_replace vapid.sh b/scripts/config/password/password_replace vapid.sh index 01398cd..9bec4ff 100755 --- a/scripts/config/password/password_replace vapid.sh +++ b/scripts/config/password/password_replace vapid.sh @@ -5,7 +5,7 @@ replaceVAPIDKeys() local file="$1" # Only scan for VAPID placeholders that actually exist in the file - local existing_placeholders=$(sudo grep -oE 'RANDOMIZEDVAPID[0-9]*' "$file" 2>/dev/null | sort -u) + local existing_placeholders=$(runInstallOp grep -oE 'RANDOMIZEDVAPID[0-9]*' "$file" 2>/dev/null | sort -u) if [[ -n "$existing_placeholders" ]]; then while IFS= read -r placeholder; do @@ -13,7 +13,7 @@ replaceVAPIDKeys() local vapid_key vapid_key=$(openssl rand -base64 32 | tr -d '+/=' | tr -cd '[:alnum:]') - sudo sed -i "s/${placeholder}/${vapid_key}/g" "$file" + runInstallOp sed -i "s/${placeholder}/${vapid_key}/g" "$file" checkSuccess "Updated ${placeholder} in $(basename "$file") with a new VAPID key." fi done <<< "$existing_placeholders" diff --git a/scripts/config/password/password_replace.sh b/scripts/config/password/password_replace.sh index 8174f40..216d874 100755 --- a/scripts/config/password/password_replace.sh +++ b/scripts/config/password/password_replace.sh @@ -5,13 +5,13 @@ replacePlainPasswords() local file="$1" # Only scan for placeholders that actually exist in the file - local existing_placeholders=$(sudo grep -oE 'RANDOMIZEDPASSWORD[0-9]+' "$file" 2>/dev/null | sort -u) + local existing_placeholders=$(runInstallOp grep -oE 'RANDOMIZEDPASSWORD[0-9]+' "$file" 2>/dev/null | sort -u) if [[ -n "$existing_placeholders" ]]; then while IFS= read -r password_placeholder; do if [[ -n "$password_placeholder" ]]; then local random_password=$(generateRandomPassword) - sudo sed -i 's/'"${password_placeholder}"'/'"${random_password}"'/g' "$file" + runInstallOp sed -i 's/'"${password_placeholder}"'/'"${random_password}"'/g' "$file" checkSuccess "Updated ${password_placeholder} in $(basename "$file")." fi done <<< "$existing_placeholders" diff --git a/scripts/config/password/password_replace_appkey.sh b/scripts/config/password/password_replace_appkey.sh index f9207aa..dc20e4b 100644 --- a/scripts/config/password/password_replace_appkey.sh +++ b/scripts/config/password/password_replace_appkey.sh @@ -8,14 +8,14 @@ replaceLaravelAppKeys() { local file="$1" - local existing_placeholders=$(sudo grep -oE 'RANDOMIZEDAPPKEY[0-9]*' "$file" 2>/dev/null | sort -u) + local existing_placeholders=$(runInstallOp grep -oE 'RANDOMIZEDAPPKEY[0-9]*' "$file" 2>/dev/null | sort -u) if [[ -n "$existing_placeholders" ]]; then while IFS= read -r placeholder; do if [[ -n "$placeholder" ]]; then local app_key app_key="base64:$(openssl rand -base64 32)" - sudo sed -i "s#${placeholder}#${app_key}#g" "$file" + runInstallOp sed -i "s#${placeholder}#${app_key}#g" "$file" checkSuccess "Updated ${placeholder} in $(basename "$file") with a new Laravel APP_KEY." fi done <<< "$existing_placeholders" diff --git a/scripts/config/password/password_update_all.sh b/scripts/config/password/password_update_all.sh index 6b48232..e71ed61 100755 --- a/scripts/config/password/password_update_all.sh +++ b/scripts/config/password/password_update_all.sh @@ -11,7 +11,7 @@ scanConfigsForRandomPassword() # 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 sudo grep -qE "$passplaceholder|$bcryptplaceholder" "$scanned_config_file"; then + if runInstallOp grep -qE "$passplaceholder|$bcryptplaceholder" "$scanned_config_file"; then scanFileForRandomPasswordKeysUsers "$scanned_config_file" fi done diff --git a/scripts/config/password/password_user_replace.sh b/scripts/config/password/password_user_replace.sh index ab24299..6a1052f 100755 --- a/scripts/config/password/password_user_replace.sh +++ b/scripts/config/password/password_user_replace.sh @@ -5,13 +5,13 @@ replaceRandomUsernames() local file="$1" # Only scan for placeholders that actually exist in the file - local existing_placeholders=$(sudo grep -oE 'RANDOMIZEDUSERNAME[0-9]+' "$file" 2>/dev/null | sort -u) + local existing_placeholders=$(runInstallOp grep -oE 'RANDOMIZEDUSERNAME[0-9]+' "$file" 2>/dev/null | sort -u) if [[ -n "$existing_placeholders" ]]; then while IFS= read -r username_placeholder; do if [[ -n "$username_placeholder" ]]; then local random_username=$(generateRandomUsername) - sudo sed -i 's/'"${username_placeholder}"'/'"${random_username}"'/g' "$file" + runInstallOp sed -i 's/'"${username_placeholder}"'/'"${random_username}"'/g' "$file" checkSuccess "Updated ${username_placeholder} in $(basename "$file")." fi done <<< "$existing_placeholders"