Skip to content

Commit

Permalink
Merge pull request #8482 from inverse-inc/8475-mariadb-server-upgrade…
Browse files Browse the repository at this point in the history
…-fails

add function to upgrade major version of database
  • Loading branch information
JeGoi authored Jan 10, 2025
2 parents 655fb1d + b67ccfc commit d019469
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/full-upgrade/run-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function yum_upgrade_packetfence_package() {
set_upgrade_to
yum localinstall -y https://www.inverse.ca/downloads/PacketFence/RHEL8/packetfence-release-$UPGRADE_TO.el8.noarch.rpm
yum clean all --enablerepo=packetfence
yum_upgrade_mariadb_server
if is_enabled $1; then
yum update -y --enablerepo=packetfence --exclude=packetfence-upgrade --allowerasing
else
Expand Down
22 changes: 22 additions & 0 deletions addons/functions/database.functions
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,25 @@ function handle_devel_db_schema() {
cp /usr/local/pf/db/pf-schema-X.Y.sql /usr/local/pf/db/pf-schema-$restoring_version.sql
fi
}

function yum_upgrade_mariadb_server() {
installed=`rpm -q --whatprovides mysql-server 2> /dev/null`
if [ $? -eq 0 -a -n "$installed" ]; then
installed=`echo "$installed"|sed -n 1p`
version=`rpm -q --queryformat='%''{VERSION}' "$installed" 2>&1`
myversion=$(yum '--disablerepo=*' --enablerepo=packetfence --quiet list available --showduplicates MariaDB-server | grep -i mariadb-server | awk '{print $2}' | tail -1 2> /dev/null)

old_family=`echo $version | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
new_family=`echo $myversion | sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`

if [ "$old_family" != "$new_family" ]; then
echo "Upgrade MariaDB-server from ${old_family} to ${new_family}"
systemctl stop packetfence-mariadb.service
rpm -e --nodeps MariaDB-client MariaDB-common MariaDB-server MariaDB-shared
yum install -q -y MariaDB-server --enablerepo=packetfence
systemctl start packetfence-mariadb.service
mariadb-upgrade
fi
fi
}

0 comments on commit d019469

Please sign in to comment.