Browse Source

Merge branch 'python'

bugfixes
gau1991 10 years ago
parent
commit
05222ebe4f
  1. 2
      ee/cli/plugins/clean.py
  2. 19
      ee/cli/plugins/secure.py
  3. 15
      ee/cli/plugins/site_functions.py
  4. 6
      ee/cli/plugins/stack.py
  5. 15
      ee/core/apt_repo.py
  6. 5
      ee/core/mysql.py
  7. 2
      ee/core/variables.py
  8. 8
      install

2
ee/cli/plugins/clean.py

@ -50,7 +50,7 @@ class EECleanController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def clean_memcache(self): def clean_memcache(self):
"""This function Clears memcache""" """This function Clears memcache """
try: try:
if(EEAptGet.is_installed(self, "memcached")): if(EEAptGet.is_installed(self, "memcached")):
EEService.restart_service(self, "memcached") EEService.restart_service(self, "memcached")

19
ee/cli/plugins/secure.py

@ -3,6 +3,7 @@ from cement.core import handler, hook
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.variables import EEVariables from ee.core.variables import EEVariables
from ee.core.logging import Log from ee.core.logging import Log
from ee.core.git import EEGit
import string import string
import random import random
import sys import sys
@ -55,8 +56,8 @@ class EESecureController(CementBaseController):
if username == "": if username == "":
self.app.pargs.user_input = EEVariables.ee_user self.app.pargs.user_input = EEVariables.ee_user
if not self.app.pargs.user_pass: if not self.app.pargs.user_pass:
password = input("Provide HTTP authentication " password = getpass.getpass("Provide HTTP authentication "
"password [{0}] :".format(passwd)) "password [{0}] :".format(passwd))
self.app.pargs.user_pass = password self.app.pargs.user_pass = password
if password == "": if password == "":
self.app.pargs.user_pass = passwd self.app.pargs.user_pass = passwd
@ -71,12 +72,8 @@ class EESecureController(CementBaseController):
.format(username=self.app.pargs.user_input, .format(username=self.app.pargs.user_input,
password=self.app.pargs.user_pass), password=self.app.pargs.user_pass),
log=False) log=False)
Log.info(self, "Successfully changed HTTP authentication" EEGit.add(self, ["/etc/nginx"],
" username to : {username}" msg="Adding changed secure auth into Git")
.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)
@expose(hide=True) @expose(hide=True)
def secure_port(self): def secure_port(self):
@ -104,6 +101,9 @@ class EESecureController(CementBaseController):
"{port} default_server ssl;/\" " "{port} default_server ssl;/\" "
"/etc/nginx/sites-available/22222" "/etc/nginx/sites-available/22222"
.format(port=self.app.pargs.user_input)) .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}" Log.info(self, "Successfully port changed {port}"
.format(port=self.app.pargs.user_input)) .format(port=self.app.pargs.user_input))
@ -127,6 +127,9 @@ class EESecureController(CementBaseController):
"\"/deny/i allow {whitelist_adre}\;\"" "\"/deny/i allow {whitelist_adre}\;\""
" /etc/nginx/common/acl.conf" " /etc/nginx/common/acl.conf"
.format(whitelist_adre=ip_addr)) .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") Log.info(self, "Successfully added IP address in acl.conf file")

15
ee/cli/plugins/site_functions.py

@ -112,15 +112,15 @@ def setupdatabase(self, data):
# create MySQL database # create MySQL database
Log.info(self, "Setting up database\t\t", end='') Log.info(self, "Setting up database\t\t", end='')
Log.debug(self, "Creating databse {0}".format(ee_db_name)) 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") .format(ee_db_name), errormsg="Cannot create database")
# Create MySQL User # Create MySQL User
Log.debug(self, "Creating user {0}".format(ee_db_username)) 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)) .format(ee_db_username, ee_mysql_grant_host))
EEMysql.execute(self, 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, .format(ee_db_username, ee_mysql_grant_host,
ee_db_password), ee_db_password),
errormsg="Cannot setup database user", log=False) errormsg="Cannot setup database user", log=False)
@ -128,7 +128,7 @@ def setupdatabase(self, data):
# Grant permission # Grant permission
Log.debug(self, "Setting up user privileges") Log.debug(self, "Setting up user privileges")
EEMysql.execute(self, 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), .format(ee_db_name, ee_db_username, ee_mysql_grant_host),
errormsg="Cannot setup database user privileges") errormsg="Cannot setup database user privileges")
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") 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") Log.debug(self, "Setting packages variable for WP-CLI")
if not EEShellExec.cmd_exec(self, "which wp"): if not EEShellExec.cmd_exec(self, "which wp"):
packages = packages + [["https://github.com/wp-cli/wp-cli/" packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v0.17.1/" "releases/download/v{0}/"
"wp-cli.phar", "/usr/bin/wp", "wp-cli-{0}.phar"
"WP-CLI"]] .format(EEVariables.ee_wp_cli),
"/usr/bin/wp", "WP-CLI"]]
return(stack.install(apt_packages=apt_packages, packages=packages, return(stack.install(apt_packages=apt_packages, packages=packages,
disp_msg=False)) disp_msg=False))

6
ee/cli/plugins/stack.py

@ -90,7 +90,7 @@ class EEStackController(CementBaseController):
Log.debug(self, 'Adding key for {0}' Log.debug(self, 'Adding key for {0}'
.format(EEVariables.ee_mysql_repo)) .format(EEVariables.ee_mysql_repo))
EERepo.add_key(self, '1C4CBDCDCD2EFD2A', EERepo.add_key(self, '1C4CBDCDCD2EFD2A',
keyserver="subkeys.pgp.net") keyserver="keyserver.ubuntu.com")
chars = ''.join(random.sample(string.ascii_letters, 8)) chars = ''.join(random.sample(string.ascii_letters, 8))
Log.debug(self, "Pre-seeding MySQL") Log.debug(self, "Pre-seeding MySQL")
EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 "
@ -155,8 +155,8 @@ class EEStackController(CementBaseController):
EEService.reload_service(self, 'postfix') EEService.reload_service(self, 'postfix')
if set(EEVariables.ee_nginx).issubset(set(apt_packages)): if set(EEVariables.ee_nginx).issubset(set(apt_packages)):
if ((not os.path.isfile('/etc/nginx/conf.d/ee-nginx.conf')) and if ((not EEShellExec.cmd_exec(self, "grep -Hr EasyEngine "
os.path.isfile('/etc/nginx/nginx.conf')): "/etc/nginx")) and os.path.isfile('/etc/nginx/nginx.conf')):
nc = NginxConfig() nc = NginxConfig()
Log.debug(self, 'Loading file /etc/nginx/nginx.conf ') Log.debug(self, 'Loading file /etc/nginx/nginx.conf ')
nc.loadf('/etc/nginx/nginx.conf') nc.loadf('/etc/nginx/nginx.conf')

15
ee/core/apt_repo.py

@ -71,11 +71,10 @@ class EERepo():
default keyserver is hkp://keys.gnupg.net default keyserver is hkp://keys.gnupg.net
user can provide other keyserver with keyserver="hkp://xyz" user can provide other keyserver with keyserver="hkp://xyz"
""" """
if keyserver is None: EEShellExec.cmd_exec(self, "gpg --keyserver {serv}"
EEShellExec.cmd_exec(self, "gpg --keyserver {serv}" .format(serv=(keyserver or
.format(serv=(keyserver or "hkp://keys.gnupg.net"))
"hkp://keys.gnupg.net")) + " --recv-keys {key}".format(key=keyids))
+ " --recv-keys {key}".format(key=keyids)) EEShellExec.cmd_exec(self, "gpg -a --export --armor {0}"
EEShellExec.cmd_exec(self, "gpg -a --export --armor {0}" .format(keyids)
.format(keyids) + " | apt-key add - ")
+ " | apt-key add - ")

5
ee/core/mysql.py

@ -48,6 +48,9 @@ class EEMysql():
.format(statement)) .format(statement))
cur.execute(statement) cur.execute(statement)
cur.close()
conn.close()
except Exception as e: except Exception as e:
cur.close() cur.close()
conn.close() conn.close()
@ -57,8 +60,6 @@ class EEMysql():
else: else:
Log.error(self, '{0}'.format(errormsg)) Log.error(self, '{0}'.format(errormsg))
cur.close()
conn.close()
# def __del__(self): # def __del__(self):
# self.cur.close() # self.cur.close()

2
ee/core/variables.py

@ -12,7 +12,7 @@ class EEVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# EasyEngine version # EasyEngine version
ee_version = "3.0.1" ee_version = "3.0.2"
# EasyEngine packages versions # EasyEngine packages versions
ee_wp_cli = "0.18.0" ee_wp_cli = "0.18.0"

8
install

@ -5,7 +5,7 @@
# to update current EasyEngine from 2.x to 3.x # to update current EasyEngine from 2.x to 3.x
old_ee_version="2.2.3" old_ee_version="2.2.3"
new_ee_version="3.0.1" new_ee_version="3.0.2"
branch=$1 branch=$1
# Define echo function # Define echo function
@ -39,13 +39,13 @@ function install_dep()
# Install Python3 on users system # Install Python3 on users system
ee_lib_echo "Installing pre depedencies" ee_lib_echo "Installing pre depedencies"
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then 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 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 fi
# Generating Locale # Generating Locale
locale-gen en &>> /dev/null locale-gen en &>> /dev/null
} }
function sync_db() function sync_db()

Loading…
Cancel
Save