@@ -98,14 +98,10 @@ resolve_host() {
9898 local result=()
9999
100100 # Try to get IPv4 address
101- if ping -4 -c 1 " ${host} " & > /dev/null; then
102- ipv4=$( ping -4 -c 1 " $host " | awk -F'[ ()]' ' {print $2 }' | head -n 1)
103- fi
101+ ipv4=$( ping -4 -c 1 " $host " | awk -F'[ ()]' ' {print $2 }' | head -n 1)
104102
105103 # Fallback to find IP
106- if getent hosts "${host}" &>/dev/null; then
107- ip_fallback=$(getent hosts "${host}" | awk ' { print $1 }' )
108- fi
104+ ip_fallback=$(getent hosts "${host}" | awk ' { print $1 }' )
109105
110106 # No IP found
111107 if [[ -z "${ipv4}" && -z "${ip_fallback}" ]]; then
@@ -132,20 +128,20 @@ resolve_host() {
132128
133129# To enable NPP Plugin Nginx Cache Preload action:
134130# ############################################################################################################
135- # The NPP WordPress plugin uses ' wget' with ' WP_SITEURL' from inside the WordPress container to Preload cache.
136- # This means that if ' WP_SITEURL' is set to "localhost", wget will attempt to fetch URLs from
137- # the container’s own loopback interface rather than reaching the Nginx server that handles
131+ # The NPP WordPress plugin uses " wget" with " WP_SITEURL" from inside the WordPress container to Preload cache.
132+ # This means that if " WP_SITEURL" is set to "localhost", wget will attempt to fetch URLs from
133+ # the containers own loopback interface rather than reaching the Nginx server that handles
138134# cache preload requests.
139135#
140136# To handle that;
141137#
142138# Development Environments:
143- # - During ' wp core install' , the ' --url' parameter is hardcoded as ' https://localhost' ,
144- # so WP_SITEURL ends up being ' https://localhost' within the container.
145- # - In this scenario, Nginx Cache Preload requests will try to access ' https://localhost' , which
139+ # - During " wp core install" , the " --url" parameter is hardcoded as " https://localhost" ,
140+ # so WP_SITEURL ends up being " https://localhost" within the container.
141+ # - In this scenario, Nginx Cache Preload requests will try to access " https://localhost" , which
146142# incorrectly refers to the wordpress container itself.
147- # - To work around this, we update the wordpress container’s ' /etc/hosts' file to remap ' localhost' to either
148- # ' host.docker.internal' or the actual ' Nginx container IP' . This forces to retrieve resources
143+ # - To work around this, we update the wordpress containers " /etc/hosts" file to remap " localhost" to either
144+ # " host.docker.internal" or the actual " Nginx container IP" . This forces to retrieve resources
149145# from the correct endpoint, enabling the Nginx Cache Preload action during development.
150146# - Keep in mind! Below settings will not work here because of priority issue in /etc/hosts
151147# extra_hosts:
@@ -164,6 +160,7 @@ resolve_host() {
164160# extra_hosts:
165161# - "example.com:Nginx_LAN_IP"
166162# ##############################################################################################################
163+
167164if [[ " ${NPP_DEV_ENABLED} " -eq 1 ]]; then
168165 # Create array
169166 mapfile -t ip_array < <( resolve_host host.docker.internal)
@@ -191,7 +188,7 @@ if [[ "${NPP_DEV_ENABLED}" -eq 1 ]]; then
191188 echo -e " ${COLOR_GREEN}${COLOR_BOLD} NPP-WP:${COLOR_RESET} ${COLOR_RED} Hacked!${COLOR_RESET} Mapped ${COLOR_LIGHT_CYAN}${NPP_HTTP_HOST}${COLOR_RESET} to Nginx container IP ${COLOR_LIGHT_CYAN}${IP}${COLOR_RESET} in ${COLOR_LIGHT_CYAN}${HOSTS}${COLOR_RESET} ."
192189 fi
193190fi
194- # ######################################################################
191+ # ###############################################################################################################
195192
196193# Check ownership of webroot for consistency
197194check_ownership () {
0 commit comments