Fix shenanigans when removing DEB and RPM packages with 1.5.X versions

This commit is contained in:
Théophile Diot 2024-03-28 10:49:43 +00:00
parent f2154fb6af
commit 8e771ec379
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
4 changed files with 10 additions and 5 deletions

View file

@ -35,7 +35,7 @@ for test in tests/core/* ; do
done
shopt -u globstar
# linux
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" src/linux/scripts/*.sh
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" src/linux/scripts/beforeInstall.sh
# db
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" src/common/db/Database.py
sed -i "s@${OLD_VERSION}@${NEW_VERSION}@g" src/common/db/model.py

View file

@ -128,14 +128,15 @@ elif [ "$1" = "purge" ]; then
purge
else
echo "Package is being upgraded"
# Check the version of the package and if it's inferior to 1.5.6, we need to copy the variables.env file
# Check the version of the package and if it's inferior to 1.5.0, we need to copy the variables.env file
VERSION=$(dpkg-query -W -f='${Version}' bunkerweb)
if [ "$VERSION" != "1.5.6" ]; then
if ! [[ "$VERSION" =~ ^1\.5 ]]; then
echo " Copyenv variables to /var/tmp/bunkerweb/*.env"
do_and_check_cmd cp -f /opt/bunkerweb/variables.env /var/tmp/variables.env
do_and_check_cmd cp -f /opt/bunkerweb/ui.env /var/tmp/ui.env
fi
cp -f /etc/bunkerweb/variables.env /var/tmp/variables.env
cp -f /etc/bunkerweb/ui.env /var/tmp/ui.env
cp -f /var/lib/bunkerweb/db.sqlite3 /var/tmp/db.sqlite3
exit 0
fi

View file

@ -130,9 +130,9 @@ if [ "$1" = "0" ]; then
purge
elif [ "$1" = "1" ]; then
echo "Package is being upgraded"
# Check the version of the package and if it's inferior to 1.5.6, we need to copy the variables.env file
# Check the version of the package and if it's inferior to 1.5, we need to copy the variables.env file
VERSION=$(rpm -q --queryformat '%{VERSION}' bunkerweb)
if [ "$VERSION" != "1.5.6" ]; then
if ! [[ "$VERSION" =~ ^1\.5 ]]; then
echo " Copy /etc/bunkerweb/variables.env to /var/tmp/bunkerweb/variables.env"
do_and_check_cmd cp -f /opt/bunkerweb/variables.env /var/tmp/variables.env
do_and_check_cmd cp -f /opt/bunkerweb/ui.env /var/tmp/ui.env

View file

@ -39,6 +39,10 @@ if [ -f /etc/os-release ]; then
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
else
echo "❌ Error: /etc/os-release not found"
exit 1