mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[run] Fix
Fix get path
This commit is contained in:
@ -8,29 +8,28 @@ import subprocess
|
||||
mysqlParams = _dependence.install_params['MySQLServer']
|
||||
|
||||
def check_MySQLConfig(mysqlPath = ''):
|
||||
if (mysqlPath == ''):
|
||||
mysqlPath = _dependence.get_mysql_install_path()
|
||||
|
||||
if (base.run_command('"' + mysqlPath + 'bin\\mysql" -u ' + mysqlParams['user'] + ' -p' + mysqlParams['pass'] + ' -e "SHOW DATABASES;"')['stdout'].find('onlyoffice') == -1):
|
||||
mysql_path_to_bin = _dependence.get_mysql_path_to_bin(mysqlPath)
|
||||
|
||||
if (base.run_command(mysql_path_to_bin + ' -u ' + mysqlParams['user'] + ' -p' + mysqlParams['pass'] + ' -e "SHOW DATABASES;"')['stdout'].find('onlyoffice') == -1):
|
||||
print('Database onlyoffice not found')
|
||||
execMySQLScript(mysqlPath, os.getcwd() + '\\schema\\mysql\\createdb.sql')
|
||||
if (base.run_command('"' + mysqlPath + 'bin\\mysql" -u ' + mysqlParams['user'] + ' -p' + mysqlParams['pass'] + ' -e "SELECT plugin from mysql.user where User=' + "'" + mysqlParams['user'] + "';")['stdout'].find('mysql_native_password') == -1):
|
||||
execMySQLScript(mysql_path_to_bin, os.getcwd() + '\\schema\\mysql\\createdb.sql')
|
||||
if (base.run_command(mysql_path_to_bin + ' -u ' + mysqlParams['user'] + ' -p' + mysqlParams['pass'] + ' -e "SELECT plugin from mysql.user where User=' + "'" + mysqlParams['user'] + "';")['stdout'].find('mysql_native_password') == -1):
|
||||
print('Password encryption is not valid')
|
||||
set_MySQLEncrypt(mysqlPath, 'mysql_native_password')
|
||||
set_MySQLEncrypt(mysql_path_to_bin, 'mysql_native_password')
|
||||
|
||||
return True
|
||||
|
||||
def execMySQLScript(mysqlPath, scriptPath):
|
||||
def execMySQLScript(mysql_path_to_bin, scriptPath):
|
||||
print('Execution ' + scriptPath)
|
||||
code = subprocess.call('"' + mysqlPath + 'bin\\mysql" -u ' + mysqlParams['user'] + ' -p' + mysqlParams['pass'] + ' -e "source ' + scriptPath + '"', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
code = subprocess.call(mysql_path_to_bin + ' -u ' + mysqlParams['user'] + ' -p' + mysqlParams['pass'] + ' -e "source ' + scriptPath + '"', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
if (code != 0):
|
||||
print('Execution was failed!')
|
||||
return False
|
||||
print('Completed!')
|
||||
|
||||
def set_MySQLEncrypt(mysqlPath, sEncrypt):
|
||||
def set_MySQLEncrypt(mysql_path_to_bin, sEncrypt):
|
||||
print('Setting MySQL password encrypting...')
|
||||
code = subprocess.call('"' + mysqlPath + 'bin\\mysql" -u ' + mysqlParams['user'] + ' -p' + mysqlParams['pass'] + ' -e "' + "ALTER USER '" + mysqlParams['user'] + "'@'localhost' IDENTIFIED WITH " + sEncrypt + " BY '" + mysqlParams['pass'] + "';" + '"', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
code = subprocess.call(mysql_path_to_bin + ' -u ' + mysqlParams['user'] + ' -p' + mysqlParams['pass'] + ' -e "' + "ALTER USER '" + mysqlParams['user'] + "'@'localhost' IDENTIFIED WITH " + sEncrypt + " BY '" + mysqlParams['pass'] + "';" + '"', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
if (code != 0):
|
||||
print('Setting password encryption was failed!')
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user