pull/632/head
Mr Chen 6 months ago
parent 741e1aedf6
commit 3340112c11
  1. 6
      plugins/mysql-apt/index_mysql_apt.py
  2. 41
      plugins/mysql-yum/index.py
  3. 6
      plugins/mysql-yum/index_mysql_yum.py
  4. 2
      plugins/mysql/index.py
  5. 6
      plugins/mysql/index_mysql.py

@ -51,7 +51,7 @@ def getConf():
def getDataDir(): def getDataDir():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'datadir\s*=\s*(.*)' rep = r'datadir\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -59,7 +59,7 @@ def getDataDir():
def getRelayLogName(): def getRelayLogName():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'relay-log\s*=\s*(.*)' rep = r'relay-log\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -67,7 +67,7 @@ def getRelayLogName():
def getLogBinName(): def getLogBinName():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'log-bin\s*=\s*(.*)' rep = r'log-bin\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()

@ -85,21 +85,21 @@ def getConf():
def getDataDir(): def getDataDir():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'datadir\s*=\s*(.*)' rep = r'datadir\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
def getLogBinName(): def getLogBinName():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'log-bin\s*=\s*(.*)' rep = r'log-bin\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
def getPidFile(): def getPidFile():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'pid-file\s*=\s*(.*)' rep = r'pid-file\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -107,7 +107,7 @@ def getPidFile():
def getDbPort(): def getDbPort():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'port\s*=\s*(.*)' rep = r'port\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -115,7 +115,7 @@ def getDbPort():
def getDbServerId(): def getDbServerId():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'server-id\s*=\s*(.*)' rep = r'server-id\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -123,7 +123,7 @@ def getDbServerId():
def getSocketFile(): def getSocketFile():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'socket\s*=\s*(.*)' rep = r'socket\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
socket = tmp.groups()[0].strip() socket = tmp.groups()[0].strip()
@ -136,14 +136,14 @@ def getSocketFile():
def getErrorLogsFile(): def getErrorLogsFile():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'log-error\s*=\s*(.*)' rep = r'log-error\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
def getAuthPolicy(): def getAuthPolicy():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'authentication_policy\s*=\s*(.*)' rep = r'authentication_policy\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
if tmp: if tmp:
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -385,7 +385,7 @@ def getErrorLog():
def getShowLogFile(): def getShowLogFile():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'slow-query-log-file\s*=\s*(.*)' rep = r'slow-query-log-file\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -435,7 +435,7 @@ def initMysql8Data():
return True return True
def getLib64Pos(name=''): def getLib64Pos(name=''):
cmd = "ls /usr/lib64 | grep "+name+".so | cut -d \ -f 1 | awk 'END {print}'" cmd = "ls /usr/lib64 | grep "+name+".so | cut -d \\ -f 1 | awk 'END {print}'"
d = mw.execShell(cmd) d = mw.execShell(cmd)
return '/usr/lib64/'+d[0] return '/usr/lib64/'+d[0]
@ -604,7 +604,7 @@ def initdUinstall():
def getMyDbPos(): def getMyDbPos():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'datadir\s*=\s*(.*)' rep = r'datadir\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -655,7 +655,7 @@ def setMyDbPos(version=''):
def getMyPort(): def getMyPort():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'port\s*=\s*(.*)' rep = r'port\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -669,7 +669,7 @@ def setMyPort():
port = args['port'] port = args['port']
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = "port\s*=\s*([0-9]+)\s*\n" rep = r"port\s*=\s*([0-9]+)\s*\n"
content = re.sub(rep, 'port = ' + port + '\n', content) content = re.sub(rep, 'port = ' + port + '\n', content)
mw.writeFile(file, content) mw.writeFile(file, content)
restart() restart()
@ -757,7 +757,7 @@ def setDbStatus(version):
s = 'K' s = 'K'
if g in emptys: if g in emptys:
s = '' s = ''
rep = '\s*' + g + '\s*=\s*\d+(M|K|k|m|G)?\n' rep = r'\s*' + g + r'\s*=\s*\d+(M|K|k|m|G)?\n'
c = g + ' = ' + args[g] + s + '\n' c = g + ' = ' + args[g] + s + '\n'
if content.find(g) != -1: if content.find(g) != -1:
content = re.sub(rep, '\n' + c, content, 1) content = re.sub(rep, '\n' + c, content, 1)
@ -1349,7 +1349,7 @@ def addDb():
dataAccess = args['dataAccess'].strip() dataAccess = args['dataAccess'].strip()
ps = args['ps'].strip() ps = args['ps'].strip()
reg = "^[\w-]+$" reg = r"^[\w-]+$"
if not re.match(reg, args['name']): if not re.match(reg, args['name']):
return mw.returnJson(False, '数据库名称不能带有特殊符号!') return mw.returnJson(False, '数据库名称不能带有特殊符号!')
checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema'] checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema']
@ -1512,13 +1512,10 @@ def resetDbRootPwd(version):
auth_policy = getAuthPolicy() auth_policy = getAuthPolicy()
reset_pwd = 'flush privileges;' reset_pwd = 'flush privileges;'
reset_pwd = reset_pwd + \ reset_pwd = reset_pwd + "UPDATE mysql.user SET authentication_string='' WHERE user='root';"
"UPDATE mysql.user SET authentication_string='' WHERE user='root';"
reset_pwd = reset_pwd + "flush privileges;" reset_pwd = reset_pwd + "flush privileges;"
reset_pwd = reset_pwd + \ reset_pwd = reset_pwd + "alter user 'root'@'localhost' IDENTIFIED by '" + pwd + "';"
"alter user 'root'@'localhost' IDENTIFIED by '" + pwd + "';" reset_pwd = reset_pwd + "alter user 'root'@'localhost' IDENTIFIED WITH "+auth_policy+" by '" + pwd + "';"
reset_pwd = reset_pwd + \
"alter user 'root'@'localhost' IDENTIFIED WITH "+auth_policy+" by '" + pwd + "';"
reset_pwd = reset_pwd + "flush privileges;" reset_pwd = reset_pwd + "flush privileges;"
tmp_file = "/tmp/mysql_init_tmp.log" tmp_file = "/tmp/mysql_init_tmp.log"
@ -2113,7 +2110,7 @@ def addMasterRepSlaveUser(version=''):
username = args['username'].strip() username = args['username'].strip()
password = args['password'].strip() password = args['password'].strip()
reg = "^[\w-]+$" reg = r"^[\w-]+$"
if not re.match(reg, username): if not re.match(reg, username):
return mw.returnJson(False, '用户名不能带有特殊符号!') return mw.returnJson(False, '用户名不能带有特殊符号!')
checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema'] checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema']

@ -51,7 +51,7 @@ def getConf():
def getDataDir(): def getDataDir():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'datadir\s*=\s*(.*)' rep = r'datadir\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -59,7 +59,7 @@ def getDataDir():
def getRelayLogName(): def getRelayLogName():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'relay-log\s*=\s*(.*)' rep = r'relay-log\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -67,7 +67,7 @@ def getRelayLogName():
def getLogBinName(): def getLogBinName():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'log-bin\s*=\s*(.*)' rep = r'log-bin\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()

@ -954,7 +954,7 @@ def __createUser(dbname, username, password, address):
def getDbBackupListFunc(dbname=''): def getDbBackupListFunc(dbname=''):
bkDir = mw.getFatherDir() + '/backup/database' bkDir = mw.getBackupDir() + '/database'
blist = os.listdir(bkDir) blist = os.listdir(bkDir)
r = [] r = []

@ -52,7 +52,7 @@ def getConf():
def getDataDir(): def getDataDir():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'datadir\s*=\s*(.*)' rep = r'datadir\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -60,7 +60,7 @@ def getDataDir():
def getRelayLogName(): def getRelayLogName():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'relay-log\s*=\s*(.*)' rep = r'relay-log\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()
@ -68,7 +68,7 @@ def getRelayLogName():
def getLogBinName(): def getLogBinName():
file = getConf() file = getConf()
content = mw.readFile(file) content = mw.readFile(file)
rep = 'log-bin\s*=\s*(.*)' rep = r'log-bin\s*=\s*(.*)'
tmp = re.search(rep, content) tmp = re.search(rep, content)
return tmp.groups()[0].strip() return tmp.groups()[0].strip()

Loading…
Cancel
Save