Skip to content

Commit

Permalink
mariadb db upgraded for alma/redhat
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 12, 2024
1 parent 6de2b2c commit c3f4095
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion plogical/mysqlUtilities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os,sys
import shutil
from urllib.parse import unquote

sys.path.append('/usr/local/CyberCP')
Expand Down Expand Up @@ -1142,8 +1143,54 @@ def UpgradeMariaDB(versionToInstall, tempStatusPath):
command = 'DEBIAN_FRONTEND=noninteractive sudo apt-get install mariadb-server -y'
ProcessUtilities.executioner(command, 'root', True)

logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Completed [200]')

else:
CNFCurrentPath = '/etc/my.cnf.d/ '
CNFBackupPath = '/etc/cnfbackup/'

command = f'rsync -av {CNFCurrentPath} {CNFBackupPath}'
ProcessUtilities.executioner(command)

if os.path.exists('/etc/my.cnf'):
shutil.copy('/etc/my.cnf', f'{CNFBackupPath}/my.cnf')

command = 'yum remove mariadb* -y'
ProcessUtilities.executioner(command, 'root', True)


RepoPath = '/etc/yum.repos.d/mariadb.repo'
RepoContent = f"""
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/{versionToInstall}/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
"""

WriteToFile = open(RepoPath, 'w')
WriteToFile.write(RepoContent)
WriteToFile.close()



command = 'dnf update -y'
result = ProcessUtilities.outputExecutioner(command, 'root', True)

print(result)

command = 'dnf install mariadb-server -y'
result = ProcessUtilities.outputExecutioner(command, 'root', True)

print(result)

command = 'systemctl start mariadb && systemctl enable mariadb'
result = ProcessUtilities.outputExecutioner(command, 'root', True)

print(result)


logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'Completed [200]')


def main():
Expand Down

0 comments on commit c3f4095

Please sign in to comment.