From b948e08bd5eb12c5567e53998b3a70fadf025f92 Mon Sep 17 00:00:00 2001 From: bunkerity Date: Wed, 18 Aug 2021 14:09:42 +0200 Subject: [PATCH] UI - use systemctl on Linux --- helpers/install.sh | 6 +++--- tests/Dockerfile-fedora | 2 +- ui/linux-reload.sh | 5 ----- ui/linux.sh | 10 ++++++++++ ui/src/Instances.py | 16 +++++++++------- 5 files changed, 23 insertions(+), 16 deletions(-) delete mode 100644 ui/linux-reload.sh create mode 100644 ui/linux.sh diff --git a/helpers/install.sh b/helpers/install.sh index 92fc620..8270c40 100755 --- a/helpers/install.sh +++ b/helpers/install.sh @@ -838,9 +838,9 @@ fi do_and_check_cmd chmod 755 /opt/bunkerized-nginx # Allow nginx group to do nginx reload as root if [ "$OS" != "alpine" ] ; then - do_and_check_cmd chown root:nginx /opt/bunkerized-nginx/ui/nginx-reload.sh - do_and_check_cmd chmod 750 /opt/bunkerized-nginx/ui/nginx-reload.sh - do_and_check_cmd chmod u+s /opt/bunkerized-nginx/ui/nginx-reload.sh + do_and_check_cmd chown root:nginx /opt/bunkerized-nginx/ui/linux.sh + do_and_check_cmd chmod 750 /opt/bunkerized-nginx/ui/linux.sh + do_and_check_cmd chmod u+s /opt/bunkerized-nginx/ui/linux.sh fi # Prepare log files and folders diff --git a/tests/Dockerfile-fedora b/tests/Dockerfile-fedora index f84a061..19efb67 100644 --- a/tests/Dockerfile-fedora +++ b/tests/Dockerfile-fedora @@ -13,4 +13,4 @@ rm -f /lib/systemd/system/anaconda.target.wants/*;\ rm -f /lib/systemd/system/*tmpfiles*;\ rm -f /lib/systemd/user/*tmpfiles*;\ find /lib/systemd/ -type f -iname "*.service" -exec rm -f {} \;;\ -find /etc/systemd/ -type f -inaùe "*.service" -exec rm -f {} \; +find /etc/systemd/ -type f -iname "*.service" -exec rm -f {} \; diff --git a/ui/linux-reload.sh b/ui/linux-reload.sh deleted file mode 100644 index c32f6bc..0000000 --- a/ui/linux-reload.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -systemctl reload nginx - -exit $? diff --git a/ui/linux.sh b/ui/linux.sh new file mode 100644 index 0000000..ed1a81b --- /dev/null +++ b/ui/linux.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +order="$1" +if [ "$order" != "reload" ] && [ "$order" != "start" ] && [ "$order" != "stop" ] && [ "$order" != "restart" ] ; then + exit 1 +fi + +systemctl "$1" nginx + +exit $? diff --git a/ui/src/Instances.py b/ui/src/Instances.py index 976208e..c73f86f 100644 --- a/ui/src/Instances.py +++ b/ui/src/Instances.py @@ -92,9 +92,13 @@ class Instances : all_reload = False continue if instance["type"] == "local" : - proc = subprocess.run(["/usr/sbin/nginx", "-s", "reload"], capture_output=True) + proc = subprocess.run(["/opt/bunkerized-nginx/entrypoint/jobs.sh"], capture_output=True) if proc.returncode != 0 : all_reload = False + else : + proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "reload"], capture_output=True) + if proc.returncode != 0 : + all_reload = False elif instance["type"] == "container" or instance["type"] == "service" : all_reload = self.__api_request(instance, "/reload") return all_reload @@ -107,7 +111,7 @@ class Instances : if proc.returncode != 0 : result = False else : - proc = subprocess.run(["/opt/bunkerized-nginx/ui/nginx-reload.sh"], capture_output=True) + proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "reload"], capture_output=True) result = proc.returncode == 0 elif instance["type"] == "container" or instance["type"] == "service" : result = self.__api_request(instance, "/reload") @@ -119,7 +123,7 @@ class Instances : instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : - proc = subprocess.run(["/usr/sbin/nginx", "-g", "daemon on;"], capture_output=True) + proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "start"], capture_output=True) result = proc.returncode == 0 elif instance["type"] == "container" or instance["type"] == "service" : result = False #self.__api_request(instance, "/start") @@ -131,7 +135,7 @@ class Instances : instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : - proc = subprocess.run(["/usr/sbin/nginx", "-s", "quit"], capture_output=True) + proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "stop"], capture_output=True) result = proc.returncode == 0 elif instance["type"] == "container" or instance["type"] == "service" : result = self.__api_request(instance, "/stop") @@ -143,9 +147,7 @@ class Instances : instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : - proc = subprocess.run(["/usr/sbin/nginx", "-s", "quit"], capture_output=True) - if proc.returncode == 0 : - proc = subprocess.run(["/usr/sbin/nginx", "-g", "daemon on;"], capture_output=True) + proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "restart"], capture_output=True) result = proc.returncode == 0 elif instance["type"] == "container" or instance["type"] == "service" : result = False #self.__api_request(instance, "/restart")