Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function to upgrade major version of database #8482

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}