UI - use sudo for Linux integration

This commit is contained in:
bunkerity 2021-08-18 14:38:31 +02:00
parent b948e08bd5
commit 0938b20eb8
No known key found for this signature in database
GPG Key ID: 3D80806F12602A7C
3 changed files with 12 additions and 9 deletions

View File

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

View File

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

View File

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