UI - use systemctl on Linux

This commit is contained in:
bunkerity 2021-08-18 14:09:42 +02:00
parent fde14d1621
commit b948e08bd5
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
5 changed files with 23 additions and 16 deletions

View File

@ -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

View File

@ -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 {} \;

View File

@ -1,5 +0,0 @@
#!/bin/sh
systemctl reload nginx
exit $?

10
ui/linux.sh Normal file
View File

@ -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 $?

View File

@ -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")