Update basic_search_replace.sh

main
jay 2023-10-20 19:46:44 +00:00
parent 4edad200b7
commit a70fb165cb
1 changed files with 6 additions and 11 deletions

View File

@ -1,15 +1,10 @@
#!/bin/bash
# Read wp-config.php once and extract required values using awk
read WPDBPHOST WPDBNAME WPDBUSER WPDBPASS <<< $(awk -F"'" '
/DB_HOST/ {host=$4}
/DB_NAME/ {name=$4}
/DB_USER/ {user=$4}
/DB_PASSWORD/ {pass=$4}
END {print host, name, user, pass}
' ../ROOT/wp-config.php)
WPDBPHOST=`wp config get DB_HOST --path=/var/www/webroot/ROOT`
WPDBNAME=`wp config get DB_NAME --path=/var/www/webroot/ROOT`
WPDBUSER=`wp config get DB_USER --path=/var/www/webroot/ROOT`
WPDBPASS=`wp config get DB_PASSWORD --path=/var/www/webroot/ROOT`
keywordSearch=$1
keywordreplace=$2
php srdb.cli.php -h "$WPDBPHOST" -n "$WPDBNAME" -u "$WPDBUSER" -p "$WPDBPASS" -s "$keywordSearch" -r "$keywordreplace"
php srdb.cli.php -h $WPDBPHOST -n $WPDBNAME -u $WPDBUSER -p "$WPDBPASS" -s "$keywordSearch" -r "$keywordreplace"
wp w3-total-cache flush all --path=/var/www/webroot/ROOT