mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
Check mysql fix
This commit is contained in:
@ -2,14 +2,17 @@ import sys
|
||||
sys.path.append('../build_tools/scripts')
|
||||
import base
|
||||
import dependence as _dependence
|
||||
import shutil
|
||||
import os
|
||||
|
||||
if (sys.version_info[0] >= 3):
|
||||
import winreg
|
||||
else:
|
||||
import _winreg as winreg
|
||||
|
||||
def get_mysqlServersInfo(sParam):
|
||||
arrInfo = []
|
||||
def get_mysqlServersInfo():
|
||||
dictInfo = {'Location': [], 'Version': [], 'DataLocation' : []}
|
||||
|
||||
aReg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
|
||||
aKey= winreg.OpenKey(aReg, "SOFTWARE\\", 0, winreg.KEY_READ | winreg.KEY_WOW64_32KEY)
|
||||
|
||||
@ -21,68 +24,54 @@ def get_mysqlServersInfo(sParam):
|
||||
MySQLsubkey_name = winreg.EnumKey(asubkey, i)
|
||||
if (MySQLsubkey_name.find('MySQL Server') != - 1):
|
||||
MySQLsubkey = winreg.OpenKey(asubkey, MySQLsubkey_name)
|
||||
arrInfo.append(winreg.QueryValueEx(MySQLsubkey, sParam)[0])
|
||||
dictInfo['Location'].append(winreg.QueryValueEx(MySQLsubkey, 'Location')[0])
|
||||
dictInfo['Version'].append(winreg.QueryValueEx(MySQLsubkey, 'Version')[0])
|
||||
dictInfo['DataLocation'].append(winreg.QueryValueEx(MySQLsubkey, 'DataLocation')[0])
|
||||
except:
|
||||
pass
|
||||
|
||||
return arrInfo
|
||||
return dictInfo
|
||||
|
||||
def check_mysqlServersBitness(MySQLPaths):
|
||||
serversBitness = []
|
||||
def check_mysqlServer():
|
||||
base.print_info('Check MySQL Server')
|
||||
|
||||
for i in range(len(MySQLPaths)):
|
||||
mysqlServerPath = MySQLPaths[i]
|
||||
result = ""
|
||||
if (mysqlServerPath == ""):
|
||||
serversBitness.append("")
|
||||
else:
|
||||
result = base.run_command('"' + mysqlServerPath + 'bin\\mysql" --version')['stdout']
|
||||
if (result.find('for Win32') != -1):
|
||||
serversBitness.append('x32')
|
||||
elif (result.find('for Win64') != -1):
|
||||
serversBitness.append('x64')
|
||||
else:
|
||||
serversBitness.append('')
|
||||
return serversBitness
|
||||
|
||||
def check_mysqlServer(serversBitness, serversVersions, serversPaths, dataPaths):
|
||||
dependence = _dependence.CDependencies()
|
||||
|
||||
base.print_info('Check MySQL Server')
|
||||
for i in range(len(serversBitness)):
|
||||
if serversBitness[i] != '':
|
||||
break
|
||||
if (i == len(serversBitness) - 1):
|
||||
print('MySQL Server not found')
|
||||
dependence.append_install('MySQLServer')
|
||||
return dependence
|
||||
|
||||
for i in range(len(serversBitness)):
|
||||
result = serversBitness[i]
|
||||
if (result == ""):
|
||||
continue
|
||||
elif (result == 'x32'):
|
||||
print('MySQL Server ' + serversVersions[i][0:3] + ' bitness is x32, is not valid')
|
||||
dependence.append_uninstall('MySQL Server ' + serversVersions[i][0:3])
|
||||
dictInfo = get_mysqlServersInfo()
|
||||
mySQLServersPaths = dictInfo['Location']
|
||||
mySQLServersVersions = dictInfo['Version']
|
||||
mySQLServersDataPaths = dictInfo['DataLocation']
|
||||
|
||||
for i in range(len(mySQLServersPaths)):
|
||||
if (base.is_dir(mySQLServersPaths[i]) == False):
|
||||
continue
|
||||
elif (result == 'x64'):
|
||||
print('MySQL Server bitness is valid')
|
||||
connectionResult = base.run_command('"' + serversPaths[i] + 'bin\\mysql" -u root -ponlyoffice -e "SHOW GLOBAL VARIABLES LIKE ' + r"'PORT';" + '"')['stdout']
|
||||
|
||||
version_info = base.run_command('"' + mySQLServersPaths[i] + 'bin\\mysql" --version')['stdout']
|
||||
if (version_info.find('for Win64') != -1):
|
||||
print('MySQL Server ' + mySQLServersVersions[i] + ' bitness is valid')
|
||||
connectionResult = base.run_command('"' + mySQLServersPaths[i] + 'bin\\mysql" -u root -ponlyoffice -e "SHOW GLOBAL VARIABLES LIKE ' + r"'PORT';" + '"')['stdout']
|
||||
if (connectionResult.find('port') != -1 and connectionResult.find('3306') != -1):
|
||||
if (base.run_command('"' + serversPaths[i] + 'bin\\mysql" -u root -ponlyoffice -e "SHOW DATABASES;"')['stdout'].find('onlyoffice') == -1):
|
||||
print('MySQL Server ' + mySQLServersVersions[i] + ' configuration is valid')
|
||||
if (base.run_command('"' + mySQLServersPaths[i] + 'bin\\mysql" -u root -ponlyoffice -e "SHOW DATABASES;"')['stdout'].find('onlyoffice') == -1):
|
||||
print('Database onlyoffice not found')
|
||||
dependence.append_install('MySQLDatabase')
|
||||
if (base.run_command('"' + serversPaths[i] + 'bin\\mysql" -u root -ponlyoffice -e "SELECT plugin from mysql.user where User=' + "'root';")['stdout'].find('mysql_native_password') == -1):
|
||||
if (base.run_command('"' + mySQLServersPaths[i] + 'bin\\mysql" -u root -ponlyoffice -e "SELECT plugin from mysql.user where User=' + "'root';")['stdout'].find('mysql_native_password') == -1):
|
||||
print('Password encryption is not valid')
|
||||
dependence.append_install('MySQLEncrypt')
|
||||
dependence.pathToValidMySQLServer = serversPaths[i]
|
||||
dependence.pathToValidMySQLServer = mySQLServersPaths[i]
|
||||
return dependence
|
||||
else:
|
||||
print('MySQL Server configuration is not valid')
|
||||
dependence.append_uninstall('MySQL Server ' + serversVersions[i][0:3])
|
||||
dependence.append_removepath(serversPaths[i])
|
||||
dependence.append_install('MySQLServer')
|
||||
continue
|
||||
print('MySQL Server ' + mySQLServersVersions[i] + ' configuration is not valid')
|
||||
else:
|
||||
print('MySQL Server ' + mySQLServersVersions[i] + ' bitness is not valid')
|
||||
|
||||
print('Valid MySQL Server not found')
|
||||
|
||||
for i in range(len(mySQLServersVersions)):
|
||||
dependence.append_uninstall('MySQL Server ' + mySQLServersVersions[i][0:3])
|
||||
dependence.append_removepath(mySQLServersDataPaths[i])
|
||||
|
||||
dependence.append_install('MySQLServer')
|
||||
|
||||
return dependence
|
||||
|
||||
def check_dependencies():
|
||||
@ -95,13 +84,7 @@ def check_dependencies():
|
||||
final_dependence.append(_dependence.check_gruntcli())
|
||||
final_dependence.append(_dependence.check_buildTools())
|
||||
final_dependence.append(_dependence.check_mysqlInstaller())
|
||||
|
||||
mySQLServersPaths = get_mysqlServersInfo('Location')
|
||||
mySQLServersBitness = check_mysqlServersBitness(mySQLServersPaths)
|
||||
mySQLServersVersions = get_mysqlServersInfo('Version')
|
||||
mySQLServersDataPaths = get_mysqlServersInfo('DataLocation')
|
||||
|
||||
final_dependence.append(check_mysqlServer(mySQLServersBitness, mySQLServersVersions, mySQLServersPaths, mySQLServersDataPaths))
|
||||
final_dependence.append(check_mysqlServer())
|
||||
|
||||
return final_dependence
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ def installingProgram(sProgram, sParam = ''):
|
||||
return True
|
||||
elif (sProgram == 'MySQLServer'):
|
||||
print('Installing MySQL Server...')
|
||||
code = subprocess.call('"' + os.path.abspath(os.sep) + 'Program Files (x86)\\MySQL\\MySQL Installer for Windows\\MySQLInstallerConsole" community install server;8.0.21;x64:*:type=config;openfirewall=true;generallog=true;binlog=true;serverid=3306;enable_tcpip=true;port=3306;rootpasswd=onlyoffice -silent', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
code = subprocess.call('"' + os.environ['ProgramFiles(x86)'] + '\\MySQL\\MySQL Installer for Windows\\MySQLInstallerConsole" community install server;8.0.21;x64:*:type=config;openfirewall=true;generallog=true;binlog=true;serverid=3306;enable_tcpip=true;port=3306;rootpasswd=onlyoffice -silent', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
print(code)
|
||||
if (code == 0):
|
||||
print("Install success!")
|
||||
@ -83,7 +83,8 @@ configOptions = vars(options)
|
||||
for item in configOptions["uninstall"]:
|
||||
dependence.uninstallProgram(item)
|
||||
for item in configOptions["remove-path"]:
|
||||
shutil.rmtree(item)
|
||||
if (base.is_dir(item) == True):
|
||||
shutil.rmtree(item)
|
||||
for item in configOptions["install"]:
|
||||
if (item == 'MySQLDatabase' or item == 'MySQLEncrypt'):
|
||||
installingProgram(item, configOptions["mysql-path"])
|
||||
|
||||
Reference in New Issue
Block a user