Improving and correcting problems on packages
This commit is contained in:
parent
f5d87849a9
commit
4d49f2f4b6
|
@ -5,8 +5,8 @@ After=bunkerweb.service
|
|||
|
||||
[Service]
|
||||
Restart=no
|
||||
StartLimitBurst=1
|
||||
User=root
|
||||
PIDFile=/var/tmp/bunkerweb/ui.pid
|
||||
ExecStart=/usr/share/bunkerweb/scripts/bunkerweb-ui.sh start
|
||||
ExecStop=/usr/share/bunkerweb/scripts/bunkerweb-ui.sh stop
|
||||
ExecReload=/usr/share/bunkerweb/scripts/bunkerweb-ui.sh reload
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--license agpl3
|
||||
--version %VERSION%
|
||||
--architecture x86_64
|
||||
--depends bash --depends epel-release --depends python39 --depends 'nginx = 1:1.22.1-1.el8.ngx' --depends libcurl-devel --depends libxml2 --depends lmdb-libs --depends GeoIP-devel --depends file-libs --depends net-tools --depends gd --depends sudo --depends procps
|
||||
--depends bash --depends epel-release --depends python39 --depends 'nginx = 1:1.22.1-1.el8.ngx' --depends libcurl-devel --depends libxml2 --depends lmdb-libs --depends GeoIP-devel --depends file-libs --depends net-tools --depends gd --depends sudo --depends procps --depends lsof
|
||||
--description "BunkerWeb %VERSION% for CentOS Stream 8"
|
||||
--url "https://www.bunkerweb.io"
|
||||
--maintainer "Bunkerity <contact at bunkerity dot com>"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--license agpl3
|
||||
--version %VERSION%
|
||||
--architecture amd64
|
||||
--depends bash --depends python3 --depends procps --depends python3-pip --depends 'nginx = 1.22.1-1~bullseye' --depends libcurl4 --depends libgeoip-dev --depends libxml2 --depends libyajl2 --depends libmagic1 --depends net-tools --depends sudo
|
||||
--depends bash --depends python3 --depends procps --depends python3-pip --depends 'nginx = 1.22.1-1~bullseye' --depends libcurl4 --depends libgeoip-dev --depends libxml2 --depends libyajl2 --depends libmagic1 --depends net-tools --depends sudo --depends lsof
|
||||
--description "BunkerWeb %VERSION% for Debian 11"
|
||||
--url "https://www.bunkerweb.io"
|
||||
--maintainer "Bunkerity <contact at bunkerity dot com>"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--license agpl3
|
||||
--version %VERSION%
|
||||
--architecture x86_64
|
||||
--depends bash --depends python3 --depends 'nginx = 1:1.22.1-2.fc36' --depends libcurl-devel --depends libxml2 --depends lmdb-libs --depends geoip-devel --depends gd --depends sudo --depends procps
|
||||
--depends bash --depends python3 --depends 'nginx = 1:1.22.1-2.fc36' --depends libcurl-devel --depends libxml2 --depends lmdb-libs --depends geoip-devel --depends gd --depends sudo --depends procps --depends lsof
|
||||
--description "BunkerWeb %VERSION% for Fedora 36"
|
||||
--url "https://www.bunkerweb.io"
|
||||
--maintainer "Bunkerity <contact at bunkerity dot com>"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--license agpl3
|
||||
--version %VERSION%
|
||||
--architecture x86_64
|
||||
--depends bash --depends epel-release --depends python39 --depends 'nginx = 1:1.22.1-1.el8.ngx' --depends libcurl-devel --depends libxml2 --depends lmdb-libs --depends GeoIP-devel --depends file-libs --depends net-tools --depends gd --depends sudo --depends procps
|
||||
--depends bash --depends epel-release --depends python39 --depends 'nginx = 1:1.22.1-1.el8.ngx' --depends libcurl-devel --depends libxml2 --depends lmdb-libs --depends GeoIP-devel --depends file-libs --depends net-tools --depends gd --depends sudo --depends procps --depends lsof
|
||||
--description "BunkerWeb %VERSION% for Rhel 8"
|
||||
--url "https://www.bunkerweb.io"
|
||||
--maintainer "Bunkerity <contact at bunkerity dot com>"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
--name bunkerweb
|
||||
--license agpl3
|
||||
--version %VERSION%
|
||||
--depends bash --depends python3 --depends python3-pip --depends 'nginx = 1.22.1-1~jammy' --depends libcurl4 --depends libgeoip-dev --depends libxml2 --depends libyajl2 --depends libmagic1 --depends net-tools --depends sudo --depends procps
|
||||
--depends bash --depends python3 --depends python3-pip --depends 'nginx = 1.22.1-1~jammy' --depends libcurl4 --depends libgeoip-dev --depends libxml2 --depends libyajl2 --depends libmagic1 --depends net-tools --depends sudo --depends procps --depends lsof
|
||||
--description "BunkerWeb %VERSION% for Ubuntu 22.04"
|
||||
--url "https://www.bunkerweb.io"
|
||||
--maintainer "Bunkerity <contact at bunkerity dot com>"
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
#!/bin/bash
|
||||
|
||||
function do_and_check_cmd() {
|
||||
if [ "$CHANGE_DIR" != "" ] ; then
|
||||
cd "$CHANGE_DIR"
|
||||
fi
|
||||
output=$("$@" 2>&1)
|
||||
ret="$?"
|
||||
if [ $ret -ne 0 ] ; then
|
||||
echo "❌ Error from command : $*"
|
||||
echo "$output"
|
||||
exit $ret
|
||||
fi
|
||||
#echo $output
|
||||
return 0
|
||||
}
|
||||
|
||||
# Check if we are root
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect OS
|
||||
OS=""
|
||||
if [ "$(grep Debian /etc/os-release)" != "" ] ; then
|
||||
OS="debian"
|
||||
elif [ "$(grep Ubuntu /etc/os-release)" != "" ] ; then
|
||||
OS="ubuntu"
|
||||
elif [ "$(grep CentOS /etc/os-release)" != "" ] ; then
|
||||
OS="centos"
|
||||
elif [ "$(grep Fedora /etc/os-release)" != "" ] ; then
|
||||
OS="fedora"
|
||||
fi
|
||||
|
||||
if [ "$OS" = "" ] ; then
|
||||
echo "❌ Unsupported Operating System"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stop nginx
|
||||
systemctl status nginx > /dev/null 2>&1
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "ℹ️ Stop nginx service"
|
||||
do_and_check_cmd systemctl stop nginx
|
||||
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
|
||||
|
||||
# echo "ℹ️ Remove bunkerweb-ui service"
|
||||
if [ -f "/lib/systemd/system/bunkerweb-ui.service" ] ; then
|
||||
echo "ℹ️ Remove bunkerweb-ui service"
|
||||
do_and_check_cmd systemctl stop bunkerweb-ui
|
||||
do_and_check_cmd systemctl disable bunkerweb-ui
|
||||
do_and_check_cmd rm -f /lib/systemd/system/bunkerweb-ui.service
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
do_and_check_cmd systemctl reset-failed
|
||||
fi
|
||||
# do_and_check_cmd systemctl disable bunkerweb-ui
|
||||
# do_and_check_cmd rm -f /etc/systemd/system/bunkerweb-ui.service
|
||||
# do_and_check_cmd systemctl daemon-reload
|
||||
# do_and_check_cmd systemctl reset-failed
|
||||
# do_and_check_cmd sed -i "s@nginx ALL=(root:root) NOPASSWD: /usr/share/bunkerweb/ui/linux.sh@@" /etc/sudoers
|
||||
|
||||
# Remove /usr/share/bunkerweb
|
||||
if [ -e "/usr/share/bunkerweb" ] ; then
|
||||
echo "ℹ️ Remove /usr/share/bunkerweb"
|
||||
do_and_check_cmd rm -rf /usr/share/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /etc/bunkerweb
|
||||
if [ -e "/etc/bunkerweb" ] ; then
|
||||
echo "ℹ️ Remove /etc/bunkerweb"
|
||||
do_and_check_cmd rm -rf /etc/bunkerweb
|
||||
fi
|
||||
|
||||
# # Remove /var/tmp/bunkerweb
|
||||
# if [ -e "/var/tmp/bunkerweb" ] ; then
|
||||
# echo "ℹ️ Remove /var/tmp/bunkerweb"
|
||||
# do_and_check_cmd rm -rf /var/tmp/bunkerweb
|
||||
# fi
|
||||
|
||||
# Remove /var/lib/bunkerweb
|
||||
if [ -e "/var/lib/bunkerweb" ] ; then
|
||||
echo "ℹ️ Remove /var/lib/bunkerweb"
|
||||
do_and_check_cmd rm -rf /var/lib/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /usr/bin/bwcli
|
||||
if [ -f "/usr/bin/bwcli" ] ; then
|
||||
echo "ℹ️ Remove /usr/bin/bwcli"
|
||||
do_and_check_cmd rm -f /usr/bin/bwcli
|
||||
fi
|
||||
|
||||
# Remove systemd service
|
||||
if [ -f "/lib/systemd/system/bunkerweb.service" ] ; then
|
||||
echo "ℹ️ Remove bunkerweb service"
|
||||
do_and_check_cmd systemctl stop bunkerweb
|
||||
do_and_check_cmd systemctl disable bunkerweb
|
||||
do_and_check_cmd rm -f /lib/systemd/system/bunkerweb.service
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
do_and_check_cmd systemctl reset-failed
|
||||
fi
|
||||
|
||||
# Uninstall nginx
|
||||
# if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] ; then
|
||||
# echo "ℹ️ Uninstall nginx"
|
||||
# do_and_check_cmd systemctl stop nginx
|
||||
# do_and_check_cmd apt remove nginx -y
|
||||
# echo "ℹ️ If you want to reinstall nginx, run the following command:"
|
||||
# echo "apt-get install nginx"
|
||||
# elif [ "$OS" = "centos" ] || [ "$OS" = "fedora" ] ; then
|
||||
# echo "ℹ️ Uninstall nginx"
|
||||
# do_and_check_cmd systemctl stop nginx
|
||||
# do_and_check_cmd yum remove nginx -y
|
||||
# echo "ℹ️ If you want to reinstall nginx, run the following command:"
|
||||
# echo "apt-get install nginx"
|
||||
# fi
|
||||
|
||||
# We're done
|
||||
echo "ℹ️ BunkerWeb successfully uninstalled"
|
|
@ -1,131 +1,123 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Function to run a command and check its return code
|
||||
function do_and_check_cmd() {
|
||||
if [ "$CHANGE_DIR" != "" ] ; then
|
||||
cd "$CHANGE_DIR"
|
||||
fi
|
||||
output=$("$@" 2>&1)
|
||||
ret="$?"
|
||||
if [ $ret -ne 0 ] ; then
|
||||
echo "❌ Error from command : $*"
|
||||
echo "$output"
|
||||
exit $ret
|
||||
fi
|
||||
#echo $output
|
||||
return 0
|
||||
output=$("$@" 2>&1)
|
||||
ret="$?"
|
||||
if [ $ret -ne 0 ] ; then
|
||||
echo "❌ Error from command : $*"
|
||||
echo "$output"
|
||||
exit $ret
|
||||
else
|
||||
echo "✔️ Success: $*"
|
||||
echo "$output"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function reload_systemd() {
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
do_and_check_cmd systemctl reset-failed
|
||||
}
|
||||
|
||||
# remove a systemd service
|
||||
function remove_systemd_service {
|
||||
service=$1
|
||||
service_file="/lib/systemd/system/$service.service"
|
||||
echo "checking service $service with $service_file file "
|
||||
if test -f "$service_file"; then
|
||||
echo "ℹ️ Remove $service service"
|
||||
do_and_check_cmd systemctl stop $service
|
||||
do_and_check_cmd systemctl disable $service
|
||||
do_and_check_cmd rm -f "$service_file"
|
||||
reload_systemd
|
||||
else
|
||||
echo "❌ Error: $service file not found"
|
||||
do_and_check_cmd systemctl stop $service
|
||||
do_and_check_cmd systemctl disable $service
|
||||
reload_systemd
|
||||
fi
|
||||
}
|
||||
|
||||
function remove {
|
||||
echo "Package is being uninstalled"
|
||||
|
||||
# Stop nginx
|
||||
if systemctl is-active nginx; then
|
||||
echo "ℹ️ Stop nginx service"
|
||||
do_and_check_cmd systemctl stop nginx
|
||||
fi
|
||||
|
||||
remove_systemd_service "bunkerweb"
|
||||
remove_systemd_service "bunkerweb-ui"
|
||||
|
||||
# Remove /usr/share/bunkerweb
|
||||
if test -e "/usr/share/bunkerweb"; then
|
||||
echo "ℹ️ Remove /usr/share/bunkerweb"
|
||||
do_and_check_cmd rm -rf /usr/share/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /etc/bunkerweb
|
||||
if test -e "/var/tmp/bunkerweb"; then
|
||||
echo "ℹ️ Remove /var/tmp/bunkerweb"
|
||||
do_and_check_cmd rm -rf /var/tmp/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /var/lib/bunkerweb
|
||||
if test -e "/var/cache/bunkerweb"; then
|
||||
echo "ℹ️ Remove /var/cache/bunkerweb"
|
||||
do_and_check_cmd rm -rf /var/cache/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /usr/bin/bwcli
|
||||
if test -f "/usr/bin/bwcli"; then
|
||||
echo "ℹ️ Remove /usr/bin/bwcli"
|
||||
do_and_check_cmd rm -f /usr/bin/bwcli
|
||||
fi
|
||||
|
||||
echo "ℹ️ BunkerWeb successfully uninstalled"
|
||||
}
|
||||
|
||||
function purge() {
|
||||
echo "Package is being purged"
|
||||
remove
|
||||
|
||||
# Remove /var/lib/bunkerweb
|
||||
if test -e "/var/lib/bunkerweb"; then
|
||||
echo "ℹ️ Remove /var/lib/bunkerweb"
|
||||
do_and_check_cmd rm -rf /var/lib/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /var/tmp/bunkerweb/variables.env
|
||||
if test -d "/etc/bunkerweb"; then
|
||||
echo "ℹ️ Remove /etc/bunkerweb"
|
||||
do_and_check_cmd rm -rf /etc/bunkerweb
|
||||
fi
|
||||
|
||||
echo "ℹ️ BunkerWeb successfully purged"
|
||||
}
|
||||
|
||||
# Check if we are root
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect OS
|
||||
OS=""
|
||||
if [ "$(grep Debian /etc/os-release)" != "" ] ; then
|
||||
OS="debian"
|
||||
elif [ "$(grep Ubuntu /etc/os-release)" != "" ] ; then
|
||||
OS="ubuntu"
|
||||
elif [ "$(grep CentOS /etc/os-release)" != "" ] ; then
|
||||
OS="centos"
|
||||
elif [ "$(grep Fedora /etc/os-release)" != "" ] ; then
|
||||
OS="fedora"
|
||||
OS=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
|
||||
if ! [[ "$OS" =~ (debian|ubuntu|centos|fedora) ]]; then
|
||||
echo "❌ Unsupported Operating System"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$OS" = "" ] ; then
|
||||
echo "❌ Unsupported Operating System"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stop nginx
|
||||
systemctl status nginx > /dev/null 2>&1
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "ℹ️ Stop nginx service"
|
||||
do_and_check_cmd systemctl stop nginx
|
||||
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
|
||||
|
||||
# Remove UI service
|
||||
systemctl status bunkerweb-ui > /dev/null 2>&1
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo "ℹ️ Stop bunkerweb-ui service"
|
||||
do_and_check_cmd systemctl stop bunkerweb-ui
|
||||
fi
|
||||
|
||||
# echo "ℹ️ Remove bunkerweb-ui service"
|
||||
if [ -f "/lib/systemd/system/bunkerweb-ui.service" ] ; then
|
||||
echo "ℹ️ Remove bunkerweb-ui service"
|
||||
do_and_check_cmd systemctl stop bunkerweb-ui
|
||||
do_and_check_cmd systemctl disable bunkerweb-ui
|
||||
do_and_check_cmd rm -f /lib/systemd/system/bunkerweb-ui.service
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
do_and_check_cmd systemctl reset-failed
|
||||
fi
|
||||
# do_and_check_cmd systemctl disable bunkerweb-ui
|
||||
# do_and_check_cmd rm -f /etc/systemd/system/bunkerweb-ui.service
|
||||
# do_and_check_cmd systemctl daemon-reload
|
||||
# do_and_check_cmd systemctl reset-failed
|
||||
# do_and_check_cmd sed -i "s@nginx ALL=(root:root) NOPASSWD: /usr/share/bunkerweb/ui/linux.sh@@" /etc/sudoers
|
||||
|
||||
# Remove /usr/share/bunkerweb
|
||||
if [ -e "/usr/share/bunkerweb" ] ; then
|
||||
echo "ℹ️ Remove /usr/share/bunkerweb"
|
||||
do_and_check_cmd rm -rf /usr/share/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /etc/bunkerweb
|
||||
if [ -e "/etc/bunkerweb" ] ; then
|
||||
echo "ℹ️ Remove /etc/bunkerweb"
|
||||
do_and_check_cmd rm -rf /etc/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /var/tmp/bunkerweb
|
||||
if [ -e "/var/tmp/bunkerweb" ] ; then
|
||||
echo "ℹ️ Remove /var/tmp/bunkerweb"
|
||||
do_and_check_cmd rm -rf /var/tmp/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /var/lib/bunkerweb
|
||||
if [ -e "/var/lib/bunkerweb" ] ; then
|
||||
echo "ℹ️ Remove /var/lib/bunkerweb"
|
||||
do_and_check_cmd rm -rf /var/lib/bunkerweb
|
||||
fi
|
||||
|
||||
# Remove /usr/bin/bwcli
|
||||
if [ -f "/usr/bin/bwcli" ] ; then
|
||||
echo "ℹ️ Remove /usr/bin/bwcli"
|
||||
do_and_check_cmd rm -f /usr/bin/bwcli
|
||||
fi
|
||||
|
||||
# Remove systemd service
|
||||
if [ -f "/etc/systemd/system/bunkerweb.service" ] ; then
|
||||
echo "ℹ️ Remove bunkerweb service"
|
||||
do_and_check_cmd systemctl stop bunkerweb
|
||||
do_and_check_cmd systemctl disable bunkerweb
|
||||
do_and_check_cmd rm -f /etc/systemd/system/bunkerweb.service
|
||||
do_and_check_cmd systemctl daemon-reload
|
||||
do_and_check_cmd systemctl reset-failed
|
||||
fi
|
||||
|
||||
# Uninstall nginx
|
||||
# if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ] ; then
|
||||
# echo "ℹ️ Uninstall nginx"
|
||||
# do_and_check_cmd systemctl stop nginx
|
||||
# do_and_check_cmd apt remove nginx -y
|
||||
# echo "ℹ️ If you want to reinstall nginx, run the following command:"
|
||||
# echo "apt-get install nginx"
|
||||
# elif [ "$OS" = "centos" ] || [ "$OS" = "fedora" ] ; then
|
||||
# echo "ℹ️ Uninstall nginx"
|
||||
# do_and_check_cmd systemctl stop nginx
|
||||
# do_and_check_cmd yum remove nginx -y
|
||||
# echo "ℹ️ If you want to reinstall nginx, run the following command:"
|
||||
# echo "apt-get install nginx"
|
||||
# fi
|
||||
|
||||
# We're done
|
||||
echo "ℹ️ BunkerWeb successfully uninstalled"
|
||||
# Check if the package is being upgraded or uninstalled
|
||||
if [ "$1" = "remove" ]; then
|
||||
# Call the remove function
|
||||
remove
|
||||
elif [ "$1" = "purge" ]; then
|
||||
# Call the purge function
|
||||
purge
|
||||
else
|
||||
echo "Package is being upgraded"
|
||||
exit 0
|
||||
fi
|
|
@ -1,71 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# A shell option that causes the shell to exit immediately if a command exits with a non-zero status.
|
||||
set -e
|
||||
# if directory /usr/bin/bunkerweb/ exists then remove it
|
||||
if [ -d /usr/bin/bunkerweb/ ]; then
|
||||
echo "Removing /usr/bin/bunkerweb/ ..."
|
||||
rm -rf /usr/bin/bunkerweb/
|
||||
echo "Done !"
|
||||
fi
|
||||
# if directory /etc/systemd/system/bunkerweb.service exists then remove it
|
||||
if [ -f /etc/systemd/system/bunkerweb.service ]; then
|
||||
echo "Removing /etc/systemd/system/bunkerweb.service ..."
|
||||
rm -f /etc/systemd/system/bunkerweb.service
|
||||
echo "Done !"
|
||||
fi
|
||||
# if directory /etc/systemd/system/bunkerweb-ui.service exists then remove it
|
||||
if [ -f /etc/systemd/system/bunkerweb-ui.service ]; then
|
||||
echo "Removing /etc/systemd/system/bunkerweb-ui.service ..."
|
||||
rm -f /etc/systemd/system/bunkerweb-ui.service
|
||||
echo "Done !"
|
||||
fi
|
||||
|
||||
# Detect OS between Debian, Ubuntu, CentOS, Fedora
|
||||
if [ -f /etc/debian_version ]; then
|
||||
# Loop to erase all the files in /etc/nginx/
|
||||
for i in $( ls /etc/nginx/ ); do
|
||||
echo "Removing /etc/nginx/$i ..."
|
||||
rm -rf /etc/nginx/$i
|
||||
echo "Done !"
|
||||
done
|
||||
echo "If you want to reinstall nginx, please run the following command:"
|
||||
echo "sudo apt-get install nginx"
|
||||
elif [ -f /etc/centos-release ]; then
|
||||
# Loop to erase all the files in /etc/nginx/
|
||||
for i in $( ls /etc/nginx/ ); do
|
||||
echo "Removing /etc/nginx/$i ..."
|
||||
rm -rf /etc/nginx/$i
|
||||
echo "Done !"
|
||||
done
|
||||
echo "If you want to reinstall nginx, please run the following command:"
|
||||
echo "sudo yum install nginx"
|
||||
elif [ -f /etc/fedora-release ]; then
|
||||
# Loop to erase all the files in /etc/nginx/
|
||||
for i in $( ls /etc/nginx/ ); do
|
||||
echo "Removing /etc/nginx/$i ..."
|
||||
rm -rf /etc/nginx/$i
|
||||
echo "Done !"
|
||||
done
|
||||
echo "If you want to reinstall nginx, please run the following command:"
|
||||
echo "sudo dnf install nginx"
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
# Loop to erase all the files in /etc/nginx/
|
||||
for i in $( ls /etc/nginx/ ); do
|
||||
echo "Removing /etc/nginx/$i ..."
|
||||
rm -rf /etc/nginx/$i
|
||||
echo "Done !"
|
||||
done
|
||||
echo "If you want to reinstall nginx, please run the following command:"
|
||||
echo "sudo apt-get install nginx"
|
||||
else
|
||||
echo "Your OS is not supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if previous command was successful then restart systemd unit
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Restarting systemd ..."
|
||||
systemctl daemon-reload
|
||||
echo "Done !"
|
||||
fi
|
|
@ -1,59 +1,65 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Set the PYTHONPATH
|
||||
export PYTHONPATH=/usr/share/bunkerweb/deps/python
|
||||
|
||||
# Create ui.env file if it doesn't exist
|
||||
# Create the ui.env file if it doesn't exist
|
||||
if [ ! -f /etc/bunkerweb/ui.env ]; then
|
||||
# Creating a file called `ui.env` in the `/etc/bunkerweb` directory.
|
||||
echo -e "ADMIN_USERNAME=admin\nADMIN_PASSWORD=changeme\nABSOLUTE_URI=" > /etc/bunkerweb/ui.env
|
||||
echo "ADMIN_USERNAME=admin" > /etc/bunkerweb/ui.env
|
||||
echo "ADMIN_PASSWORD=changeme" >> /etc/bunkerweb/ui.env
|
||||
echo "ABSOLUTE_URI=" >> /etc/bunkerweb/ui.env
|
||||
fi
|
||||
|
||||
# function to start the UI
|
||||
# Function to start the UI
|
||||
start() {
|
||||
echo "Starting UI"
|
||||
python3 -m gunicorn --bind=127.0.0.1:7000 --chdir /usr/share/bunkerweb/ui/ --workers=1 --threads=2 --user scheduler --group scheduler main:app &
|
||||
# Source /etc/bunkerweb/ui.env to load variables
|
||||
source /etc/bunkerweb/ui.env
|
||||
# Export all variables to environment
|
||||
export $(cat /etc/bunkerweb/ui.env)
|
||||
echo "Starting UI"
|
||||
if [ ! -f /var/tmp/bunkerweb/ui.pid ]; then
|
||||
touch /var/tmp/bunkerweb/ui.pid
|
||||
fi
|
||||
# Check if there is a process listening on port 7000
|
||||
if lsof -i :7000; then
|
||||
echo "Killing existing process on port 7000"
|
||||
lsof -i :7000 | awk '{if(NR>1) print $2}' | xargs kill -9
|
||||
fi
|
||||
python3 -m gunicorn --bind=127.0.0.1:7000 --chdir /usr/share/bunkerweb/ui/ --workers=1 --threads=2 main:app &
|
||||
echo $! > /var/tmp/bunkerweb/ui.pid
|
||||
source /etc/bunkerweb/ui.env
|
||||
export $(cat /etc/bunkerweb/ui.env)
|
||||
}
|
||||
|
||||
# function to stop the UI
|
||||
stop(){
|
||||
echo "Stoping ui service ..."
|
||||
# Check if pid file exist and remove it if so
|
||||
PID_FILE_PATH="/var/tmp/bunkerweb/ui.pid"
|
||||
if [ -f "$PID_FILE_PATH" ];
|
||||
then
|
||||
var=$( cat $PID_FILE_PATH )
|
||||
kill -SIGINT $var
|
||||
echo "Killing : $var"
|
||||
|
||||
# Function to stop the UI
|
||||
stop() {
|
||||
echo "Stopping UI service..."
|
||||
if [ -f "/var/tmp/bunkerweb/ui.pid" ]; then
|
||||
kill -SIGINT $(cat /var/tmp/bunkerweb/ui.pid)
|
||||
rm -f /var/tmp/bunkerweb/ui.pid
|
||||
echo "UI service stopped."
|
||||
else
|
||||
echo "File doesn't exist"
|
||||
echo "UI service is not running or the pid file doesn't exist."
|
||||
fi
|
||||
}
|
||||
|
||||
# function reload the UI
|
||||
# Function to reload the UI
|
||||
reload() {
|
||||
stop_ui
|
||||
# Wait for ui to stop
|
||||
sleep 5
|
||||
start_ui
|
||||
# if previous command worked then exit with 0
|
||||
exit 0
|
||||
stop
|
||||
sleep 5
|
||||
start
|
||||
}
|
||||
|
||||
# Check the command line argument
|
||||
case $1 in
|
||||
"start")
|
||||
start
|
||||
;;
|
||||
"stop")
|
||||
stop
|
||||
;;
|
||||
"reload")
|
||||
reload
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ./bunkerweb-ui.sh start"
|
||||
"start")
|
||||
start
|
||||
;;
|
||||
esac
|
||||
"stop")
|
||||
stop
|
||||
;;
|
||||
"reload")
|
||||
reload
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|reload}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,13 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Stop nginx if it's running and remove the old config file if it exists
|
||||
#Start the nginx service
|
||||
echo "Starting nginx service..."
|
||||
systemctl start nginx
|
||||
|
||||
# Give all the permissions to the nginx user
|
||||
#Give all the permissions to the nginx user
|
||||
echo "Setting ownership for all necessary directories to nginx user and group..."
|
||||
chown -R nginx:nginx /usr/share/bunkerweb /var/cache/bunkerweb /var/lib/bunkerweb /etc/bunkerweb /var/tmp/bunkerweb
|
||||
|
||||
# Start bunkerweb service as nginx user and enable it to start on boot
|
||||
#Start bunkerweb service as nginx user and enable it to start on boot
|
||||
echo "Enabling and starting bunkerweb service..."
|
||||
systemctl enable bunkerweb
|
||||
systemctl start bunkerweb
|
||||
|
||||
#Start and enable bunkerweb-ui service
|
||||
echo "Enabling and starting bunkerweb-ui service..."
|
||||
systemctl enable bunkerweb-ui
|
||||
systemctl start bunkerweb-ui
|
||||
systemctl start bunkerweb-ui
|
||||
|
||||
echo "All services started and enabled successfully!"
|
|
@ -1,19 +0,0 @@
|
|||
#! /bin/sh
|
||||
|
||||
# A shell option that causes the shell to exit immediately if a command exits with a non-zero status.
|
||||
set -e
|
||||
|
||||
# if purge is called, we want to remove the old config file from the system
|
||||
# if it exists
|
||||
|
||||
if [ "$1" = "purge" ]; then
|
||||
# purge bunkerweb
|
||||
sudo systemctl stop bunkerweb
|
||||
sudo systemctl disable bunkerweb
|
||||
sudo rm -rf /usr/bin/bunkerweb/
|
||||
sudo rm -rf /etc/systemd/system/bunkerweb.service
|
||||
sudo rm -rf /etc/systemd/system/bunkerweb-ui.service
|
||||
|
||||
# reload unit files
|
||||
sudo systemctl daemon-reload
|
||||
fi
|
|
@ -1,57 +1,49 @@
|
|||
#!/bin/bash
|
||||
|
||||
. /usr/share/bunkerweb/helpers/utils.sh
|
||||
|
||||
#############################################################
|
||||
# Help #
|
||||
#############################################################
|
||||
function display_help()
|
||||
{
|
||||
# Display Help
|
||||
echo "Usage of this script"
|
||||
echo
|
||||
echo "Syntax: start [start|stop|reload]"
|
||||
echo "options:"
|
||||
echo "start Create the configurations file and run all the jobs needed throught the bunkerweb service."
|
||||
echo "stop Stop the bunkerweb service."
|
||||
echo "reload Reload the bunkerweb service"
|
||||
echo
|
||||
}
|
||||
# Source the utils helper script
|
||||
source /usr/share/bunkerweb/helpers/utils.sh
|
||||
|
||||
# Set the PYTHONPATH
|
||||
export PYTHONPATH=/usr/share/bunkerweb/deps/python/
|
||||
|
||||
#############################################################
|
||||
# Start #
|
||||
#############################################################
|
||||
# Display usage information
|
||||
function display_help() {
|
||||
echo "Usage: $(basename "$0") [start|stop|reload]"
|
||||
echo "Options:"
|
||||
echo " start: Create configurations and run necessary jobs for the bunkerweb service."
|
||||
echo " stop: Stop the bunkerweb service."
|
||||
echo " reload: Reload the bunkerweb service."
|
||||
}
|
||||
|
||||
# Start the bunkerweb service
|
||||
function start() {
|
||||
|
||||
# Set the PYTHONPATH
|
||||
export PYTHONPATH=/usr/share/bunkerweb/deps/python
|
||||
|
||||
# Get the pid of nginx and put it in a file
|
||||
log "ENTRYPOINT" "ℹ️" "Getting nginx pid ..."
|
||||
nginx_pid=$(ps aux | grep nginx | awk '{print $2}')
|
||||
nginx_pid=$(pgrep -x "nginx")
|
||||
echo $nginx_pid > /var/tmp/bunkerweb/nginx.pid
|
||||
|
||||
ps -ef | grep nginx | grep -v grep | awk '{print $2}' > /var/tmp/bunkerweb/nginx.pid
|
||||
|
||||
# Check if scheduler pid file exist and remove it if so
|
||||
if [ -f /var/tmp/bunkerweb/scheduler.pid ] ; then
|
||||
rm -f /var/tmp/bunkerweb/scheduler.pid
|
||||
fi
|
||||
|
||||
# setup and check /data folder
|
||||
# Setup and check /data folder
|
||||
/usr/share/bunkerweb/helpers/data.sh "ENTRYPOINT"
|
||||
|
||||
# Init database
|
||||
# generate "temp" config
|
||||
#get_env > "/tmp/variables.env"
|
||||
echo -e "IS_LOADING=yes\nSERVER_NAME=\nAPI_HTTP_PORT=${API_HTTP_PORT:-5000}\nAPI_SERVER_NAME=${API_SERVER_NAME:-bwapi}\nAPI_WHITELIST_IP=${API_WHITELIST_IP:-127.0.0.0/8}" > /var/tmp/bunkerweb/variables.env
|
||||
/usr/share/bunkerweb/gen/save_config.py --variables /var/tmp/bunkerweb/variables.env --init
|
||||
echo -e "IS_LOADING=yes\nSERVER_NAME=\nAPI_HTTP_PORT=${API_HTTP_PORT:-7000}\nAPI_SERVER_NAME=${API_SERVER_NAME:-bwapi}\nAPI_WHITELIST_IP=${API_WHITELIST_IP:-127.0.0.0/8}" > /etc/bunkerweb/variables.env
|
||||
/usr/share/bunkerweb/gen/save_config.py --variables /etc/bunkerweb/variables.env --init
|
||||
if [ "$?" -ne 0 ] ; then
|
||||
log "ENTRYPOINT" "❌" "Scheduler generator failed"
|
||||
exit 1
|
||||
fi
|
||||
# execute jobs
|
||||
|
||||
# Execute jobs
|
||||
log "ENTRYPOINT" "ℹ️ " "Executing scheduler ..."
|
||||
/usr/share/bunkerweb/scheduler/main.py --variables /var/tmp/bunkerweb/variables.env
|
||||
/usr/share/bunkerweb/scheduler/main.py --variables /etc/bunkerweb/variables.env
|
||||
if [ "$?" -ne 0 ] ; then
|
||||
log "ENTRYPOINT" "❌" "Scheduler failed"
|
||||
exit 1
|
||||
|
@ -61,44 +53,41 @@ function start() {
|
|||
exit 0
|
||||
}
|
||||
|
||||
function stop()
|
||||
{
|
||||
ret=0
|
||||
function stop() {
|
||||
ret=0
|
||||
|
||||
log "ENTRYPOINT" "ℹ️" "Stopping BunkerWeb service ..."
|
||||
|
||||
|
||||
# Check if pid file exist and remove it if so
|
||||
PID_FILE_PATH="/var/tmp/bunkerweb/scheduler.pid"
|
||||
if [ -f "$PID_FILE_PATH" ];
|
||||
then
|
||||
var=$(cat "$PID_FILE_PATH")
|
||||
log "ENTRYPOINT" "ℹ️" "Sending stop signal to scheduler ..."
|
||||
kill -SIGINT $var
|
||||
result=$?
|
||||
if [ $result -ne 0 ] ; then
|
||||
log "ENTRYPOINT" "❌" "Your command exited with non-zero status $result"
|
||||
exit 1
|
||||
fi
|
||||
pid_file_path="/var/tmp/bunkerweb/scheduler.pid"
|
||||
if [ -f "$pid_file_path" ]; then
|
||||
scheduler_pid=$(cat "$pid_file_path")
|
||||
log "ENTRYPOINT" "ℹ️" "Sending stop signal to scheduler with pid: $scheduler_pid"
|
||||
kill -SIGINT $scheduler_pid
|
||||
if [ "$?" -ne 0 ]; then
|
||||
log "ENTRYPOINT" "❌" "Failed to stop scheduler process with pid: $scheduler_pid"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log "ENTRYPOINT" "❌" "Scheduler is not running"
|
||||
ret=1
|
||||
ret=1
|
||||
fi
|
||||
|
||||
# Check if nginx running and if so, stop it
|
||||
SERVICE="nginx"
|
||||
if pgrep -x "$SERVICE" > /dev/null
|
||||
then
|
||||
log "ENTRYPOINT" "ℹ️" "Sending stop signal to BunkerWeb ..."
|
||||
# Check if nginx is running and if so, stop it
|
||||
service="nginx"
|
||||
if pgrep -x "$service" > /dev/null; then
|
||||
log "ENTRYPOINT" "ℹ️" "Stopping $service service"
|
||||
nginx -s quit
|
||||
result=$?
|
||||
if [ $result -ne 0 ] ; then
|
||||
log "ENTRYPOINT" "❌" "Your command exited with non-zero status $result"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$?" -ne 0 ]; then
|
||||
log "ENTRYPOINT" "❌" "Failed to stop $service service"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log "ENTRYPOINT" "❌" "BunkerWeb is not running"
|
||||
exit 1
|
||||
log "ENTRYPOINT" "❌" "$service is not running"
|
||||
ret=1
|
||||
fi
|
||||
exit $ret
|
||||
|
||||
exit $ret
|
||||
}
|
||||
|
||||
function reload()
|
||||
|
@ -138,4 +127,4 @@ case $1 in
|
|||
echo "Invalid option!"
|
||||
echo "List of options availables:"
|
||||
display_help
|
||||
esac
|
||||
esac
|
|
@ -66,7 +66,7 @@ def handle_reload(signum, frame):
|
|||
try:
|
||||
if scheduler is not None and run:
|
||||
# Get the env by reading the .env file
|
||||
env = dotenv_values("/var/tmp/bunkerweb/variables.env")
|
||||
env = dotenv_values("/etc/bunkerweb/variables.env")
|
||||
if scheduler.reload(env):
|
||||
logger.info("Reload successful")
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue