add ip to the remote

This commit is contained in:
Usman Nasir
2020-07-05 21:04:38 +05:00
parent c881066878
commit 239cf01233
2 changed files with 12 additions and 6 deletions

View File

@@ -633,7 +633,7 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
if distro == ubuntu: if distro == ubuntu:
installer.fixMariaDB() installer.fixMariaDB()
mysqlUtilities.createDatabase("cyberpanel","cyberpanel", InstallCyberPanel.mysqlPassword) mysqlUtilities.createDatabase("cyberpanel","cyberpanel", InstallCyberPanel.mysqlPassword, publicip)
if ftp == None: if ftp == None:
installer.installPureFTPD() installer.installPureFTPD()

View File

@@ -5,7 +5,7 @@ import time
class mysqlUtilities: class mysqlUtilities:
@staticmethod @staticmethod
def createDatabase(dbname, dbuser, dbpassword): def createDatabase(dbname, dbuser, dbpassword, publicip):
try: try:
createDB = "CREATE DATABASE " + dbname createDB = "CREATE DATABASE " + dbname
@@ -16,8 +16,7 @@ class mysqlUtilities:
initCommand = 'mysql -h %s --port %s -u %s -p%s -e "' % (mysqlData['mysqlhost'], mysqlData['mysqlport'], mysqlData['mysqluser'], mysqlData['mysqlpassword']) initCommand = 'mysql -h %s --port %s -u %s -p%s -e "' % (mysqlData['mysqlhost'], mysqlData['mysqlport'], mysqlData['mysqluser'], mysqlData['mysqlpassword'])
remote = 1
except: except:
passFile = "/etc/cyberpanel/mysqlPassword" passFile = "/etc/cyberpanel/mysqlPassword"
@@ -26,6 +25,7 @@ class mysqlUtilities:
password = data.split('\n', 1)[0] password = data.split('\n', 1)[0]
initCommand = 'mysql -u root -p' + password + ' -e "' initCommand = 'mysql -u root -p' + password + ' -e "'
remote = 0
command = initCommand + createDB + '"' command = initCommand + createDB + '"'
@@ -39,7 +39,10 @@ class mysqlUtilities:
if res == 1: if res == 1:
return 0 return 0
createUser = "CREATE USER '" + dbuser + "'@'localhost' IDENTIFIED BY '" + dbpassword + "'" if remote:
createUser = "CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (publicip) + dbpassword + "'"
else:
createUser = "CREATE USER '" + dbuser + "'@'localhost' IDENTIFIED BY '" + dbpassword + "'"
command = initCommand + createUser + '"' command = initCommand + createUser + '"'
@@ -53,7 +56,10 @@ class mysqlUtilities:
if res == 1: if res == 1:
return 0 return 0
else: else:
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'" if remote:
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip)
else:
dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'"
command = initCommand + dropDB + '"' command = initCommand + dropDB + '"'
if install.preFlightsChecks.debug: if install.preFlightsChecks.debug: