v-change-database-password-for-wordpress: enhance database name and user retrieval to support both single and double quotes in wp-config.php

This commit is contained in:
Peca 2025-07-16 15:35:46 +02:00
commit 403dd65400

View file

@ -70,6 +70,12 @@ if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
fi
db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*'\K[^']+")
db_user=$(grep "DB_USER" $wp_config_path | grep -oP "define\s*\(\s*'DB_USER'\s*,\s*'\K[^']+")
if [ -z "$db_name" ]; then
db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*\"\K[^\"]+")
fi
if [ -z "$db_user" ]; then
db_user=$(grep "DB_USER" $wp_config_path | grep -oP "define\s*\(\s*'DB_USER'\s*,\s*\"\K[^\"]+")
fi
new_password=''
found_existing_password=0
if [ -f "/root/remember-db-user-pass.txt" ]; then