diff --git a/helpers/install.sh b/helpers/install.sh index b05efcc..477c536 100644 --- a/helpers/install.sh +++ b/helpers/install.sh @@ -299,4 +299,6 @@ echo "[*] Download proxies list" do_and_check_cmd /opt/bunkerized-nginx/scripts/geoip.sh # We're done +echo "[*] Remove temp files" +do_and_check_cmd rm -rf /tmp/bunkerized-nginx echo "[*] bunkerized-nginx successfully installed !" \ No newline at end of file diff --git a/ui/src/Instances.py b/ui/src/Instances.py index 6d58a3a..13c0b94 100644 --- a/ui/src/Instances.py +++ b/ui/src/Instances.py @@ -1,4 +1,4 @@ -import docker, os, requests +import docker, os, requests, subprocess class Instances : @@ -16,6 +16,7 @@ class Instances : instance["type"] = type instance["status"] = status instance["data"] = data + return instance def __api_request(self, instance, order) : result = True @@ -34,6 +35,13 @@ class Instances : except : result = False + def __instance_from_id(self, id) : + instances = self.get_instances() + for instance in instances : + if instance["id"] == id : + return instance + raise Exception("Can't find instance with id " + id) + def get_instances(self) : instances = [] @@ -87,17 +95,20 @@ class Instances : return all_reload - def reload_instance(self, instance) : + def reload_instance(self, id) : + instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : - instance["data"].kill(signal="SIGHUP") + proc = subprocess.run(["/usr/sbin/nginx", "-s", "reload"], capture_output=True) + result = proc.returncode == 0 elif instance["type"] == "container" or instance["type"] == "service" : result = self.__api_request(instance, "/reload") if result : return "Instance " + instance["name"] + " has been reloaded." return "Can't reload " + instance["name"] - def start_instance(self, instance) : + def start_instance(self, id) : + instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : proc = subprocess.run(["/usr/sbin/nginx", "-g", "daemon on;"], capture_output=True) @@ -108,7 +119,8 @@ class Instances : return "Instance " + instance["name"] + " has been started." return "Can't start " + instance["name"] - def stop_instance(self, instance) : + def stop_instance(self, id) : + instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : proc = subprocess.run(["/usr/sbin/nginx", "-s", "quit"], capture_output=True) @@ -119,7 +131,8 @@ class Instances : return "Instance " + instance["name"] + " has been stopped." return "Can't stop " + instance["name"] - def restart_instance(self, instance) : + def restart_instance(self, id) : + instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : proc = subprocess.run(["/usr/sbin/nginx", "-s", "quit"], capture_output=True)