fix: simplify beforeInstall.sh by removing OS checks and focusing on nginx backup

This commit is contained in:
Théophile Diot 2024-11-26 11:54:30 +01:00
parent 65040dec6f
commit 719eff3827
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -15,40 +15,8 @@ function do_and_check_cmd() {
return 0
}
# Check the os running
if [ -f /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
OS=$NAME
if [[ "$OS" == "Ubuntu" || "$OS" == "Debian" ]]; then
# Get the version of the package
VERSION=$(dpkg-query -W -f='${Version}' bunkerweb)
if dpkg --compare-versions "$VERSION" lt "1.6.0-beta" && [ -f /var/tmp/variables.env ] && [ -f /var/tmp/ui.env ]; then
echo " Copy /var/tmp/variables.env to /etc/bunkerweb/variables.env"
do_and_check_cmd cp -f /var/tmp/variables.env /etc/bunkerweb/variables.env
echo " Copy /var/tmp/ui.env to /etc/bunkerweb/ui.env"
do_and_check_cmd cp -f /var/tmp/ui.env /etc/bunkerweb/ui.env
fi
elif [[ "$OS" == "Red Hat Enterprise Linux" || "$OS" == "Fedora" ]]; then
# Get the version of the package
VERSION=$(rpm -q --queryformat '%{VERSION}' bunkerweb)
if [ "$(printf '%s\n' "$VERSION" "$(echo '1.6.0-beta' | tr -d ' ')" | sort -V | head -n 1)" = "$VERSION" ] && [ -f /var/tmp/variables.env ] && [ -f /var/tmp/ui.env ]; then
echo " Copy /var/tmp/variables.env to /etc/bunkerweb/variables.env"
do_and_check_cmd cp -f /var/tmp/variables.env /etc/bunkerweb/variables.env
echo " Copy /var/tmp/ui.env to /etc/bunkerweb/ui.env"
do_and_check_cmd cp -f /var/tmp/ui.env /etc/bunkerweb/ui.env
fi
fi
if [ -f /var/tmp/db.sqlite3 ]; then
echo " Copy /var/tmp/db.sqlite3 to /var/lib/bunkerweb/db.sqlite3"
do_and_check_cmd cp -f /var/tmp/db.sqlite3 /var/lib/bunkerweb/db.sqlite3
fi
if [ -d /etc/nginx ]; then
output_path="/etc/nginx_backup_$(date +%s)"
echo " Copy /etc/nginx to $output_path"
do_and_check_cmd cp -R /etc/nginx $output_path
fi
else
echo "❌ Error: /etc/os-release not found"
exit 1
if [ -d /etc/nginx ]; then
output_path="/etc/nginx_backup_$(date +%s)"
echo " Copy /etc/nginx to $output_path"
do_and_check_cmd cp -R /etc/nginx "$output_path"
fi