From 4f2cb9f85ca078a3ef65cc8d8463c197e55f38ff Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Fri, 9 Oct 2020 12:04:14 +0500 Subject: [PATCH 1/3] install wordpress via cli --- cli/cliParser.py | 6 ++++++ cli/cyberPanel.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/cli/cliParser.py b/cli/cliParser.py index a6e6752b0..20dae31b6 100755 --- a/cli/cliParser.py +++ b/cli/cliParser.py @@ -63,4 +63,10 @@ class cliParser: parser.add_argument('--securityLevel', help='Set security level while creating user.') parser.add_argument('--state', help='State value used in user suspension.') + + ### WP Install + + parser.add_argument('--siteTitle', help='Site Title for application installers.') + parser.add_argument('--path', help='Path for application installers.') + return parser.parse_args() \ No newline at end of file diff --git a/cli/cyberPanel.py b/cli/cyberPanel.py index b04273bf5..82634c4c6 100755 --- a/cli/cyberPanel.py +++ b/cli/cyberPanel.py @@ -1471,6 +1471,51 @@ def main(): print(response.content.decode()) + ### Application installers + + elif args.function == "installWordPress": + completeCommandExample = 'cyberpanel installWordPress --domainName cyberpanel.net --email support@cyberpanel.net --userName cyberpanel --password helloworld --siteTitle "WordPress Site" --path helloworld (this is optional)' + + if not args.domainName: + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") + return + + if not args.email: + print("\n\nPlease enter email. For example:\n\n" + completeCommandExample + "\n\n") + return + + if not args.userName: + print("\n\nPlease enter User name. For example:\n\n" + completeCommandExample + "\n\n") + return + + if not args.password: + print("\n\nPlease enter password. For example:\n\n" + completeCommandExample + "\n\n") + return + + if not args.siteTitle: + print("\n\nPlease enter site title. For example:\n\n" + completeCommandExample + "\n\n") + return + + if not args.path: + home = '1' + path = '' + else: + home = '0' + path = args.path + + from websiteFunctions.website import WebsiteManager + + data = {} + data['adminUser'] = args.userName + data['blogTitle'] = args.siteTitle + data['domain'] = args.domainName + data['adminEmail'] = args.email + data['passwordByPass'] = args.password + data['home'] = home + data['path'] = path + + wm = WebsiteManager() + wm.installWordpress(1, data) From 36253438f772716a3bb3e162b4103107a332ad22 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Fri, 9 Oct 2020 15:04:44 +0500 Subject: [PATCH 2/3] install joomla via cli --- cli/cyberPanel.py | 36 ++++++++++++++++++++++++++++++++ plogical/applicationInstaller.py | 23 ++++++++++++++------ 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/cli/cyberPanel.py b/cli/cyberPanel.py index 82634c4c6..132665a12 100755 --- a/cli/cyberPanel.py +++ b/cli/cyberPanel.py @@ -1517,6 +1517,42 @@ def main(): wm = WebsiteManager() wm.installWordpress(1, data) + elif args.function == "installJoomla": + + completeCommandExample = 'cyberpanel installJoomla --domainName cyberpanel.net --password helloworld --siteTitle "WordPress Site" --path helloworld (this is optional)' + + if not args.domainName: + print("\n\nPlease enter Domain name. For example:\n\n" + completeCommandExample + "\n\n") + return + + if not args.password: + print("\n\nPlease enter password. For example:\n\n" + completeCommandExample + "\n\n") + return + + if not args.siteTitle: + print("\n\nPlease enter site title. For example:\n\n" + completeCommandExample + "\n\n") + return + + if not args.path: + home = '1' + path = '' + else: + home = '0' + path = args.path + + from websiteFunctions.website import WebsiteManager + + data = {} + data['prefix'] = 'jm_' + data['siteName'] = args.siteTitle + data['domain'] = args.domainName + data['passwordByPass'] = args.password + data['home'] = home + data['path'] = path + + wm = WebsiteManager() + wm.installJoomla(1, data) + if __name__ == "__main__": diff --git a/plogical/applicationInstaller.py b/plogical/applicationInstaller.py index 9684df29a..d3a44d59c 100755 --- a/plogical/applicationInstaller.py +++ b/plogical/applicationInstaller.py @@ -944,7 +944,8 @@ $parameters = array( try: os.remove('/usr/local/CyberCP/joomla.zip') os.remove('/usr/local/CyberCP/lscache_plugin.zip') - os.remove('/usr/local/CyberCP/com_lscache.zip') + os.remove('/usr/local/CyberCP/pkg_lscache.xml') + os.remove('/usr/local/CyberCP/pkg_script.php') except: pass @@ -956,7 +957,7 @@ $parameters = array( command = 'wget https://raw.githubusercontent.com/litespeedtech/lscache-joomla/master/package/lscache-1.3.1.zip -O /usr/local/CyberCP/joomla.zip' ProcessUtilities.executioner(command) - command = 'unzip /usr/local/CyberCP/joomla.zip -d /usr/local/CyberCP/' + command = 'unzip -o /usr/local/CyberCP/joomla.zip -d /usr/local/CyberCP/' ProcessUtilities.executioner(command) command = '/home/%s/.composer/vendor/bin/joomla extension:installfile %s --www %s /usr/local/CyberCP/lscache_plugin.zip' % (self.masterDomain, dbUser, finalPath) @@ -969,13 +970,13 @@ $parameters = array( ProcessUtilities.executioner(command) command = 'mv %s%s/* %s' % (finalPath, dbUser, finalPath) - ProcessUtilities.executioner(command) + ProcessUtilities.executioner(command, None, True) command = 'mv %s%s/.[^.]* %s' % (finalPath, dbUser, finalPath) - ProcessUtilities.executioner(command) + ProcessUtilities.executioner(command, None, True) command = "sed -i 's|$debug = 1|$debug = 0|g' %sconfiguration.php" % (finalPath) - ProcessUtilities.executioner(command) + ProcessUtilities.executioner(command, None, True) ## @@ -986,10 +987,20 @@ $parameters = array( command = "sed -i \"s|sitename = '%s'|sitename = '%s'|g\" %sconfiguration.php" % ( dbUser, siteName, finalPath) - ProcessUtilities.executioner(command, externalApp) + ProcessUtilities.executioner(command, externalApp, True) installUtilities.reStartLiteSpeedSocket() + content = """ + ===================================================================== + Joomla Successfully installed, login details below: + Username: admin + Password: %s + ===================================================================== + """ % (self.extraArgs['password']) + + print(content) + statusFile = open(tempStatusPath, 'w') statusFile.writelines("Successfully Installed. [200]") statusFile.close() From 1ed18b5e59b8e7eaa90d03a7adfab9a7d9f7557a Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Fri, 9 Oct 2020 19:42:36 +0500 Subject: [PATCH 3/3] update localhost in phpmyadminsign --- plogical/upgrade.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 269812a59..4ff034dfe 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -261,6 +261,24 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; command = 'cp /usr/local/CyberCP/plogical/phpmyadminsignin.php /usr/local/CyberCP/public/phpmyadmin/phpmyadminsignin.php' Upgrade.executioner(command, 0) + passFile = "/etc/cyberpanel/mysqlPassword" + + try: + import json + jsonData = json.loads(open(passFile, 'r').read()) + + mysqluser = jsonData['mysqluser'] + mysqlpassword = jsonData['mysqlpassword'] + mysqlport = jsonData['mysqlport'] + mysqlhost = jsonData['mysqlhost'] + + command = "sed -i 's|localhost|%s|g' /usr/local/CyberCP/public/phpmyadmin/phpmyadminsignin.php" % ( + mysqlhost) + Upgrade.executioner(command, 0) + + except: + pass + os.chdir(cwd) except BaseException as msg: