mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 13:56:01 +01:00
bug fix: remote mysql install
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import subprocess, shlex
|
||||
import install
|
||||
import time
|
||||
|
||||
class mysqlUtilities:
|
||||
|
||||
@@ -6,14 +8,16 @@ class mysqlUtilities:
|
||||
def createDatabase(dbname, dbuser, dbpassword):
|
||||
|
||||
try:
|
||||
createDB = "CREATE DATABASE " + dbname
|
||||
|
||||
try:
|
||||
from json import loads
|
||||
mysqlData = loads(open("/etc/cyberpanel/mysqlPassword", 'r').read())
|
||||
|
||||
createDB = "CREATE DATABASE " + dbname
|
||||
|
||||
initCommand = 'mysql -h %s --port %s -u %s -p%s -e "' % (mysqlData['mysqlhost'], mysqlData['mysqlport'], mysqlData['mysqluser'], mysqlData['mysqlpassword'])
|
||||
|
||||
|
||||
except:
|
||||
passFile = "/etc/cyberpanel/mysqlPassword"
|
||||
|
||||
@@ -21,11 +25,14 @@ class mysqlUtilities:
|
||||
data = f.read()
|
||||
password = data.split('\n', 1)[0]
|
||||
|
||||
createDB = "CREATE DATABASE " + dbname
|
||||
initCommand = 'mysql -u root -p' + password + ' -e "'
|
||||
|
||||
command = initCommand + createDB + '"'
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(command)
|
||||
time.sleep(10)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
@@ -36,6 +43,10 @@ class mysqlUtilities:
|
||||
|
||||
command = initCommand + createUser + '"'
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(command)
|
||||
time.sleep(10)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
@@ -44,6 +55,11 @@ class mysqlUtilities:
|
||||
else:
|
||||
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'"
|
||||
command = initCommand + dropDB + '"'
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(command)
|
||||
time.sleep(10)
|
||||
|
||||
cmd = shlex.split(command)
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user