diff --git a/helpers/install.sh b/helpers/install.sh index 8270c40..31d2d2b 100755 --- a/helpers/install.sh +++ b/helpers/install.sh @@ -652,14 +652,14 @@ if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] ; then fi echo "[*] Install runtime dependencies" if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] ; then - DEBIAN_DEPS="certbot git cron curl python3 python3-pip procps" + DEBIAN_DEPS="certbot git cron curl python3 python3-pip procps sudo" DEBIAN_FRONTEND=noninteractive do_and_check_cmd apt install -y $DEBIAN_DEPS elif [ "$OS" = "centos" ] ; then do_and_check_cmd yum install -y epel-release - CENTOS_DEPS="certbot git crontabs curl python3 python3-pip procps" + CENTOS_DEPS="certbot git crontabs curl python3 python3-pip procps sudo" do_and_check_cmd yum install -y $CENTOS_DEPS elif [ "$OS" = "fedora" ] ; then - FEDORA_DEPS="certbot git crontabs curl python3 python3-pip procps nginx-mod-stream" + FEDORA_DEPS="certbot git crontabs curl python3 python3-pip procps nginx-mod-stream sudo" do_and_check_cmd dnf install -y $FEDORA_DEPS # Temp fix do_and_check_cmd cp /usr/lib64/nginx/modules/ngx_stream_module.so /usr/lib/nginx/modules/ngx_stream_module.so @@ -840,7 +840,7 @@ do_and_check_cmd chmod 755 /opt/bunkerized-nginx if [ "$OS" != "alpine" ] ; then 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 + echo "nginx ALL=(root:root) NOPASSWD: /opt/bunkerized-nginx/ui/linux.sh" >> /etc/sudoers fi # Prepare log files and folders diff --git a/helpers/uninstall.sh b/helpers/uninstall.sh index 121e406..894a288 100755 --- a/helpers/uninstall.sh +++ b/helpers/uninstall.sh @@ -44,6 +44,7 @@ if [ $? -eq 0 ] ; then fi # Reload old nginx.service file +echo "[*] Restore old nginx service" do_and_check_cmd mv /lib/systemd/system/nginx.service.bak /lib/systemd/system/nginx.service do_and_check_cmd systemctl daemon-reload @@ -54,10 +55,12 @@ if [ $? -eq 0 ] ; then systemctl status nginx > /dev/null 2>&1 do_and_check_cmd systemctl stop bunkerized-nginx-ui fi +echo "[*] Remove bunkerized-nginx-ui service" do_and_check_cmd systemctl disable bunkerized-nginx-ui do_and_check_cmd rm -f /lib/systemd/system/bunkerized-nginx-ui.service do_and_check_cmd systemctl daemon-reload do_and_check_cmd systemctl reset-failed +sed -i "s@nginx ALL=(root:root) NOPASSWD: /opt/bunkerized-nginx/ui/linux.sh@@" /etc/sudoers # Remove cron echo "[*] Remove cron" diff --git a/ui/src/Instances.py b/ui/src/Instances.py index c73f86f..0313962 100644 --- a/ui/src/Instances.py +++ b/ui/src/Instances.py @@ -96,7 +96,7 @@ class Instances : if proc.returncode != 0 : all_reload = False else : - proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "reload"], capture_output=True) + proc = subprocess.run(["sudo", "/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" : @@ -111,7 +111,7 @@ class Instances : if proc.returncode != 0 : result = False else : - proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "reload"], capture_output=True) + proc = subprocess.run(["sudo", "/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") @@ -123,7 +123,7 @@ class Instances : instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : - proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "start"], capture_output=True) + proc = subprocess.run(["sudo", "/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") @@ -135,7 +135,7 @@ class Instances : instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : - proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "stop"], capture_output=True) + proc = subprocess.run(["sudo", "/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") @@ -147,7 +147,7 @@ class Instances : instance = self.__instance_from_id(id) result = True if instance["type"] == "local" : - proc = subprocess.run(["/opt/bunkerized-nginx/ui/linux.sh", "restart"], capture_output=True) + proc = subprocess.run(["sudo", "/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")