From 46c473ba9cf977ad0e500b1efc1adffef97a671a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 3 Feb 2015 14:58:28 +0530 Subject: [PATCH 1/7] Merged install and update script to single script --- upgrade => install | 205 +++++++++++++++++++++++++-------------------- 1 file changed, 115 insertions(+), 90 deletions(-) rename upgrade => install (54%) diff --git a/upgrade b/install similarity index 54% rename from upgrade rename to install index 3f44b4cb..5c7b6a20 100644 --- a/upgrade +++ b/install @@ -1,11 +1,13 @@ #!/bin/bash # EasyEngine update script. -# This script is designed to update current EasyEngine from 2.2.2 to 3.x -# Define echo function +# This script is designed to install latest EasyEngine or +# to update current EasyEngine from 2.x to 3.x + old_ee_version="2.2.3" branch=$1 +# Define echo function # Blue color function ee_lib_echo() @@ -23,6 +25,36 @@ function ee_lib_echo_fail() echo $(tput setaf 1)$@$(tput sgr0) } +# Capture errors +function ee_lib_error() +{ + echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" + exit $2 +} + +function install_dep() +{ + # Execute: apt-get update + ee_lib_echo "Executing apt-get update" + apt-get update &>> /dev/null + + # Install Python3 on users system + ee_lib_echo "Installing Python3" + apt-get -y install python3 python3-apt python3-setuptools python3-dev + if [[ $? -ne 0 ]]; then + ee_lib_echo_fail "Unable to install Python3 on system" + exit 1 + fi + + # Install sqlite3 + ee_lib_echo "Installing sqlite3" + apt-get -y install sqlite3 + if [[ $? -ne 0 ]]; then + ee_lib_echo_fail "Unable to install sqlite3 on system" + exit 1 + fi +} + function sync_db() { mkdir /var/lib/ee @@ -122,103 +154,96 @@ function sync_db() } -# Checking permissions -if [[ $EUID -ne 0 ]]; then - ee_lib_echo_fail "Sudo privilege required..." - ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee" - exit 1 -fi - -# Check old EasyEngine is installed or not -if [ ! -f /usr/local/sbin/easyengine ]; then - ee_lib_echo_fail "EasyEngine 2.0 not found" - exit 1 -fi +function install_ee3() +{ + # Remove old clone of EasyEngine (ee) if any + rm -rf /tmp/easyengine &>> /dev/null -# Check old EasyEngine version -ee version | grep ${old_ee_version} &>> /dev/null -if [[ $? -ne 0 ]]; then - ee_lib_echo_fail "EasyEngine $old_ee_version not found on your system" - ee_lib_echo_fail "Please update is using command: ee update" - exit 1 -fi + # Clone EE 3.0 Python branch + ee_lib_echo "Cloning EasyEngine 3.0" + if [ "$branch" = "" ]; then + branch=python + fi -# Capture errors -function ee_lib_error() -{ - echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" - exit $2 -} + git clone -b $branch https://github.com/rtCamp/easyengine.git /tmp/easyengine --quiet > /dev/null || ee_lib_error "Unable to clone EasyEngine, exit status" 1 -# Execute: apt-get update -ee_lib_echo "Executing apt-get update" -apt-get update &>> /dev/null + cd /tmp/easyengine + ee_lib_echo "Installing EasyEngine 3.0" + python3 setup.py install || ee_lib_error "Unable to install EasyEngine 3.0, exit status " 1 -# Install Python3 on users system -ee_lib_echo "Installing Python3" -apt-get -y install python3 python3-apt python3-setuptools python3-dev -if [[ $? -ne 0 ]]; then - ee_lib_echo_fail "Unable to install Python3 on system" - exit 1 -fi +} -# Install sqlite3 -ee_lib_echo "Installing sqlite3" -apt-get -y install sqlite3 +function update_to_ee3() +{ + # Preserve old configuration + ee_lib_echo "Updating EasyEngine 3.0 configuration" + + grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }') + db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') + db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') + wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }') + wp_user=$(grep 'user ' /etc/easyengine/ee.conf | grep -v db-user |awk '{ print $3 }') + wp_pass=$(grep password /etc/easyengine/ee.conf | awk '{ print $3 }') + wp_email=$(grep email /etc/easyengine/ee.conf | awk '{ print $3 }') + ip_addr=$(grep ip-address /etc/easyengine/ee.conf |awk -F'=' '{ print $2 }') + + sed -i "s/ip-address.*/ip-address = ${ip_addr}/" /etc/ee/ee.conf && \ + sed -i "s/grant-host.*/grant-host = ${grant_host}/" /etc/ee/ee.conf && \ + sed -i "s/db-name.*/db-name = ${db-name}/" /etc/ee/ee.conf && \ + sed -i "s/db-user.*/db-user = ${db_user}/" /etc/ee/ee.conf && \ + sed -i "s/prefix.*/prefix = ${wp_prefix}/" /etc/ee/ee.conf && \ + sed -i "s/^user.*/user = ${wp_user}/" /etc/ee/ee.conf && \ + sed -i "s/password.*/password = ${wp_password}/" /etc/ee/ee.conf && \ + sed -i "s/email.*/email = ${wp_email}/" /etc/ee/ee.conf || ee_lib_error "Unable to update configuration, exit status " 1 + + + # Remove old EasyEngine + ee_lib_echo "Removing EasyEngine 2" + rm -rf /etc/bash_completion.d/ee /etc/easyengine/ /usr/share/easyengine/ /usr/local/lib/easyengine /usr/local/sbin/easyengine /usr/local/sbin/ee /var/log/easyengine -if [[ $? -ne 0 ]]; then - ee_lib_echo_fail "Unable to install sqlite3 on system" - exit 1 -fi +} -sync_db +function git_init() +{ + # Do git intialisation on EasyEngine configuration + cd /etc/ee + if [ ! -d /etc/ee/.git ]; then + git init > /dev/null + fi + git add . + git commit -am "Installed/Updated to EasyEngine 3" > /dev/null -# Remove old version of EasyEngine (ee) -rm -rf /tmp/easyengine &>> /dev/null +} -# Clone EE 3.0 Python branch -ee_lib_echo "Cloning EasyEngine 3.0" -if [ "$branch" = "" ]; then - branch=python +# Checking permissions +if [[ $EUID -ne 0 ]]; then + ee_lib_echo_fail "Sudo privilege required..." + ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee" + exit 1 fi -git clone -b $branch https://github.com/rtCamp/easyengine.git /tmp/easyengine > /dev/null || ee_lib_error "Unable to clone EasyEngine, exit status" 1 - -cd /tmp/easyengine -ee_lib_echo "Installing EasyEngine 3.0" -python3 setup.py install || ee_lib_error "Unable to install EasyEngine 3.0, exit status " 1 - -# Preserve old configuration -ee_lib_echo "Updating EasyEngine 3.0 configuration" - -grant_host=$(grep grant-host /etc/easyengine/ee.conf | awk '{ print $3 }') -db_name=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') -db_user=$(grep db-name /etc/easyengine/ee.conf | awk '{ print $3 }') -wp_prefix=$(grep prefix /etc/easyengine/ee.conf | awk '{ print $3 }') -wp_user=$(grep 'user ' /etc/easyengine/ee.conf | grep -v db-user |awk '{ print $3 }') -wp_pass=$(grep password /etc/easyengine/ee.conf | awk '{ print $3 }') -wp_email=$(grep email /etc/easyengine/ee.conf | awk '{ print $3 }') -ip_addr=$(grep ip-address /etc/easyengine/ee.conf |awk -F'=' '{ print $2 }') - -sed -i "s/ip-address.*/ip-address = ${ip_addr}/" /etc/ee/ee.conf && \ -sed -i "s/grant-host.*/grant-host = ${grant_host}/" /etc/ee/ee.conf && \ -sed -i "s/db-name.*/db-name = ${db-name}/" /etc/ee/ee.conf && \ -sed -i "s/db-user.*/db-user = ${db_user}/" /etc/ee/ee.conf && \ -sed -i "s/prefix.*/prefix = ${wp_prefix}/" /etc/ee/ee.conf && \ -sed -i "s/^user.*/user = ${wp_user}/" /etc/ee/ee.conf && \ -sed -i "s/password.*/password = ${wp_password}/" /etc/ee/ee.conf && \ -sed -i "s/email.*/email = ${wp_email}/" /etc/ee/ee.conf || ee_lib_error "Unable to update configuration, exit status " 1 - - -# Remove old EasyEngine -ee_lib_echo "Removing EasyEngine 2" -rm -rf /etc/bash_completion.d/ee /etc/easyengine/ /usr/share/easyengine/ /usr/local/lib/easyengine /usr/local/sbin/easyengine /usr/local/sbin/ee /var/log/easyengine - -ee_lib_echo "Doing GIT init" -cd /etc/ee -if [ ! -d /etc/ee/.git ]; then - git init > /dev/null +# Check old EasyEngine is installed or not +if [ ! -f /usr/local/sbin/easyengine ]; then + # Check latest EasyEngine is installed or not + if [ ! -f /usr/local/bin/ee ]; then + install_dep + install_ee3 + git_init + else + ee_lib_echo_fail "EasyEngine 3 allready installed on ur system" + exit 1 + fi +else + # Check old EasyEngine version + ee version | grep ${old_ee_version} &>> /dev/null + if [[ $? -ne 0 ]]; then + ee_lib_echo_fail "EasyEngine $old_ee_version not found on your system" + ee_lib_echo_fail "Please update it using command: ee update" + exit 1 + fi + sync_db + install_dep + install_ee3 + update_to_ee3 + git_init fi -git commit -am "Update EasyEngine 2 to EasyEngine 3" > /dev/null - -ee_lib_echo "Successfully update to EasyEngine 3" From 345d458524ca4191f2489477da105ea4158a60f0 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 3 Feb 2015 15:06:17 +0530 Subject: [PATCH 2/7] Added missing packages :) --- install | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/install b/install index 5c7b6a20..12192bd2 100644 --- a/install +++ b/install @@ -39,18 +39,10 @@ function install_dep() apt-get update &>> /dev/null # Install Python3 on users system - ee_lib_echo "Installing Python3" - apt-get -y install python3 python3-apt python3-setuptools python3-dev + ee_lib_echo "Installing pre depedencies" + apt-get -y install python3 python3-apt python3-setuptools python3-dev sqlite3 git if [[ $? -ne 0 ]]; then - ee_lib_echo_fail "Unable to install Python3 on system" - exit 1 - fi - - # Install sqlite3 - ee_lib_echo "Installing sqlite3" - apt-get -y install sqlite3 - if [[ $? -ne 0 ]]; then - ee_lib_echo_fail "Unable to install sqlite3 on system" + ee_lib_echo_fail "Unable to install pre depedencies" exit 1 fi } From e15bd877c1b59e819f37d6c47ecea5807b922674 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 3 Feb 2015 15:11:34 +0530 Subject: [PATCH 3/7] Fixed sequence for updatation of ee2 to ee3 --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index 12192bd2..ecb5125d 100644 --- a/install +++ b/install @@ -233,8 +233,8 @@ else ee_lib_echo_fail "Please update it using command: ee update" exit 1 fi - sync_db install_dep + sync_db install_ee3 update_to_ee3 git_init From 31907b450807d3bd0314149478e50deada49219f Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 3 Feb 2015 15:21:09 +0530 Subject: [PATCH 4/7] Fix bug of secure.py --- ee/cli/plugins/secure.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 9deb235c..359d8513 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -76,9 +76,11 @@ class EESecureController(CementBaseController): @expose(hide=True) def secure_port(self): """This function Secures port""" - while not self.app.pargs.user_input.isdigit(): - Log.info(self, "Please Enter valid port number ") - self.app.pargs.user_input = input("EasyEngine admin port [22222]:") + if self.app.pargs.user_input: + while not self.app.pargs.user_input.isdigit(): + Log.info(self, "Please Enter valid port number ") + self.app.pargs.user_input = input("EasyEngine " + "admin port [22222]:") if not self.app.pargs.user_input: port = input("EasyEngine admin port [22222]:") if port == "": From 9b948278b09c1b38d7c05a0e7a8e1eb9b9694d8a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 3 Feb 2015 16:53:33 +0530 Subject: [PATCH 5/7] Fixed git name/eamil not set --- ee/core/variables.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ee/core/variables.py b/ee/core/variables.py index e3d03117..a80c68cc 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -46,6 +46,8 @@ class EEVariables(): except Exception as e: ee_user = input("Enter your name: ") ee_email = input("Enter your email: ") + os.system("git config --global user.name {0}".format(ee_user)) + os.system("git config --global user.email {0}".format(ee_email)) # Get System RAM and SWAP details ee_ram = psutil.virtual_memory().total / (1024 * 1024) From e2a952866d0b49a987cfdabb12d0d9b730a85721 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 3 Feb 2015 18:06:55 +0530 Subject: [PATCH 6/7] changed log.info message in site_function.py --- ee/cli/plugins/site_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 0886f6a2..a8851a60 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -279,12 +279,12 @@ def setupwordpress(self, data): def setupwordpressnetwork(self, data): ee_site_webroot = data['webroot'] EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) - Log.info(self, "Setting up WordPress Network \t\t", end='') + Log.info(self, "Setting up WordPress Network \t", end='') EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert' ' --title={0} {subdomains}' .format(data['www_domain'], subdomains='--subdomains' if not data['wpsubdir'] else '')) - Log.info(self, "Done") + Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") def installwp_plugin(self, plugin_name, data): From db350dfa204244e7f1079f5fa6f208710d0a7d88 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 3 Feb 2015 19:41:57 +0530 Subject: [PATCH 7/7] modified log message in services.py --- ee/core/services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/services.py b/ee/core/services.py index 392c7d56..13b30ce7 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -99,7 +99,7 @@ class EEService(): Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") return False - Log.info(self, "Reload : {0:10}".format(service_name), end='') + Log.info(self, "Reload : {0:10}".format(service_name), end='') retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: