diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 9718fc3b..28c5a5ab 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -50,7 +50,7 @@ class EECleanController(CementBaseController): @expose(hide=True) def clean_memcache(self): - """This function Clears memcache""" + """This function Clears memcache """ try: if(EEAptGet.is_installed(self, "memcached")): EEService.restart_service(self, "memcached") diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index d29ac091..c7007bb9 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -3,6 +3,7 @@ from cement.core import handler, hook from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables from ee.core.logging import Log +from ee.core.git import EEGit import string import random import sys @@ -55,8 +56,8 @@ class EESecureController(CementBaseController): if username == "": self.app.pargs.user_input = EEVariables.ee_user if not self.app.pargs.user_pass: - password = input("Provide HTTP authentication " - "password [{0}] :".format(passwd)) + password = getpass.getpass("Provide HTTP authentication " + "password [{0}] :".format(passwd)) self.app.pargs.user_pass = password if password == "": self.app.pargs.user_pass = passwd @@ -71,12 +72,8 @@ class EESecureController(CementBaseController): .format(username=self.app.pargs.user_input, password=self.app.pargs.user_pass), log=False) - Log.info(self, "Successfully changed HTTP authentication" - " username to : {username}" - .format(username=self.app.pargs.user_input), log=False) - Log.info(self, "Successfully changed HTTP authentication" - " password to : {password}" - .format(password=self.app.pargs.user_pass), log=False) + EEGit.add(self, ["/etc/nginx"], + msg="Adding changed secure auth into Git") @expose(hide=True) def secure_port(self): @@ -104,6 +101,9 @@ class EESecureController(CementBaseController): "{port} default_server ssl;/\" " "/etc/nginx/sites-available/22222" .format(port=self.app.pargs.user_input)) + EEGit.add(self, ["/etc/nginx"], + msg="Adding changed secure port into Git") + Log.info(self, "Successfully port changed {port}" .format(port=self.app.pargs.user_input)) @@ -127,6 +127,9 @@ class EESecureController(CementBaseController): "\"/deny/i allow {whitelist_adre}\;\"" " /etc/nginx/common/acl.conf" .format(whitelist_adre=ip_addr)) + EEGit.add(self, ["/etc/nginx"], + msg="Adding changed secure ip into Git") + Log.info(self, "Successfully added IP address in acl.conf file") diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 379f9d89..680c5263 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -112,15 +112,15 @@ def setupdatabase(self, data): # create MySQL database Log.info(self, "Setting up database\t\t", end='') Log.debug(self, "Creating databse {0}".format(ee_db_name)) - EEMysql.execute(self, "create database {0}" + EEMysql.execute(self, "create database `{0}`" .format(ee_db_name), errormsg="Cannot create database") # Create MySQL User Log.debug(self, "Creating user {0}".format(ee_db_username)) - Log.debug(self, "create user {0}@{1} identified by ''" + Log.debug(self, "create user `{0}`@`{1}` identified by ''" .format(ee_db_username, ee_mysql_grant_host)) EEMysql.execute(self, - "create user {0}@{1} identified by '{2}'" + "create user `{0}`@`{1}` identified by '{2}'" .format(ee_db_username, ee_mysql_grant_host, ee_db_password), errormsg="Cannot setup database user", log=False) @@ -128,7 +128,7 @@ def setupdatabase(self, data): # Grant permission Log.debug(self, "Setting up user privileges") EEMysql.execute(self, - "grant all privileges on {0}.* to {1}@{2}" + "grant all privileges on `{0}`.* to `{1}`@`{2}`" .format(ee_db_name, ee_db_username, ee_mysql_grant_host), errormsg="Cannot setup database user privileges") Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") @@ -423,9 +423,10 @@ def site_package_check(self, stype): Log.debug(self, "Setting packages variable for WP-CLI") if not EEShellExec.cmd_exec(self, "which wp"): packages = packages + [["https://github.com/wp-cli/wp-cli/" - "releases/download/v0.17.1/" - "wp-cli.phar", "/usr/bin/wp", - "WP-CLI"]] + "releases/download/v{0}/" + "wp-cli-{0}.phar" + .format(EEVariables.ee_wp_cli), + "/usr/bin/wp", "WP-CLI"]] return(stack.install(apt_packages=apt_packages, packages=packages, disp_msg=False)) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 56535fb1..0690a2bf 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -90,7 +90,7 @@ class EEStackController(CementBaseController): Log.debug(self, 'Adding key for {0}' .format(EEVariables.ee_mysql_repo)) EERepo.add_key(self, '1C4CBDCDCD2EFD2A', - keyserver="subkeys.pgp.net") + keyserver="keyserver.ubuntu.com") chars = ''.join(random.sample(string.ascii_letters, 8)) Log.debug(self, "Pre-seeding MySQL") EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " @@ -155,8 +155,8 @@ class EEStackController(CementBaseController): EEService.reload_service(self, 'postfix') if set(EEVariables.ee_nginx).issubset(set(apt_packages)): - if ((not os.path.isfile('/etc/nginx/conf.d/ee-nginx.conf')) and - os.path.isfile('/etc/nginx/nginx.conf')): + if ((not EEShellExec.cmd_exec(self, "grep -Hr EasyEngine " + "/etc/nginx")) and os.path.isfile('/etc/nginx/nginx.conf')): nc = NginxConfig() Log.debug(self, 'Loading file /etc/nginx/nginx.conf ') nc.loadf('/etc/nginx/nginx.conf') diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index aea5b2a7..a32794b5 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -71,11 +71,10 @@ class EERepo(): default keyserver is hkp://keys.gnupg.net user can provide other keyserver with keyserver="hkp://xyz" """ - if keyserver is None: - EEShellExec.cmd_exec(self, "gpg --keyserver {serv}" - .format(serv=(keyserver or - "hkp://keys.gnupg.net")) - + " --recv-keys {key}".format(key=keyids)) - EEShellExec.cmd_exec(self, "gpg -a --export --armor {0}" - .format(keyids) - + " | apt-key add - ") + EEShellExec.cmd_exec(self, "gpg --keyserver {serv}" + .format(serv=(keyserver or + "hkp://keys.gnupg.net")) + + " --recv-keys {key}".format(key=keyids)) + EEShellExec.cmd_exec(self, "gpg -a --export --armor {0}" + .format(keyids) + + " | apt-key add - ") diff --git a/ee/core/mysql.py b/ee/core/mysql.py index c40b2bfd..cc245ede 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -48,6 +48,9 @@ class EEMysql(): .format(statement)) cur.execute(statement) + cur.close() + conn.close() + except Exception as e: cur.close() conn.close() @@ -57,8 +60,6 @@ class EEMysql(): else: Log.error(self, '{0}'.format(errormsg)) - cur.close() - conn.close() # def __del__(self): # self.cur.close() diff --git a/ee/core/variables.py b/ee/core/variables.py index 24b3c269..e42c3950 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -12,7 +12,7 @@ class EEVariables(): """Intialization of core variables""" # EasyEngine version - ee_version = "3.0.1" + ee_version = "3.0.2" # EasyEngine packages versions ee_wp_cli = "0.18.0" diff --git a/install b/install index 336a37aa..e9892983 100644 --- a/install +++ b/install @@ -5,7 +5,7 @@ # to update current EasyEngine from 2.x to 3.x old_ee_version="2.2.3" -new_ee_version="3.0.1" +new_ee_version="3.0.2" branch=$1 # Define echo function @@ -39,13 +39,13 @@ function install_dep() # Install Python3 on users system ee_lib_echo "Installing pre depedencies" if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - apt-get -y install python-software-properties software-properties-common python3 python3-apt python3-setuptools python3-dev sqlite3 git || ee_lib_error "Unable to install pre depedencies, exit status " 1 + apt-get -y install gcc python-software-properties software-properties-common python3 python3-apt python3-setuptools python3-dev sqlite3 git || ee_lib_error "Unable to install pre depedencies, exit status " 1 elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - apt-get -y install graphviz python-software-properties python3 python3-apt python3-setuptools python3-dev sqlite3 git || ee_lib_error "Unable to pre depedencies, exit status " 1 + apt-get -y install gcc graphviz python-software-properties python3 python3-apt python3-setuptools python3-dev sqlite3 git || ee_lib_error "Unable to pre depedencies, exit status " 1 fi # Generating Locale - locale-gen en &>> /dev/null + locale-gen en &>> /dev/null } function sync_db()