Upgrade Debian/Ubuntu working

This commit is contained in:
AxyFr 2023-01-30 17:26:37 +01:00
parent 64961e3955
commit 8fcba30ab0
3 changed files with 163 additions and 34 deletions

View File

@ -6,7 +6,7 @@ export PYTHONPATH=/usr/share/bunkerweb/deps/python
# Create the ui.env file if it doesn't exist
if [ ! -f /etc/bunkerweb/ui.env ]; then
echo "ADMIN_USERNAME=admin" > /etc/bunkerweb/ui.env
echo "ADMIN_PASSWORD=changeme" >> /etc/bunkerweb/ui.env
echo "ADMIN_PASSWORD=PasswordChanged" >> /etc/bunkerweb/ui.env
echo "ABSOLUTE_URI=" >> /etc/bunkerweb/ui.env
fi
@ -16,25 +16,17 @@ start() {
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)
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
}
# Function to stop the UI
stop() {
echo "Stopping UI service..."
if [ -f "/var/tmp/bunkerweb/ui.pid" ]; then
pid = ps aux | grep gunicorn
kill $pid
#kill -SIGINT $(cat /var/tmp/bunkerweb/ui.pid)
rm -f /var/tmp/bunkerweb/ui.pid
kill -TERM $(cat /var/tmp/bunkerweb/ui.pid)
echo "UI service stopped."
else
echo "UI service is not running or the pid file doesn't exist."

View File

@ -1,4 +1,4 @@
FROM fedora:latest
FROM fedora:36
ENV container docker
@ -22,8 +22,6 @@ RUN dnf update -y && \
dnf install -y php-fpm curl gnupg2 ca-certificates redhat-lsb-core python3-pip which && \
dnf install nginx-1.20.2 -y
COPY ./packages/fedora/*.rpm /opt
VOLUME ["/sys/fs/cgroup"]
CMD ["/usr/sbin/init"]

View File

@ -14,6 +14,7 @@ if distro == "ubuntu":
}
subprocess.run(
[
"sudo",
"docker",
"build",
"-t",
@ -414,7 +415,29 @@ if distro == "ubuntu":
"systemd-ubuntu",
"bash",
"-c",
'sudo apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" nginx=1.20.2-1~jammy',
"sudo apt purge -y nginx",
]
)
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-ubuntu",
"bash",
"-c",
"sudo apt autoremove -y",
]
)
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-ubuntu",
"bash",
"-c",
'sudo apt-get install -y nginx=1.20.2-1~jammy',
]
)
subprocess.run(
@ -459,6 +482,39 @@ if distro == "ubuntu":
print("Old version:", old_version.stdout.decode().strip())
# Upgrading package
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-ubuntu",
"bash",
"-c",
"sudo apt remove -y nginx",
]
)
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-ubuntu",
"bash",
"-c",
"sudo apt purge -y nginx",
]
)
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-ubuntu",
"bash",
"-c",
"sudo apt autoremove -y",
]
)
subprocess.run(
[
"docker",
@ -510,6 +566,7 @@ elif distro == "debian":
}
subprocess.run(
[
"sudo",
"docker",
"build",
"-t",
@ -815,9 +872,9 @@ elif distro == "debian":
or os.path.exists("/var/cache/bunkerweb")
or os.path.exists("/usr/bin/bwcli")
):
test_results["Removing test"] = "OK"
else:
test_results["Removing test"] = "KO"
else:
test_results["Removing test"] = "OK"
except:
test_results["Removing test"] = "KO"
@ -871,9 +928,9 @@ elif distro == "debian":
# Checking Purging test
try:
if os.path.isdir("/var/lib/bunkerweb") or os.path.isdir("/etc/bunkerweb"):
test_results["Purging test"] = "OK"
else:
test_results["Purging test"] = "KO"
else:
test_results["Purging test"] = "OK"
except:
test_results["Purging test"] = "KO"
@ -899,7 +956,29 @@ elif distro == "debian":
"systemd-debian",
"bash",
"-c",
'sudo apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" nginx=1.20.2-1~bullseye',
"sudo apt purge -y nginx",
]
)
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-debian",
"bash",
"-c",
"sudo apt autoremove -y",
]
)
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-debian",
"bash",
"-c",
'sudo apt-get install -y nginx=1.20.2-1~bullseye',
]
)
subprocess.run(
@ -944,6 +1023,39 @@ elif distro == "debian":
print("Old version:", old_version.stdout.decode().strip())
# Upgrading package
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-debian",
"bash",
"-c",
"sudo apt remove -y nginx",
]
)
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-debian",
"bash",
"-c",
"sudo apt purge -y nginx",
]
)
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-debian",
"bash",
"-c",
"sudo apt autoremove -y",
]
)
subprocess.run(
[
"docker",
@ -994,6 +1106,7 @@ elif distro == "fedora":
}
subprocess.run(
[
"sudo",
"docker",
"build",
"-t",
@ -1005,6 +1118,7 @@ elif distro == "fedora":
)
subprocess.run(
[
"sudo",
"docker",
"run",
"-it",
@ -1017,6 +1131,7 @@ elif distro == "fedora":
)
subprocess.run(
[
"sudo",
"docker",
"run",
"-d",
@ -1351,23 +1466,37 @@ elif distro == "fedora":
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-fedora",
"bash",
"-c",
"sudo dnf remove -y nginx",
"rm",
"-f",
"systemd-{distro}".format(distro),
]
)
subprocess.run(
[
"sudo",
"docker",
"exec",
"-it",
"systemd-fedora",
"bash",
"-c",
"sudo dnf install -y nginx-1.20.2",
"build",
"-t",
"systemd-{}".format(distro),
"-f",
"tests/Dockerfile-fedora",
".",
]
)
subprocess.run(
[
"sudo",
"docker",
"run",
"-d",
"--name",
"systemd-{}".format(distro),
"--privileged",
"-v",
"/sys/fs/cgroup:/sys/fs/cgroup",
"-v",
"deb:/data",
"systemd-{}".format(distro),
]
)
subprocess.run(
@ -1420,6 +1549,17 @@ elif distro == "fedora":
print("Old version:", old_version.stdout.decode().strip())
# Upgrading package
subprocess.run(
[
"docker",
"exec",
"-it",
"systemd-fedora",
"bash",
"-c",
"sudo dnf upgrade -y",
]
)
subprocess.run(
[
"docker",
@ -1431,7 +1571,6 @@ elif distro == "fedora":
"sudo dnf install -y /data/bunkerweb.deb",
]
)
# Checking version
new_version = subprocess.run(
[