Fixed the sed commands
parent
c7668bee46
commit
f9d144e6f7
|
|
@ -230,7 +230,14 @@ if [[ -f "$CONFIG_FILE" && -w "$CONFIG_FILE" ]]; then
|
||||||
[[ -z "$HOST_ONLY" ]] && HOST_ONLY="$TARGET_URL"
|
[[ -z "$HOST_ONLY" ]] && HOST_ONLY="$TARGET_URL"
|
||||||
# shellcheck disable=SC2016 # we want literal quotes inside sed replacement
|
# shellcheck disable=SC2016 # we want literal quotes inside sed replacement
|
||||||
# Replace existing definitions (handle both single and double quotes)
|
# Replace existing definitions (handle both single and double quotes)
|
||||||
sed -i -E "s|define\([[:space:]]*['\"]WP_HOME['\"][[:space:]]*,[[:space:]]*['\"][^'\"]*['\"][[:space:]]*\);|define( 'WP_HOME', '${TARGET_URL}' );|; s|define\([[:space:]]*['\"]WP_SITEURL['\"][[:space:]]*,[[:space:]]*['\"][^'\"]*['\"][[:space:]]*\);|define( 'WP_SITEURL', '${TARGET_URL}' );|; s|\$_SERVER\[(\"|')HTTP_HOST\1\][[:space:]]*=[[:space:]]*(\"|')[^"']*\2;|\$_SERVER['HTTP_HOST'] = '${HOST_ONLY}';|" "$CONFIG_FILE" || warning "Failed to update wp-config.php"
|
# Update WP_HOME if it exists
|
||||||
|
sed -i -E "s|define[[:space:]]*\([[:space:]]*['\"]WP_HOME['\"][[:space:]]*,[[:space:]]*['\"][^'\"]*['\"][[:space:]]*\)|define( 'WP_HOME', '${TARGET_URL}' )|g" "$CONFIG_FILE"
|
||||||
|
|
||||||
|
# Update WP_SITEURL if it exists
|
||||||
|
sed -i -E "s|define[[:space:]]*\([[:space:]]*['\"]WP_SITEURL['\"][[:space:]]*,[[:space:]]*['\"][^'\"]*['\"][[:space:]]*\)|define( 'WP_SITEURL', '${TARGET_URL}' )|g" "$CONFIG_FILE"
|
||||||
|
|
||||||
|
# Update HTTP_HOST if it exists
|
||||||
|
sed -i -E "s|(\\\$_SERVER\[['\"]HTTP_HOST['\"]\][[:space:]]*=[[:space:]]*['\"])[^'\"]*(['\"];)|\1${HOST_ONLY}\2|g" "$CONFIG_FILE"
|
||||||
|
|
||||||
# Determine which entries are missing to avoid duplicates
|
# Determine which entries are missing to avoid duplicates
|
||||||
needs_home=1
|
needs_home=1
|
||||||
|
|
@ -243,7 +250,7 @@ sed -i -E "s|define\([[:space:]]*['\"]WP_HOME['\"][[:space:]]*,[[:space:]]*['\"]
|
||||||
if grep -Eq "define[[:space:]]*\([[:space:]]*['\"]WP_SITEURL['\"]" "$CONFIG_FILE"; then
|
if grep -Eq "define[[:space:]]*\([[:space:]]*['\"]WP_SITEURL['\"]" "$CONFIG_FILE"; then
|
||||||
needs_siteurl=0
|
needs_siteurl=0
|
||||||
fi
|
fi
|
||||||
if grep -Eq "\$_SERVER\[(\"|')HTTP_HOST\1\][[:space:]]*=" "$CONFIG_FILE"; then
|
if grep -Eq '\$_SERVER\[["\x27]HTTP_HOST["\x27]\][[:space:]]*=' "$CONFIG_FILE"; then
|
||||||
needs_http_host=0
|
needs_http_host=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue