bunkerweb/tests/linux/Linux.sh

103 lines
3.1 KiB
Bash
Raw Permalink Normal View History

2023-10-02 10:05:15 +00:00
#!/bin/bash
2023-06-14 13:14:41 +00:00
# Small code to build and run the tests on Linux with docker
# Check if the package already exists in /tmp/$DISTRO/bunkerweb.deb or /tmp/$DISTRO/bunkerweb.rpm
# Always remove the package before building it
function checkPackage() {
2023-10-02 10:05:15 +00:00
if [ -n "$DISTRO" ]; then
2023-06-14 13:14:41 +00:00
if [ -f "/tmp/$DISTRO/bunkerweb.deb" ]; then
2023-10-02 10:05:15 +00:00
sudo rm -rf /tmp/"$DISTRO"/bunkerweb.deb
2023-06-14 13:14:41 +00:00
fi
if [ -f "/tmp/$DISTRO/bunkerweb.rpm" ]; then
2023-10-02 10:05:15 +00:00
sudo rm -rf /tmp/"$DISTRO"/bunkerweb.rpm
2023-06-14 13:14:41 +00:00
fi
fi
}
# Build the package using the dockerfile
function buildPackage() {
2023-10-02 10:05:15 +00:00
if [ -n "$DISTRO" ]; then
2023-06-14 13:14:41 +00:00
if [ "$DISTRO" = "ubuntu" ]; then
sudo docker build -t linux-ubuntu -f src/linux/Dockerfile-ubuntu .
fi
if [ "$DISTRO" = "debian-bookworm" ]; then
sudo docker build -t linux-debian-bookworm -f src/linux/Dockerfile-debian-bookworm .
2023-06-14 13:14:41 +00:00
fi
if [ "$DISTRO" = "debian-trixie" ]; then
sudo docker build -t linux-debian-trixie -f src/linux/Dockerfile-debian-trixie .
2023-06-14 13:14:41 +00:00
fi
2025-12-08 10:32:18 +00:00
if [ "$DISTRO" = "fedora-43" ]; then
sudo docker build -t linux-fedora-43 -f src/linux/Dockerfile-fedora-43 .
fi
2026-05-05 10:03:39 +00:00
if [ "$DISTRO" = "fedora-44" ]; then
sudo docker build -t linux-fedora-44 -f src/linux/Dockerfile-fedora-44 .
fi
2025-08-13 14:32:30 +00:00
if [ "$DISTRO" = "rhel-8" ]; then
sudo docker build -t linux-rhel-8 -f src/linux/Dockerfile-rhel-8 .
2024-02-05 09:44:38 +00:00
fi
2025-08-13 14:32:30 +00:00
if [ "$DISTRO" = "rhel-9" ]; then
sudo docker build -t linux-rhel-9 -f src/linux/Dockerfile-rhel-9 .
fi
if [ "$DISTRO" = "rhel-10" ]; then
sudo docker build -t linux-rhel-10 -f src/linux/Dockerfile-rhel-10 .
2024-02-05 09:44:38 +00:00
fi
2024-06-01 08:11:34 +00:00
if [ "$DISTRO" = "ubuntu-jammy" ]; then
sudo docker build -t linux-ubuntu-jammy -f src/linux/Dockerfile-ubuntu-jammy .
fi
2023-06-14 13:14:41 +00:00
fi
}
# Create the container and copy the package to the host
function createContainer() {
2023-10-02 10:05:15 +00:00
if [ -n "$DISTRO" ]; then
2023-06-14 13:14:41 +00:00
if [ "$DISTRO" = "ubuntu" ]; then
sudo docker run -v /tmp/ubuntu:/data linux-ubuntu
fi
if [ "$DISTRO" = "debian-bookworm" ]; then
sudo docker run -v /tmp/debian-bookworm:/data linux-debian-bookworm
fi
if [ "$DISTRO" = "debian-trixie" ]; then
sudo docker run -v /tmp/debian-trixie:/data linux-debian-trixie
2023-06-14 13:14:41 +00:00
fi
2025-12-08 10:32:18 +00:00
if [ "$DISTRO" = "fedora-43" ]; then
sudo docker run -v /tmp/fedora-43:/data linux-fedora-43
fi
2026-05-05 10:03:39 +00:00
if [ "$DISTRO" = "fedora-44" ]; then
sudo docker run -v /tmp/fedora-44:/data linux-fedora-44
fi
2025-08-13 14:32:30 +00:00
if [ "$DISTRO" = "rhel-8" ]; then
sudo docker run -v /tmp/rhel-8:/data linux-rhel-8
fi
if [ "$DISTRO" = "rhel-9" ]; then
sudo docker run -v /tmp/rhel-9:/data linux-rhel-9
2024-02-05 09:44:38 +00:00
fi
2025-08-13 14:32:30 +00:00
if [ "$DISTRO" = "rhel-10" ]; then
sudo docker run -v /tmp/rhel-10:/data linux-rhel-10
2024-02-05 09:44:38 +00:00
fi
2024-06-01 08:11:34 +00:00
if [ "$DISTRO" = "ubuntu-jammy" ]; then
sudo docker run -v /tmp/ubuntu-jammy:/data linux-ubuntu-jammy
fi
2023-06-14 13:14:41 +00:00
fi
}
# Retrieve $DISTRO from the user
function retrieveDistro() {
2026-05-16 15:19:17 +00:00
echo "Which distro do you want to use? (ubuntu, debian-bookworm, debian-trixie, fedora-43, fedora-44, rhel-8, rhel-9, rhel-10)"
2023-10-02 10:05:15 +00:00
read -r DISTRO
2023-06-14 13:14:41 +00:00
}
# Main function
function main() {
retrieveDistro
checkPackage
buildPackage
createContainer
}
main