From 239cf012332896d5490358cb1ab66e34b97237c2 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Sun, 5 Jul 2020 21:04:38 +0500 Subject: [PATCH] add ip to the remote --- install/installCyberPanel.py | 2 +- install/mysqlUtilities.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 9ee008dc9..91e9204dd 100755 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -633,7 +633,7 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns if distro == ubuntu: installer.fixMariaDB() - mysqlUtilities.createDatabase("cyberpanel","cyberpanel", InstallCyberPanel.mysqlPassword) + mysqlUtilities.createDatabase("cyberpanel","cyberpanel", InstallCyberPanel.mysqlPassword, publicip) if ftp == None: installer.installPureFTPD() diff --git a/install/mysqlUtilities.py b/install/mysqlUtilities.py index 33e6044a2..580460b78 100755 --- a/install/mysqlUtilities.py +++ b/install/mysqlUtilities.py @@ -5,7 +5,7 @@ import time class mysqlUtilities: @staticmethod - def createDatabase(dbname, dbuser, dbpassword): + def createDatabase(dbname, dbuser, dbpassword, publicip): try: 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']) - - + remote = 1 except: passFile = "/etc/cyberpanel/mysqlPassword" @@ -26,6 +25,7 @@ class mysqlUtilities: password = data.split('\n', 1)[0] initCommand = 'mysql -u root -p' + password + ' -e "' + remote = 0 command = initCommand + createDB + '"' @@ -39,7 +39,10 @@ class mysqlUtilities: if res == 1: 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 + '"' @@ -53,7 +56,10 @@ class mysqlUtilities: if res == 1: return 0 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 + '"' if install.preFlightsChecks.debug: