mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
bug fix: remote mysql install
This commit is contained in:
@@ -92,6 +92,7 @@ def get_Ubuntu_release():
|
||||
|
||||
|
||||
class preFlightsChecks:
|
||||
debug = 1
|
||||
cyberPanelMirror = "mirror.cyberpanel.net/pip"
|
||||
cdn = 'cyberpanel.sh'
|
||||
|
||||
@@ -429,6 +430,11 @@ class preFlightsChecks:
|
||||
else:
|
||||
writeDataToFile.writelines(items)
|
||||
|
||||
if self.distro == ubuntu:
|
||||
os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
if self.remotemysql == 'ON':
|
||||
command = "sed -i 's|'HOST': 'localhost',|'HOST': '%s',|g' %s" % (self.mysqlhost, path)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
@@ -439,11 +445,6 @@ class preFlightsChecks:
|
||||
command = "sed -i 's|'PORT':''|'PORT':'%s'|g' %s" % (self.mysqlport, path)
|
||||
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
|
||||
|
||||
if self.distro == ubuntu:
|
||||
os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
writeDataToFile.close()
|
||||
|
||||
logging.InstallLog.writeToFile("settings.py updated!")
|
||||
|
||||
#self.setupVirtualEnv(self.distro)
|
||||
@@ -2164,6 +2165,11 @@ def main():
|
||||
mysqluser = args.mysqluser
|
||||
mysqlpassword = args.mysqlpassword
|
||||
mysqlport = args.mysqlport
|
||||
|
||||
if preFlightsChecks.debug:
|
||||
print('mysqlhost: %s, mysqluser: %s, mysqlpassword: %s, mysqlport: %s' % (mysqlhost, mysqluser, mysqlpassword, mysqlport))
|
||||
time.sleep(10)
|
||||
|
||||
else:
|
||||
remotemysql = args.remotemysql
|
||||
mysqlhost = ''
|
||||
|
||||
@@ -8,6 +8,7 @@ import errno
|
||||
import MySQLdb as mariadb
|
||||
import install
|
||||
from os.path import exists
|
||||
import time
|
||||
|
||||
#distros
|
||||
centos=0
|
||||
@@ -630,6 +631,11 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
|
||||
writeToFile.write(dumps(mysqlData))
|
||||
writeToFile.close()
|
||||
|
||||
if install.preFlightsChecks.debug:
|
||||
print(open(file_name, 'r').read())
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
|
||||
try:
|
||||
command = 'chmod 640 %s' % (file_name)
|
||||
@@ -668,9 +674,6 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
|
||||
|
||||
mysqlUtilities.createDatabase("cyberpanel","cyberpanel", InstallCyberPanel.mysqlPassword)
|
||||
|
||||
import time
|
||||
time.sleep(10)
|
||||
|
||||
if ftp == None:
|
||||
installer.installPureFTPD()
|
||||
installer.installPureFTPDConfigurations(mysql)
|
||||
|
||||
@@ -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