Merge pull request #2906 from manuel-colmenero/master
fix: Check the location of nginx in a central way
This commit is contained in:
commit
8004f0962c
1 file changed
+32
-15
@@ -6,14 +6,36 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
|||||||
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
||||||
|
|
||||||
|
get_nginx_location() {
|
||||||
|
declare desc="check that nginx is at the expected location and return it"
|
||||||
|
local NGINX_LOCATION
|
||||||
|
|
||||||
|
NGINX_LOCATION=$(which nginx 2>/dev/null)
|
||||||
|
if [[ -z "$NGINX_LOCATION" ]]; then
|
||||||
|
NGINX_LOCATION="/usr/sbin/nginx"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$NGINX_LOCATION" ]]; then
|
||||||
|
dokku_log_fail "Could not find nginx binary in \$PATH or at '${NGINX_LOCATION}'."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$NGINX_LOCATION"
|
||||||
|
}
|
||||||
|
|
||||||
validate_nginx() {
|
validate_nginx() {
|
||||||
declare desc="validate entire nginx config"
|
declare desc="validate entire nginx config"
|
||||||
|
local NGINX_LOCATION
|
||||||
|
NGINX_LOCATION=$(get_nginx_location)
|
||||||
|
if [[ -z "$NGINX_LOCATION" ]]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
sudo /usr/sbin/nginx -t > /dev/null 2>&1
|
sudo "$NGINX_LOCATION" -t > /dev/null 2>&1
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
set -e
|
set -e
|
||||||
if [[ "$exit_code" -ne "0" ]]; then
|
if [[ "$exit_code" -ne "0" ]]; then
|
||||||
sudo /usr/sbin/nginx -t
|
sudo "$NGINX_LOCATION" -t
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
local conf_file
|
local conf_file
|
||||||
for conf_file in $DOKKU_ROOT/*/nginx.conf; do
|
for conf_file in $DOKKU_ROOT/*/nginx.conf; do
|
||||||
@@ -152,11 +174,6 @@ is_spdy_enabled() {
|
|||||||
local MAJOR_VERSION MINOR_VERSION PATCH_VERSION
|
local MAJOR_VERSION MINOR_VERSION PATCH_VERSION
|
||||||
local HAS_SUPPORT=true
|
local HAS_SUPPORT=true
|
||||||
|
|
||||||
if ! which nginx > /dev/null 2>&1; then
|
|
||||||
echo $HAS_SUPPORT
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
MAJOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[1]}')
|
MAJOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[1]}')
|
||||||
MINOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[2]}')
|
MINOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[2]}')
|
||||||
PATCH_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[3]}')
|
PATCH_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[3]}')
|
||||||
@@ -179,11 +196,6 @@ is_http2_enabled() {
|
|||||||
local MAJOR_VERSION MINOR_VERSION PATCH_VERSION
|
local MAJOR_VERSION MINOR_VERSION PATCH_VERSION
|
||||||
local HAS_SUPPORT=false
|
local HAS_SUPPORT=false
|
||||||
|
|
||||||
if ! which nginx > /dev/null 2>&1; then
|
|
||||||
echo $HAS_SUPPORT
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
MAJOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[1]}')
|
MAJOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[1]}')
|
||||||
MINOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[2]}')
|
MINOR_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[2]}')
|
||||||
PATCH_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[3]}')
|
PATCH_VERSION=$(echo "$NGINX_VERSION" | awk '{split($0,a,"."); print a[3]}')
|
||||||
@@ -281,9 +293,14 @@ nginx_build_config() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NGINX_VERSION="$(nginx -v 2>&1 | cut -d'/' -f 2)"
|
local NGINX_LOCATION NGINX_VERSION SPDY_SUPPORTED HTTP2_SUPPORTED
|
||||||
local SPDY_SUPPORTED="$(is_spdy_enabled "$NGINX_VERSION")"
|
NGINX_LOCATION=$(get_nginx_location)
|
||||||
local HTTP2_SUPPORTED="$(is_http2_enabled "$NGINX_VERSION")"
|
if [[ -z "$NGINX_LOCATION" ]]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
NGINX_VERSION="$("$NGINX_LOCATION" -v 2>&1 | cut -d'/' -f 2)"
|
||||||
|
SPDY_SUPPORTED="$(is_spdy_enabled "$NGINX_VERSION")"
|
||||||
|
HTTP2_SUPPORTED="$(is_http2_enabled "$NGINX_VERSION")"
|
||||||
|
|
||||||
eval "$(config_export app "$APP")"
|
eval "$(config_export app "$APP")"
|
||||||
local SIGIL_PARAMS=(-f $NGINX_TEMPLATE APP="$APP" DOKKU_ROOT="$DOKKU_ROOT"
|
local SIGIL_PARAMS=(-f $NGINX_TEMPLATE APP="$APP" DOKKU_ROOT="$DOKKU_ROOT"
|
||||||
|
|||||||
Reference in new issue
Block a user