From bf44ee8377ee9f9cd587a9b20abcad5673324a4e Mon Sep 17 00:00:00 2001 From: luison Date: Sat, 12 Jan 2019 18:07:51 +0100 Subject: [PATCH 1/4] Added support for a nginx-custom.options file that can optionally replace any of the 2 compiling vars for nginx with custom values and retain them over updates if file is ignored. --- nginx-autoinstall.sh | 71 +++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/nginx-autoinstall.sh b/nginx-autoinstall.sh index a7a2cdde..2390e81f 100755 --- a/nginx-autoinstall.sh +++ b/nginx-autoinstall.sh @@ -191,30 +191,53 @@ case $OPTION in fi cd /usr/local/src/nginx/nginx-${NGINX_VER} || exit 1 - NGINX_OPTIONS=" - --prefix=/etc/nginx \ - --sbin-path=/usr/sbin/nginx \ - --conf-path=/etc/nginx/nginx.conf \ - --error-log-path=/var/log/nginx/error.log \ - --http-log-path=/var/log/nginx/access.log \ - --pid-path=/var/run/nginx.pid \ - --lock-path=/var/run/nginx.lock \ - --http-client-body-temp-path=/var/cache/nginx/client_temp \ - --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ - --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ - --user=nginx \ - --group=nginx \ - --with-cc-opt=-Wno-deprecated-declarations" - - NGINX_MODULES="--with-threads \ - --with-file-aio \ - --with-http_ssl_module \ - --with-http_v2_module \ - --with-http_mp4_module \ - --with-http_auth_request_module \ - --with-http_slice_module \ - --with-http_stub_status_module \ - --with-http_realip_module" + # Modules default configuration + # Check if custom nginx configuration exists + if [ -f nginx-custom.options ]; then + source nginx-custom.options + fi + + if [ -z ${NGINX_OPTIONS+x} ]; + then + echo "No NGINX_OPTIONS found, using default" + # Common configuration + NGINX_OPTIONS=" + --prefix=/etc/nginx \ + --sbin-path=/usr/sbin/nginx \ + --conf-path=/etc/nginx/nginx.conf \ + --error-log-path=/var/log/nginx/error.log \ + --http-log-path=/var/log/nginx/access.log \ + --pid-path=/var/run/nginx.pid \ + --lock-path=/var/run/nginx.lock \ + --http-client-body-temp-path=/var/cache/nginx/client_temp \ + --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ + --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ + --user=nginx \ + --group=nginx \ + --with-cc-opt=-Wno-deprecated-declarations" + fi + + if [ -z ${NGINX_MODULES+x} ]; + then + echo "No NGINX_MODULES found, using default" + NGINX_MODULES="--without-http_ssi_module \ + --without-http_scgi_module \ + --without-http_uwsgi_module \ + --without-http_geo_module \ + --without-http_split_clients_module \ + --without-http_memcached_module \ + --without-http_empty_gif_module \ + --without-http_browser_module \ + --with-threads \ + --with-file-aio \ + --with-http_ssl_module \ + --with-http_v2_module \ + --with-http_mp4_module \ + --with-http_auth_request_module \ + --with-http_slice_module \ + --with-http_stub_status_module \ + --with-http_realip_module" + fi # Optional modules if [[ "$LIBRESSL" = 'y' ]]; then From b51c720696c04f64d4aea0980b6dcb3657c64795 Mon Sep 17 00:00:00 2001 From: luison Date: Sat, 12 Jan 2019 18:15:31 +0100 Subject: [PATCH 2/4] Custom files and sample --- nginx-custom.options | 27 +++++++++++++++++++++++++ nginx-custom.options.sample | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 nginx-custom.options create mode 100644 nginx-custom.options.sample diff --git a/nginx-custom.options b/nginx-custom.options new file mode 100644 index 00000000..b4dae756 --- /dev/null +++ b/nginx-custom.options @@ -0,0 +1,27 @@ +# Custom Nginx compile options +# if renamed to nginx-custom.options +# will overwride values of NGINX_OPTIONS and/or NGINX_MODULES +# if defined here + + # Common configuration +# --prefix=/etc/nginx \0 +# --sbin-path=/usr/sbin/nginx" + + + NGINX_MODULES="--without-http_ssi_module \ + --without-http_scgi_module \ + --without-http_uwsgi_module \ + --without-http_split_clients_module \ + --without-http_memcached_module \ + --without-http_empty_gif_module \ + --without-http_browser_module \ + --without-http_mp4_module \ + --with-http_geo_module \ + --with-threads \ + --with-file-aio \ + --with-http_ssl_module \ + --with-http_v2_module \ + --with-http_auth_request_module \ + --with-http_slice_module \ + --with-http_stub_status_module \ + --with-http_realip_module" diff --git a/nginx-custom.options.sample b/nginx-custom.options.sample new file mode 100644 index 00000000..9f682334 --- /dev/null +++ b/nginx-custom.options.sample @@ -0,0 +1,40 @@ +# Custom Nginx compile options +# if renamed to nginx-custom.options +# will overwride values of NGINX_OPTIONS and/or NGINX_MODULES +# if defined here + + + # Optional + # NGINX_OPTIONS=" + # --prefix=/etc/nginx \ + # --sbin-path=/usr/sbin/nginx \ + # --conf-path=/etc/nginx/nginx.conf \ + # --error-log-path=/var/log/nginx/error.log \ + # --http-log-path=/var/log/nginx/access.log \ + # --pid-path=/var/run/nginx.pid \ + # --lock-path=/var/run/nginx.lock \ + # --http-client-body-temp-path=/var/cache/nginx/client_temp \ + # --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ + # --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ + # --user=nginx \ + # --group=nginx \ + # --with-cc-opt=-Wno-deprecated-declarations" + + #Optional + # NGINX_MODULES="--without-http_ssi_module \ + # --without-http_scgi_module \ + # --without-http_uwsgi_module \ + # --without-http_geo_module \ + # --without-http_split_clients_module \ + # --without-http_memcached_module \ + # --without-http_empty_gif_module \ + # --without-http_browser_module \ + # --with-threads \ + # --with-file-aio \ + # --with-http_ssl_module \ + # --with-http_v2_module \ + # --with-http_mp4_module \ + # --with-http_auth_request_module \ + # --with-http_slice_module \ + # --with-http_stub_status_module \ + # --with-http_realip_module" From 8809e7e993962d006bb00a2828b255354a861a61 Mon Sep 17 00:00:00 2001 From: luison Date: Sat, 12 Jan 2019 19:14:10 +0100 Subject: [PATCH 3/4] Moved conditional load of custom file as we are still on the scripts path --- nginx-autoinstall.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/nginx-autoinstall.sh b/nginx-autoinstall.sh index 2390e81f..9e8eb687 100755 --- a/nginx-autoinstall.sh +++ b/nginx-autoinstall.sh @@ -87,6 +87,13 @@ case $OPTION in ;; esac echo "" + # Check if custom nginx configuration exists and load it + if [ -f nginx-custom.options ]; then + #read -p "Found nginx-custom.options, we'll use those instead of default." + echo "Found nginx-custom.options, we'll use those instead of default." + source nginx-custom.options + fi + echo "" read -n1 -r -p "Nginx is ready to be installed, press any key to continue..." echo "" @@ -192,14 +199,11 @@ case $OPTION in cd /usr/local/src/nginx/nginx-${NGINX_VER} || exit 1 # Modules default configuration - # Check if custom nginx configuration exists - if [ -f nginx-custom.options ]; then - source nginx-custom.options - fi - + # Can be overwritten by custom file if loaded + if [ -z ${NGINX_OPTIONS+x} ]; then - echo "No NGINX_OPTIONS found, using default" + echo "No custom NGINX_OPTIONS found, using default" # Common configuration NGINX_OPTIONS=" --prefix=/etc/nginx \ @@ -219,7 +223,8 @@ case $OPTION in if [ -z ${NGINX_MODULES+x} ]; then - echo "No NGINX_MODULES found, using default" + echo "No custom NGINX_MODULES found, using default" + read -p "No NGINX_OPTIONS found, using default, press to continue" NGINX_MODULES="--without-http_ssi_module \ --without-http_scgi_module \ --without-http_uwsgi_module \ From 999a9703b9c266bf1e03a57d97ff3ee19e531adc Mon Sep 17 00:00:00 2001 From: luison Date: Sat, 12 Jan 2019 20:23:41 +0100 Subject: [PATCH 4/4] Ignoring local testing custom file --- .gitignore | 1 + nginx-custom.options | 27 --------------------------- 2 files changed, 1 insertion(+), 27 deletions(-) create mode 100644 .gitignore delete mode 100644 nginx-custom.options diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..53c7c081 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/nginx-custom.options diff --git a/nginx-custom.options b/nginx-custom.options deleted file mode 100644 index b4dae756..00000000 --- a/nginx-custom.options +++ /dev/null @@ -1,27 +0,0 @@ -# Custom Nginx compile options -# if renamed to nginx-custom.options -# will overwride values of NGINX_OPTIONS and/or NGINX_MODULES -# if defined here - - # Common configuration -# --prefix=/etc/nginx \0 -# --sbin-path=/usr/sbin/nginx" - - - NGINX_MODULES="--without-http_ssi_module \ - --without-http_scgi_module \ - --without-http_uwsgi_module \ - --without-http_split_clients_module \ - --without-http_memcached_module \ - --without-http_empty_gif_module \ - --without-http_browser_module \ - --without-http_mp4_module \ - --with-http_geo_module \ - --with-threads \ - --with-file-aio \ - --with-http_ssl_module \ - --with-http_v2_module \ - --with-http_auth_request_module \ - --with-http_slice_module \ - --with-http_stub_status_module \ - --with-http_realip_module"