From cc65b80eb0bebe0e2d61c4e4b413b3bac729cf39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Nov=C3=BD?= Date: Fri, 5 Jun 2020 09:47:08 +0200 Subject: [PATCH] Check if port 80 is free before starting during install --- debian/control | 3 +++ debian/nginx-core.postinst | 7 ++++++- debian/nginx-extras.postinst | 7 ++++++- debian/nginx-light.postinst | 7 ++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index d1fc34b..4f00178 100644 --- a/debian/control +++ b/debian/control @@ -75,6 +75,7 @@ Depends: libnginx-mod-http-geoip (= ${binary:Version}), libnginx-mod-stream (= ${binary:Version}), libnginx-mod-stream-geoip (= ${binary:Version}), nginx-common (= ${source:Version}), + iproute2, ${misc:Depends}, ${shlibs:Depends} Breaks: nginx (<< 1.4.5-1), @@ -150,6 +151,7 @@ Package: nginx-light Architecture: any Depends: libnginx-mod-http-echo (= ${binary:Version}), nginx-common (= ${source:Version}), + iproute2, ${misc:Depends}, ${shlibs:Depends} Breaks: nginx (<< 1.4.5-1) @@ -196,6 +198,7 @@ Depends: libnginx-mod-http-auth-pam (= ${binary:Version}), libnginx-mod-stream-geoip (= ${binary:Version}), libnginx-mod-stream-geoip2 (= ${binary:Version}), nginx-common (= ${source:Version}), + iproute2, ${misc:Depends}, ${shlibs:Depends} Breaks: nginx (<< 1.4.5-1) diff --git a/debian/nginx-core.postinst b/debian/nginx-core.postinst index 2a1730f..b43571a 100644 --- a/debian/nginx-core.postinst +++ b/debian/nginx-core.postinst @@ -24,7 +24,12 @@ if [ -x /etc/init.d/nginx ]; then invoke-rc.d nginx upgrade || invoke-rc.d nginx restart exit $? else - invoke-rc.d nginx start || exit $? + if [ -z "$(ss -nlt 'sport = 80' | grep -v ^State)" ]; then + invoke-rc.d nginx start || exit $? + else + echo "Not attempting to start NGINX, port 80 is already in use." + exit 0 + fi fi fi diff --git a/debian/nginx-extras.postinst b/debian/nginx-extras.postinst index 2a1730f..b43571a 100644 --- a/debian/nginx-extras.postinst +++ b/debian/nginx-extras.postinst @@ -24,7 +24,12 @@ if [ -x /etc/init.d/nginx ]; then invoke-rc.d nginx upgrade || invoke-rc.d nginx restart exit $? else - invoke-rc.d nginx start || exit $? + if [ -z "$(ss -nlt 'sport = 80' | grep -v ^State)" ]; then + invoke-rc.d nginx start || exit $? + else + echo "Not attempting to start NGINX, port 80 is already in use." + exit 0 + fi fi fi diff --git a/debian/nginx-light.postinst b/debian/nginx-light.postinst index 2a1730f..b43571a 100644 --- a/debian/nginx-light.postinst +++ b/debian/nginx-light.postinst @@ -24,7 +24,12 @@ if [ -x /etc/init.d/nginx ]; then invoke-rc.d nginx upgrade || invoke-rc.d nginx restart exit $? else - invoke-rc.d nginx start || exit $? + if [ -z "$(ss -nlt 'sport = 80' | grep -v ^State)" ]; then + invoke-rc.d nginx start || exit $? + else + echo "Not attempting to start NGINX, port 80 is already in use." + exit 0 + fi fi fi