- Reverse proxy info message for / at the end.
- Parked delete message improved.
- WP ENV better messages.
- Fix: WP ENV not working with cache parameter.
- Fix: redirection manager not deleting some regex.
This commit is contained in:
Cristhian Martínez Ochoa 2022-04-28 16:13:14 -06:00
parent 0b85aacbcf
commit 504dd5ef4d
3 changed files with 25 additions and 19 deletions

View file

@ -718,7 +718,7 @@ is_url() {
if [[ $2 == "-split" && $out != "false" ]]; then
url_scheme=$scheme
url_host=$host
[[ -n $path ]] && url_path="/$path"
[[ -n $path || $(echo "${1}" | rev | cut -c-1) == "/" ]] && url_path="/$path" # Check if / is alone, it's also a valid path!
url_port=$port
elif [[ $2 != "-split" ]]; then
echo $out
@ -990,8 +990,8 @@ is_log() {
escaped_string() {
# Escaped characters: Put a backslash before $.*/[\]^()
echo $(echo $1 | sed "s#/#\\\/#g" | sed "s/\./\\\./g" | sed "s/\\$/\\\\$/g" | sed "s/\*/\\\*/g" | sed "s/\\\/\\\\/g" | sed "s/\[/\\\[/g" | sed "s/\]/\\\]/g" | sed "s/\^/\\\^/g" | sed -E "s/\(/\\\(/g" | sed -E "s/\)/\\\)/g")
# Escaped characters: Put a backslash before $.*/[\]^()+
echo $(echo $1 | sed "s#/#\\\/#g" | sed "s/\./\\\./g" | sed "s/\\$/\\\\$/g" | sed "s/\*/\\\*/g" | sed "s/\\\/\\\\/g" | sed "s/\[/\\\[/g" | sed "s/\]/\\\]/g" | sed "s/\^/\\\^/g" | sed -E "s/\(/\\\(/g" | sed -E "s/\)/\\\)/g" | sed "s/\+/\\\+/g")
}

View file

@ -532,6 +532,9 @@ deletesite() {
echo "${red}[WARNING] This site is set as default site. Deleting this site can cause unexpected behaviour in your server."
sudo webinoly -default-site=default
fi
if [[ $(is_parked $domain) == "true" ]]; then
echo "${dim}This site is a parked site and main site data will not be removed.${end}"
fi
[[ $delete == "force" ]] && local dbdel="Y"
[[ $delete == "keep-db" ]] && local dbdel="N"
@ -886,7 +889,7 @@ redirection_manager() {
fi
if [[ -f /etc/nginx/apps.d/$domain-nginx.conf ]]; then
sudo sed -Ei "/^# RedirectFrom: $(escaped_string $from)( .*)?$/,/^# RedirectEnd/{/.*/d}" /etc/nginx/apps.d/$domain-nginx.conf
sudo sed -Ei '/^# RedirectFrom: '$(escaped_string $from)'( .*)?$/,/^# RedirectEnd/{/.*/d}' /etc/nginx/apps.d/$domain-nginx.conf
if [[ ! -s /etc/nginx/apps.d/$domain-nginx.conf ]]; then
sudo rm /etc/nginx/apps.d/$domain-nginx.conf
@ -1280,6 +1283,12 @@ reverse_proxy() {
[[ $(is_ssl $domain) != "true" ]] && sudo sed -i '/CacheStaticFiles/,/expires max;/{/headers-https.conf;/d}' /etc/nginx/apps.d/$domain$subname-proxy.conf
# Suggest / at the end of the url to pass
if [[ $(echo "${rpurl}" | rev | cut -c-1) != "/" ]]; then
echo "${dim}[INFO] Your endpoint URL doesn't have a / at the end! You should note that it can have a different behavior."
echo "Read: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass ${end}"
fi
# Check host and port
local code=$(wget -t 1 --timeout=5 --server-response --spider $rpurl 2>&1 | awk '/^ HTTP/{print $2}')
code="${code##*$'\n'}"
@ -1992,19 +2001,15 @@ wp_env_type() {
else
local index="0"
wp_config_write $domain WP_ENVIRONMENT_TYPE \'$env\' $subfolder
if [[ -n $cache ]]; then
wp_cache
elif [[ $(is_cache $domain $subfolder) =~ ^(wp|custom)$ ]]; then
cache="off"
wp_cache
fi
[[ -z $cache ]] && cache="off"
wp_cache
fi
# Not change WP debug when invoked from LOG command
if [[ -z $skip_debug ]]; then
if [[ $env =~ ^(production|staging)$ && $(is_wp_debug $domain $subfolder) == "true" ]]; then
if [[ $env =~ ^(production|staging)$ ]]; then
[[ -z $subfolder ]] && log $domain -wp=off || log $domain -wp=off -subfolder=$subfolder
elif [[ $env =~ ^(development|local)$ && $(is_wp_debug $domain $subfolder) != "true" ]]; then
else
[[ -z $subfolder ]] && log $domain -wp=on || log $domain -wp=on -subfolder=$subfolder
fi
fi
@ -2037,7 +2042,7 @@ _EOF_
[[ $index == "0" ]] && echo "${gre}Discourage Search Engines WP option has been enabled for${blu} $domain$subfolder ${gre}site!${end}"
[[ $index == "1" ]] && echo "${gre}Discourage Search Engines WP option has been disabled for${blu} $domain$subfolder ${gre}site!${end}"
else
echo "${blu}${dim}Database cannot be updated because WP is still empty! ${end}"
echo "${blu}${dim}Discourage Search Engines cannot be updated because WP is still empty! ${end}"
fi
else
echo "${red}${dim}[ERROR] Discourage Search Engines WP option not updated! (WP Configuration corrupted)${end}"

View file

@ -280,6 +280,13 @@ elif [[ -n $redirection && -f /etc/nginx/sites-available/$domain ]]; then
redirection_manager
# WordPress Environment Type
elif [[ -n $env && -f /etc/nginx/sites-available/$domain ]]; then
wp_env_type
nginx_not="true" # Nginx-Reload not-needed.
# ENV should be always before cache
# FastCGI Cache
elif [[ -n $cache && -f /etc/nginx/sites-available/$domain ]]; then
wp_cache
@ -421,12 +428,6 @@ elif [[ -n $replace_content && -f /etc/nginx/sites-available/$domain ]]; then
else
wp_replace_content
fi
# WordPress Environment Type
elif [[ -n $env && -f /etc/nginx/sites-available/$domain ]]; then
wp_env_type
nginx_not="true" # Nginx-Reload not-needed.
# List Sites