From 429ab851bc91d08b16f36f71acbf8f153b8c626f Mon Sep 17 00:00:00 2001 From: Making GitHub Delicious Date: Mon, 7 Jul 2014 07:52:39 -0600 Subject: [PATCH 001/829] add waffle.io badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b6ac2d44..1477fcae 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Stories in Ready](https://badge.waffle.io/rtcamp/easyengine.png?label=ready&title=Ready)](https://waffle.io/rtcamp/easyengine) EasyEngine Logo [![Travis Build Status](https://travis-ci.org/rtCamp/easyengine.svg "Travis Build Status")] (https://travis-ci.org/rtCamp/easyengine) From d22d163a77e462dfd49f618a398eee2ecafa5875 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 7 Aug 2014 17:04:46 +0530 Subject: [PATCH 002/829] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 23f20a8c..14a6d443 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ [![Stories in Ready](https://badge.waffle.io/rtcamp/easyengine.png?label=ready&title=Ready)](https://waffle.io/rtcamp/easyengine) +[![Stories in Progress](https://badge.waffle.io/rtcamp/easyengine.png?label=in%20progress&title=In%20Progress)](https://waffle.io/rtcamp/easyengine) + EasyEngine Logo [![Travis Build Status](https://travis-ci.org/rtCamp/easyengine.svg "Travis Build Status")] (https://travis-ci.org/rtCamp/easyengine) From 90a6eb2efe52c5b523355a5212a97431369164bf Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 13 Aug 2014 13:21:16 +0530 Subject: [PATCH 003/829] Support for remote mysql #147 --- config/easyengine/ee.conf | 2 +- src/lib/ee_lib_mysql_info.sh | 3 +-- src/lib/ee_lib_variables.sh | 16 +++++++--------- src/modules/site/create/ee_mod_setup_database.sh | 4 ++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/config/easyengine/ee.conf b/config/easyengine/ee.conf index 4b6e9204..286f105e 100644 --- a/config/easyengine/ee.conf +++ b/config/easyengine/ee.conf @@ -6,7 +6,7 @@ ip-address = [mysql] - host = localhost + client-host = localhost db-name = false db-user = false diff --git a/src/lib/ee_lib_mysql_info.sh b/src/lib/ee_lib_mysql_info.sh index 93943df9..0108d6c2 100644 --- a/src/lib/ee_lib_mysql_info.sh +++ b/src/lib/ee_lib_mysql_info.sh @@ -12,8 +12,7 @@ function ee_lib_mysql_info() local ee_mysql_max_used_connections=$(mysql -e "show global status" | grep Max_used_connections | awk '{print($2)}') ee_lib_echo - ee_lib_echo "MySQL ($ee_mysql_version):" - ee_lib_echo_escape "user\t\t\t\t \033[37m$EE_MYSQL_USER" + ee_lib_echo "MySQL ($ee_mysql_version) on $EE_MYSQL_HOST:" ee_lib_echo_escape "port\t\t\t\t \033[37m$ee_mysql_port" ee_lib_echo_escape "wait_timeout\t\t\t \033[37m$ee_mysql_wait_timeout" ee_lib_echo_escape "interactive_timeout\t\t \033[37m$ee_mysql_interactive_timeout" diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index ed5cc394..82df02c2 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -39,17 +39,15 @@ else fi # Find out MySQL hostname -if [ -z $($EE_CONFIG_GET mysql.host) ]; then +if [ -z $(git config --file $HOME/.my.cnf client.host) ]; then readonly EE_MYSQL_HOST=localhost else - readonly EE_MYSQL_HOST=$($EE_CONFIG_GET mysql.host) + readonly EE_MYSQL_HOST=$(git config --file $HOME/.my.cnf client.host) fi -# Find out MySQL login -if [ -f ~/.my.cnf ];then - readonly EE_MYSQL_USER=$(cat ~/.my.cnf | grep user | cut -d'=' -f2) - readonly EE_MYSQL_PASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//') -elif [ -f /root/.my.cnf ];then - readonly EE_MYSQL_USER=$(cat /root/.my.cnf | grep user | cut -d'=' -f2) - readonly EE_MYSQL_PASS=$(cat /root/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//') +# Find out MySQL client-host to setup grants +if [ -z $($EE_CONFIG_GET mysql.client-host) ]; then + readonly EE_MYSQL_CLIENT_HOST=localhost +else + readonly EE_MYSQL_CLIENT_HOST=$($EE_CONFIG_GET mysql.client-host) fi diff --git a/src/modules/site/create/ee_mod_setup_database.sh b/src/modules/site/create/ee_mod_setup_database.sh index 30d7d339..8c467f0d 100644 --- a/src/modules/site/create/ee_mod_setup_database.sh +++ b/src/modules/site/create/ee_mod_setup_database.sh @@ -56,11 +56,11 @@ function ee_mod_setup_database() || ee_lib_error "Unable to create $EE_DB_NAME database, exit status = " $? # Create MySQL User - mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_HOST' identified by '$EE_DB_PASS'" \ + mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_CLIENT_HOST' identified by '$EE_DB_PASS'" \ || ee_lib_error "Unable to create $EE_DB_USER database user, exit status = " $? # Grant permission - mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_HOST'" \ + mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_CLIENT_HOST'" \ || ee_lib_error "Unable to grant privileges for $EE_DB_USER database user, exit status = " $? mysql -e "flush privileges" } From f8c9d78c1a101f2cd966a74082f935405bfb51ee Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 13 Aug 2014 13:41:38 +0530 Subject: [PATCH 004/829] Logs Mysql host and client host value --- src/modules/site/create/ee_mod_setup_database.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/create/ee_mod_setup_database.sh b/src/modules/site/create/ee_mod_setup_database.sh index 8c467f0d..4afe9fc2 100644 --- a/src/modules/site/create/ee_mod_setup_database.sh +++ b/src/modules/site/create/ee_mod_setup_database.sh @@ -51,7 +51,7 @@ function ee_mod_setup_database() fi # Create MySQL database - echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS" &>> $EE_COMMAND_LOG + echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS \nEE_MYSQL_HOST = $EE_MYSQL_HOST \nEE_MYSQL_CLIENT_HOST = $EE_MYSQL_CLIENT_HOST" &>> $EE_COMMAND_LOG mysql -e "create database \`$EE_DB_NAME\`" \ || ee_lib_error "Unable to create $EE_DB_NAME database, exit status = " $? From 2d70c2e73b127746a7d40faf276de5d58913f8f1 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 13 Aug 2014 13:55:58 +0530 Subject: [PATCH 005/829] Rename variables --- config/easyengine/ee.conf | 2 +- src/lib/ee_lib_variables.sh | 6 +++--- src/modules/site/create/ee_mod_setup_database.sh | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/easyengine/ee.conf b/config/easyengine/ee.conf index 286f105e..d34a2e21 100644 --- a/config/easyengine/ee.conf +++ b/config/easyengine/ee.conf @@ -6,7 +6,7 @@ ip-address = [mysql] - client-host = localhost + grant-host = localhost db-name = false db-user = false diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 82df02c2..7a1a767d 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -46,8 +46,8 @@ else fi # Find out MySQL client-host to setup grants -if [ -z $($EE_CONFIG_GET mysql.client-host) ]; then - readonly EE_MYSQL_CLIENT_HOST=localhost +if [ -z $($EE_CONFIG_GET mysql.grant-host) ]; then + readonly EE_MYSQL_GRANT_HOST=localhost else - readonly EE_MYSQL_CLIENT_HOST=$($EE_CONFIG_GET mysql.client-host) + readonly EE_MYSQL_GRANT_HOST=$($EE_CONFIG_GET mysql.grant-host) fi diff --git a/src/modules/site/create/ee_mod_setup_database.sh b/src/modules/site/create/ee_mod_setup_database.sh index 4afe9fc2..a8c53d2b 100644 --- a/src/modules/site/create/ee_mod_setup_database.sh +++ b/src/modules/site/create/ee_mod_setup_database.sh @@ -51,16 +51,16 @@ function ee_mod_setup_database() fi # Create MySQL database - echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS \nEE_MYSQL_HOST = $EE_MYSQL_HOST \nEE_MYSQL_CLIENT_HOST = $EE_MYSQL_CLIENT_HOST" &>> $EE_COMMAND_LOG + echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS \nEE_MYSQL_HOST = $EE_MYSQL_HOST \nEE_MYSQL_GRANT_HOST = $EE_MYSQL_GRANT_HOST" &>> $EE_COMMAND_LOG mysql -e "create database \`$EE_DB_NAME\`" \ || ee_lib_error "Unable to create $EE_DB_NAME database, exit status = " $? # Create MySQL User - mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_CLIENT_HOST' identified by '$EE_DB_PASS'" \ + mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_GRANT_HOST' identified by '$EE_DB_PASS'" \ || ee_lib_error "Unable to create $EE_DB_USER database user, exit status = " $? # Grant permission - mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_CLIENT_HOST'" \ + mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_GRANT_HOST'" \ || ee_lib_error "Unable to grant privileges for $EE_DB_USER database user, exit status = " $? mysql -e "flush privileges" } From 8701c198daf40050091a852e139454fd2d92cf9c Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 13 Aug 2014 14:02:03 +0530 Subject: [PATCH 006/829] Fix --mysql autocomplete --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index a31bbe71..72d723b6 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -87,7 +87,7 @@ function EE_AUTO() *) if [ "$PREVIOUS2" = "create" ]; then - COMPREPLY=( $( compgen -W "--html --php --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) + COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "delete" ]; then COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) ) fi From a32a54c40b1e1af63e6f276cec957cc96e9fe045 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 13 Aug 2014 15:30:36 +0530 Subject: [PATCH 007/829] EasyEngine 2.0.2 --- CHANGELOG.txt | 3 +++ bin/update | 17 ++++++++++++++--- docs/index.md | 3 --- src/lib/ee_lib_variables.sh | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) delete mode 100644 docs/index.md diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 448047fb..caaacd8d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,6 @@ +v 2.0.2 - July 21, 2014 + - Remote MySQL Support + v 2.0.1 - July 21, 2014 - Fixed wp-cli installation #289 diff --git a/bin/update b/bin/update index bb8accd5..cf770751 100644 --- a/bin/update +++ b/bin/update @@ -155,6 +155,9 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do source $ee_include done + + # Avoid re-source and readonly errors + ee_source=1 # Lets modify the $EE_COMMAND_LOG value # So all the logs write in $EE_UPDATE_LOG @@ -383,11 +386,14 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then fi if [[ $EE_CURRENT_VERSION < 2.0.1 ]]; then + # Lets re-used our functions # Include library - for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do - source $ee_include - done + if [ $ee_source != 1 ]; then + for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do + source $ee_include + done + fi if [[ $EE_CURRENT_VERSION = 2.0.0 ]]; then dpkg -l | grep php5-fpm &>> $EE_UPDATE_LOG @@ -399,6 +405,11 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Install WP-CLI ee_ven_install_wpcli fi + # Update EasyEngine current version + EE_CURRENT_VERSION="2.0.1" + fi + if [[ $EE_CURRENT_VERSION = 2.0.1 ]]; then + sed -i 's/host =.*/grant-host = localhost/' /etc/easyengine/ee.conf fi fi diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index ff4c324f..00000000 --- a/docs/index.md +++ /dev/null @@ -1,3 +0,0 @@ -### Test - -Markdown diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 7a1a767d..cb2ee37a 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -1,7 +1,7 @@ # Define global variables # EasyEngine version -readonly EE_VERSION='2.0.1' +readonly EE_VERSION='2.0.2' # WP-CLI version readonly EE_WP_CLI_VERSION='0.16.0' From a294ec4771e3909e2396bd64ee124086b8a6e61b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 13 Aug 2014 16:01:14 +0530 Subject: [PATCH 008/829] EasyEngine 2.0.2 --- bin/update | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/update b/bin/update index cf770751..d332bd74 100644 --- a/bin/update +++ b/bin/update @@ -143,7 +143,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then || ee_lib_error "Unable to copy EasyEngine (ee) man page, exit status = " $? - if [[ $EE_CURRENT_VERSION < 2.0.0 ]]; then + if [[ $EE_CURRENT_VERSION < 1.9.0 ]]; then # EasyEngine (ee) config file cp -av /etc/easyengine/ee.conf /etc/easyengine/ee.bak &>> $EE_UPDATE_LOG cp -av /tmp/easyengine/config/easyengine/ee.conf /etc/easyengine/ &>> $EE_UPDATE_LOG \ @@ -385,11 +385,11 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then fi fi - if [[ $EE_CURRENT_VERSION < 2.0.1 ]]; then + if [[ $EE_CURRENT_VERSION > 1.9.0 ]]; then # Lets re-used our functions # Include library - if [ $ee_source != 1 ]; then + if [ -z $ee_source ]; then for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do source $ee_include done @@ -408,6 +408,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Update EasyEngine current version EE_CURRENT_VERSION="2.0.1" fi + if [[ $EE_CURRENT_VERSION = 2.0.1 ]]; then sed -i 's/host =.*/grant-host = localhost/' /etc/easyengine/ee.conf fi From 2f8cc9b30f02d7a21fd6b089c0f5fa3420d8d1ea Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 13 Aug 2014 16:32:07 +0530 Subject: [PATCH 009/829] Update CHANGELOG.txt --- CHANGELOG.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index caaacd8d..c64f5e2d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,4 @@ -v 2.0.2 - July 21, 2014 +v 2.0.2 - Aug 13, 2014 - Remote MySQL Support v 2.0.1 - July 21, 2014 From d67770380e576c3c8e1d875fa8b63df7cbe84fec Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 14 Aug 2014 13:20:18 +0530 Subject: [PATCH 010/829] Support Remote MySQL for mail server --- src/vendor/ee_ven_setup_roundcube.sh | 2 +- src/vendor/ee_ven_setup_vimbadmin.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vendor/ee_ven_setup_roundcube.sh b/src/vendor/ee_ven_setup_roundcube.sh index 620f79c6..f7908aae 100644 --- a/src/vendor/ee_ven_setup_roundcube.sh +++ b/src/vendor/ee_ven_setup_roundcube.sh @@ -12,7 +12,7 @@ function ee_ven_setup_roundcube() || ee_lib_error "Unable to create Roundcube database, exit status = " $? # Create MySQL user - mysql -e "grant all privileges on roundcubemail.* to roundcube@'$EE_MYSQL_HOST' IDENTIFIED BY '$ee_random'" \ + mysql -e "grant all privileges on roundcubemail.* to roundcube@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_random'" \ || ee_lib_error "Unable to grant privileges for Roundcube database user, exit status = " $? mysql -e "flush privileges" diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index fad62321..eb419282 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -12,7 +12,7 @@ function ee_ven_setup_vimbadmin() || ee_lib_error "Unable to create ViMbAdmin database, exit status = " $? # Create MySQL User - mysql -e "grant all privileges on vimbadmin.* to vimbadmin@'$EE_MYSQL_HOST' IDENTIFIED BY '$ee_random'" \ + mysql -e "grant all privileges on vimbadmin.* to vimbadmin@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_random'" \ || ee_lib_error "Unable to grant privileges for ViMbAdmin database user, exit status = " $? mysql -e "flush privileges" From 3788de9b74ec41002b5e7ec2ffc49fdf5d47396d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 14 Aug 2014 17:11:43 +0530 Subject: [PATCH 011/829] Fixes #189 --- src/vendor/ee_ven_install_utils.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index be315097..26c3ad1c 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -115,6 +115,12 @@ function ee_ven_install_utils() echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server echo -e "}" >> /etc/logrotate.d/mysql-server fi + + # Download pt-query-advisor Fixed #189 + wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ + || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? + chmod 0755 /usr/bin/pt-query-advisor + fi fi # Change permission From 086cbad99c77a5b124339d2ee910b58295865586 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 14 Aug 2014 17:15:26 +0530 Subject: [PATCH 012/829] Added -i to sed --- src/vendor/ee_ven_install_utils.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index 26c3ad1c..348cbf3f 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -121,6 +121,10 @@ function ee_ven_install_utils() || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? chmod 0755 /usr/bin/pt-query-advisor + # Enable pt-query-advisor plugin in Anemometer + sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ + || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $? + fi fi # Change permission From 3a45e5615b62224bbc2bbaf6e6d6821f6dde5315 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 14 Aug 2014 17:24:13 +0530 Subject: [PATCH 013/829] Removed Extra Space --- src/vendor/ee_ven_install_utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index 348cbf3f..502598d1 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -122,7 +122,7 @@ function ee_ven_install_utils() chmod 0755 /usr/bin/pt-query-advisor # Enable pt-query-advisor plugin in Anemometer - sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ + sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $? fi From 54cb5127a995a07be8c11242d10c8e1ab13975e9 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 19 Aug 2014 19:52:36 +0530 Subject: [PATCH 014/829] Introduced mail command --- bin/easyengine | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 5735fad8..8f1d36ce 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -90,7 +90,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display success message ee_lib_echo "$EE_THIRD successfully installed" - elif [ "$EE_THIRD" = "" ]; then + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "--web" ] || [ "$EE_THIRD" = "--all" ]; then # Setup NGINX/PHP repository ee_mod_repo_nginx ee_mod_repo_php @@ -128,6 +128,44 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo "Successfully installed all packages" ee_lib_echo "Create your first WordPress site powered by NGINX using:" ee_lib_echo_info "ee site create example.com --wp" + + # EasyEngine mail server setup + elif ["$EE_THIRD" = "--mail" ] || [ "$EE_THIRD" = "--all" ];then + # Install Dovecot + ee_mod_install_dovecot + + # Install ViMbAdmin + ee_ven_install_vimbadmin + + # Install Roundcube + ee_ven_install_roundcube + + # Install Amavis + ee_ven_install_amavis + + # Install Sieve + ee_ven_install_sieve + + # Configure PostFix + ee_mod_setup_postfix + + # Configure Dovecot + ee_mod_setup_dovecot + + # Setup ViMbAdmin + ee_ven_setup_vimbadmin + + # Setup Roundcube + ee_ven_setup_roundcube + + # Setup Amavis + ee_ven_setup_amavis + + # Setup Sieve + ee_ven_setup_sieve + + ee_lib_echo "Successfully installed mail server" + fi # EasyEngine remove/purge From bd413dca0072b26d8f232aed1f2b9122f9d647ef Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 20 Aug 2014 18:39:07 +0530 Subject: [PATCH 015/829] Added Roundcbue Nginx configuration --- src/vendor/ee_ven_setup_roundcube.sh | 7 +++++++ templates/mail/webmail | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 templates/mail/webmail diff --git a/src/vendor/ee_ven_setup_roundcube.sh b/src/vendor/ee_ven_setup_roundcube.sh index f7908aae..2ea51517 100644 --- a/src/vendor/ee_ven_setup_roundcube.sh +++ b/src/vendor/ee_ven_setup_roundcube.sh @@ -25,4 +25,11 @@ function ee_ven_setup_roundcube() sed -i "s'mysql://roundcube:pass@localhost/roundcubemail'mysql://roundcube:${ee_random}@${EE_MYSQL_HOST}/roundcubemail'" /var/www/roundcubemail/htdocs/config/config.inc.php \ || ee_lib_error "Unable to setup Roundcube database details in config.inc.php file, exit status = " $? + # Setup Nginx configuration to access Webmail + cp -v /usr/share/easyengine/mail/webmail /etc/nginx/sites-available/ &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to copy Nginx configuration for Roundcube, exit status = " $? + + ln -sf /etc/nginx/sites-available/webmail /etc/nginx/sites-enabled/ \ + || ee_lib_error "Unable to create softlink for Webmail, exit status = " $? + } diff --git a/templates/mail/webmail b/templates/mail/webmail new file mode 100644 index 00000000..fff3a464 --- /dev/null +++ b/templates/mail/webmail @@ -0,0 +1,23 @@ +# Nginx Configuration to access webmail +# Don't modify this file, EasyEngine replaces it with new version + +server { + server_name webmail.*; + + access_log /var/log/nginx/webmail.access.log; + error_log /var/log/nginx/webmail.error.log; + + root /var/www/roundcube/htdocs; + index index.php; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass 127.0.0.1:9000; + } + +} From ee34f8b21fb8fb43a9bb818a656d2043dbd8cd88 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 20 Aug 2014 18:45:42 +0530 Subject: [PATCH 016/829] Fixed Typo --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 8f1d36ce..f4fd3003 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -130,7 +130,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo_info "ee site create example.com --wp" # EasyEngine mail server setup - elif ["$EE_THIRD" = "--mail" ] || [ "$EE_THIRD" = "--all" ];then + elif [ "$EE_THIRD" = "--mail" ] || [ "$EE_THIRD" = "--all" ];then # Install Dovecot ee_mod_install_dovecot From a62c20935bcb69cfd3daa51dc9e003b2e9afd2dc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 20 Aug 2014 19:12:01 +0530 Subject: [PATCH 017/829] Fixed some function names and Added service restart code --- bin/easyengine | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index f4fd3003..bfcae201 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -141,10 +141,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_install_roundcube # Install Amavis - ee_ven_install_amavis + ee_mod_install_amavis # Install Sieve - ee_ven_install_sieve + ee_mod_install_sieve # Configure PostFix ee_mod_setup_postfix @@ -159,10 +159,15 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_setup_roundcube # Setup Amavis - ee_ven_setup_amavis + ee_mod_setup_amavis # Setup Sieve - ee_ven_setup_sieve + ee_mod_setup_sieve + + + ee_lib_service nginx postfix dovecot restart + + ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git" ee_lib_echo "Successfully installed mail server" From fc75b25d0b05438185a314f505b9e1761db463f0 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 20 Aug 2014 19:43:08 +0530 Subject: [PATCH 018/829] Added --all option for Web and Mail install and added dovecot package check --- bin/easyengine | 4 ++-- .../stack/install/mail/ee_mod_install_dovecot.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index bfcae201..c988b222 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -128,9 +128,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo "Successfully installed all packages" ee_lib_echo "Create your first WordPress site powered by NGINX using:" ee_lib_echo_info "ee site create example.com --wp" - + fi # EasyEngine mail server setup - elif [ "$EE_THIRD" = "--mail" ] || [ "$EE_THIRD" = "--all" ];then + if [ "$EE_THIRD" = "--mail" ] || [ "$EE_THIRD" = "--all" ];then # Install Dovecot ee_mod_install_dovecot diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index 44c2b8c1..ad247354 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -3,9 +3,23 @@ function ee_mod_install_dovecot() { # Install Dovecot + dpkg -l | grep nginx > /dev/null \ + && dpkg -l | grep php5-fpm > /dev/null \ + && dpkg -l | grep mysql > /dev/null \ + && dpkg -l | grep postfix > /dev/null + if [ $? -ne 0 ];then + ee_lib_error "Failed to find pre dependencies. Please install Nginx, PHP5, MySQL and Postfix using command ee stack install, exit status " 1 + fi + + dkpg -l | grep dovecot-core > /dev/null + if [$? -eq 0 ];then + ee_lib_error "Found installed mail server, Please remove it before installation, exit status=" 1 + fi + ee_lib_echo "Installing Dovecot, please wait..." debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ || ee_lib_error "Unable to install Dovecot, exit status = " $? + } From ac1aac8695932b5cdc5b78207c3c717e67660b2d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 20 Aug 2014 19:47:15 +0530 Subject: [PATCH 019/829] Fixed typo --- src/modules/stack/install/mail/ee_mod_install_dovecot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index ad247354..c0942291 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -3,7 +3,7 @@ function ee_mod_install_dovecot() { # Install Dovecot - dpkg -l | grep nginx > /dev/null \ + dpkg -l | grep nginx > /dev/null \ && dpkg -l | grep php5-fpm > /dev/null \ && dpkg -l | grep mysql > /dev/null \ && dpkg -l | grep postfix > /dev/null @@ -12,7 +12,7 @@ function ee_mod_install_dovecot() fi dkpg -l | grep dovecot-core > /dev/null - if [$? -eq 0 ];then + if [ $? -eq 0 ];then ee_lib_error "Found installed mail server, Please remove it before installation, exit status=" 1 fi From deab1c5f40c99749b982030a0c9110cd908117a5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 20 Aug 2014 19:50:43 +0530 Subject: [PATCH 020/829] Fixed typo --- src/modules/stack/install/mail/ee_mod_install_dovecot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index c0942291..38af7058 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -11,7 +11,7 @@ function ee_mod_install_dovecot() ee_lib_error "Failed to find pre dependencies. Please install Nginx, PHP5, MySQL and Postfix using command ee stack install, exit status " 1 fi - dkpg -l | grep dovecot-core > /dev/null + dpkg -l | grep dovecot-core > /dev/null if [ $? -eq 0 ];then ee_lib_error "Found installed mail server, Please remove it before installation, exit status=" 1 fi From 928752cd00b3805d55ed94a1581f0582ca86d87e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 20 Aug 2014 20:13:40 +0530 Subject: [PATCH 021/829] Fixed Wrong function name --- src/modules/stack/install/mail/ee_mod_setup_sieve.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index 8b80c72c..58e62a92 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -1,6 +1,6 @@ # Setup Sieve -function ee_mod_setup_amavis() +function ee_mod_setup_sieve() { # Enable sieve plugin support for dovecot-lmtp sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address = admin@example.com\n mns sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ From 08be992c5b2de659d15566799266a5d3d25ddbac Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 21 Aug 2014 12:12:47 +0530 Subject: [PATCH 022/829] Added ViMbAdmin Nginx configuration --- src/vendor/ee_ven_setup_vimbadmin.sh | 8 ++++++++ templates/mail/vma | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 templates/mail/vma diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index eb419282..d5df5091 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -53,4 +53,12 @@ function ee_ven_setup_vimbadmin() /var/www/22222/htdocs/vimbadmin/bin/doctrine2-cli.php orm:schema-tool:create \ || ee_lib_error "Unable to setup ViMbAdmin default database , exit status = " $? + # Setup Nginx configuration to access ViMbAdmin + cp -v /usr/share/easyengine/mail/vma /etc/nginx/sites-available/ &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to copy Nginx configuration for ViMbAdmin, exit status = " $? + + ln -sf /etc/nginx/sites-available/vma /etc/nginx/sites-enabled/ \ + || ee_lib_error "Unable to create softlink for ViMbAdmin, exit status = " $? + + } diff --git a/templates/mail/vma b/templates/mail/vma new file mode 100644 index 00000000..fc15e31b --- /dev/null +++ b/templates/mail/vma @@ -0,0 +1,23 @@ +# Nginx Configuration to access webmail +# Don't modify this file,After update EasyEngine replaces it with new version + +server { + server_name vma.*; + + access_log /var/log/nginx/vma.access.log; + error_log /var/log/nginx/vma.error.log; + + root /var/www/22222/htdocs/vimbadmin; + index index.php; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass 127.0.0.1:9000; + } + +} From c2d53dd3ca25a26854f733895200612b4e90c72b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 21 Aug 2014 13:55:46 +0530 Subject: [PATCH 023/829] Fixed Sieve rules compialtion issue --- src/modules/stack/install/mail/ee_mod_setup_sieve.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index 58e62a92..4fcfac88 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -3,7 +3,7 @@ function ee_mod_setup_sieve() { # Enable sieve plugin support for dovecot-lmtp - sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address = admin@example.com\n mns sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ + sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address = admin@example.com\n mail_plugins = \$mail_plugins sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ || ee_lib_error "Unable to add sieve plugin support for dovecot-lmtp, exit status = " $? # Sieve dovecot-pluign configuration From a423dc0f513c0ede1f22d830a1a1689f8d2a639c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 21 Aug 2014 14:23:03 +0530 Subject: [PATCH 024/829] Fixed wrong functin name --- src/modules/stack/install/mail/ee_mod_install_amavis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_amavis.sh b/src/modules/stack/install/mail/ee_mod_install_amavis.sh index c2804cb1..0ad49490 100644 --- a/src/modules/stack/install/mail/ee_mod_install_amavis.sh +++ b/src/modules/stack/install/mail/ee_mod_install_amavis.sh @@ -1,6 +1,6 @@ # Install Amavis package -function ee_mod_install_dovecot() +function ee_mod_install_amavis() { # Install Amavis ee_lib_echo "Installing Amavis, please wait..." From 2e0dac463e30c259266a8fcbd5de0b2b03eae556 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 21 Aug 2014 15:31:08 +0530 Subject: [PATCH 025/829] Fixed Amavis installation --- src/modules/stack/install/mail/ee_mod_install_amavis.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_amavis.sh b/src/modules/stack/install/mail/ee_mod_install_amavis.sh index 0ad49490..6f72603a 100644 --- a/src/modules/stack/install/mail/ee_mod_install_amavis.sh +++ b/src/modules/stack/install/mail/ee_mod_install_amavis.sh @@ -3,7 +3,7 @@ function ee_mod_install_amavis() { # Install Amavis - ee_lib_echo "Installing Amavis, please wait..." - $EE_APT_GET amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl libmail-dkim-perl p7zip rpm unrar-free libsnmp-perl \ - || ee_lib_error "Unable to install Amavis, exit status = " $? + ee_lib_echo "Installing Amavis and ClamAV, please wait..." + $EE_APT_GET install amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl libmail-dkim-perl p7zip rpm unrar-free libsnmp-perl \ + || ee_lib_error "Unable to install Amavis and ClamAV, exit status = " $? } From 6ca0597b9570407eee8f7243c6adede580464b5d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 22 Aug 2014 13:14:29 +0530 Subject: [PATCH 026/829] Fixed Missing package and ROundcube setup issue: --- src/modules/stack/install/mail/ee_mod_install_dovecot.sh | 2 +- src/modules/stack/install/mail/ee_mod_setup_sieve.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index 38af7058..692dcad4 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -19,7 +19,7 @@ function ee_mod_install_dovecot() ee_lib_echo "Installing Dovecot, please wait..." debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" - $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ + $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved postfix-mysql \ || ee_lib_error "Unable to install Dovecot, exit status = " $? } diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index 4fcfac88..f49222ef 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -21,7 +21,7 @@ function ee_mod_setup_sieve() || ee_lib_error "Unable to compile Sieve rules, exit status = " $? # Configure Roundcube - sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'sieverules':" /var/www/roundcubemail/htdocs/config/config.inc.php \ + sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'sieverules',:" /var/www/roundcubemail/htdocs/config/config.inc.php \ || ee_lib_error "Unable to configure Sieve Roundcube plugin, exit status = " $? echo "\$config['sieverules_port'] = 4190;" >> /var/www/roundcubemail/htdocs/config/config.inc.php } From c3d5cbb383a9039c44d467b9b50e4097c2d19e96 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 22 Aug 2014 16:16:45 +0530 Subject: [PATCH 027/829] Added Certificate for Dovecot and Postfix --- .../stack/install/mail/ee_mod_setup_dovecot.sh | 18 ++++++++++++++++++ .../stack/install/mail/ee_mod_setup_postfix.sh | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index ca77fc4a..43b4e9e7 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -2,6 +2,14 @@ function ee_mod_setup_dovecot() { + + EE_EMAIL=$($EE_CONFIG_GET wordpress.email) + if [[ $EE_EMAIL = "" ]]; then + EE_EMAIL=$(git config user.email) + fi + + EE_HOSTNAME=$(hostname -f) + ee_lib_echo "Setting up Dovecot, please wait..." # Adding mail user with GID 5000 and UID 5000 groupadd -g 5000 vmail && useradd -g vmail -u 5000 vmail -d /var/vmail -m \ @@ -39,4 +47,14 @@ function ee_mod_setup_dovecot() # Change Dovecot log location sed -i "s/#log_path = syslog/log_path = \/var\/log\/dovecot.log/" /etc/dovecot/conf.d/10-logging.conf \ || ee_lib_error "Unable to setup Dovecot log_path, exit status = " $? + + # Configure self signed SSL for Dovecot + ee_lib_echo "Generating self signed certificate for Dovecot, please wait..." + openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/dovecot.pem -keyout /etc/ssl/private/dovecot.pem &>> $EE_COMMAND_LOG + + # Setting up certificate in file + sed -i "s'/etc/dovecot/dovecot.pem'/etc/ssl/certs/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ + sed -i "s'/etc/dovecot/private/dovecot.pem'/etc/ssl/private/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ + || ee_lib_error "Unable to setup Dovecot SSL certificate path, exit status = " $? + } diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index a8d19fa5..9c0bd7bb 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -2,6 +2,13 @@ function ee_mod_setup_postfix() { + + EE_EMAIL=$($EE_CONFIG_GET wordpress.email) + if [[ $EE_EMAIL = "" ]]; then + EE_EMAIL=$(git config user.email) + fi + + EE_HOSTNAME=$(hostname -f) ee_lib_echo "Setting up Postfix, please wait..." #Configure Master.cf sed -i 's/#submission/submission/' /etc/postfix/master.cf && @@ -43,4 +50,10 @@ function ee_mod_setup_postfix() cp -av /usr/share/easyengine/mail/virtual_mailbox_maps.cf /etc/postfix/mysql/virtual_mailbox_maps.cf &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to copy Postfix MySQL configuration files, exit status = " $? + # Configure self signed SSL for Postfix + ee_lib_echo "Generating self signed certificate for Postfix, please wait..." + openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/postfix.pem -keyout /etc/ssl/private/postfix.pem &>> $EE_COMMAND_LOG + postconf -e smtpd_tls_cert_file=/etc/ssl/certs/postfix.pem + postconf -e smtpd_tls_key_file=/etc/ssl/private/postfix.pem + } From 6945d6ada9b554959a1adc6709622d1331541a79 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 22 Aug 2014 16:29:34 +0530 Subject: [PATCH 028/829] Added Dovecot init.d script and Set the permission for dovcot/postfix key file --- .../install/mail/ee_mod_setup_dovecot.sh | 3 + .../install/mail/ee_mod_setup_postfix.sh | 2 + templates/mail/dovecot | 72 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 templates/mail/dovecot diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index 43b4e9e7..876ca553 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -57,4 +57,7 @@ function ee_mod_setup_dovecot() sed -i "s'/etc/dovecot/private/dovecot.pem'/etc/ssl/private/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ || ee_lib_error "Unable to setup Dovecot SSL certificate path, exit status = " $? + # Setting Dovecot init.d script + cp -v /usr/share/easyengine/mail/dovecot /etc/init.d/dovecot &>> $EE_COMMAND_LOG \ + } diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index 9c0bd7bb..c49b05f2 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -53,6 +53,8 @@ function ee_mod_setup_postfix() # Configure self signed SSL for Postfix ee_lib_echo "Generating self signed certificate for Postfix, please wait..." openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/postfix.pem -keyout /etc/ssl/private/postfix.pem &>> $EE_COMMAND_LOG + chmod 0600 /etc/ssl/private/postfix.pem + postconf -e smtpd_tls_cert_file=/etc/ssl/certs/postfix.pem postconf -e smtpd_tls_key_file=/etc/ssl/private/postfix.pem diff --git a/templates/mail/dovecot b/templates/mail/dovecot new file mode 100644 index 00000000..d3bdd857 --- /dev/null +++ b/templates/mail/dovecot @@ -0,0 +1,72 @@ +### BEGIN INIT INFO +# Provides: dovecot +# Required-Start: $local_fs $remote_fs $network $syslog $time +# Required-Stop: $local_fs $remote_fs $network $syslog +# Should-Start: postgresql mysql slapd winbind +# Should-Stop: postgresql mysql slapd winbind +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Dovecot init script +# Description: Init script for dovecot services +### END INIT INFO + +# Example /etc/init.d/dovecot script. Change DAEMON if necessary. +# License is public domain. + +DAEMON=/usr/sbin/dovecot + +# Uncomment to allow Dovecot daemons to produce core dumps. +#ulimit -c unlimited + +test -x $DAEMON || exit 1 +set -e + +base_dir=`$DAEMON config -h base_dir` +pidfile=$base_dir/master.pid + +if test -f $pidfile; then + running=yes +else + running=no +fi + +case "$1" in + start) + echo -n "Starting Dovecot" + $DAEMON + echo "." + ;; + stop) + if test $running = yes; then + echo "Stopping Dovecot" + kill `cat $pidfile` + echo "." + else + echo "Dovecot is already stopped." + fi + ;; + reload) + if test $running = yes; then + echo -n "Reloading Dovecot configuration" + kill -HUP `cat $pidfile` + echo "." + else + echo "Dovecot isn't running." + fi + ;; + restart|force-reload) + echo -n "Restarting Dovecot" + if test $running = yes; then + kill `cat $pidfile` + sleep 1 + fi + $DAEMON + echo "." + ;; + *) + echo "Usage: /etc/init.d/dovecot {start|stop|reload|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 \ No newline at end of file From e271db2c50d7a428b4fc1c936f1c91763a518a3b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 25 Aug 2014 13:08:50 +0530 Subject: [PATCH 029/829] Fixed 'Unable to setup Dovecot SSL certificate path' --- src/modules/stack/install/mail/ee_mod_setup_dovecot.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index 876ca553..5c3d1dd4 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -51,10 +51,11 @@ function ee_mod_setup_dovecot() # Configure self signed SSL for Dovecot ee_lib_echo "Generating self signed certificate for Dovecot, please wait..." openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/dovecot.pem -keyout /etc/ssl/private/dovecot.pem &>> $EE_COMMAND_LOG + chmod 0600 /etc/ssl/private/dovecot.pem # Setting up certificate in file sed -i "s'/etc/dovecot/dovecot.pem'/etc/ssl/certs/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ - sed -i "s'/etc/dovecot/private/dovecot.pem'/etc/ssl/private/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ + && sed -i "s'/etc/dovecot/private/dovecot.pem'/etc/ssl/private/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ || ee_lib_error "Unable to setup Dovecot SSL certificate path, exit status = " $? # Setting Dovecot init.d script From 46eb15f272e32ea764aa07d9953ded74220aa861 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 25 Aug 2014 13:17:16 +0530 Subject: [PATCH 030/829] Fixed various small issues --- bin/easyengine | 3 +-- src/modules/stack/install/mail/ee_mod_setup_amavis.sh | 2 ++ src/modules/stack/install/mail/ee_mod_setup_sieve.sh | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index c988b222..092ea23a 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -163,11 +163,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Setup Sieve ee_mod_setup_sieve - ee_lib_service nginx postfix dovecot restart - ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git" + ee_lib_git /etc/nginx/ /etc/dovecot /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git" ee_lib_echo "Successfully installed mail server" diff --git a/src/modules/stack/install/mail/ee_mod_setup_amavis.sh b/src/modules/stack/install/mail/ee_mod_setup_amavis.sh index 84af5a92..ce0e3177 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_amavis.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_amavis.sh @@ -3,6 +3,8 @@ function ee_mod_setup_amavis() { # Confiure Amavis + + ee_lib_echo "Setting up Amavis, please wait..." sed -i "s'#@'@'" /etc/amavis/conf.d/15-content_filter_mode && \ sed -i "s'# ' '" /etc/amavis/conf.d/15-content_filter_mode \ || ee_lib_error "Unable to setup Amavis, exit status = " $? diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index f49222ef..6f47f2dd 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -2,6 +2,8 @@ function ee_mod_setup_sieve() { + ee_lib_echo "Setting up Sieve, please wait..." + # Enable sieve plugin support for dovecot-lmtp sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address = admin@example.com\n mail_plugins = \$mail_plugins sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ || ee_lib_error "Unable to add sieve plugin support for dovecot-lmtp, exit status = " $? From 1f0723ec06edaabcb684f5e6f982f49dcf9ac735 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 25 Aug 2014 15:27:34 +0530 Subject: [PATCH 031/829] Added conotent to Identify mail server is done by EasyEngine or not --- templates/mail/dovecot | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/mail/dovecot b/templates/mail/dovecot index d3bdd857..c7b13ace 100644 --- a/templates/mail/dovecot +++ b/templates/mail/dovecot @@ -1,3 +1,4 @@ +# EasyEngine Dovecot init script ### BEGIN INIT INFO # Provides: dovecot # Required-Start: $local_fs $remote_fs $network $syslog $time From 410f8b166a6f4dbabaf8000f8783ef8ff273b853 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 25 Aug 2014 16:42:26 +0530 Subject: [PATCH 032/829] Simplified Installation code --- bin/easyengine | 19 +++++++++++++++++-- bin/update | 6 +++--- .../install/mail/ee_mod_install_dovecot.sh | 15 +-------------- ...l_amavis.sh => ee_mod_install_mailscan.sh} | 6 +++--- .../install/mail/ee_mod_install_sieve.sh | 2 +- ...tup_amavis.sh => ee_mod_setup_mailscan.sh} | 2 +- .../install/mail/ee_mod_setup_postfix.sh | 7 +++++++ 7 files changed, 33 insertions(+), 24 deletions(-) rename src/modules/stack/install/mail/{ee_mod_install_amavis.sh => ee_mod_install_mailscan.sh} (56%) rename src/modules/stack/install/mail/{ee_mod_setup_amavis.sh => ee_mod_setup_mailscan.sh} (97%) diff --git a/bin/easyengine b/bin/easyengine index 092ea23a..505db325 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -131,6 +131,21 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then fi # EasyEngine mail server setup if [ "$EE_THIRD" = "--mail" ] || [ "$EE_THIRD" = "--all" ];then + + # Check required Packages are installed or not + dpkg --get-selections | grep -v deinstall | grep nginx > /dev/null \ + && dpkg --get-selections | grep -v deinstall | grep php5-fpm > /dev/null \ + && dpkg --get-selections | grep -v deinstall | grep mysql > /dev/null \ + && dpkg --get-selections | grep -v deinstall | grep postfix > /dev/null + if [ $? -ne 0 ];then + ee_lib_error "Failed to find pre dependencies. Please install Nginx, PHP5, MySQL and Postfix using command ee stack install, exit status " 1 + fi + + dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null + if [ $? -eq 0 ];then + ee_lib_error "Found installed mail server, Please remove it before installation, exit status=" 1 + fi + # Install Dovecot ee_mod_install_dovecot @@ -141,7 +156,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_install_roundcube # Install Amavis - ee_mod_install_amavis + ee_mod_install_mailscan # Install Sieve ee_mod_install_sieve @@ -159,7 +174,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_setup_roundcube # Setup Amavis - ee_mod_setup_amavis + ee_mod_setup_mailscan # Setup Sieve ee_mod_setup_sieve diff --git a/bin/update b/bin/update index d332bd74..6f3f05a0 100644 --- a/bin/update +++ b/bin/update @@ -285,7 +285,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then || ee_lib_error "Unable to generate SSL certificate for port 22222, exit status = " $? # Update PHP configuration - dpkg -l | grep php5-fpm &>> $EE_UPDATE_LOG + dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG if [ $? -eq 0 ]; then ee_lib_echo "Installing php5-xdebug package, please wait..." apt-get -y install php5-xdebug \ @@ -325,7 +325,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then || ee_lib_error "Unable to add xdebug settings for debug pool, exit status = " $? fi - dpkg -l | grep mysql-server &>> $EE_UPDATE_LOG + dpkg --get-selections | grep -v deinstall | grep mysql-server &>> $EE_UPDATE_LOG if [ $? -eq 0 ]; then ee_lib_echo "Installing percona-toolkit package, please wait..." apt-get -y install percona-toolkit \ @@ -396,7 +396,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then fi if [[ $EE_CURRENT_VERSION = 2.0.0 ]]; then - dpkg -l | grep php5-fpm &>> $EE_UPDATE_LOG + dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG if [ $? -eq 0 ]; then # WP-CLI change the installation method diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index 692dcad4..ed49ba86 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -3,23 +3,10 @@ function ee_mod_install_dovecot() { # Install Dovecot - dpkg -l | grep nginx > /dev/null \ - && dpkg -l | grep php5-fpm > /dev/null \ - && dpkg -l | grep mysql > /dev/null \ - && dpkg -l | grep postfix > /dev/null - if [ $? -ne 0 ];then - ee_lib_error "Failed to find pre dependencies. Please install Nginx, PHP5, MySQL and Postfix using command ee stack install, exit status " 1 - fi - - dpkg -l | grep dovecot-core > /dev/null - if [ $? -eq 0 ];then - ee_lib_error "Found installed mail server, Please remove it before installation, exit status=" 1 - fi - ee_lib_echo "Installing Dovecot, please wait..." debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" - $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved postfix-mysql \ + $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql \ || ee_lib_error "Unable to install Dovecot, exit status = " $? } diff --git a/src/modules/stack/install/mail/ee_mod_install_amavis.sh b/src/modules/stack/install/mail/ee_mod_install_mailscan.sh similarity index 56% rename from src/modules/stack/install/mail/ee_mod_install_amavis.sh rename to src/modules/stack/install/mail/ee_mod_install_mailscan.sh index 6f72603a..d30be7ef 100644 --- a/src/modules/stack/install/mail/ee_mod_install_amavis.sh +++ b/src/modules/stack/install/mail/ee_mod_install_mailscan.sh @@ -1,9 +1,9 @@ # Install Amavis package -function ee_mod_install_amavis() +function ee_mod_install_mailscan() { # Install Amavis - ee_lib_echo "Installing Amavis and ClamAV, please wait..." + ee_lib_echo "Installing Amavis, SpamAssassin and ClamAV, please wait..." $EE_APT_GET install amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl libmail-dkim-perl p7zip rpm unrar-free libsnmp-perl \ - || ee_lib_error "Unable to install Amavis and ClamAV, exit status = " $? + || ee_lib_error "Unable to install Amavis, SpamAssassin and ClamAV, exit status = " $? } diff --git a/src/modules/stack/install/mail/ee_mod_install_sieve.sh b/src/modules/stack/install/mail/ee_mod_install_sieve.sh index bf20b52e..e72503cb 100644 --- a/src/modules/stack/install/mail/ee_mod_install_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_install_sieve.sh @@ -4,6 +4,6 @@ function ee_mod_install_sieve() { # Install Sieve ee_lib_echo "Installing Sieve, please wait..." - $EE_APT_GET install amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl libmail-dkim-perl p7zip rpm unrar-free libsnmp-perl \ + $EE_APT_GET install apt-get install dovecot-sieve dovecot-managesieved \ || ee_lib_error "Unable to install Sieve, exit status = " $? } diff --git a/src/modules/stack/install/mail/ee_mod_setup_amavis.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh similarity index 97% rename from src/modules/stack/install/mail/ee_mod_setup_amavis.sh rename to src/modules/stack/install/mail/ee_mod_setup_mailscan.sh index ce0e3177..811242e5 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_amavis.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh @@ -1,6 +1,6 @@ # Setup Amavis -function ee_mod_setup_amavis() +function ee_mod_setup_mailscan() { # Confiure Amavis diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index c49b05f2..59dac0d6 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -9,6 +9,13 @@ function ee_mod_setup_postfix() fi EE_HOSTNAME=$(hostname -f) + + #We previously not used this package. So, if some one don't have Postfix-MySQL installed, + #Postfix will not work + ee_lib_echo "Installing Postfix-MySQL, please wait..." + $EE_APT_GET install postfix-mysql \ + || ee_lib_error "Unable to install Postfix-MySQL, exit status = " $? + ee_lib_echo "Setting up Postfix, please wait..." #Configure Master.cf sed -i 's/#submission/submission/' /etc/postfix/master.cf && From 22b1b368ab6fad7b3387b5a2d6f2fa2cda986fa7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 25 Aug 2014 17:35:16 +0530 Subject: [PATCH 033/829] Fixed Wrong package names --- src/modules/stack/install/mail/ee_mod_install_sieve.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_sieve.sh b/src/modules/stack/install/mail/ee_mod_install_sieve.sh index e72503cb..5deecdbf 100644 --- a/src/modules/stack/install/mail/ee_mod_install_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_install_sieve.sh @@ -4,6 +4,6 @@ function ee_mod_install_sieve() { # Install Sieve ee_lib_echo "Installing Sieve, please wait..." - $EE_APT_GET install apt-get install dovecot-sieve dovecot-managesieved \ + $EE_APT_GET install dovecot-sieve dovecot-managesieved \ || ee_lib_error "Unable to install Sieve, exit status = " $? } From a590c12a7a6959cbad11d6c46cdb60f70ece1fb7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 25 Aug 2014 17:44:20 +0530 Subject: [PATCH 034/829] Addded missing ViMbAdmin Packages --- src/vendor/ee_ven_install_vimbadmin.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vendor/ee_ven_install_vimbadmin.sh b/src/vendor/ee_ven_install_vimbadmin.sh index 1468782c..8b550622 100644 --- a/src/vendor/ee_ven_install_vimbadmin.sh +++ b/src/vendor/ee_ven_install_vimbadmin.sh @@ -2,6 +2,12 @@ function ee_ven_install_vimbadmin() { + + # Install needed PHP5 libraries for ViMbAdmin + ee_lib_echo "Installing PHP5 libraries for ViMbAdmin, please wait..." + $EE_APT_GET install php5-cgi php5-mcrypt php5-memcache php5-json php5-mysqlnd php-gettext \ + || ee_lib_error "Unable to install php-pear, exit status = " $? + # Install ViMbAdmin ee_lib_echo "Downloading ViMbAdmin, please wait..." wget -cqO /var/www/22222/htdocs/vimbadmin.tar.gz https://github.com/opensolutions/ViMbAdmin/archive/3.0.10.tar.gz \ From b0628ef3642a881d5e3780127591aa9c0c6c5860 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 26 Aug 2014 14:26:51 +0530 Subject: [PATCH 035/829] Created ViMbAdmin Nginx rules --- src/vendor/ee_ven_setup_vimbadmin.sh | 8 -------- templates/mail/vma | 23 ----------------------- templates/nginx/22222 | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 31 deletions(-) delete mode 100644 templates/mail/vma diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index d5df5091..eb419282 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -53,12 +53,4 @@ function ee_ven_setup_vimbadmin() /var/www/22222/htdocs/vimbadmin/bin/doctrine2-cli.php orm:schema-tool:create \ || ee_lib_error "Unable to setup ViMbAdmin default database , exit status = " $? - # Setup Nginx configuration to access ViMbAdmin - cp -v /usr/share/easyengine/mail/vma /etc/nginx/sites-available/ &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to copy Nginx configuration for ViMbAdmin, exit status = " $? - - ln -sf /etc/nginx/sites-available/vma /etc/nginx/sites-enabled/ \ - || ee_lib_error "Unable to create softlink for ViMbAdmin, exit status = " $? - - } diff --git a/templates/mail/vma b/templates/mail/vma deleted file mode 100644 index fc15e31b..00000000 --- a/templates/mail/vma +++ /dev/null @@ -1,23 +0,0 @@ -# Nginx Configuration to access webmail -# Don't modify this file,After update EasyEngine replaces it with new version - -server { - server_name vma.*; - - access_log /var/log/nginx/vma.access.log; - error_log /var/log/nginx/vma.error.log; - - root /var/www/22222/htdocs/vimbadmin; - index index.php; - - location / { - try_files $uri $uri/ /index.php?$args; - } - - location ~ \.php$ { - try_files $uri =404; - include fastcgi_params; - fastcgi_pass 127.0.0.1:9000; - } - -} diff --git a/templates/nginx/22222 b/templates/nginx/22222 index 1ea0e1bd..44e50952 100644 --- a/templates/nginx/22222 +++ b/templates/nginx/22222 @@ -39,4 +39,23 @@ server { fastcgi_pass php; } + # ViMbAdmin Rules + location = /vimbadmin/ { + return 301 $scheme://$host:22222/vimbadmin/public/; + } + + location ~* \.(js|css|jpg|gif|png)$ { + root /var/www/22222/htdocs/; + } + + location ~* /vimbadmin/public/(.*)/(.*) { + root /var/www/22222/htdocs/vimbadmin/public; + try_files $uri $uri/ /vimbadmin/public/index.php?$args; + } + + location ~* /vimbadmin/public/(.*) { + root /var/www/22222/htdocs/vimbadmin/public; + try_files $uri $uri/ /vimbadmin/public/index.php?$args; + } + } From b28f3eec20fd5f4404d48e14cde135948134de63 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 26 Aug 2014 16:32:08 +0530 Subject: [PATCH 036/829] Fixed Amavis MySQL issue --- bin/easyengine | 16 ++++++++-------- .../stack/install/mail/ee_mod_setup_sieve.sh | 7 ++++++- src/vendor/ee_ven_setup_vimbadmin.sh | 5 +++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 505db325..354cba73 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -167,21 +167,21 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Configure Dovecot ee_mod_setup_dovecot - # Setup ViMbAdmin - ee_ven_setup_vimbadmin - - # Setup Roundcube - ee_ven_setup_roundcube - # Setup Amavis ee_mod_setup_mailscan # Setup Sieve ee_mod_setup_sieve + + # Setup ViMbAdmin + ee_ven_setup_vimbadmin + + # Setup Roundcube + ee_ven_setup_roundcube - ee_lib_service nginx postfix dovecot restart + ee_lib_service nginx postfix dovecot amavis restart - ee_lib_git /etc/nginx/ /etc/dovecot /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git" + ee_lib_git /etc/nginx/ /etc/dovecot /etc/php5/ /etc/mysql/ /etc/postfix /etc/amavis "Initialize Git" ee_lib_echo "Successfully installed mail server" diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index 6f47f2dd..35d2b561 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -2,10 +2,15 @@ function ee_mod_setup_sieve() { + EE_EMAIL=$($EE_CONFIG_GET wordpress.email) + if [[ $EE_EMAIL = "" ]]; then + EE_EMAIL=$(git config user.email) + fi + ee_lib_echo "Setting up Sieve, please wait..." # Enable sieve plugin support for dovecot-lmtp - sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address = admin@example.com\n mail_plugins = \$mail_plugins sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ + sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address =$EE_EMAIL \n mail_plugins = \$mail_plugins sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ || ee_lib_error "Unable to add sieve plugin support for dovecot-lmtp, exit status = " $? # Sieve dovecot-pluign configuration diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index eb419282..c6e72744 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -46,6 +46,11 @@ function ee_ven_setup_vimbadmin() sed -i "s/hosts=localhost/hosts=$EE_MYSQL_HOST/" /etc/dovecot/dovecot-sql.conf.ext \ || ee_lib_error "Unable to setup ViMbAdmin database details in dovecot-sql.conf.ext file, exit status = " $? + # Changing hosts and password of ViMbAdmin database in Amavis configuration + sed -s "s/127.0.0.1/$EE_MYSQL_HOST/" /etc/amavis/conf.d/50-user && + sed -s "s/password/$ee_random/" /etc/amavis/conf.d/50-user \ + || ee_lib_error "Unable to setup ViMbAdmin database details in 50-user file, exit status = " $? + # Copying HTACCESS cp -av /var/www/22222/htdocs/vimbadmin/public/.htaccess.dist /var/www/22222/htdocs/vimbadmin/public/.htaccess &>> $EE_COMMAND_LOG From 81379517cbca9e9894139224f0a356a7c9e69910 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 26 Aug 2014 17:22:09 +0530 Subject: [PATCH 037/829] Fixed Sieve configuration issue --- bin/easyengine | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 354cba73..78e9271f 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -170,14 +170,14 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Setup Amavis ee_mod_setup_mailscan - # Setup Sieve - ee_mod_setup_sieve - # Setup ViMbAdmin ee_ven_setup_vimbadmin # Setup Roundcube ee_ven_setup_roundcube + + # Setup Sieve + ee_mod_setup_sieve ee_lib_service nginx postfix dovecot amavis restart From 07176bb90a8b47b2211646b3f343f4199f38febc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 26 Aug 2014 18:11:49 +0530 Subject: [PATCH 038/829] Fixed Amavis setup issue --- src/vendor/ee_ven_setup_vimbadmin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index c6e72744..e432897c 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -47,8 +47,8 @@ function ee_ven_setup_vimbadmin() || ee_lib_error "Unable to setup ViMbAdmin database details in dovecot-sql.conf.ext file, exit status = " $? # Changing hosts and password of ViMbAdmin database in Amavis configuration - sed -s "s/127.0.0.1/$EE_MYSQL_HOST/" /etc/amavis/conf.d/50-user && - sed -s "s/password/$ee_random/" /etc/amavis/conf.d/50-user \ + sed -i "s/127.0.0.1/$EE_MYSQL_HOST/" /etc/amavis/conf.d/50-user && + sed -i "s/password/$ee_random/" /etc/amavis/conf.d/50-user \ || ee_lib_error "Unable to setup ViMbAdmin database details in 50-user file, exit status = " $? # Copying HTACCESS From 3eeb0dcafe0c000d1449cf195610c6461ca6386a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 26 Aug 2014 18:40:29 +0530 Subject: [PATCH 039/829] Fixed Roundcube path issue in Nginx Conf file --- templates/mail/webmail | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mail/webmail b/templates/mail/webmail index fff3a464..b1b2b3a1 100644 --- a/templates/mail/webmail +++ b/templates/mail/webmail @@ -7,7 +7,7 @@ server { access_log /var/log/nginx/webmail.access.log; error_log /var/log/nginx/webmail.error.log; - root /var/www/roundcube/htdocs; + root /var/www/roundcubemail/htdocs/; index index.php; location / { From b6231d187cba9c0f91d60f603f5d0c6f68538113 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 26 Aug 2014 19:35:34 +0530 Subject: [PATCH 040/829] Fixed Postfix not connecting to local MySQL --- src/vendor/ee_ven_setup_vimbadmin.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index e432897c..c60161a5 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -2,6 +2,12 @@ function ee_ven_setup_vimbadmin() { + if [ $EE_MYSQL_HOST = "localhost" ];then + ee_vimbadmin_host="127.0.0.1" + else + ee_vimbadmin_host=$EE_MYSQL_HOST + fi + ee_lib_echo "configuring ViMbAdmin, please wait..." # Random characters @@ -25,29 +31,29 @@ function ee_ven_setup_vimbadmin() sed -i "s'/srv/vmail/%d/%u'/var/vmail/'" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && sed -i "s/pdo_mysql/mysqli/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && sed -i "s/'xxx'/'$ee_random'/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && - sed -i "s/resources.doctrine2.connection.options.host = 'localhost'/resources.doctrine2.connection.options.host = '$EE_MYSQL_HOST'/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && + sed -i "s/resources.doctrine2.connection.options.host = 'localhost'/resources.doctrine2.connection.options.host = '$ee_vimbadmin_host'/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && sed -i "s/defaults.mailbox.password_scheme = \"md5.salted\"/defaults.mailbox.password_scheme = \"md5\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ || ee_lib_error "Unable to setup ViMbAdmin configuration file, exit status = " $? # Changing hosts and password of ViMbAdmin database in postfix configuration sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_alias_maps.cf && - sed -i "s/hosts = 127.0.0.1/hosts = $EE_MYSQL_HOST/" /etc/postfix/mysql/virtual_alias_maps.cf \ + sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_alias_maps.cf \ || ee_lib_error "Unable to setup ViMbAdmin database details in virtual_alias_maps.cf file, exit status = " $? sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_domains_maps.cf && - sed -i "s/hosts = 127.0.0.1/hosts = $EE_MYSQL_HOST/" /etc/postfix/mysql/virtual_domains_maps.cf \ + sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_domains_maps.cf \ || ee_lib_error "Unable to setup ViMbAdmin database details in virtual_domains_maps.cf file, exit status = " $? sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_mailbox_maps.cf && - sed -i "s/hosts = 127.0.0.1/hosts = $EE_MYSQL_HOST/" /etc/postfix/mysql/virtual_mailbox_maps.cf \ + sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_mailbox_maps.cf \ || ee_lib_error "Unable to setup ViMbAdmin database details in virtual_mailbox_maps.cf file, exit status = " $? sed -i "s/password=password/password=$ee_random/" /etc/dovecot/dovecot-sql.conf.ext && - sed -i "s/hosts=localhost/hosts=$EE_MYSQL_HOST/" /etc/dovecot/dovecot-sql.conf.ext \ + sed -i "s/hosts=localhost/hosts=$ee_vimbadmin_host/" /etc/dovecot/dovecot-sql.conf.ext \ || ee_lib_error "Unable to setup ViMbAdmin database details in dovecot-sql.conf.ext file, exit status = " $? # Changing hosts and password of ViMbAdmin database in Amavis configuration - sed -i "s/127.0.0.1/$EE_MYSQL_HOST/" /etc/amavis/conf.d/50-user && + sed -i "s/127.0.0.1/$ee_vimbadmin_host/" /etc/amavis/conf.d/50-user && sed -i "s/password/$ee_random/" /etc/amavis/conf.d/50-user \ || ee_lib_error "Unable to setup ViMbAdmin database details in 50-user file, exit status = " $? From efe9cdd0f9fbf87d14c4b03fe930200e81646663 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 13:22:08 +0530 Subject: [PATCH 041/829] Added mail remove and purge commands --- bin/easyengine | 30 +++++++++++++++++-- .../remove/mail/ee_mod_remove_dovecot.sh | 9 ++++++ .../remove/mail/ee_mod_remove_mailscan.sh | 9 ++++++ .../stack/remove/mail/ee_mode_remove_sieve.sh | 10 +++++++ src/vendor/ee_ven_install_vimbadmin.sh | 3 +- src/vendor/ee_ven_remove_roundcube.sh | 15 +++++++++- src/vendor/ee_ven_remove_vimbadmin.sh | 8 +++++ 7 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh create mode 100644 src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh create mode 100644 src/modules/stack/remove/mail/ee_mode_remove_sieve.sh diff --git a/bin/easyengine b/bin/easyengine index 78e9271f..f350492d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -210,7 +210,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then elif [ "$EE_SECOND" = "purge" ];then ee_lib_echo "$EE_THIRD successfully purged" fi - elif [ "$EE_THIRD" = "" ]; then + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "--web" ] || [ "$EE_THIRD" = "--all" ]; then # Remove/Purge NGINX/PHP/MySQL/Postfix package ee_mod_remove_nginx ee_mod_remove_php @@ -228,11 +228,35 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display success message if [ "$EE_SECOND" = "remove" ];then - ee_lib_echo "Successfully removed all packages" + ee_lib_echo "Successfully removed web packages" + elif [ "$EE_SECOND" = "purge" ];then + ee_lib_echo "Successfully purged web packages" + fi + fi + if [ "$EE_THIRD" = "--all" ] || [ "$EE_THIRD" = "--mail"];then + # Remove Dovecot + ee_mod_remove_dovecot + + # Remove ViMbAdmin + ee_ven_remove_vimbadmin + + # Remove Roundcube + ee_ven_remove_roundcube + + # Remove Amavis + ee_mod_remove_mailscan + + # Remove Sieve + ee_mod_remove_sieve + + # Display success message + if [ "$EE_SECOND" = "remove" ];then + ee_lib_echo "Successfully removed mail server packages" elif [ "$EE_SECOND" = "purge" ];then - ee_lib_echo "Successfully purged all packages" + ee_lib_echo "Successfully purged mail server packages" fi fi + elif [ "$EE_SECOND" = "status" ]; then ee_mod_stack_status elif [ "$EE_SECOND" = "start" ] || [ "$EE_SECOND" = "stop" ] || [ "$EE_SECOND" = "reload" ] || [ "$EE_SECOND" = "restart" ]; then diff --git a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh new file mode 100644 index 00000000..8119d457 --- /dev/null +++ b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh @@ -0,0 +1,9 @@ +# Remove Dovecot package + +function ee_mod_remove_dovecot() +{ + ee_lib_echo "$EE_SECOND Dovecot package, please wait..." + $EE_APT_GET $EE_SECOND dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql \ + || ee_lib_error "Unable to $EE_SECOND Dovecot, exit status = " $? + +} diff --git a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh new file mode 100644 index 00000000..8ebd8808 --- /dev/null +++ b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh @@ -0,0 +1,9 @@ +# Remove MailScan package + +function ee_mod_remove_mysql() +{ + ee_lib_echo "$EE_SECOND Amavis, SpamAssassin and ClamAV package, please wait..." + $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl libmail-dkim-perl p7zip rpm unrar-free libsnmp-perl \ + || ee_lib_error "Unable to $EE_SECOND Amavis, SpamAssassin and ClamAV,, exit status = " $? + +} diff --git a/src/modules/stack/remove/mail/ee_mode_remove_sieve.sh b/src/modules/stack/remove/mail/ee_mode_remove_sieve.sh new file mode 100644 index 00000000..0c553907 --- /dev/null +++ b/src/modules/stack/remove/mail/ee_mode_remove_sieve.sh @@ -0,0 +1,10 @@ +# Remove Sieve package + +function ee_mod_remove_sieve() +{ + ee_lib_echo "$EE_SECOND Sieve package, please wait..." + $EE_APT_GET $EE_SECOND dovecot-sieve dovecot-managesieved \ + || ee_lib_error "Unable to $EE_SECOND Sieve, exit status = " $? + + +} diff --git a/src/vendor/ee_ven_install_vimbadmin.sh b/src/vendor/ee_ven_install_vimbadmin.sh index 8b550622..ef96eaf1 100644 --- a/src/vendor/ee_ven_install_vimbadmin.sh +++ b/src/vendor/ee_ven_install_vimbadmin.sh @@ -5,7 +5,8 @@ function ee_ven_install_vimbadmin() # Install needed PHP5 libraries for ViMbAdmin ee_lib_echo "Installing PHP5 libraries for ViMbAdmin, please wait..." - $EE_APT_GET install php5-cgi php5-mcrypt php5-memcache php5-json php5-mysqlnd php-gettext \ + # ee stack install php installed php5-mcrypt, php5-memcache, php5-mysqlnd + $EE_APT_GET install php5-cgi php5-json php-gettext \ || ee_lib_error "Unable to install php-pear, exit status = " $? # Install ViMbAdmin diff --git a/src/vendor/ee_ven_remove_roundcube.sh b/src/vendor/ee_ven_remove_roundcube.sh index fe9e4cda..31297b3a 100644 --- a/src/vendor/ee_ven_remove_roundcube.sh +++ b/src/vendor/ee_ven_remove_roundcube.sh @@ -2,7 +2,20 @@ function ee_ven_remove_roundcube() { + ee_lib_echo "Removing Roundcube dependencies, please wait..." + # Remove packages installed using Pear + pear uninstall Mail_Mime Net_SMTP Mail_mimeDecode Net_IDNA2-beta Auth_SASL Net_Sieve Crypt_GPG &>> $EE_COMMAND_LOG + + # Remove Php-Pear + $EE_APT_GET $EE_SECOND php-pear \ + ||ee_lib_error "Unable to $EE_SECOND Roundcube PHP dependencies, exit status = " $? + + # Remove Roundcube ee_lib_echo "Removing Roundcube, please wait..." - rm -rf /var/www/roundcubemail \ + + mysql -e "drop database \`roundcubemail\`" &>> $EE_COMMAND_LOG + mysql -e "drop user roundcube@'$EE_MYSQL_GRANT_HOST'" &>> $EE_COMMAND_LOG + + rm -rf /var/www/roundcubemail /etc/nginx/sites-available/webmail /etc/nginx/sites-enabled/webmail \ || ee_lib_error "Unable to remove Roundcube, exit status = " $? } diff --git a/src/vendor/ee_ven_remove_vimbadmin.sh b/src/vendor/ee_ven_remove_vimbadmin.sh index f7090e86..962f0784 100644 --- a/src/vendor/ee_ven_remove_vimbadmin.sh +++ b/src/vendor/ee_ven_remove_vimbadmin.sh @@ -3,6 +3,14 @@ function ee_ven_remove_vimbadmin() { ee_lib_echo "Removing ViMbAdmin, please wait..." + + mysql -e "drop database \`vimbadmin\`" &>> $EE_COMMAND_LOG + mysql -e "drop user vimbadmin@'$EE_MYSQL_GRANT_HOST'" &>> $EE_COMMAND_LOG + + ee_lib_echo "Removing ViMbAdmin PHP dependencies, please wait..." + $EE_APT_GET $EE_SECOND php5-cgi php5-json php-gettext \ + ||ee_lib_error "Unable to $EE_SECOND ViMbAdmin PHP dependencies, exit status = " $? + rm -rf /var/www/22222/htdocs/vimbadmin \ || ee_lib_error "Unable to remove ViMbAdmin, exit status = " $? } From 34221bcc954b3dfcd195b5be18e3380ef2f77b65 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 13:25:08 +0530 Subject: [PATCH 042/829] Fixed Missing space --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index f350492d..8ac20cac 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -233,7 +233,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo "Successfully purged web packages" fi fi - if [ "$EE_THIRD" = "--all" ] || [ "$EE_THIRD" = "--mail"];then + if [ "$EE_THIRD" = "--all" ] || [ "$EE_THIRD" = "--mail" ];then # Remove Dovecot ee_mod_remove_dovecot From 893d4185615be7a93fc4804f49310e42d2726f78 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 13:28:48 +0530 Subject: [PATCH 043/829] Fixed Typo --- .../stack/remove/mail/ee_mod_remove_mailscan.sh | 2 +- src/modules/stack/remove/mail/ee_mode_remove_sieve.sh | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 src/modules/stack/remove/mail/ee_mode_remove_sieve.sh diff --git a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh index 8ebd8808..be4b8dc1 100644 --- a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh +++ b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh @@ -1,6 +1,6 @@ # Remove MailScan package -function ee_mod_remove_mysql() +function ee_mod_remove_mailscan() { ee_lib_echo "$EE_SECOND Amavis, SpamAssassin and ClamAV package, please wait..." $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl libmail-dkim-perl p7zip rpm unrar-free libsnmp-perl \ diff --git a/src/modules/stack/remove/mail/ee_mode_remove_sieve.sh b/src/modules/stack/remove/mail/ee_mode_remove_sieve.sh deleted file mode 100644 index 0c553907..00000000 --- a/src/modules/stack/remove/mail/ee_mode_remove_sieve.sh +++ /dev/null @@ -1,10 +0,0 @@ -# Remove Sieve package - -function ee_mod_remove_sieve() -{ - ee_lib_echo "$EE_SECOND Sieve package, please wait..." - $EE_APT_GET $EE_SECOND dovecot-sieve dovecot-managesieved \ - || ee_lib_error "Unable to $EE_SECOND Sieve, exit status = " $? - - -} From 9a72563e2a39deee010172368308958ab4b5ce58 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 13:30:09 +0530 Subject: [PATCH 044/829] Fixed Typo --- src/modules/stack/remove/mail/ee_mod_remove_sieve.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/modules/stack/remove/mail/ee_mod_remove_sieve.sh diff --git a/src/modules/stack/remove/mail/ee_mod_remove_sieve.sh b/src/modules/stack/remove/mail/ee_mod_remove_sieve.sh new file mode 100644 index 00000000..0c553907 --- /dev/null +++ b/src/modules/stack/remove/mail/ee_mod_remove_sieve.sh @@ -0,0 +1,10 @@ +# Remove Sieve package + +function ee_mod_remove_sieve() +{ + ee_lib_echo "$EE_SECOND Sieve package, please wait..." + $EE_APT_GET $EE_SECOND dovecot-sieve dovecot-managesieved \ + || ee_lib_error "Unable to $EE_SECOND Sieve, exit status = " $? + + +} From e755f3b2955050b3f982a47216533e1a70e470c8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 13:40:31 +0530 Subject: [PATCH 045/829] Removed Missing packages --- src/modules/stack/install/mail/ee_mod_install_mailscan.sh | 2 +- src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_mailscan.sh b/src/modules/stack/install/mail/ee_mod_install_mailscan.sh index d30be7ef..18559f74 100644 --- a/src/modules/stack/install/mail/ee_mod_install_mailscan.sh +++ b/src/modules/stack/install/mail/ee_mod_install_mailscan.sh @@ -4,6 +4,6 @@ function ee_mod_install_mailscan() { # Install Amavis ee_lib_echo "Installing Amavis, SpamAssassin and ClamAV, please wait..." - $EE_APT_GET install amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl libmail-dkim-perl p7zip rpm unrar-free libsnmp-perl \ + $EE_APT_GET install amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract p7zip rpm unrar-free \ || ee_lib_error "Unable to install Amavis, SpamAssassin and ClamAV, exit status = " $? } diff --git a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh index be4b8dc1..15364ea9 100644 --- a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh +++ b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh @@ -3,7 +3,7 @@ function ee_mod_remove_mailscan() { ee_lib_echo "$EE_SECOND Amavis, SpamAssassin and ClamAV package, please wait..." - $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract apt-listchanges libauthen-sasl-perl libdbi-perl libmail-dkim-perl p7zip rpm unrar-free libsnmp-perl \ + $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract p7zip rpm unrar-free \ || ee_lib_error "Unable to $EE_SECOND Amavis, SpamAssassin and ClamAV,, exit status = " $? } From df6a62ed62ae5c068ecff6bb4d50c055da1af24f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 14:42:35 +0530 Subject: [PATCH 046/829] Removed unwanted packages --- src/vendor/ee_ven_remove_vimbadmin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vendor/ee_ven_remove_vimbadmin.sh b/src/vendor/ee_ven_remove_vimbadmin.sh index 962f0784..3966ae19 100644 --- a/src/vendor/ee_ven_remove_vimbadmin.sh +++ b/src/vendor/ee_ven_remove_vimbadmin.sh @@ -8,7 +8,7 @@ function ee_ven_remove_vimbadmin() mysql -e "drop user vimbadmin@'$EE_MYSQL_GRANT_HOST'" &>> $EE_COMMAND_LOG ee_lib_echo "Removing ViMbAdmin PHP dependencies, please wait..." - $EE_APT_GET $EE_SECOND php5-cgi php5-json php-gettext \ + $EE_APT_GET $EE_SECOND php5-cgi php-gettext \ ||ee_lib_error "Unable to $EE_SECOND ViMbAdmin PHP dependencies, exit status = " $? rm -rf /var/www/22222/htdocs/vimbadmin \ From e52ceb3b5f95ec05212cb35e90fab1de3b546f9f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 14:53:07 +0530 Subject: [PATCH 047/829] Removed unwanted packages --- src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh | 2 +- src/vendor/ee_ven_remove_roundcube.sh | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh index 15364ea9..d893959f 100644 --- a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh +++ b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh @@ -3,7 +3,7 @@ function ee_mod_remove_mailscan() { ee_lib_echo "$EE_SECOND Amavis, SpamAssassin and ClamAV package, please wait..." - $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract p7zip rpm unrar-free \ + $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch lzop cabextract p7zip rpm unrar-free \ || ee_lib_error "Unable to $EE_SECOND Amavis, SpamAssassin and ClamAV,, exit status = " $? } diff --git a/src/vendor/ee_ven_remove_roundcube.sh b/src/vendor/ee_ven_remove_roundcube.sh index 31297b3a..57546631 100644 --- a/src/vendor/ee_ven_remove_roundcube.sh +++ b/src/vendor/ee_ven_remove_roundcube.sh @@ -6,10 +6,6 @@ function ee_ven_remove_roundcube() # Remove packages installed using Pear pear uninstall Mail_Mime Net_SMTP Mail_mimeDecode Net_IDNA2-beta Auth_SASL Net_Sieve Crypt_GPG &>> $EE_COMMAND_LOG - # Remove Php-Pear - $EE_APT_GET $EE_SECOND php-pear \ - ||ee_lib_error "Unable to $EE_SECOND Roundcube PHP dependencies, exit status = " $? - # Remove Roundcube ee_lib_echo "Removing Roundcube, please wait..." From 74272d710b2601ad67035ece1527b0811055177b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 15:02:01 +0530 Subject: [PATCH 048/829] Added apt-get autoremove --- bin/easyengine | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 8ac20cac..064760ac 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -249,6 +249,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Remove Sieve ee_mod_remove_sieve + # Execute: apt-get autoremove + ee_lib_autoremove + # Display success message if [ "$EE_SECOND" = "remove" ];then ee_lib_echo "Successfully removed mail server packages" From 536d9c963962f035c0da5424d46f895723855126 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 15:17:34 +0530 Subject: [PATCH 049/829] Added autocompletion for mail --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 72d723b6..9f2b57da 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -25,7 +25,7 @@ function EE_AUTO() ;; install|remove|purge) - COMPREPLY=( $( compgen -W '$( cd /usr/local/lib/easyengine/modules/stack/install; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null)' -- $CURRENT ) ) + COMPREPLY=( $( compgen -W '$(echo --mail --all --web; cd /usr/local/lib/easyengine/modules/stack/install; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) return 0 ;; From 63746ee33493e639567f7e1567d66810f877252e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 15:21:04 +0530 Subject: [PATCH 050/829] Added user vmail deletion --- src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh index 8119d457..fb733dad 100644 --- a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh +++ b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh @@ -6,4 +6,5 @@ function ee_mod_remove_dovecot() $EE_APT_GET $EE_SECOND dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql \ || ee_lib_error "Unable to $EE_SECOND Dovecot, exit status = " $? + userdel -rf vmail || ee_lib_error "Unable to Remove user vmail, exit status = " $? } From fe5cb1bd439cbbfcc2cb76140ee124aa1c2c9fd0 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 15:33:55 +0530 Subject: [PATCH 051/829] Fixed autocompletion --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 9f2b57da..68e7278e 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -25,7 +25,7 @@ function EE_AUTO() ;; install|remove|purge) - COMPREPLY=( $( compgen -W '$(echo --mail --all --web; cd /usr/local/lib/easyengine/modules/stack/install; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) + COMPREPLY=( $( compgen -W '$(echo --mail --all --web; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) return 0 ;; From d5a1f2c00a41d6ebee21a6c3aa1bc64616409ad1 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 27 Aug 2014 17:23:25 +0530 Subject: [PATCH 052/829] Fixed Spam mail filetring --- src/modules/stack/install/mail/ee_mod_setup_dovecot.sh | 7 ++++++- .../stack/install/mail/ee_mod_setup_mailscan.sh | 4 ++++ templates/mail/autocreate | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 templates/mail/autocreate diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index 5c3d1dd4..b4a7a3ad 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -59,6 +59,11 @@ function ee_mod_setup_dovecot() || ee_lib_error "Unable to setup Dovecot SSL certificate path, exit status = " $? # Setting Dovecot init.d script - cp -v /usr/share/easyengine/mail/dovecot /etc/init.d/dovecot &>> $EE_COMMAND_LOG \ + cp -v /usr/share/easyengine/mail/dovecot /etc/init.d/dovecot &>> $EE_COMMAND_LOG + + # Add autocreate plugin + sed -i "s'#mail_plugins = \$mail_plugins'mail_plugins = \$mail_plugins autocreate'" /etc/dovecot/conf.d/20-imap.conf \ + || ee_lib_error "Unable to setup Dovecot autocreate plugin, exit status = " $? + cat /usr/share/easyengine/mail/autocreate >> /etc/dovecot/conf.d/20-imap.conf } diff --git a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh index 811242e5..841fb4f5 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh @@ -23,4 +23,8 @@ function ee_mod_setup_mailscan() || ee_lib_error "Unable to setup Amavis, exit status = " $? cat /usr/share/easyengine/mail/amavis-master.cf >> /etc/postfix/master.cf + # Configure ClamAv and Amavis to each other files + adduser clamav amavis &>> $EE_COMMAND_LOG + adduser amavis clamav &>> $EE_COMMAND_LOG + chmod -R 775 /var/lib/amavis/tmp &>> $EE_COMMAND_LOG } diff --git a/templates/mail/autocreate b/templates/mail/autocreate new file mode 100644 index 00000000..66a68eb0 --- /dev/null +++ b/templates/mail/autocreate @@ -0,0 +1,10 @@ +plugin { +autocreate = Trash +autocreate2 = Junk +autocreate3 = Drafts +autocreate4 = Sent +autosubscribe = Trash +autosubscribe2 = Junk +autosubscribe3 = Drafts +autosubscribe4 = Sent +} From 2d479de3012746d22c0261d2278663e5c0acd415 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 28 Aug 2014 19:49:16 +0530 Subject: [PATCH 053/829] Fixed Ubuntu 12.04 file not found error --- .../stack/install/mail/ee_mod_setup_dovecot.sh | 3 +-- templates/mail/auth-sql.conf.ext | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 templates/mail/auth-sql.conf.ext diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index b4a7a3ad..fb75771c 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -34,8 +34,7 @@ function ee_mod_setup_dovecot() cp -v /usr/share/easyengine/mail/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to copy dovecot-sql.conf.ext, exit status = " $? - # Configuring auth-sql.conf.ext - sed -i "s/# driver = prefetch/userdb {\n driver = prefetch\n}/" /etc/dovecot/conf.d/auth-sql.conf.ext \ + cp -v /usr/share/easyengine/mail/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext || ee_lib_error "Unable to setup auth-sql.conf.ext, exit status = " $? diff --git a/templates/mail/auth-sql.conf.ext b/templates/mail/auth-sql.conf.ext new file mode 100644 index 00000000..b302f482 --- /dev/null +++ b/templates/mail/auth-sql.conf.ext @@ -0,0 +1,13 @@ +passdb { +driver = sql +args = /etc/dovecot/dovecot-sql.conf.ext +} + +userdb { +driver = prefetch +} + +userdb { +driver = sql +args = /etc/dovecot/dovecot-sql.conf.ext +} \ No newline at end of file From 045f3fe20ee46f5a8319ce67c125e00236a1ed4e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 11:53:32 +0530 Subject: [PATCH 054/829] Fixed typo --- src/modules/stack/install/mail/ee_mod_setup_dovecot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index fb75771c..fc54803a 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -34,7 +34,7 @@ function ee_mod_setup_dovecot() cp -v /usr/share/easyengine/mail/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to copy dovecot-sql.conf.ext, exit status = " $? - cp -v /usr/share/easyengine/mail/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext + cp -v /usr/share/easyengine/mail/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext \ || ee_lib_error "Unable to setup auth-sql.conf.ext, exit status = " $? From 2b98ebe6df56436eb8d033c947b63232dcc9aa82 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 12:45:21 +0530 Subject: [PATCH 055/829] Fixed printing cp output on Screen --- src/modules/stack/install/mail/ee_mod_setup_dovecot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index fc54803a..623b54b7 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -34,7 +34,7 @@ function ee_mod_setup_dovecot() cp -v /usr/share/easyengine/mail/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to copy dovecot-sql.conf.ext, exit status = " $? - cp -v /usr/share/easyengine/mail/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext \ + cp -v /usr/share/easyengine/mail/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to setup auth-sql.conf.ext, exit status = " $? From aeeb9eb5f44f17cb54f5e54af1341c9545425daf Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 14:00:45 +0530 Subject: [PATCH 056/829] Redirect doctrine message to log --- src/vendor/ee_ven_setup_vimbadmin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index c60161a5..10a97b51 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -61,7 +61,7 @@ function ee_ven_setup_vimbadmin() cp -av /var/www/22222/htdocs/vimbadmin/public/.htaccess.dist /var/www/22222/htdocs/vimbadmin/public/.htaccess &>> $EE_COMMAND_LOG # Setting default database - /var/www/22222/htdocs/vimbadmin/bin/doctrine2-cli.php orm:schema-tool:create \ + /var/www/22222/htdocs/vimbadmin/bin/doctrine2-cli.php orm:schema-tool:create &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to setup ViMbAdmin default database , exit status = " $? } From a74b54ec95763279b057f7b435b8b6ef7423f744 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 14:46:23 +0530 Subject: [PATCH 057/829] Removed Hardcoded ViMbAdmin and Roundcube version --- src/lib/ee_lib_variables.sh | 6 ++++++ src/vendor/ee_ven_install_roundcube.sh | 2 +- src/vendor/ee_ven_install_vimbadmin.sh | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index cb2ee37a..e24ddc87 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -9,6 +9,12 @@ readonly EE_WP_CLI_VERSION='0.16.0' # Adminer version readonly EE_ADMINER_VERSION='4.1.0' +# Roundcube Version +readonly EE_ROUNDCUBE_VERSION='1.0.2' + +# ViMbAdmin Version +readonly EE_VIMBADMIN_VERSION='3.0.10' + EE_COMMAND_LOG=/var/log/easyengine/ee.log readonly EE_LOG_DIR=/var/log/easyengine readonly EE_ERROR_LOG=/var/log/easyengine/error.log diff --git a/src/vendor/ee_ven_install_roundcube.sh b/src/vendor/ee_ven_install_roundcube.sh index 1bafe87e..9424545b 100644 --- a/src/vendor/ee_ven_install_roundcube.sh +++ b/src/vendor/ee_ven_install_roundcube.sh @@ -16,7 +16,7 @@ function ee_ven_install_roundcube() # Install Roundcube ee_lib_echo "Downloading Roundcube, please wait..." - wget -cqO /var/www/roundcube.tar.gz https://github.com/roundcube/roundcubemail/releases/download/1.0.2/roundcubemail-1.0.2.tar.gz \ + wget -cqO /var/www/roundcube.tar.gz https://github.com/roundcube/roundcubemail/releases/download/${EE_ROUNDCUBE_VERSION}/roundcubemail-${EE_ROUNDCUBE_VERSION}.tar.gz \ || ee_lib_error "Unable to download Roundcube, exit status = " $? ee_lib_echo "Installing Roundcube, please wait..." diff --git a/src/vendor/ee_ven_install_vimbadmin.sh b/src/vendor/ee_ven_install_vimbadmin.sh index ef96eaf1..6c0ed857 100644 --- a/src/vendor/ee_ven_install_vimbadmin.sh +++ b/src/vendor/ee_ven_install_vimbadmin.sh @@ -11,7 +11,7 @@ function ee_ven_install_vimbadmin() # Install ViMbAdmin ee_lib_echo "Downloading ViMbAdmin, please wait..." - wget -cqO /var/www/22222/htdocs/vimbadmin.tar.gz https://github.com/opensolutions/ViMbAdmin/archive/3.0.10.tar.gz \ + wget -cqO /var/www/22222/htdocs/vimbadmin.tar.gz https://github.com/opensolutions/ViMbAdmin/archive/${EE_VIMBADMIN_VERSION}.tar.gz \ || ee_lib_error "Unable to download ViMbAdmin, exit status = " $? mkdir -p /var/www/22222/htdocs/vimbadmin From cb23f2714320f52ca99f74e19fbc05eb75150561 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 15:52:51 +0530 Subject: [PATCH 058/829] Updated update script --- bin/update | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bin/update b/bin/update index 6f3f05a0..5783a27f 100644 --- a/bin/update +++ b/bin/update @@ -414,6 +414,28 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then fi fi + if [[ $EE_CURRENT_VERSION < 2.1.0 ]];then + if [ -f /etc/nginx/common/locations.conf ];then + cp -av /usr/share/easyengine/nginx/common/locations.conf /etc/nginx/common/locations.conf &>> $EE_UPDATE_LOG + fi + if [ -f /etc/nginx/sites-available/22222 ];then + cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG + fi + if [ -d /var/www/22222/htdocs/db/anemometer ];then + # Download pt-query-advisor Fixed #189 + wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ + || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? + chmod 0755 /usr/bin/pt-query-advisor + + # Enable pt-query-advisor plugin in Anemometer + sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ + || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $? + fi + + # Update EasyEngine current version + EE_CURRENT_VERSION="2.0.1" + fi + # Restart service ee_lib_service nginx php5-fpm restart From 9ee327ecf3952e2cf4a2e66e7f38505b06febef5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 15:54:13 +0530 Subject: [PATCH 059/829] Updated Travis Test suite --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a2bffd87..88e68603 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,6 +126,8 @@ script: - sudo bash ee debug - sudo bash ee debug --stop +- sudo bash ee stack install --mail + - sudo cat /var/log/easyengine/* From 79e64320764718737bff19c0496c71a432821230 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 16:16:51 +0530 Subject: [PATCH 060/829] Updated Release no --- src/lib/ee_lib_variables.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index e24ddc87..65e84076 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -1,7 +1,7 @@ # Define global variables # EasyEngine version -readonly EE_VERSION='2.0.2' +readonly EE_VERSION='2.1.0' # WP-CLI version readonly EE_WP_CLI_VERSION='0.16.0' From eb17400f8672e91042d22cc105fcdd6999e2c36f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 18:04:31 +0530 Subject: [PATCH 061/829] Fixes #299 --- src/modules/debug/ee_mod_debug_rewrite.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/debug/ee_mod_debug_rewrite.sh b/src/modules/debug/ee_mod_debug_rewrite.sh index 387cc43d..e7560a67 100644 --- a/src/modules/debug/ee_mod_debug_rewrite.sh +++ b/src/modules/debug/ee_mod_debug_rewrite.sh @@ -18,7 +18,9 @@ function ee_mod_debug_rewrite() fi # Debug message - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/nginx/*.error.log" + if [ "$EE_DEBUG_MSG" != "/var/log/nginx/*.error.log" ];then + EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/nginx/*.error.log" + fi else grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG if [ $? -ne 0 ]; then @@ -34,7 +36,9 @@ function ee_mod_debug_rewrite() fi # Debug message - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/$EE_DOMAIN/logs/error.log" + if [ "$EE_DEBUG_MSG" != "/var/www/$EE_DOMAIN/logs/error.log" ];then + EE_DEBUG_MSG="$EE_DEBUG_MSG /var/www/$EE_DOMAIN/logs/error.log" + fi fi elif [ "$EE_DEBUG" = "--stop" ]; then if [ -z $EE_DOMAIN ]; then From 4ba2c91d58c39b59bc4d755853585efdf8466397 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 18:30:05 +0530 Subject: [PATCH 062/829] Otimized Code --- bin/easyengine | 6 +++--- bin/update | 14 ++++++++++---- src/lib/ee_lib_error.sh | 2 +- .../stack/install/mail/ee_mod_install_dovecot.sh | 2 +- .../stack/install/mail/ee_mod_install_sieve.sh | 9 --------- .../stack/remove/mail/ee_mod_remove_dovecot.sh | 2 +- .../stack/remove/mail/ee_mod_remove_sieve.sh | 10 ---------- 7 files changed, 16 insertions(+), 29 deletions(-) delete mode 100644 src/modules/stack/install/mail/ee_mod_install_sieve.sh delete mode 100644 src/modules/stack/remove/mail/ee_mod_remove_sieve.sh diff --git a/bin/easyengine b/bin/easyengine index 064760ac..424f2ce6 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -135,15 +135,15 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Check required Packages are installed or not dpkg --get-selections | grep -v deinstall | grep nginx > /dev/null \ && dpkg --get-selections | grep -v deinstall | grep php5-fpm > /dev/null \ - && dpkg --get-selections | grep -v deinstall | grep mysql > /dev/null \ + && mysqladmin ping &> /dev/null \ && dpkg --get-selections | grep -v deinstall | grep postfix > /dev/null if [ $? -ne 0 ];then - ee_lib_error "Failed to find pre dependencies. Please install Nginx, PHP5, MySQL and Postfix using command ee stack install, exit status " 1 + ee_lib_error "Failed to find pre dependencies.\nPlease install Nginx, PHP5, MySQL and Postfix using command ee stack install, exit status " 1 fi dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null if [ $? -eq 0 ];then - ee_lib_error "Found installed mail server, Please remove it before installation, exit status=" 1 + ee_lib_error "Found installed Dovecot Packages server, exit status=" 1 fi # Install Dovecot diff --git a/bin/update b/bin/update index 5783a27f..c719cdda 100644 --- a/bin/update +++ b/bin/update @@ -415,11 +415,17 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then fi if [[ $EE_CURRENT_VERSION < 2.1.0 ]];then - if [ -f /etc/nginx/common/locations.conf ];then - cp -av /usr/share/easyengine/nginx/common/locations.conf /etc/nginx/common/locations.conf &>> $EE_UPDATE_LOG - fi if [ -f /etc/nginx/sites-available/22222 ];then + ee_port=$(grep listen /etc/nginx/sites-available/22222 | awk '{ print $2 }') cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG + if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then + sed -i "s/listen.*/listen $ee_port default_server ssl spdy;/" /etc/nginx/sites-available/22222 \ + || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? + elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then + # Dotdeb nginx repository doesn't support spdy + sed -i "s/listen.*/listen $ee_port default_server ssl;/" /etc/nginx/sites-available/22222 \ + || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? + fi fi if [ -d /var/www/22222/htdocs/db/anemometer ];then # Download pt-query-advisor Fixed #189 @@ -431,7 +437,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $? fi - + # Update EasyEngine current version EE_CURRENT_VERSION="2.0.1" fi diff --git a/src/lib/ee_lib_error.sh b/src/lib/ee_lib_error.sh index eabfdf04..206a9023 100644 --- a/src/lib/ee_lib_error.sh +++ b/src/lib/ee_lib_error.sh @@ -2,6 +2,6 @@ function ee_lib_error() { - echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" | tee -ai $EE_ERROR_LOG + echo -e "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" | tee -ai $EE_ERROR_LOG exit $2 } diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index ed49ba86..e7ce0ca8 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -6,7 +6,7 @@ function ee_mod_install_dovecot() ee_lib_echo "Installing Dovecot, please wait..." debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" - $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql \ + $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ || ee_lib_error "Unable to install Dovecot, exit status = " $? } diff --git a/src/modules/stack/install/mail/ee_mod_install_sieve.sh b/src/modules/stack/install/mail/ee_mod_install_sieve.sh deleted file mode 100644 index 5deecdbf..00000000 --- a/src/modules/stack/install/mail/ee_mod_install_sieve.sh +++ /dev/null @@ -1,9 +0,0 @@ -# Install Sieve package - -function ee_mod_install_sieve() -{ - # Install Sieve - ee_lib_echo "Installing Sieve, please wait..." - $EE_APT_GET install dovecot-sieve dovecot-managesieved \ - || ee_lib_error "Unable to install Sieve, exit status = " $? -} diff --git a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh index fb733dad..f3fcc9cf 100644 --- a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh +++ b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh @@ -3,7 +3,7 @@ function ee_mod_remove_dovecot() { ee_lib_echo "$EE_SECOND Dovecot package, please wait..." - $EE_APT_GET $EE_SECOND dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql \ + $EE_APT_GET $EE_SECOND dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ || ee_lib_error "Unable to $EE_SECOND Dovecot, exit status = " $? userdel -rf vmail || ee_lib_error "Unable to Remove user vmail, exit status = " $? diff --git a/src/modules/stack/remove/mail/ee_mod_remove_sieve.sh b/src/modules/stack/remove/mail/ee_mod_remove_sieve.sh deleted file mode 100644 index 0c553907..00000000 --- a/src/modules/stack/remove/mail/ee_mod_remove_sieve.sh +++ /dev/null @@ -1,10 +0,0 @@ -# Remove Sieve package - -function ee_mod_remove_sieve() -{ - ee_lib_echo "$EE_SECOND Sieve package, please wait..." - $EE_APT_GET $EE_SECOND dovecot-sieve dovecot-managesieved \ - || ee_lib_error "Unable to $EE_SECOND Sieve, exit status = " $? - - -} From 506c5e3dc7a94d622701b5325c4c6be77a27893d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 18:34:14 +0530 Subject: [PATCH 063/829] Added Missed newline --- templates/mail/amavis-master.cf | 2 +- templates/mail/auth-sql.conf.ext | 2 +- templates/mail/default.sieve | 2 +- templates/mail/dovecot | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/mail/amavis-master.cf b/templates/mail/amavis-master.cf index 1ffae842..cc4b872c 100644 --- a/templates/mail/amavis-master.cf +++ b/templates/mail/amavis-master.cf @@ -21,4 +21,4 @@ smtp-amavis unix - - n - 2 smtp -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks - -o local_header_rewrite_clients= \ No newline at end of file + -o local_header_rewrite_clients= diff --git a/templates/mail/auth-sql.conf.ext b/templates/mail/auth-sql.conf.ext index b302f482..d3f0b7fa 100644 --- a/templates/mail/auth-sql.conf.ext +++ b/templates/mail/auth-sql.conf.ext @@ -10,4 +10,4 @@ driver = prefetch userdb { driver = sql args = /etc/dovecot/dovecot-sql.conf.ext -} \ No newline at end of file +} diff --git a/templates/mail/default.sieve b/templates/mail/default.sieve index 476a52a6..62532322 100644 --- a/templates/mail/default.sieve +++ b/templates/mail/default.sieve @@ -1,4 +1,4 @@ require "fileinto"; if header :contains "X-Spam-Flag" "YES" { fileinto "Junk"; -} \ No newline at end of file +} diff --git a/templates/mail/dovecot b/templates/mail/dovecot index c7b13ace..7d001128 100644 --- a/templates/mail/dovecot +++ b/templates/mail/dovecot @@ -70,4 +70,4 @@ case "$1" in ;; esac -exit 0 \ No newline at end of file +exit 0 From 3fc87e4910cd32f9947cd30293816738dbf5462d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 29 Aug 2014 18:42:57 +0530 Subject: [PATCH 064/829] Optimized Code --- bin/easyengine | 10 ++-------- .../stack/install/mail/ee_mod_setup_mailscan.sh | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 424f2ce6..52af6e39 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -155,12 +155,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Install Roundcube ee_ven_install_roundcube - # Install Amavis + # Install mail scanner packages ee_mod_install_mailscan - # Install Sieve - ee_mod_install_sieve - # Configure PostFix ee_mod_setup_postfix @@ -181,7 +178,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_service nginx postfix dovecot amavis restart - ee_lib_git /etc/nginx/ /etc/dovecot /etc/php5/ /etc/mysql/ /etc/postfix /etc/amavis "Initialize Git" + ee_lib_git /etc/nginx/ /etc/dovecot /etc/postfix /etc/amavis "Initialize Git" ee_lib_echo "Successfully installed mail server" @@ -246,9 +243,6 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Remove Amavis ee_mod_remove_mailscan - # Remove Sieve - ee_mod_remove_sieve - # Execute: apt-get autoremove ee_lib_autoremove diff --git a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh index 841fb4f5..a5d85462 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh @@ -1,4 +1,4 @@ -# Setup Amavis +# Install mail scanner packages function ee_mod_setup_mailscan() { From 067f5ddcf740cb0b80b21b06c0d2d0c8d8b460f4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 12:52:58 +0530 Subject: [PATCH 065/829] Added FQDN check --- bin/install | 19 +++++++++++++++++++ bin/update | 3 +++ src/lib/ee_lib_check_fqdn.sh | 18 ++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 src/lib/ee_lib_check_fqdn.sh diff --git a/bin/install b/bin/install index 980ded4a..a752a326 100644 --- a/bin/install +++ b/bin/install @@ -81,6 +81,23 @@ function ee_lib_package_check() done } +# Check hostname is FQDN or not. If not set it +function ee_lib_check_fqdn() +{ + case $1 in + *.*) + if [ $EE_FQDN != "" ];then + echo $EE_FQDN > /etc/hostname + service hostname restart &>> $EE_INSTALL_LOG + hostname -f &>> $EE_INSTALL_LOG + fi + ;; + *) + read -p "Enter FQDN to set for Hostname: " EE_FQDN + ee_lib_check_fqdn $EE_FQDN + ;; + esac +} # Pre checks to avoid later screw ups # Checking EasyEngine (ee) log directory @@ -184,6 +201,8 @@ fi cp -a /tmp/easyengine/docs/man/ee.8 /usr/share/man/man8/ &>> $EE_INSTALL_LOG \ || ee_lib_error "Unable to copy EasyEngine (ee) man page, exit status = " $? +# Make hostname as FQDN +ee_lib_check_fqdn $(hostname -f) # Git config settings GIT_USER_NAME=$(git config user.name) diff --git a/bin/update b/bin/update index c719cdda..55ec38a0 100644 --- a/bin/update +++ b/bin/update @@ -395,6 +395,9 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then done fi + # Make hostname as FQDN + ee_lib_check_fqdn $(hostname -f) + if [[ $EE_CURRENT_VERSION = 2.0.0 ]]; then dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG if [ $? -eq 0 ]; then diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh new file mode 100644 index 00000000..8639d523 --- /dev/null +++ b/src/lib/ee_lib_check_fqdn.sh @@ -0,0 +1,18 @@ +# Check Server hostname is FQDN or not + +function ee_lib_check_fqdn() +{ + case $1 in + *.*) + if [ $EE_FQDN != "" ];then + echo $EE_FQDN > /etc/hostname + service hostname restart &>> $EE_COMMAND_LOG + hostname -f &>> $EE_COMMAND_LOG + fi + ;; + *) + read -p "Enter FQDN to set for Hostname: " EE_FQDN + ee_lib_check_fqdn $EE_FQDN + ;; + esac +} From 62ca00e4bb667aca76113c782614eb8fb9bc1bde Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 14:51:41 +0530 Subject: [PATCH 066/829] Better Instllation order and Messages --- bin/easyengine | 16 ++++++++-------- .../stack/install/mail/ee_mod_setup_sieve.sh | 4 ++-- src/vendor/ee_ven_install_roundcube.sh | 4 +--- src/vendor/ee_ven_install_vimbadmin.sh | 6 ++---- src/vendor/ee_ven_setup_roundcube.sh | 2 +- src/vendor/ee_ven_setup_vimbadmin.sh | 2 +- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 52af6e39..cfe14e46 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -138,7 +138,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then && mysqladmin ping &> /dev/null \ && dpkg --get-selections | grep -v deinstall | grep postfix > /dev/null if [ $? -ne 0 ];then - ee_lib_error "Failed to find pre dependencies.\nPlease install Nginx, PHP5, MySQL and Postfix using command ee stack install, exit status " 1 + ee_lib_error "Failed to find NGINX PHP MySQL Postfix, exit status=" 1 fi dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null @@ -149,15 +149,15 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Install Dovecot ee_mod_install_dovecot + # Install mail scanner packages + ee_mod_install_mailscan + # Install ViMbAdmin ee_ven_install_vimbadmin # Install Roundcube ee_ven_install_roundcube - # Install mail scanner packages - ee_mod_install_mailscan - # Configure PostFix ee_mod_setup_postfix @@ -173,7 +173,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Setup Roundcube ee_ven_setup_roundcube - # Setup Sieve + # Setup Sieve Rules ee_mod_setup_sieve ee_lib_service nginx postfix dovecot amavis restart @@ -234,15 +234,15 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Remove Dovecot ee_mod_remove_dovecot + # Remove Amavis + ee_mod_remove_mailscan + # Remove ViMbAdmin ee_ven_remove_vimbadmin # Remove Roundcube ee_ven_remove_roundcube - # Remove Amavis - ee_mod_remove_mailscan - # Execute: apt-get autoremove ee_lib_autoremove diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index 35d2b561..40cf3889 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -1,4 +1,4 @@ -# Setup Sieve +# Setup Sieve rules function ee_mod_setup_sieve() { @@ -7,7 +7,7 @@ function ee_mod_setup_sieve() EE_EMAIL=$(git config user.email) fi - ee_lib_echo "Setting up Sieve, please wait..." + ee_lib_echo "Setting up Sieve rules, please wait..." # Enable sieve plugin support for dovecot-lmtp sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address =$EE_EMAIL \n mail_plugins = \$mail_plugins sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ diff --git a/src/vendor/ee_ven_install_roundcube.sh b/src/vendor/ee_ven_install_roundcube.sh index 9424545b..03e65f02 100644 --- a/src/vendor/ee_ven_install_roundcube.sh +++ b/src/vendor/ee_ven_install_roundcube.sh @@ -3,7 +3,7 @@ function ee_ven_install_roundcube() { # Install Roundcube dependencies - ee_lib_echo "Installing Roundcube dependencies, please wait..." + ee_lib_echo "Installing Roundcube, please wait..." $EE_APT_GET install php-pear \ || ee_lib_error "Unable to install php-pear, exit status = " $? pear install Mail_Mime Net_SMTP Mail_mimeDecode Net_IDNA2-beta Auth_SASL Net_Sieve Crypt_GPG &>> $EE_COMMAND_LOG \ @@ -15,11 +15,9 @@ function ee_ven_install_roundcube() ee_lib_symbolic_link /var/log/nginx/roundcubemail.error.log /var/www/roundcubemail/logs/error.log # Install Roundcube - ee_lib_echo "Downloading Roundcube, please wait..." wget -cqO /var/www/roundcube.tar.gz https://github.com/roundcube/roundcubemail/releases/download/${EE_ROUNDCUBE_VERSION}/roundcubemail-${EE_ROUNDCUBE_VERSION}.tar.gz \ || ee_lib_error "Unable to download Roundcube, exit status = " $? - ee_lib_echo "Installing Roundcube, please wait..." tar -zxf /var/www/roundcube.tar.gz -C /var/www/roundcubemail/htdocs/ --strip-components=1 \ || ee_lib_error "Unable to extract Roundcube, exit status = " $? diff --git a/src/vendor/ee_ven_install_vimbadmin.sh b/src/vendor/ee_ven_install_vimbadmin.sh index 6c0ed857..4f1d23a9 100644 --- a/src/vendor/ee_ven_install_vimbadmin.sh +++ b/src/vendor/ee_ven_install_vimbadmin.sh @@ -4,13 +4,13 @@ function ee_ven_install_vimbadmin() { # Install needed PHP5 libraries for ViMbAdmin - ee_lib_echo "Installing PHP5 libraries for ViMbAdmin, please wait..." # ee stack install php installed php5-mcrypt, php5-memcache, php5-mysqlnd $EE_APT_GET install php5-cgi php5-json php-gettext \ || ee_lib_error "Unable to install php-pear, exit status = " $? # Install ViMbAdmin - ee_lib_echo "Downloading ViMbAdmin, please wait..." + ee_lib_echo "Installing ViMbAdmin, please wait..." + ee_lib_echo "It will take nearly 10-20 minutes, please wait..." wget -cqO /var/www/22222/htdocs/vimbadmin.tar.gz https://github.com/opensolutions/ViMbAdmin/archive/${EE_VIMBADMIN_VERSION}.tar.gz \ || ee_lib_error "Unable to download ViMbAdmin, exit status = " $? @@ -18,8 +18,6 @@ function ee_ven_install_vimbadmin() tar --strip-components=1 -zxf /var/www/22222/htdocs/vimbadmin.tar.gz -C /var/www/22222/htdocs/vimbadmin # Install Composer - ee_lib_echo "Installing ViMbAdmin, please wait..." - ee_lib_echo "It will take nearly 10-20 minutes, please wait..." cd /var/www/22222/htdocs/vimbadmin curl -sS https://getcomposer.org/installer | php &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to install Composer, exit status = " $? diff --git a/src/vendor/ee_ven_setup_roundcube.sh b/src/vendor/ee_ven_setup_roundcube.sh index 2ea51517..0af6c635 100644 --- a/src/vendor/ee_ven_setup_roundcube.sh +++ b/src/vendor/ee_ven_setup_roundcube.sh @@ -2,7 +2,7 @@ function ee_ven_setup_roundcube() { - ee_lib_echo "configuring Roundcube, please wait..." + ee_lib_echo "Setting up Roundcube, please wait..." # Random characters local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index 10a97b51..c87cce5e 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -8,7 +8,7 @@ function ee_ven_setup_vimbadmin() ee_vimbadmin_host=$EE_MYSQL_HOST fi - ee_lib_echo "configuring ViMbAdmin, please wait..." + ee_lib_echo "Setting up ViMbAdmin, please wait..." # Random characters local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) From 05fc3dfe5ce9c0682d9128528df95b33dbeaeba2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 15:59:30 +0530 Subject: [PATCH 067/829] Automated ViMbAdmin security salt --- bin/easyengine | 7 +++++-- src/vendor/ee_ven_setup_vimbadmin.sh | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index cfe14e46..1ddc919f 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -125,7 +125,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_install_utils # Display success message - ee_lib_echo "Successfully installed all packages" + ee_lib_echo "Successfully installed web server packages" ee_lib_echo "Create your first WordPress site powered by NGINX using:" ee_lib_echo_info "ee site create example.com --wp" fi @@ -180,7 +180,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_git /etc/nginx/ /etc/dovecot /etc/postfix /etc/amavis "Initialize Git" - ee_lib_echo "Successfully installed mail server" + # Display message for mail server + ee_lib_echo "Successfully installed mail server packages" + ee_lib_echo "Open https://(hostname -f):22222/vimbadmin in your browser" + ee_lib_echo "Security Salt=${ee_security_salt}" fi diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index c87cce5e..cbcb200b 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -64,4 +64,13 @@ function ee_ven_setup_vimbadmin() /var/www/22222/htdocs/vimbadmin/bin/doctrine2-cli.php orm:schema-tool:create &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to setup ViMbAdmin default database , exit status = " $? + ee_security_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) + sed -i "s/securitysalt = \"\"/securitysalt = \"$ee_security_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini + + + ee_rememberme_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) + sed -i "s/resources.auth.oss.rememberme.salt = \"\"/resources.auth.oss.rememberme.salt = \"$ee_rememberme_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini + + ee_password_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) + sed "s/defaults.mailbox.password_salt = \"\"/defaults.mailbox.password_salt = \"$ee_password_salt\"/" } From e408a15180601e8a4417e80a0c0d17f92b0ee8fb Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 16:29:07 +0530 Subject: [PATCH 068/829] Fixed sed file not defined error --- src/vendor/ee_ven_setup_vimbadmin.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index cbcb200b..993b94fc 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -65,12 +65,14 @@ function ee_ven_setup_vimbadmin() || ee_lib_error "Unable to setup ViMbAdmin default database , exit status = " $? ee_security_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) - sed -i "s/securitysalt = \"\"/securitysalt = \"$ee_security_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini - + sed -i "s/securitysalt = \"\"/securitysalt = \"$ee_security_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ + || ee_lib_error "Unable to setup ViMbAdmin security salt , exit status = " $? ee_rememberme_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) - sed -i "s/resources.auth.oss.rememberme.salt = \"\"/resources.auth.oss.rememberme.salt = \"$ee_rememberme_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini + sed -i "s/resources.auth.oss.rememberme.salt = \"\"/resources.auth.oss.rememberme.salt = \"$ee_rememberme_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ + || ee_lib_error "Unable to setup ViMbAdmin remember me salt , exit status = " $? ee_password_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) - sed "s/defaults.mailbox.password_salt = \"\"/defaults.mailbox.password_salt = \"$ee_password_salt\"/" + sed -i "s/defaults.mailbox.password_salt = \"\"/defaults.mailbox.password_salt = \"$ee_password_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ + || ee_lib_error "Unable to setup ViMbAdmin mailbox password salt , exit status = " $? } From a65743bde50ff5322a06df603ea44a819afa0023 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 16:40:37 +0530 Subject: [PATCH 069/829] Fixed missing $ --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 1ddc919f..663f68c1 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -182,7 +182,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display message for mail server ee_lib_echo "Successfully installed mail server packages" - ee_lib_echo "Open https://(hostname -f):22222/vimbadmin in your browser" + ee_lib_echo "Open https://$(hostname -f):22222/vimbadmin in your browser" ee_lib_echo "Security Salt=${ee_security_salt}" fi From d13a5b5a21c91eb7a1a8190422b7c2ff82dcc6f8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 16:53:16 +0530 Subject: [PATCH 070/829] Improved Display Message --- bin/easyengine | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 663f68c1..f08ca60a 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -181,10 +181,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_git /etc/nginx/ /etc/dovecot /etc/postfix /etc/amavis "Initialize Git" # Display message for mail server - ee_lib_echo "Successfully installed mail server packages" - ee_lib_echo "Open https://$(hostname -f):22222/vimbadmin in your browser" - ee_lib_echo "Security Salt=${ee_security_salt}" + ee_lib_echo_escape "Configure ViMbAdmin:\t\thttps://$(hostname -f):22222/vimbadmin" + ee_lib_echo_escape "Security Salt:\t\t${ee_security_salt}\n" + ee_lib_echo "Successfully installed mail server packages" fi # EasyEngine remove/purge From 3a7bfcae83bde07abeef26be68167471c0a8a17d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 17:01:46 +0530 Subject: [PATCH 071/829] Fixed Unary operator Expected error --- bin/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install b/bin/install index a752a326..5d0cf22b 100644 --- a/bin/install +++ b/bin/install @@ -86,7 +86,7 @@ function ee_lib_check_fqdn() { case $1 in *.*) - if [ $EE_FQDN != "" ];then + if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname service hostname restart &>> $EE_INSTALL_LOG hostname -f &>> $EE_INSTALL_LOG From 971a0901dc6fd757d1e9fa8d5f30ade885d06008 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 17:04:41 +0530 Subject: [PATCH 072/829] Fixed Unary operator Expected error --- src/lib/ee_lib_check_fqdn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh index 8639d523..987c3b03 100644 --- a/src/lib/ee_lib_check_fqdn.sh +++ b/src/lib/ee_lib_check_fqdn.sh @@ -4,7 +4,7 @@ function ee_lib_check_fqdn() { case $1 in *.*) - if [ $EE_FQDN != "" ];then + if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname service hostname restart &>> $EE_COMMAND_LOG hostname -f &>> $EE_COMMAND_LOG From 8d5ad94e36cd1b39b08901c76c3f5c90c683d023 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 17:13:56 +0530 Subject: [PATCH 073/829] Improved display message --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index f08ca60a..91b3c92b 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -181,7 +181,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_git /etc/nginx/ /etc/dovecot /etc/postfix /etc/amavis "Initialize Git" # Display message for mail server - ee_lib_echo_escape "Configure ViMbAdmin:\t\thttps://$(hostname -f):22222/vimbadmin" + ee_lib_echo_escape "Configure ViMbAdmin:\thttps://$(hostname -f):22222/vimbadmin" ee_lib_echo_escape "Security Salt:\t\t${ee_security_salt}\n" ee_lib_echo "Successfully installed mail server packages" From 9465324bb4d2b04763fb025c3b67b7a2cdce11ab Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 18:14:02 +0530 Subject: [PATCH 074/829] Improved code --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 91b3c92b..1659ad07 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -178,7 +178,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_service nginx postfix dovecot amavis restart - ee_lib_git /etc/nginx/ /etc/dovecot /etc/postfix /etc/amavis "Initialize Git" + ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Initialize Git" # Display message for mail server ee_lib_echo_escape "Configure ViMbAdmin:\thttps://$(hostname -f):22222/vimbadmin" From fc243422e294f8b4f2037ee836b020f9f713664a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Sep 2014 19:11:19 +0530 Subject: [PATCH 075/829] Fixed Amavis not writing mail scanning header --- src/modules/stack/install/mail/ee_mod_setup_mailscan.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh index a5d85462..833ad583 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh @@ -13,6 +13,8 @@ function ee_mod_setup_mailscan() sed -i "s/use strict;/use strict;\n\$sa_spam_subject_tag = undef;\n\$spam_quarantine_to = undef;\n\$sa_tag_level_deflt = undef;\n\n# Prevent spams from automatically rejected by mail-server\n\$final_spam_destiny = D_PASS;\n# We need to provide list of domains for which filtering need to be done\n@lookup_sql_dsn = (\n ['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306',\n 'vimbadmin',\n 'password']);\n\n\$sql_select_policy = 'SELECT domain FROM domain WHERE CONCAT("@",domain) IN (%k)';/" /etc/amavis/conf.d/50-user \ || ee_lib_error "Unable to setup Amavis, exit status = " $? + sed -i "s'\@local_domains_acl = ( \".\$mydomain\" );'\@local_domains_acl = ( \".\" );'" /etc/amavis/conf.d/05-domain_id \ + || ee_lib_error "Unable to setup Amavis, exit status = " $? # Configure Postfix to use Amavis # For postfix main.cf From 2e820ec0b160a205b08547ef23ccc1baaa5b2f54 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 11:59:21 +0530 Subject: [PATCH 076/829] Added freshclam --- src/modules/stack/install/mail/ee_mod_setup_mailscan.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh index 833ad583..8fe08a1f 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh @@ -29,4 +29,12 @@ function ee_mod_setup_mailscan() adduser clamav amavis &>> $EE_COMMAND_LOG adduser amavis clamav &>> $EE_COMMAND_LOG chmod -R 775 /var/lib/amavis/tmp &>> $EE_COMMAND_LOG + + # Update ClamAV database (freshclam) + ee_lib_echo "Updating ClamAV database, please wait..." + freshclam &>> $EE_COMMAND_LOG + + service clamav-daemon restart &>> $EE_COMMAND_LOG \ + || ee_lib_echo "Unable to start ClamAV deamon" + } From ef2693d8a06b9e457261fa439366c4689b8f6fb3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 12:04:39 +0530 Subject: [PATCH 077/829] Update man pages --- docs/man/ee.8 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/man/ee.8 b/docs/man/ee.8 index 7294a639..2b70dad1 100644 --- a/docs/man/ee.8 +++ b/docs/man/ee.8 @@ -5,7 +5,7 @@ .SH SYNOPSIS ee [ version | help | info | stack | site | debug | update ] .TP -ee stack [ install | remove | purge ] [ nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] +ee stack [ install | remove | purge ] [ --web | --mail | --all | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] .TP ee stack [ status | start | stop | reload | restart ] .TP @@ -44,19 +44,19 @@ Display easyengine (ee) help. .TP .B stack .TP -.B install [ nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] +.B install [ --all | --web | --mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] .br Install Nginx PHP5 MySQL Postfix stack Packages if not used with .br any options.Installs specific package if used with option. .TP -.B remove [ nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] +.B remove [ --all | --web | --mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] .br Remove Nginx PHP5 MySQL Postfix stack Packages if not used with .br any options. Remove specific package if used with option. .TP -.B purge [ nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] +.B purge [ --all | --web | --mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] .br Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any .br From 2bade5596f614872f7868d47607ef6364c20c867 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 12:50:52 +0530 Subject: [PATCH 078/829] Updated Changelog --- CHANGELOG.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index caaacd8d..1efcf316 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,4 +1,9 @@ -v 2.0.2 - July 21, 2014 +v 2.1.0 - Sept 2, 2014 + - Added Mail Server Package installation #65 + - Fixed incorrect log file path during debug #299 + - Added support for pt-query-advisor #189 + +v 2.0.2 - Aug 13, 2014 - Remote MySQL Support v 2.0.1 - July 21, 2014 From 7f62724232bd54de8e2efb6537809bbfb89adfc8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 13:52:46 +0530 Subject: [PATCH 079/829] Change --mail,--web,--all to mail,web,all --- bin/easyengine | 8 ++++---- config/bash_completion.d/ee | 2 +- docs/man/ee.8 | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 1659ad07..ecfa54a5 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -90,7 +90,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display success message ee_lib_echo "$EE_THIRD successfully installed" - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "--web" ] || [ "$EE_THIRD" = "--all" ]; then + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then # Setup NGINX/PHP repository ee_mod_repo_nginx ee_mod_repo_php @@ -130,7 +130,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo_info "ee site create example.com --wp" fi # EasyEngine mail server setup - if [ "$EE_THIRD" = "--mail" ] || [ "$EE_THIRD" = "--all" ];then + if [ "$EE_THIRD" = "mail" ] || [ "$EE_THIRD" = "all" ];then # Check required Packages are installed or not dpkg --get-selections | grep -v deinstall | grep nginx > /dev/null \ @@ -210,7 +210,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then elif [ "$EE_SECOND" = "purge" ];then ee_lib_echo "$EE_THIRD successfully purged" fi - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "--web" ] || [ "$EE_THIRD" = "--all" ]; then + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then # Remove/Purge NGINX/PHP/MySQL/Postfix package ee_mod_remove_nginx ee_mod_remove_php @@ -233,7 +233,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo "Successfully purged web packages" fi fi - if [ "$EE_THIRD" = "--all" ] || [ "$EE_THIRD" = "--mail" ];then + if [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "mail" ];then # Remove Dovecot ee_mod_remove_dovecot diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 68e7278e..1efbbef1 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -25,7 +25,7 @@ function EE_AUTO() ;; install|remove|purge) - COMPREPLY=( $( compgen -W '$(echo --mail --all --web; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) + COMPREPLY=( $( compgen -W '$(echo mail all web; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) return 0 ;; diff --git a/docs/man/ee.8 b/docs/man/ee.8 index 2b70dad1..d36a25bd 100644 --- a/docs/man/ee.8 +++ b/docs/man/ee.8 @@ -44,19 +44,19 @@ Display easyengine (ee) help. .TP .B stack .TP -.B install [ --all | --web | --mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] +.B install [ all | web | mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] .br Install Nginx PHP5 MySQL Postfix stack Packages if not used with .br any options.Installs specific package if used with option. .TP -.B remove [ --all | --web | --mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] +.B remove [ all | web | mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] .br Remove Nginx PHP5 MySQL Postfix stack Packages if not used with .br any options. Remove specific package if used with option. .TP -.B purge [ --all | --web | --mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] +.B purge [ all | web | mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] .br Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any .br From 561b0c52ccb8aed560f70aeda8dfc7724b4d431e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 15:45:40 +0530 Subject: [PATCH 080/829] Update Changelog --- CHANGELOG.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1efcf316..eee173cb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,6 +2,7 @@ v 2.1.0 - Sept 2, 2014 - Added Mail Server Package installation #65 - Fixed incorrect log file path during debug #299 - Added support for pt-query-advisor #189 + - Fixed Firefox cross-domain fonts v 2.0.2 - Aug 13, 2014 - Remote MySQL Support From 041e68dcdd5c67375ea959f3b68903348504ae64 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 15:57:23 +0530 Subject: [PATCH 081/829] Improved display messages --- bin/easyengine | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index ecfa54a5..a8d2a05e 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -125,9 +125,11 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_install_utils # Display success message - ee_lib_echo "Successfully installed web server packages" - ee_lib_echo "Create your first WordPress site powered by NGINX using:" - ee_lib_echo_info "ee site create example.com --wp" + if [ "$EE_THIRD" != "all" ];then + ee_lib_echo "Successfully installed web server packages" + ee_lib_echo "Create your first WordPress site powered by NGINX using:" + ee_lib_echo_info "ee site create example.com --wp" + fi fi # EasyEngine mail server setup if [ "$EE_THIRD" = "mail" ] || [ "$EE_THIRD" = "all" ];then From c6d988452da2bcd94afff76a224a572001904570 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 18:12:06 +0530 Subject: [PATCH 082/829] Fixed Dovcot not removing in Ubuntu 12.04 --- src/modules/stack/install/mail/ee_mod_setup_dovecot.sh | 5 +++-- src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index 623b54b7..a22d254a 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -58,8 +58,9 @@ function ee_mod_setup_dovecot() || ee_lib_error "Unable to setup Dovecot SSL certificate path, exit status = " $? # Setting Dovecot init.d script - cp -v /usr/share/easyengine/mail/dovecot /etc/init.d/dovecot &>> $EE_COMMAND_LOG - + if [ ! -f /etc/init.d/dovecot ];then + cp -v /usr/share/easyengine/mail/dovecot /etc/init.d/dovecot &>> $EE_COMMAND_LOG + fi # Add autocreate plugin sed -i "s'#mail_plugins = \$mail_plugins'mail_plugins = \$mail_plugins autocreate'" /etc/dovecot/conf.d/20-imap.conf \ || ee_lib_error "Unable to setup Dovecot autocreate plugin, exit status = " $? diff --git a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh index f3fcc9cf..199540f2 100644 --- a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh +++ b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh @@ -7,4 +7,6 @@ function ee_mod_remove_dovecot() || ee_lib_error "Unable to $EE_SECOND Dovecot, exit status = " $? userdel -rf vmail || ee_lib_error "Unable to Remove user vmail, exit status = " $? + rm -f /etc/init.d/dovecot + } From 1b970de4591575e18f21f6d33f664702a46e31f8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 18:57:43 +0530 Subject: [PATCH 083/829] Better way to add and delete user --- src/modules/stack/install/mail/ee_mod_setup_dovecot.sh | 2 +- src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index a22d254a..662fac7c 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -12,7 +12,7 @@ function ee_mod_setup_dovecot() ee_lib_echo "Setting up Dovecot, please wait..." # Adding mail user with GID 5000 and UID 5000 - groupadd -g 5000 vmail && useradd -g vmail -u 5000 vmail -d /var/vmail -m \ + adduser --uid 5000 --home /var/vmail --disabled-password --gecos '' vmail \ || ee_lib_error "Unable to setup vmail user/group = " $? # Configuring dovecot.conf diff --git a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh index 199540f2..b929b43b 100644 --- a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh +++ b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh @@ -6,7 +6,8 @@ function ee_mod_remove_dovecot() $EE_APT_GET $EE_SECOND dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ || ee_lib_error "Unable to $EE_SECOND Dovecot, exit status = " $? - userdel -rf vmail || ee_lib_error "Unable to Remove user vmail, exit status = " $? + deluser --remove-home vmail &>> $EE_COMMAND_LOG || ee_lib_error "Unable to Remove user vmail, exit status = " $? rm -f /etc/init.d/dovecot + rm -rf /var/vmail } From 1b07b019e7aa804e8ce74a3fd5d744ccff4c826e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 19:09:04 +0530 Subject: [PATCH 084/829] Hiden useradd message --- src/modules/stack/install/mail/ee_mod_setup_dovecot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index 662fac7c..2b1e62ad 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -12,7 +12,7 @@ function ee_mod_setup_dovecot() ee_lib_echo "Setting up Dovecot, please wait..." # Adding mail user with GID 5000 and UID 5000 - adduser --uid 5000 --home /var/vmail --disabled-password --gecos '' vmail \ + adduser --uid 5000 --home /var/vmail --disabled-password --gecos '' vmail &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to setup vmail user/group = " $? # Configuring dovecot.conf From 34299ccf66bbf134dde6fac24fc7a6b0a544d03b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 19:22:42 +0530 Subject: [PATCH 085/829] Fixed Version in update script --- bin/update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/update b/bin/update index 55ec38a0..278eeb20 100644 --- a/bin/update +++ b/bin/update @@ -442,7 +442,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then fi # Update EasyEngine current version - EE_CURRENT_VERSION="2.0.1" + EE_CURRENT_VERSION="2.1.0" fi # Restart service From 94f3eefbf72e4d440380ff1db7f6ea982819feac Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 19:31:45 +0530 Subject: [PATCH 086/829] Better Display msg for FQDN --- bin/install | 2 +- src/lib/ee_lib_check_fqdn.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install b/bin/install index 5d0cf22b..6335936e 100644 --- a/bin/install +++ b/bin/install @@ -93,7 +93,7 @@ function ee_lib_check_fqdn() fi ;; *) - read -p "Enter FQDN to set for Hostname: " EE_FQDN + read -p "Enter hostname [FQDN]: " EE_FQDN ee_lib_check_fqdn $EE_FQDN ;; esac diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh index 987c3b03..4432031f 100644 --- a/src/lib/ee_lib_check_fqdn.sh +++ b/src/lib/ee_lib_check_fqdn.sh @@ -11,7 +11,7 @@ function ee_lib_check_fqdn() fi ;; *) - read -p "Enter FQDN to set for Hostname: " EE_FQDN + read -p "Enter hostname [FQDN]: " EE_FQDN ee_lib_check_fqdn $EE_FQDN ;; esac From 58f03a2d07106140f22e843059c4bd8a2b322dc2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 19:43:22 +0530 Subject: [PATCH 087/829] Better way to get OS codename --- src/modules/stack/install/ee_mod_repo_nginx.sh | 2 +- src/modules/stack/install/ee_mod_repo_php.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/stack/install/ee_mod_repo_nginx.sh b/src/modules/stack/install/ee_mod_repo_nginx.sh index bb1c1bec..773b8d54 100644 --- a/src/modules/stack/install/ee_mod_repo_nginx.sh +++ b/src/modules/stack/install/ee_mod_repo_nginx.sh @@ -13,7 +13,7 @@ function ee_mod_repo_nginx() # Add Dotdeb nginx repository ee_lib_echo "Adding Dotdeb NGINX repository, please wait..." - echo "deb http://packages.dotdeb.org $(lsb_release -c | awk '{print($2)}') all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -c | awk '{print($2)}').list \ + echo "deb http://packages.dotdeb.org $(lsb_release -sc) all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc).list \ || ee_lib_error "Unable to add Dotdeb NGINX repository, exit status = " $? # Fetch and install dotdeb GnuPG key diff --git a/src/modules/stack/install/ee_mod_repo_php.sh b/src/modules/stack/install/ee_mod_repo_php.sh index d08cbed6..e21bb382 100644 --- a/src/modules/stack/install/ee_mod_repo_php.sh +++ b/src/modules/stack/install/ee_mod_repo_php.sh @@ -14,7 +14,7 @@ function ee_mod_repo_php() elif [ $EE_DEBIAN_VERSION -eq 6 ]; then ee_lib_echo "Adding Dotdeb PHP5.4 repository, please wait..." - echo "deb http://packages.dotdeb.org $(lsb_release -c | awk '{print($2)}')-php54 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -c | awk '{print($2)}')-php54.list \ + echo "deb http://packages.dotdeb.org $(lsb_release -sc)-php54 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc)-php54.list \ || ee_lib_error "Unable to add Dotdeb PHP5.4 repository, exit status = " $? # Fetch and install Dotdeb GnuPG key @@ -24,7 +24,7 @@ function ee_mod_repo_php() elif [ $EE_DEBIAN_VERSION -eq 7 ]; then ee_lib_echo "Adding Dotdeb PHP5.5 repository, please wait..." - echo "deb http://packages.dotdeb.org $(lsb_release -c | awk '{print($2)}')-php55 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -c | awk '{print($2)}')-php55.list \ + echo "deb http://packages.dotdeb.org $(lsb_release -sc)-php55 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc)-php55.list \ || ee_lib_error "Unable to add Dotdeb PHP5.5 repository, exit status = " $? # Fetch and install dotdeb GnuPG key From fdeee0a91b4c44be317f42ffbe8ad0fb7ea8c183 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 20:10:11 +0530 Subject: [PATCH 088/829] Better way to handle Debian COdename --- src/lib/ee_lib_variables.sh | 2 +- src/modules/stack/install/ee_mod_repo_php.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 65e84076..c5b2113e 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -32,7 +32,7 @@ elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then # Specify nginx package readonly EE_NGINX_PACKAGE=nginx-full # Detect Debian version - readonly EE_DEBIAN_VERSION=$(lsb_release -r | awk '{print($2)}' | cut -d'.' -f1) + readonly EE_DEBIAN_VERSION=$(lsb_release -sc) fi # Find php user-name diff --git a/src/modules/stack/install/ee_mod_repo_php.sh b/src/modules/stack/install/ee_mod_repo_php.sh index e21bb382..2e1015a5 100644 --- a/src/modules/stack/install/ee_mod_repo_php.sh +++ b/src/modules/stack/install/ee_mod_repo_php.sh @@ -11,7 +11,7 @@ function ee_mod_repo_php() || ee_lib_error "Unable to add ondrej php5 launchpad repository, exit status = " $? # Debian 6 - elif [ $EE_DEBIAN_VERSION -eq 6 ]; then + elif [ "$EE_DEBIAN_VERSION" == "squeeze" ]; then ee_lib_echo "Adding Dotdeb PHP5.4 repository, please wait..." echo "deb http://packages.dotdeb.org $(lsb_release -sc)-php54 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc)-php54.list \ @@ -21,7 +21,7 @@ function ee_mod_repo_php() ee_lib_dotdeb # Debian 7 - elif [ $EE_DEBIAN_VERSION -eq 7 ]; then + elif [ "$EE_DEBIAN_VERSION" == "wheezy" ]; then ee_lib_echo "Adding Dotdeb PHP5.5 repository, please wait..." echo "deb http://packages.dotdeb.org $(lsb_release -sc)-php55 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc)-php55.list \ From 3a5a62121aca04b13d5148f3f8c5a3f9d6f27e17 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Sep 2014 20:14:32 +0530 Subject: [PATCH 089/829] Fixed Debian hostname issue --- bin/install | 7 ++++++- src/lib/ee_lib_check_fqdn.sh | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/install b/bin/install index 6335936e..8bdb4d7a 100644 --- a/bin/install +++ b/bin/install @@ -42,6 +42,7 @@ readonly EE_LOG_DIR=/var/log/easyengine readonly EE_INSTALL_LOG=/var/log/easyengine/install.log readonly EE_ERROR_LOG=/var/log/easyengine/error.log readonly EE_LINUX_DISTRO=$(lsb_release -i |awk '{print $3}') +readonly EE_DEBIAN_VERSION=$(lsb_release -sc) # Checking linux distro if [ "$EE_LINUX_DISTRO" != "Ubuntu" ] && [ "$EE_LINUX_DISTRO" != "Debian" ]; then @@ -88,7 +89,11 @@ function ee_lib_check_fqdn() *.*) if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname - service hostname restart &>> $EE_INSTALL_LOG + if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then + /etc/init.d/hostname.sh start &>> $EE_COMMAND_LOG + else + service hostname restart &>> $EE_COMMAND_LOG + fi hostname -f &>> $EE_INSTALL_LOG fi ;; diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh index 4432031f..1f8648a0 100644 --- a/src/lib/ee_lib_check_fqdn.sh +++ b/src/lib/ee_lib_check_fqdn.sh @@ -6,7 +6,11 @@ function ee_lib_check_fqdn() *.*) if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname - service hostname restart &>> $EE_COMMAND_LOG + if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then + /etc/init.d/hostname.sh start &>> $EE_COMMAND_LOG + else + service hostname restart &>> $EE_COMMAND_LOG + fi hostname -f &>> $EE_COMMAND_LOG fi ;; From 46152b41019c0683bac67a4e75c59fe98bdc8aae Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 3 Sep 2014 12:27:04 +0530 Subject: [PATCH 090/829] Fixed hostname log issue --- bin/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install b/bin/install index 8bdb4d7a..2125dc5d 100644 --- a/bin/install +++ b/bin/install @@ -90,9 +90,9 @@ function ee_lib_check_fqdn() if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then - /etc/init.d/hostname.sh start &>> $EE_COMMAND_LOG + /etc/init.d/hostname.sh start &>> $EE_INSTALL_LOG else - service hostname restart &>> $EE_COMMAND_LOG + service hostname restart &>> $EE_INSTALL_LOG fi hostname -f &>> $EE_INSTALL_LOG fi From 7553dfb592cbae4bdef930d9977dd4ddd4c16262 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 3 Sep 2014 14:57:31 +0530 Subject: [PATCH 091/829] Added Dovecot repo for Debian 6 --- .../install/mail/ee_mod_install_dovecot.sh | 4 ++++ .../stack/install/mail/ee_mod_repo_dovecot.sh | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/modules/stack/install/mail/ee_mod_repo_dovecot.sh diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index e7ce0ca8..18bc1f38 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -2,6 +2,10 @@ function ee_mod_install_dovecot() { + # Add Dovecot repo for Debian 6 + ee_mod_repo_dovecot + ee_lib_apt_get_update + # Install Dovecot ee_lib_echo "Installing Dovecot, please wait..." debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" diff --git a/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh b/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh new file mode 100644 index 00000000..677fb1a1 --- /dev/null +++ b/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh @@ -0,0 +1,19 @@ +# Setup nginx repository + +function ee_mod_repo_dovecot() +{ + if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then + + # Add Dovecot repository + # Ref:http://wiki2.dovecot.org/PrebuiltBinaries + + ee_lib_echo "Adding Dovecot repository, please wait..." + echo "deb http://xi.rename-it.nl/debian/ oldstable-auto/dovecot-2.2 main" > /etc/apt/sources.list.d/dovecot-$(lsb_release -sc).list \ + || ee_lib_error "Unable to add Dovecot repository, exit status = " $? + + # Fetch and install Dovecot GnuPG key + wget -O - http://xi.rename-it.nl/debian/archive.key | apt-key add - \ + || ee_lib_error "Unable to fetch Dovecot GnuPG key, exit status = " $? + + fi +} From 05a47ff27b8019fea469c89f1a6b89b3a2bff7f6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 3 Sep 2014 15:31:49 +0530 Subject: [PATCH 092/829] Changed Dovcot Repo --- .../stack/install/mail/ee_mod_install_dovecot.sh | 11 +++++++++-- src/modules/stack/install/mail/ee_mod_repo_dovecot.sh | 8 +------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index 18bc1f38..09225e4b 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -10,7 +10,14 @@ function ee_mod_install_dovecot() ee_lib_echo "Installing Dovecot, please wait..." debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" - $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ - || ee_lib_error "Unable to install Dovecot, exit status = " $? + + # Debian 6 doesn't provide Dovecot 2.x + if [ "$EE_DEBIAN_VERSION" == "squeeze" ]; then + $EE_APT_GET -t squeeze-backports install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ + || ee_lib_error "Unable to install Dovecot, exit status = " $? + else + $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ + || ee_lib_error "Unable to install Dovecot, exit status = " $? + fi } diff --git a/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh b/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh index 677fb1a1..5f27164b 100644 --- a/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh @@ -5,15 +5,9 @@ function ee_mod_repo_dovecot() if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then # Add Dovecot repository - # Ref:http://wiki2.dovecot.org/PrebuiltBinaries - ee_lib_echo "Adding Dovecot repository, please wait..." - echo "deb http://xi.rename-it.nl/debian/ oldstable-auto/dovecot-2.2 main" > /etc/apt/sources.list.d/dovecot-$(lsb_release -sc).list \ + echo "deb http://http.debian.net/debian-backports squeeze-backports main" > /etc/apt/sources.list.d/dovecot-$(lsb_release -sc).list \ || ee_lib_error "Unable to add Dovecot repository, exit status = " $? - # Fetch and install Dovecot GnuPG key - wget -O - http://xi.rename-it.nl/debian/archive.key | apt-key add - \ - || ee_lib_error "Unable to fetch Dovecot GnuPG key, exit status = " $? - fi } From dd3a6787a45da115c12cfcb75d85d15694f3f8d1 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 3 Sep 2014 16:25:39 +0530 Subject: [PATCH 093/829] Updated Posfix support for Debian 6 --- .../install/mail/ee_mod_setup_postfix.sh | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index 59dac0d6..feb80e48 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -22,31 +22,27 @@ function ee_mod_setup_postfix() sed -i 's/#smtps/smtps/' /etc/postfix/master.cf \ || ee_lib_error "Unable to setup details in master.cf file, exit status = " $? - #Configure main.cf - #postconf "#smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache" - #postconf "#smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache" - #postconf "#smtpd_tls_cert_file=/etc/ssl/certs/dovecot.pem" - #postconf "#smtpd_use_tls=yes" - #postconf "#smtpd_tls_auth_only = yes" + # Handle SMTP authentication using Dovecot" + # On Debian6 following command not work + # postconf "smtpd_sasl_type = dovecot" - #Handle SMTP authentication using Dovecot" - postconf "smtpd_sasl_type = dovecot" - postconf "smtpd_sasl_path = private/auth" - postconf "smtpd_sasl_auth_enable = yes" + postconf -e "smtpd_sasl_type = dovecot" + postconf -e "smtpd_sasl_path = private/auth" + postconf -e "smtpd_sasl_auth_enable = yes" - postconf "smtpd_relay_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination" + postconf -e "smtpd_relay_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination" # other destination domains should be handled using virtual domains - postconf "mydestination = localhost" + postconf -e "mydestination = localhost" # using Dovecot's LMTP for mail delivery and giving it path to store mail - postconf "virtual_transport = lmtp:unix:private/dovecot-lmtp" + postconf -e "virtual_transport = lmtp:unix:private/dovecot-lmtp" # virtual mailbox setups - postconf "virtual_uid_maps = static:5000" - postconf "virtual_gid_maps = static:5000" - postconf "virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domains_maps.cf" - postconf "virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf" + postconf -e "virtual_uid_maps = static:5000" + postconf -e "virtual_gid_maps = static:5000" + postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domains_maps.cf" + postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf" #postconf "message_size_limit = 20971520" From 54ca9d0f58594d6521b6c94aae849240931ad049 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 3 Sep 2014 16:26:58 +0530 Subject: [PATCH 094/829] Updated Posfix support for Debian 6 --- src/modules/stack/install/mail/ee_mod_setup_postfix.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index feb80e48..6ffbf518 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -23,8 +23,9 @@ function ee_mod_setup_postfix() || ee_lib_error "Unable to setup details in master.cf file, exit status = " $? # Handle SMTP authentication using Dovecot" - # On Debian6 following command not work + # On Debian6 following command not work ( Postfix < 2.8 ) # postconf "smtpd_sasl_type = dovecot" + # The -e option is no longer needed with Postfix version 2.8 and later. postconf -e "smtpd_sasl_type = dovecot" postconf -e "smtpd_sasl_path = private/auth" From c588e018c5480de7eba7dad565f6fc6f6aa60714 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 3 Sep 2014 17:36:25 +0530 Subject: [PATCH 095/829] Fixed travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 88e68603..f9c2e332 100644 --- a/.travis.yml +++ b/.travis.yml @@ -126,7 +126,7 @@ script: - sudo bash ee debug - sudo bash ee debug --stop -- sudo bash ee stack install --mail +- sudo bash ee stack install mail - sudo cat /var/log/easyengine/* From bd575373058fdacc1ec14c97f483f0856ea56e0d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 3 Sep 2014 18:28:39 +0530 Subject: [PATCH 096/829] Fixed ee site edit command on Nano editor --- CHANGELOG.txt | 1 + src/modules/site/ee_mod_site_edit.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index eee173cb..b9f5a9a4 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ v 2.1.0 - Sept 2, 2014 - Fixed incorrect log file path during debug #299 - Added support for pt-query-advisor #189 - Fixed Firefox cross-domain fonts + - Fixed ee site edit command on Nano editor v 2.0.2 - Aug 13, 2014 - Remote MySQL Support diff --git a/src/modules/site/ee_mod_site_edit.sh b/src/modules/site/ee_mod_site_edit.sh index a9670216..6028d027 100644 --- a/src/modules/site/ee_mod_site_edit.sh +++ b/src/modules/site/ee_mod_site_edit.sh @@ -2,5 +2,5 @@ function ee_mod_site_edit() { - sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 2> /dev/null + sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 } From 365d6092af04932d14f4bc5c3874a89128e5821f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 3 Sep 2014 18:33:08 +0530 Subject: [PATCH 097/829] Update Changelog --- CHANGELOG.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9034e027..6f61bb5d 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,11 +1,10 @@ -v 2.1.0 - Sept 2, 2014 +v 2.1.0 - Sept 3, 2014 - Added Mail Server Package installation #65 - Fixed incorrect log file path during debug #299 - Added support for pt-query-advisor #189 - Fixed Firefox cross-domain fonts - Fixed ee site edit command on Nano editor - v 2.0.2 - Aug 13, 2014 - Remote MySQL Support From 915c04a5f99278b9955de58b805e7cfd160e118c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Sep 2014 14:46:54 +0530 Subject: [PATCH 099/829] Fixed Debian hostname issue --- bin/install | 2 +- src/lib/ee_lib_check_fqdn.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install b/bin/install index 2125dc5d..51f5c73f 100644 --- a/bin/install +++ b/bin/install @@ -89,7 +89,7 @@ function ee_lib_check_fqdn() *.*) if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname - if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then + if [ "$EE_LINUX_DISTRO" == "Debian" ];then /etc/init.d/hostname.sh start &>> $EE_INSTALL_LOG else service hostname restart &>> $EE_INSTALL_LOG diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh index 1f8648a0..e0b72401 100644 --- a/src/lib/ee_lib_check_fqdn.sh +++ b/src/lib/ee_lib_check_fqdn.sh @@ -6,7 +6,7 @@ function ee_lib_check_fqdn() *.*) if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname - if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then + if [ "$EE_LINUX_DISTRO" == "Debian" ];then /etc/init.d/hostname.sh start &>> $EE_COMMAND_LOG else service hostname restart &>> $EE_COMMAND_LOG From 6bf192b47da515555238b8394f53a92f5dd872fa Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Sep 2014 15:33:59 +0530 Subject: [PATCH 100/829] Fixed hostname issue in Debian --- bin/install | 5 +++++ src/lib/ee_lib_check_fqdn.sh | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/bin/install b/bin/install index 51f5c73f..57c28662 100644 --- a/bin/install +++ b/bin/install @@ -90,6 +90,11 @@ function ee_lib_check_fqdn() if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname if [ "$EE_LINUX_DISTRO" == "Debian" ];then + grep $EE_FQDN /etc/hosts &>> $EE_COMMAND_LOG + if [ $? -ne 0 ]; then + sed -i '1i\127.0.0.1 $EE_FQDN' /etc/hosts \ + || ee_lib_error "Unable setup hostname = " $? + fi /etc/init.d/hostname.sh start &>> $EE_INSTALL_LOG else service hostname restart &>> $EE_INSTALL_LOG diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh index e0b72401..467082f3 100644 --- a/src/lib/ee_lib_check_fqdn.sh +++ b/src/lib/ee_lib_check_fqdn.sh @@ -7,6 +7,11 @@ function ee_lib_check_fqdn() if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname if [ "$EE_LINUX_DISTRO" == "Debian" ];then + grep $EE_FQDN /etc/hosts &>> $EE_COMMAND_LOG + if [ $? -ne 0 ]; then + sed -i '1i\127.0.0.1 $EE_FQDN' /etc/hosts \ + || ee_lib_error "Unable setup hostname = " $? + fi /etc/init.d/hostname.sh start &>> $EE_COMMAND_LOG else service hostname restart &>> $EE_COMMAND_LOG From 5789c76e2ca0362a173448e6e6c4ee7a29bf490b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Sep 2014 15:43:50 +0530 Subject: [PATCH 101/829] Fixed hostname issue in Debian --- bin/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install b/bin/install index 57c28662..8a69a91d 100644 --- a/bin/install +++ b/bin/install @@ -90,7 +90,7 @@ function ee_lib_check_fqdn() if [ "$EE_FQDN" != "" ];then echo $EE_FQDN > /etc/hostname if [ "$EE_LINUX_DISTRO" == "Debian" ];then - grep $EE_FQDN /etc/hosts &>> $EE_COMMAND_LOG + grep $EE_FQDN /etc/hosts &>> $EE_INSTALL_LOG if [ $? -ne 0 ]; then sed -i '1i\127.0.0.1 $EE_FQDN' /etc/hosts \ || ee_lib_error "Unable setup hostname = " $? From 540386e1dee3406e72f4f9caaa872e288c8e1b59 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Sep 2014 15:48:21 +0530 Subject: [PATCH 102/829] Fixed hostname sed issue --- bin/install | 2 +- src/lib/ee_lib_check_fqdn.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install b/bin/install index 8a69a91d..28b30721 100644 --- a/bin/install +++ b/bin/install @@ -92,7 +92,7 @@ function ee_lib_check_fqdn() if [ "$EE_LINUX_DISTRO" == "Debian" ];then grep $EE_FQDN /etc/hosts &>> $EE_INSTALL_LOG if [ $? -ne 0 ]; then - sed -i '1i\127.0.0.1 $EE_FQDN' /etc/hosts \ + sed -i "1i\127.0.0.1 $EE_FQDN" /etc/hosts \ || ee_lib_error "Unable setup hostname = " $? fi /etc/init.d/hostname.sh start &>> $EE_INSTALL_LOG diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh index 467082f3..00e26686 100644 --- a/src/lib/ee_lib_check_fqdn.sh +++ b/src/lib/ee_lib_check_fqdn.sh @@ -9,7 +9,7 @@ function ee_lib_check_fqdn() if [ "$EE_LINUX_DISTRO" == "Debian" ];then grep $EE_FQDN /etc/hosts &>> $EE_COMMAND_LOG if [ $? -ne 0 ]; then - sed -i '1i\127.0.0.1 $EE_FQDN' /etc/hosts \ + sed -i "1i\127.0.0.1 $EE_FQDN" /etc/hosts \ || ee_lib_error "Unable setup hostname = " $? fi /etc/init.d/hostname.sh start &>> $EE_COMMAND_LOG From 4d86fa57d2554d7f41745ee53333bc5f5eda692e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Sep 2014 15:51:20 +0530 Subject: [PATCH 103/829] Better Hostname message --- bin/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install b/bin/install index 28b30721..24efda35 100644 --- a/bin/install +++ b/bin/install @@ -99,7 +99,7 @@ function ee_lib_check_fqdn() else service hostname restart &>> $EE_INSTALL_LOG fi - hostname -f &>> $EE_INSTALL_LOG + echo "hostname = $(hostname -f)" &>> $EE_INSTALL_LOG fi ;; *) From d952b4e3e1a3d4c467a30cc6e3ff30e3ee6e85da Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Sep 2014 15:51:59 +0530 Subject: [PATCH 104/829] Better Hostname message --- src/lib/ee_lib_check_fqdn.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh index 00e26686..712b393d 100644 --- a/src/lib/ee_lib_check_fqdn.sh +++ b/src/lib/ee_lib_check_fqdn.sh @@ -16,7 +16,7 @@ function ee_lib_check_fqdn() else service hostname restart &>> $EE_COMMAND_LOG fi - hostname -f &>> $EE_COMMAND_LOG + echo "hostname = $(hostname -f)" &>> $EE_COMMAND_LOG fi ;; *) From 939699aee87ac2f6c6f10a635f72d60d065dd18e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Sep 2014 19:00:48 +0530 Subject: [PATCH 105/829] Fixed Error in Vim Editor --- src/modules/site/ee_mod_site_edit.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_edit.sh b/src/modules/site/ee_mod_site_edit.sh index 6028d027..00f7674d 100644 --- a/src/modules/site/ee_mod_site_edit.sh +++ b/src/modules/site/ee_mod_site_edit.sh @@ -2,5 +2,10 @@ function ee_mod_site_edit() { - sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 + grep vim ~/.selected_editor &>> $EE_COMMAND_LOG + if [ $? -eq 0 ]; then + sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 2> /dev/null + else + sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 + fi } From 1921a5e0b1ad65f45245457b9c148994f1260350 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 5 Sep 2014 12:59:30 +0530 Subject: [PATCH 106/829] Fixed VIM editor warning for Debian and Ubuntu --- src/modules/site/ee_mod_site_edit.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_edit.sh b/src/modules/site/ee_mod_site_edit.sh index 00f7674d..a3d9ebe7 100644 --- a/src/modules/site/ee_mod_site_edit.sh +++ b/src/modules/site/ee_mod_site_edit.sh @@ -2,7 +2,8 @@ function ee_mod_site_edit() { - grep vim ~/.selected_editor &>> $EE_COMMAND_LOG + # Redirect VIM warning to /dev/null + sensible-editor --help | head -n1 | grep VIM &>> $EE_COMMAND_LOG if [ $? -eq 0 ]; then sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 2> /dev/null else From f0cea1b1143535099038338b77ea778067da4fe5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 9 Sep 2014 15:21:22 +0530 Subject: [PATCH 107/829] Fixes #306 --- bin/easyengine | 3 +++ bin/install | 29 ----------------------------- bin/update | 3 --- 3 files changed, 3 insertions(+), 32 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index a8d2a05e..00dd3ed6 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -148,6 +148,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_error "Found installed Dovecot Packages server, exit status=" 1 fi + # Make hostname as FQDN + ee_lib_check_fqdn $(hostname -f) + # Install Dovecot ee_mod_install_dovecot diff --git a/bin/install b/bin/install index 24efda35..4e83a263 100644 --- a/bin/install +++ b/bin/install @@ -82,32 +82,6 @@ function ee_lib_package_check() done } -# Check hostname is FQDN or not. If not set it -function ee_lib_check_fqdn() -{ - case $1 in - *.*) - if [ "$EE_FQDN" != "" ];then - echo $EE_FQDN > /etc/hostname - if [ "$EE_LINUX_DISTRO" == "Debian" ];then - grep $EE_FQDN /etc/hosts &>> $EE_INSTALL_LOG - if [ $? -ne 0 ]; then - sed -i "1i\127.0.0.1 $EE_FQDN" /etc/hosts \ - || ee_lib_error "Unable setup hostname = " $? - fi - /etc/init.d/hostname.sh start &>> $EE_INSTALL_LOG - else - service hostname restart &>> $EE_INSTALL_LOG - fi - echo "hostname = $(hostname -f)" &>> $EE_INSTALL_LOG - fi - ;; - *) - read -p "Enter hostname [FQDN]: " EE_FQDN - ee_lib_check_fqdn $EE_FQDN - ;; - esac -} # Pre checks to avoid later screw ups # Checking EasyEngine (ee) log directory @@ -211,9 +185,6 @@ fi cp -a /tmp/easyengine/docs/man/ee.8 /usr/share/man/man8/ &>> $EE_INSTALL_LOG \ || ee_lib_error "Unable to copy EasyEngine (ee) man page, exit status = " $? -# Make hostname as FQDN -ee_lib_check_fqdn $(hostname -f) - # Git config settings GIT_USER_NAME=$(git config user.name) GIT_USER_EMAIL=$(git config user.email) diff --git a/bin/update b/bin/update index 278eeb20..0dd1eccc 100644 --- a/bin/update +++ b/bin/update @@ -395,9 +395,6 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then done fi - # Make hostname as FQDN - ee_lib_check_fqdn $(hostname -f) - if [[ $EE_CURRENT_VERSION = 2.0.0 ]]; then dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG if [ $? -eq 0 ]; then From 3d7e7bbf071ef898a1337fb0559903f5d73f202a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 9 Sep 2014 16:02:06 +0530 Subject: [PATCH 108/829] Improved comments --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 00dd3ed6..aac8dd6f 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -148,7 +148,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_error "Found installed Dovecot Packages server, exit status=" 1 fi - # Make hostname as FQDN + # Check hostname is FQDN or not, if not asks user to set hostname as FQDN ee_lib_check_fqdn $(hostname -f) # Install Dovecot From 09ba61cce1631aa35097808895fc18150ffddc98 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 9 Sep 2014 19:56:27 +0530 Subject: [PATCH 109/829] ee cd --- bin/easyengine | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index a8d2a05e..be2a6b95 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -664,6 +664,22 @@ elif [ "$EE_FIRST" = "secure" ]; then ee_lib_echo_escape "\t--ip\tUpdate whitelist IP address" fi +#EasyEngine cd +elif [ "$EE_FIRST" = "cd" ]; then + # Check the website name is empty or not + EE_DOMAIN_CHECK=$EE_SECOND + ee_lib_check_domain + + #Check the website exist + ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ + || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? + + # Change Directory to $EE_DOMAIN webroot + if [ $? -eq 0 ]; then + cd $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g') \ + || ee_lib_error "Unable to change directory for $EE_DOMAIN, exit status = " $? + fi + # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then ee_lib_echo "Please set/use following alias to update EasyEngine (ee)" From ebd151d2dfee2d92b308d68e8761073841f15e14 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 10 Sep 2014 11:01:30 +0530 Subject: [PATCH 110/829] function ee_site_cd --- bin/easyengine | 3 +-- src/modules/site/ee_site_cd.sh | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 src/modules/site/ee_site_cd.sh diff --git a/bin/easyengine b/bin/easyengine index be2a6b95..02c46737 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -676,8 +676,7 @@ elif [ "$EE_FIRST" = "cd" ]; then # Change Directory to $EE_DOMAIN webroot if [ $? -eq 0 ]; then - cd $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g') \ - || ee_lib_error "Unable to change directory for $EE_DOMAIN, exit status = " $? + ee_site_cd fi # EasyEngine update diff --git a/src/modules/site/ee_site_cd.sh b/src/modules/site/ee_site_cd.sh new file mode 100644 index 00000000..aecb4b45 --- /dev/null +++ b/src/modules/site/ee_site_cd.sh @@ -0,0 +1,7 @@ +#CD to Webroot + +function ee_site_cd() +{ + cd $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g') \ + || ee_lib_error "Unable to change directory for $EE_DOMAIN, exit status = " $? +} \ No newline at end of file From ec1b1766adaea346e67005ad83abb146d9aa9bb7 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 10 Sep 2014 16:25:18 +0530 Subject: [PATCH 111/829] ee clean --- bin/easyengine | 18 +++++++++--------- src/modules/stack/ee_cache_clean.sh | 11 +++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 src/modules/stack/ee_cache_clean.sh diff --git a/bin/easyengine b/bin/easyengine index 02c46737..ac92761f 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -667,17 +667,17 @@ elif [ "$EE_FIRST" = "secure" ]; then #EasyEngine cd elif [ "$EE_FIRST" = "cd" ]; then # Check the website name is empty or not - EE_DOMAIN_CHECK=$EE_SECOND - ee_lib_check_domain + EE_DOMAIN_CHECK=$EE_SECOND + ee_lib_check_domain - #Check the website exist - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? + #Check the website exist + ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ + || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - # Change Directory to $EE_DOMAIN webroot - if [ $? -eq 0 ]; then - ee_site_cd - fi + # Change Directory to $EE_DOMAIN webroot + if [ $? -eq 0 ]; then + ee_site_cd + fi # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then diff --git a/src/modules/stack/ee_cache_clean.sh b/src/modules/stack/ee_cache_clean.sh new file mode 100644 index 00000000..0aeb776f --- /dev/null +++ b/src/modules/stack/ee_cache_clean.sh @@ -0,0 +1,11 @@ +#Clean all cache + +function ee_cache_clean() +{ + #Clean fastcgi cache + rm -rf $(grep fastcgi_cache_path /etc/nginx/conf.d/fastcgi.conf | awk '{ print $2 }' | sed 's/$/\/*/g') \ + || ee_lib_error "Unable to clean fastcgi cache, exit status = " $? + + #Clean memcache + service memcached restart &>> $EE_COMMAND_LOG || ee_lib_error "Unable to clean memcache, exit status = " $? +} \ No newline at end of file From 878c522a9623c6f238b101957dd505d2414cc6e4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Sep 2014 12:09:34 +0530 Subject: [PATCH 112/829] Fixed Anemometer not installing on some servers. Added Anemometer user permission --- src/vendor/ee_ven_install_utils.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index 502598d1..c962b3ed 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -70,7 +70,7 @@ function ee_ven_install_utils() # phpinfo() echo -e "" &>> /var/www/22222/htdocs/php/info.php fi - dpkg -l | grep mysql-server &>> $EE_COMMAND_LOG + mysqladmin ping &> /dev/null if [ $? -eq 0 ]; then # Setup Anemometer if [ ! -d /var/www/22222/htdocs/db/anemometer ]; then @@ -116,6 +116,9 @@ function ee_ven_install_utils() echo -e "}" >> /etc/logrotate.d/mysql-server fi + # Set anemometer privileges to databases + mysql -e "grant all privileges on *.* to 'anemometer'@'localhost'" ; + # Download pt-query-advisor Fixed #189 wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? From 6008591abb5d5a3dd73538909be9148ba15f5f67 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Sep 2014 12:18:23 +0530 Subject: [PATCH 113/829] Improved code --- src/vendor/ee_ven_install_utils.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index c962b3ed..a5a9e536 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -87,7 +87,10 @@ function ee_ven_install_utils() || ee_lib_error "Unable to import Anemometer database, exit status = " $? ee_anemometer_pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - mysql -e "grant all on slow_query_log.* to 'anemometer'@'localhost' IDENTIFIED BY '$ee_anemometer_pass';" + mysql -e "grant all on slow_query_log.* to 'anemometer'@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_anemometer_pass';" + + # Grant all privileges for anemometer + mysql -e "grant all privileges on *.* to 'anemometer'@'$EE_MYSQL_GRANT_HOST'" ; # Anemometer configuration cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ @@ -116,9 +119,6 @@ function ee_ven_install_utils() echo -e "}" >> /etc/logrotate.d/mysql-server fi - # Set anemometer privileges to databases - mysql -e "grant all privileges on *.* to 'anemometer'@'localhost'" ; - # Download pt-query-advisor Fixed #189 wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? From 924a3d6e8a63432971ffeafa6c01c473bcd8ee23 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Sep 2014 12:34:26 +0530 Subject: [PATCH 114/829] Anemometer read only permission --- src/vendor/ee_ven_install_utils.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index a5a9e536..7e662be4 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -87,10 +87,12 @@ function ee_ven_install_utils() || ee_lib_error "Unable to import Anemometer database, exit status = " $? ee_anemometer_pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - mysql -e "grant all on slow_query_log.* to 'anemometer'@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_anemometer_pass';" - # Grant all privileges for anemometer - mysql -e "grant all privileges on *.* to 'anemometer'@'$EE_MYSQL_GRANT_HOST'" ; + # Grant select privileges for anemometer + mysql -e "grant select on *.* to 'anemometer'@'$EE_MYSQL_GRANT_HOST'" ; + + # Grant all privileges for slow_query_log database. + mysql -e "grant all on slow_query_log.* to 'anemometer'@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_anemometer_pass';" # Anemometer configuration cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ From e8c61629baf38d52c53a46858b64db3bcc3f2e5e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Sep 2014 14:40:17 +0530 Subject: [PATCH 115/829] Fixed Anemometer hostname issue --- src/vendor/ee_ven_install_utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index 7e662be4..c37e827b 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -108,7 +108,7 @@ function ee_ven_install_utils() echo -e " pt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /etc/logrotate.d/mysql-server echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server echo -e " --history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server - echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"\$HOSTNAME\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server + echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server echo -e "}" >> /etc/logrotate.d/mysql-server else @@ -116,7 +116,7 @@ function ee_ven_install_utils() echo -e " pt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /etc/logrotate.d/mysql-server echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server echo -e " --review-history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server - echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"\$HOSTNAME\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server + echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server echo -e "}" >> /etc/logrotate.d/mysql-server fi From 96a3f0e46f225be90a016a7659cbc6cdf0365859 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Sep 2014 17:38:52 +0530 Subject: [PATCH 116/829] Addedd mailscanner install/remove/purge functions --- bin/easyengine | 42 +++++++++++++++++-- ...ilscan.sh => ee_mod_install_mailscaner.sh} | 2 +- ...mailscan.sh => ee_mod_setup_mailscaner.sh} | 4 +- .../remove/mail/ee_mod_remove_mailscan.sh | 9 ---- .../remove/mail/ee_mod_remove_mailscaner.sh | 17 ++++++++ 5 files changed, 58 insertions(+), 16 deletions(-) rename src/modules/stack/install/mail/{ee_mod_install_mailscan.sh => ee_mod_install_mailscaner.sh} (90%) rename src/modules/stack/install/mail/{ee_mod_setup_mailscan.sh => ee_mod_setup_mailscaner.sh} (97%) delete mode 100644 src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh create mode 100644 src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh diff --git a/bin/easyengine b/bin/easyengine index aac8dd6f..6dc1805d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -155,7 +155,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_mod_install_dovecot # Install mail scanner packages - ee_mod_install_mailscan + ee_mod_install_mailscaner # Install ViMbAdmin ee_ven_install_vimbadmin @@ -170,7 +170,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_mod_setup_dovecot # Setup Amavis - ee_mod_setup_mailscan + ee_mod_setup_mailscaner # Setup ViMbAdmin ee_ven_setup_vimbadmin @@ -190,6 +190,18 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo_escape "Security Salt:\t\t${ee_security_salt}\n" ee_lib_echo "Successfully installed mail server packages" + elif [ "$EE_THIRD" = "mailscanner"]; then + + # Install Mail Scanner + ee_mod_install_mailscaner + + # Setup Mail Scanner + ee_mod_setup_mailscaner + + ee_lib_service nginx postfix dovecot amavis restart + + ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Installed Mail Scanner" + ee_lib_echo "Successfully installed mail scanner packages" fi # EasyEngine remove/purge @@ -242,8 +254,8 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Remove Dovecot ee_mod_remove_dovecot - # Remove Amavis - ee_mod_remove_mailscan + # Remove Mail Scanner + ee_mod_remove_mailscaner # Remove ViMbAdmin ee_ven_remove_vimbadmin @@ -254,12 +266,34 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Execute: apt-get autoremove ee_lib_autoremove + # Restart Nginx + ee_lib_service nginx + + ee_lib_git /etc/nginx "Removed Mail Server" + # Display success message if [ "$EE_SECOND" = "remove" ];then ee_lib_echo "Successfully removed mail server packages" elif [ "$EE_SECOND" = "purge" ];then ee_lib_echo "Successfully purged mail server packages" fi + elif [ "$EE_THIRD" = "mailscanner"]; then + # Remove Amavis + ee_mod_remove_mailscaner + + # Execute: apt-get autoremove + ee_lib_autoremove + + ee_lib_service nginx postfix dovecot restart + + ee_lib_git /etc/postfix "Removed mailscanner" + + # Display success message + if [ "$EE_SECOND" = "remove" ];then + ee_lib_echo "Successfully removed Mail Scanner packages" + elif [ "$EE_SECOND" = "purge" ];then + ee_lib_echo "Successfully purged Mail Scanner packages" + fi fi elif [ "$EE_SECOND" = "status" ]; then diff --git a/src/modules/stack/install/mail/ee_mod_install_mailscan.sh b/src/modules/stack/install/mail/ee_mod_install_mailscaner.sh similarity index 90% rename from src/modules/stack/install/mail/ee_mod_install_mailscan.sh rename to src/modules/stack/install/mail/ee_mod_install_mailscaner.sh index 18559f74..4c3c5b7b 100644 --- a/src/modules/stack/install/mail/ee_mod_install_mailscan.sh +++ b/src/modules/stack/install/mail/ee_mod_install_mailscaner.sh @@ -1,6 +1,6 @@ # Install Amavis package -function ee_mod_install_mailscan() +function ee_mod_install_mailscaner() { # Install Amavis ee_lib_echo "Installing Amavis, SpamAssassin and ClamAV, please wait..." diff --git a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh similarity index 97% rename from src/modules/stack/install/mail/ee_mod_setup_mailscan.sh rename to src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh index 8fe08a1f..59c17249 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_mailscan.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh @@ -1,8 +1,8 @@ # Install mail scanner packages -function ee_mod_setup_mailscan() +function ee_mod_setup_mailscaner() { - # Confiure Amavis + # Configure Amavis ee_lib_echo "Setting up Amavis, please wait..." sed -i "s'#@'@'" /etc/amavis/conf.d/15-content_filter_mode && \ diff --git a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh b/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh deleted file mode 100644 index d893959f..00000000 --- a/src/modules/stack/remove/mail/ee_mod_remove_mailscan.sh +++ /dev/null @@ -1,9 +0,0 @@ -# Remove MailScan package - -function ee_mod_remove_mailscan() -{ - ee_lib_echo "$EE_SECOND Amavis, SpamAssassin and ClamAV package, please wait..." - $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch lzop cabextract p7zip rpm unrar-free \ - || ee_lib_error "Unable to $EE_SECOND Amavis, SpamAssassin and ClamAV,, exit status = " $? - -} diff --git a/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh b/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh new file mode 100644 index 00000000..e26dd16e --- /dev/null +++ b/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh @@ -0,0 +1,17 @@ +# Remove MailScan package + +function ee_mod_remove_mailscaner() +{ + + # Remove Amavis configuration from Postfix configuration + sed -i '/content_filter/d' /etc/postfix/main.cf + sed -i '/content_filter/d' /etc/postfix/master.cf + sed -i '/receive_override_options/d' /etc/postfix/master.cf + sed -i '/smtp-amavis/,$d' /etc/postfix/master.cf + + #Remove/Purge mailscan packages + ee_lib_echo "$EE_SECOND Amavis, SpamAssassin and ClamAV package, please wait..." + $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch lzop cabextract p7zip rpm unrar-free \ + || ee_lib_error "Unable to $EE_SECOND Amavis, SpamAssassin and ClamAV,, exit status = " $? + +} From b7b493bae56d23c5fcfbde7d1ca46f503da49a66 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Sep 2014 18:42:54 +0530 Subject: [PATCH 117/829] Fixed space issue --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 6dc1805d..39411ac4 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -277,7 +277,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then elif [ "$EE_SECOND" = "purge" ];then ee_lib_echo "Successfully purged mail server packages" fi - elif [ "$EE_THIRD" = "mailscanner"]; then + elif [ "$EE_THIRD" = "mailscanner" ]; then # Remove Amavis ee_mod_remove_mailscaner From 143bb7a78c0f7d6cf47eb1d2bcd338aa7d078f9c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Sep 2014 18:47:29 +0530 Subject: [PATCH 118/829] Improved comments --- src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh b/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh index e26dd16e..17cef9ee 100644 --- a/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh +++ b/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh @@ -4,6 +4,7 @@ function ee_mod_remove_mailscaner() { # Remove Amavis configuration from Postfix configuration + # Better approach is: postconf -X "content_filter", But available for Postfix 2.11 (latest) sed -i '/content_filter/d' /etc/postfix/main.cf sed -i '/content_filter/d' /etc/postfix/master.cf sed -i '/receive_override_options/d' /etc/postfix/master.cf From 665098f914480320aab3abc204a20f8fb656547a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Sep 2014 18:54:13 +0530 Subject: [PATCH 119/829] Fixed typo --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 39411ac4..fc023082 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -190,7 +190,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo_escape "Security Salt:\t\t${ee_security_salt}\n" ee_lib_echo "Successfully installed mail server packages" - elif [ "$EE_THIRD" = "mailscanner"]; then + elif [ "$EE_THIRD" = "mailscanner" ]; then # Install Mail Scanner ee_mod_install_mailscaner From 1579db57212a1e76a6f0e0a4cce9578ef1a5999d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 11 Sep 2014 19:15:55 +0530 Subject: [PATCH 120/829] ee site log --- src/modules/site/ee_mod_site_log.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/modules/site/ee_mod_site_log.sh diff --git a/src/modules/site/ee_mod_site_log.sh b/src/modules/site/ee_mod_site_log.sh new file mode 100644 index 00000000..ed4afbdc --- /dev/null +++ b/src/modules/site/ee_mod_site_log.sh @@ -0,0 +1,26 @@ +# Checks log + +function ee_mod_site_log() +{ + # + if [ $# -eq 0 ]; then + for site in $(ls /etc/nginx/sites-available/*); do + ee_log_path="$ee_log_path /var/log/nginx/$(basename $site).*.log" + done + else + for $ee_domain_name in $@; do + + EE_DOMAIN_CHECK=$ee_domain_name + ee_lib_check_domain + + # Check the website exist + ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ + || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? + + if [ $? -eq 0 ]; then + ee_log_path="$ee_log_path /var/log/nginx/$EE_DOMAIN.*.log" + fi + done + fi + tail -f ${ee_log_path} +} From 981735f42d3a118d8053f892175a2fecec720a0f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 11 Sep 2014 19:18:58 +0530 Subject: [PATCH 121/829] ee site log --- bin/easyengine | 5 +++++ src/modules/stack/ee_cache_clean.sh | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index ac92761f..93af29b7 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -275,6 +275,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo_escape "\trestart\tRestart NGINX, PHP5, MySQL and Postfix service" fi + # EasyEngine site elif [ "$EE_FIRST" = "site" ]; then if [ "$EE_SECOND" = "list" ]; then @@ -542,6 +543,10 @@ elif [ "$EE_FIRST" = "site" ]; then # Execute: service nginx reload ee_lib_service nginx reload fi + elif [ "$EE_SECOND" = "log" ]; then + # tail -f log + ee_site_check_logs ${@:3}|| ee_lib_error "Unable to check logs, exit status = " $? + else ee_lib_echo "ee site commands:" ee_lib_echo_escape "\tlist\tList NGINX enabled website" diff --git a/src/modules/stack/ee_cache_clean.sh b/src/modules/stack/ee_cache_clean.sh index 0aeb776f..81aee59a 100644 --- a/src/modules/stack/ee_cache_clean.sh +++ b/src/modules/stack/ee_cache_clean.sh @@ -1,11 +1,16 @@ -#Clean all cache +# Clean all cache function ee_cache_clean() { - #Clean fastcgi cache - rm -rf $(grep fastcgi_cache_path /etc/nginx/conf.d/fastcgi.conf | awk '{ print $2 }' | sed 's/$/\/*/g') \ - || ee_lib_error "Unable to clean fastcgi cache, exit status = " $? + # Clean fastcgi cache + if [ -d /var/run/nginx-cache/ ]; then + rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG + fi - #Clean memcache - service memcached restart &>> $EE_COMMAND_LOG || ee_lib_error "Unable to clean memcache, exit status = " $? -} \ No newline at end of file + # Clean memcache + dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG + + if [ $? -eq 0 ];then + service memcached restart &>> $EE_COMMAND_LOG + fi +} From 7572d9fae993f072607b40cf8ce9247e256cb08f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 12 Sep 2014 11:28:05 +0530 Subject: [PATCH 122/829] Updated WP_CLI version --- src/lib/ee_lib_variables.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index c5b2113e..67eca071 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -4,7 +4,7 @@ readonly EE_VERSION='2.1.0' # WP-CLI version -readonly EE_WP_CLI_VERSION='0.16.0' +readonly EE_WP_CLI_VERSION='0.17.0' # Adminer version readonly EE_ADMINER_VERSION='4.1.0' From 74686d072a17002e3952f7c129356f190e1dc166 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 12 Sep 2014 11:38:43 +0530 Subject: [PATCH 123/829] Added GEOIP Module --- src/modules/stack/install/ee_mod_install_php.sh | 2 +- src/modules/stack/install/ee_mod_setup_php.sh | 7 ++++++- src/modules/stack/remove/ee_mod_remove_php.sh | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/stack/install/ee_mod_install_php.sh b/src/modules/stack/install/ee_mod_install_php.sh index 57b36c96..db30fadd 100644 --- a/src/modules/stack/install/ee_mod_install_php.sh +++ b/src/modules/stack/install/ee_mod_install_php.sh @@ -5,5 +5,5 @@ function ee_mod_install_php() ee_lib_echo "Installing PHP, please wait..." $EE_APT_GET install php5-common php5-mysqlnd php5-xmlrpc \ php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached || ee_lib_error "Unable to install PHP5, exit status = " $? + php5-memcache memcached php5-geoip || ee_lib_error "Unable to install PHP5, exit status = " $? } diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh index d86399e1..944ae0d4 100644 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ b/src/modules/stack/install/ee_mod_setup_php.sh @@ -61,5 +61,10 @@ function ee_mod_setup_php() echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/ \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to add xdebug settings for debug pool, exit status = " $? - fi + ee_lib_echo "Downloading GeoIP Database, please wait..." + mkdir -p /usr/share/GeoIP + wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz /usr/share/GeoIP/GeoIPCity.dat http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz + gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz + mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat + fi } diff --git a/src/modules/stack/remove/ee_mod_remove_php.sh b/src/modules/stack/remove/ee_mod_remove_php.sh index 528ea80b..2ade5bba 100644 --- a/src/modules/stack/remove/ee_mod_remove_php.sh +++ b/src/modules/stack/remove/ee_mod_remove_php.sh @@ -5,5 +5,5 @@ function ee_mod_remove_php() ee_lib_echo "$EE_SECOND PHP5 package, please wait..." $EE_APT_GET $EE_SECOND php5-common php5-mysqlnd php5-xmlrpc \ php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached || ee_lib_error "Unable to $EE_SECOND PHP5, exit status = " $? + php5-memcache memcached php5-geoip || ee_lib_error "Unable to $EE_SECOND PHP5, exit status = " $? } From 8ca82991ef448ab7ad588da5260fd6ddc6567a86 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 12 Sep 2014 12:00:50 +0530 Subject: [PATCH 124/829] ee site info webroot path --- src/modules/site/ee_mod_site_info.sh | 12 ++++++------ src/modules/site/ee_mod_site_log.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/site/ee_mod_site_info.sh b/src/modules/site/ee_mod_site_info.sh index 64405f24..fdbff096 100644 --- a/src/modules/site/ee_mod_site_info.sh +++ b/src/modules/site/ee_mod_site_info.sh @@ -14,17 +14,17 @@ function ee_mod_site_info() ee_lib_echo_escape "error_log\t\t \033[37m$ee_error_log" ee_lib_echo_escape "Webroot\t\t\t \033[37m$ee_webroot" - if [ -f /var/www/$EE_DOMAIN/*-config.php ]; then - local ee_db_name=$(grep DB_NAME /var/www/$EE_DOMAIN/*-config.php 2> /dev/null | cut -d"'" -f4) - local ee_db_user=$(grep DB_USER /var/www/$EE_DOMAIN/*-config.php 2> /dev/null | cut -d"'" -f4) - local ee_db_pass=$(grep DB_PASS /var/www/$EE_DOMAIN/*-config.php 2> /dev/null | cut -d"'" -f4) + if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then + local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + local ee_db_user=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + local ee_db_pass=$(grep DB_PASS $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) ee_lib_echo_escape "DB_NAME\t\t\t \033[37m$ee_db_name" ee_lib_echo_escape "DB_USER\t\t\t \033[37m$ee_db_user" ee_lib_echo_escape "DB_PASS\t\t\t \033[37m$ee_db_pass" - if [ -f /var/www/$EE_DOMAIN/wp-config.php ]; then - local ee_table_prefix=$(grep table_prefix /var/www/$EE_DOMAIN/wp-config.php 2> /dev/null | cut -d"'" -f2) + if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/wp-config.php/') ]; then + local ee_table_prefix=$(grep table_prefix $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/wp-config.php/') | cut -d"'" -f2) ee_lib_echo_escape "table_prefix\t\t \033[37m$ee_table_prefix" fi fi diff --git a/src/modules/site/ee_mod_site_log.sh b/src/modules/site/ee_mod_site_log.sh index ed4afbdc..ea15d81a 100644 --- a/src/modules/site/ee_mod_site_log.sh +++ b/src/modules/site/ee_mod_site_log.sh @@ -2,7 +2,7 @@ function ee_mod_site_log() { - # + # Check if domain name present if [ $# -eq 0 ]; then for site in $(ls /etc/nginx/sites-available/*); do ee_log_path="$ee_log_path /var/log/nginx/$(basename $site).*.log" From d639970a653a927259d8e81ff3f9892503ac7472 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 12 Sep 2014 12:13:19 +0530 Subject: [PATCH 125/829] easyengine ee_site_log --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 93af29b7..7b6bd050 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -545,7 +545,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi elif [ "$EE_SECOND" = "log" ]; then # tail -f log - ee_site_check_logs ${@:3}|| ee_lib_error "Unable to check logs, exit status = " $? + ee_mod_site_log ${@:3}|| ee_lib_error "Unable to check logs, exit status = " $? else ee_lib_echo "ee site commands:" From 8207c6353885abffb97be3e796c84b7eb1356768 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 12 Sep 2014 12:56:18 +0530 Subject: [PATCH 126/829] Defined RAM based matrix --- src/lib/ee_lib_ram.sh | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/lib/ee_lib_ram.sh diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh new file mode 100644 index 00000000..276ad933 --- /dev/null +++ b/src/lib/ee_lib_ram.sh @@ -0,0 +1,45 @@ +# EasyEngine RAM based settings + +function ee_lib_ram() +{ + # Detect RAM of System + readonly EE_TOTAL_RAM=$(free -m | grep -i Mem | awk '{ print $2 }') + + # RAM < 512MB + if [ $EE_TOTAL_RAM -le 512 ]; then + EE_OPCACHE_SIZE="64" + EE_MEMCACHE_SIZE="64" + EE_PHP_MAX_CHILDREN="10" + EE_SETUP_MAILSCANNER="no" + # RAM > 512MB and RAM < 1024 + elif [ $EE_TOTAL_RAM -gt 512 ] && [ $EE_TOTAL_RAM -le 1024 ]; then + EE_OPCACHE_SIZE="128" + EE_MEMCACHE_SIZE="128" + EE_PHP_MAX_CHILDREN="10" + # RAM > 512MB and RAM < 1024 + elif [ $EE_TOTAL_RAM -gt 1024 ] && [ $EE_TOTAL_RAM -le 2048 ]; then + EE_OPCACHE_SIZE="256" + EE_MEMCACHE_SIZE="256" + EE_PHP_MAX_CHILDREN="20" + # RAM > 512MB and RAM < 1024 + elif [ $EE_TOTAL_RAM -gt 2048 ] && [ $EE_TOTAL_RAM -le 4096 ]; then + EE_OPCACHE_SIZE="512" + EE_MEMCACHE_SIZE="512" + EE_PHP_MAX_CHILDREN="40" + # RAM > 512MB and RAM < 1024 + elif [ $EE_TOTAL_RAM -gt 4096 ] && [ $EE_TOTAL_RAM -le 8192 ]; then + EE_OPCACHE_SIZE="512" + EE_MEMCACHE_SIZE="1024" + EE_PHP_MAX_CHILDREN="80" + # RAM > 512MB and RAM < 1024 + elif [ $EE_TOTAL_RAM -gt 8192 ] && [ $EE_TOTAL_RAM -le 16384 ]; then + EE_OPCACHE_SIZE="512" + EE_MEMCACHE_SIZE="2048" + EE_PHP_MAX_CHILDREN="100" + # RAM > 512MB and RAM < 1024 + elif [ $EE_TOTAL_RAM -gt 16384 ]; then + EE_OPCACHE_SIZE="512" + EE_MEMCACHE_SIZE="2048" + EE_PHP_MAX_CHILDREN="100" + fi +} \ No newline at end of file From dd4a3e42f1959ce885f9075aa29c3aa9185fcf60 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 12 Sep 2014 13:00:33 +0530 Subject: [PATCH 127/829] Improved comments --- src/lib/ee_lib_ram.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh index 276ad933..3144140d 100644 --- a/src/lib/ee_lib_ram.sh +++ b/src/lib/ee_lib_ram.sh @@ -11,32 +11,32 @@ function ee_lib_ram() EE_MEMCACHE_SIZE="64" EE_PHP_MAX_CHILDREN="10" EE_SETUP_MAILSCANNER="no" - # RAM > 512MB and RAM < 1024 + # RAM > 512MB and RAM < 1024MB elif [ $EE_TOTAL_RAM -gt 512 ] && [ $EE_TOTAL_RAM -le 1024 ]; then EE_OPCACHE_SIZE="128" EE_MEMCACHE_SIZE="128" EE_PHP_MAX_CHILDREN="10" - # RAM > 512MB and RAM < 1024 + # RAM > 1024MB and RAM < 2048MB elif [ $EE_TOTAL_RAM -gt 1024 ] && [ $EE_TOTAL_RAM -le 2048 ]; then EE_OPCACHE_SIZE="256" EE_MEMCACHE_SIZE="256" EE_PHP_MAX_CHILDREN="20" - # RAM > 512MB and RAM < 1024 + # RAM > 2048MB and RAM < 4096MB elif [ $EE_TOTAL_RAM -gt 2048 ] && [ $EE_TOTAL_RAM -le 4096 ]; then EE_OPCACHE_SIZE="512" EE_MEMCACHE_SIZE="512" EE_PHP_MAX_CHILDREN="40" - # RAM > 512MB and RAM < 1024 + # RAM > 4096MB and RAM < 8192MB elif [ $EE_TOTAL_RAM -gt 4096 ] && [ $EE_TOTAL_RAM -le 8192 ]; then EE_OPCACHE_SIZE="512" EE_MEMCACHE_SIZE="1024" EE_PHP_MAX_CHILDREN="80" - # RAM > 512MB and RAM < 1024 + # RAM > 8192MB and RAM < 16384MB elif [ $EE_TOTAL_RAM -gt 8192 ] && [ $EE_TOTAL_RAM -le 16384 ]; then EE_OPCACHE_SIZE="512" EE_MEMCACHE_SIZE="2048" EE_PHP_MAX_CHILDREN="100" - # RAM > 512MB and RAM < 1024 + # RAM > 16384MB elif [ $EE_TOTAL_RAM -gt 16384 ]; then EE_OPCACHE_SIZE="512" EE_MEMCACHE_SIZE="2048" From c639b694bdbdd8a25d94795fcf0e082c855cf421 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 12 Sep 2014 13:45:41 +0530 Subject: [PATCH 128/829] variable change --- src/modules/site/ee_mod_site_log.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/site/ee_mod_site_log.sh b/src/modules/site/ee_mod_site_log.sh index ea15d81a..23264ffa 100644 --- a/src/modules/site/ee_mod_site_log.sh +++ b/src/modules/site/ee_mod_site_log.sh @@ -4,11 +4,11 @@ function ee_mod_site_log() { # Check if domain name present if [ $# -eq 0 ]; then - for site in $(ls /etc/nginx/sites-available/*); do - ee_log_path="$ee_log_path /var/log/nginx/$(basename $site).*.log" + for ee_domain_name in $(ls /etc/nginx/sites-available/*); do + ee_log_path="$ee_log_path /var/log/nginx/$(basename $ee_domain_name).*.log" done else - for $ee_domain_name in $@; do + for ee_domain_name in $@; do EE_DOMAIN_CHECK=$ee_domain_name ee_lib_check_domain From 93aca8ca105cc0c26ca81ad256a9842bf63f9e1c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 12 Sep 2014 15:19:43 +0530 Subject: [PATCH 129/829] Fixed Amvis ViMbAdmin password issue, Fixed RAM based installation of Mail scanner --- bin/easyengine | 19 +++++++++++++------ .../install/mail/ee_mod_setup_mailscaner.sh | 9 +++++++++ src/vendor/ee_ven_setup_vimbadmin.sh | 6 +----- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index fc023082..d5a5458f 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -45,6 +45,8 @@ elif [ "$EE_FIRST" = "info" ];then elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # EasyEngine install if [ "$EE_SECOND" = "install" ]; then + # Detect RAM of system and initialize the variables. + ee_lib_ram if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ]; then # Setup NGINX/PHP repository @@ -154,8 +156,6 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Install Dovecot ee_mod_install_dovecot - # Install mail scanner packages - ee_mod_install_mailscaner # Install ViMbAdmin ee_ven_install_vimbadmin @@ -169,9 +169,6 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Configure Dovecot ee_mod_setup_dovecot - # Setup Amavis - ee_mod_setup_mailscaner - # Setup ViMbAdmin ee_ven_setup_vimbadmin @@ -180,7 +177,17 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Setup Sieve Rules ee_mod_setup_sieve - + + if [ "$EE_SETUP_MAILSCANNER" != "no" ]; then + # Install mail scanner packages + ee_mod_install_mailscaner + + # Setup Amavis + ee_mod_setup_mailscaner + else + ee_lib_echo "Found RAM less than 512MB, not installing Mail Scanner packages" + + fi ee_lib_service nginx postfix dovecot amavis restart ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Initialize Git" diff --git a/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh index 59c17249..46a391df 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh @@ -25,6 +25,15 @@ function ee_mod_setup_mailscaner() || ee_lib_error "Unable to setup Amavis, exit status = " $? cat /usr/share/easyengine/mail/amavis-master.cf >> /etc/postfix/master.cf + # Grep ViMbAdmin host and Password from Postfix Configuration + ee_vimbadmin_host=$(grep password /etc/postfix/mysql/virtual_alias_maps.cf | awk '{ print $3 }') + ee_vimbadmin_password=$(grep hosts /etc/postfix/mysql/virtual_alias_maps.cf | awk '{ print $3 }') + + # Changing hosts and password of ViMbAdmin database in Amavis configuration + sed -i "s/127.0.0.1/$ee_vimbadmin_host/" /etc/amavis/conf.d/50-user && + sed -i "s/password/$ee_vimbadmin_password/" /etc/amavis/conf.d/50-user \ + || ee_lib_error "Unable to setup ViMbAdmin database details in Amavis configuration, exit status = " $? + # Configure ClamAv and Amavis to each other files adduser clamav amavis &>> $EE_COMMAND_LOG adduser amavis clamav &>> $EE_COMMAND_LOG diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh index 993b94fc..4ad1509d 100644 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ b/src/vendor/ee_ven_setup_vimbadmin.sh @@ -36,6 +36,7 @@ function ee_ven_setup_vimbadmin() || ee_lib_error "Unable to setup ViMbAdmin configuration file, exit status = " $? # Changing hosts and password of ViMbAdmin database in postfix configuration + # Note: As Amavis is optional, Amavis ViMbAdmin settings are present is ee_mod_setup_mailscaner function sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_alias_maps.cf && sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_alias_maps.cf \ || ee_lib_error "Unable to setup ViMbAdmin database details in virtual_alias_maps.cf file, exit status = " $? @@ -52,11 +53,6 @@ function ee_ven_setup_vimbadmin() sed -i "s/hosts=localhost/hosts=$ee_vimbadmin_host/" /etc/dovecot/dovecot-sql.conf.ext \ || ee_lib_error "Unable to setup ViMbAdmin database details in dovecot-sql.conf.ext file, exit status = " $? - # Changing hosts and password of ViMbAdmin database in Amavis configuration - sed -i "s/127.0.0.1/$ee_vimbadmin_host/" /etc/amavis/conf.d/50-user && - sed -i "s/password/$ee_random/" /etc/amavis/conf.d/50-user \ - || ee_lib_error "Unable to setup ViMbAdmin database details in 50-user file, exit status = " $? - # Copying HTACCESS cp -av /var/www/22222/htdocs/vimbadmin/public/.htaccess.dist /var/www/22222/htdocs/vimbadmin/public/.htaccess &>> $EE_COMMAND_LOG From 21ab5fb7bd12128f7d60592e228fc9d627077140 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 12 Sep 2014 15:41:08 +0530 Subject: [PATCH 130/829] Fixed Typo --- src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh index 46a391df..2c5f0013 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh @@ -26,8 +26,8 @@ function ee_mod_setup_mailscaner() cat /usr/share/easyengine/mail/amavis-master.cf >> /etc/postfix/master.cf # Grep ViMbAdmin host and Password from Postfix Configuration - ee_vimbadmin_host=$(grep password /etc/postfix/mysql/virtual_alias_maps.cf | awk '{ print $3 }') - ee_vimbadmin_password=$(grep hosts /etc/postfix/mysql/virtual_alias_maps.cf | awk '{ print $3 }') + ee_vimbadmin_host=$(grep hosts /etc/postfix/mysql/virtual_alias_maps.cf | awk '{ print $3 }') + ee_vimbadmin_password=$(grep password /etc/postfix/mysql/virtual_alias_maps.cf | awk '{ print $3 }') # Changing hosts and password of ViMbAdmin database in Amavis configuration sed -i "s/127.0.0.1/$ee_vimbadmin_host/" /etc/amavis/conf.d/50-user && From 8d8a8b3b5bdd702fef9ed29bee92f5e1ec19b6f4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 12 Sep 2014 16:10:00 +0530 Subject: [PATCH 131/829] Dovecot check added for Mail Scanner Packages --- bin/easyengine | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index d5a5458f..af58f01d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -147,7 +147,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null if [ $? -eq 0 ];then - ee_lib_error "Found installed Dovecot Packages server, exit status=" 1 + ee_lib_error "Found installed Dovecot Packages, exit status=" 1 fi # Check hostname is FQDN or not, if not asks user to set hostname as FQDN @@ -186,7 +186,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_mod_setup_mailscaner else ee_lib_echo "Found RAM less than 512MB, not installing Mail Scanner packages" - + fi ee_lib_service nginx postfix dovecot amavis restart @@ -198,6 +198,11 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo "Successfully installed mail server packages" elif [ "$EE_THIRD" = "mailscanner" ]; then + + dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null + if [ $? -ne 0 ];then + ee_lib_error "Failed to find Dovecot Packages, exit status = " 1 + fi # Install Mail Scanner ee_mod_install_mailscaner From 15b167d066da7afb581b1382899d9c1f4f783811 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 12 Sep 2014 17:56:58 +0530 Subject: [PATCH 132/829] Updated Message --- bin/easyengine | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index af58f01d..6ea58436 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -185,8 +185,8 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Setup Amavis ee_mod_setup_mailscaner else - ee_lib_echo "Found RAM less than 512MB, not installing Mail Scanner packages" - + ee_lib_echo_fail "RAM is less then 512MB, EasyEngine skip installing Mail Scanner Packages" + fi ee_lib_service nginx postfix dovecot amavis restart From 082f725a5156679e8e3716d97eaa25768ea97f13 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 12 Sep 2014 19:27:29 +0530 Subject: [PATCH 133/829] ee_mod_cache_clean --- src/modules/site/ee_mod_site_log.sh | 2 +- src/modules/stack/ee_cache_clean.sh | 16 ----------- src/modules/stack/ee_mod_cache_clean.sh | 35 +++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 17 deletions(-) delete mode 100644 src/modules/stack/ee_cache_clean.sh create mode 100644 src/modules/stack/ee_mod_cache_clean.sh diff --git a/src/modules/site/ee_mod_site_log.sh b/src/modules/site/ee_mod_site_log.sh index 23264ffa..5fe46082 100644 --- a/src/modules/site/ee_mod_site_log.sh +++ b/src/modules/site/ee_mod_site_log.sh @@ -2,7 +2,7 @@ function ee_mod_site_log() { - # Check if domain name present + # Check if domain name passed if [ $# -eq 0 ]; then for ee_domain_name in $(ls /etc/nginx/sites-available/*); do ee_log_path="$ee_log_path /var/log/nginx/$(basename $ee_domain_name).*.log" diff --git a/src/modules/stack/ee_cache_clean.sh b/src/modules/stack/ee_cache_clean.sh deleted file mode 100644 index 81aee59a..00000000 --- a/src/modules/stack/ee_cache_clean.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Clean all cache - -function ee_cache_clean() -{ - # Clean fastcgi cache - if [ -d /var/run/nginx-cache/ ]; then - rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG - fi - - # Clean memcache - dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG - - if [ $? -eq 0 ];then - service memcached restart &>> $EE_COMMAND_LOG - fi -} diff --git a/src/modules/stack/ee_mod_cache_clean.sh b/src/modules/stack/ee_mod_cache_clean.sh new file mode 100644 index 00000000..599f95e0 --- /dev/null +++ b/src/modules/stack/ee_mod_cache_clean.sh @@ -0,0 +1,35 @@ +# Clean all cache + +function ee_mod_cache_clean() +{ + + for ee_param in $@ ; do + + if [ "$ee_param" = "" ] || [ "$ee_param" = "fastcgi" ] || [ "$ee_param" = "all" ]; then + # Clean fastcgi cache + ee_lib_echo "Cleaning FastCGI cache, please wait .... " + if [ -d /var/run/nginx-cache/ ]; then + rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG + fi + fi + + if [ "$ee_param" = "memcache" ] || [ "$ee_param" = "all" ]; then + # Clean memcache + ee_lib_echo "Cleaning Memcache, please wait .... " + dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ + || ee_lib_error "Memcache not installed, exit status = " $? + if [ $? -eq 0 ];then + service memcached restart &>> $EE_COMMAND_LOG + fi + fi + + if [ "$ee_param" = "opcache" ] || [ "$ee_param" = "all" ]; then + # Clean opcache + ee_lib_echo "Cleaning OPcache, please wait .... " + wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ + || ee_lib_error "Unable to clean OPcache, exit status = " $? + + fi + done + +} From d5cdd8eab6e8439d7d193886ef487d74b0c2bcf1 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 15 Sep 2014 12:31:29 +0530 Subject: [PATCH 134/829] ee clean parameters --- bin/easyengine | 5 ++ src/modules/stack/ee_mod_cache_clean.sh | 65 ++++++++++++++----------- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 7b6bd050..47699deb 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -684,6 +684,11 @@ elif [ "$EE_FIRST" = "cd" ]; then ee_site_cd fi +# EasyEngine clean +elif [ "$EE_FIRST" = "clean" ]; then + ee_mod_cache_clean ${@:2} || ee_lib_error "Unable to clean cache = " $? + + # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then ee_lib_echo "Please set/use following alias to update EasyEngine (ee)" diff --git a/src/modules/stack/ee_mod_cache_clean.sh b/src/modules/stack/ee_mod_cache_clean.sh index 599f95e0..939feb26 100644 --- a/src/modules/stack/ee_mod_cache_clean.sh +++ b/src/modules/stack/ee_mod_cache_clean.sh @@ -3,33 +3,42 @@ function ee_mod_cache_clean() { - for ee_param in $@ ; do - - if [ "$ee_param" = "" ] || [ "$ee_param" = "fastcgi" ] || [ "$ee_param" = "all" ]; then - # Clean fastcgi cache - ee_lib_echo "Cleaning FastCGI cache, please wait .... " - if [ -d /var/run/nginx-cache/ ]; then - rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG - fi - fi - - if [ "$ee_param" = "memcache" ] || [ "$ee_param" = "all" ]; then - # Clean memcache - ee_lib_echo "Cleaning Memcache, please wait .... " - dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ - || ee_lib_error "Memcache not installed, exit status = " $? - if [ $? -eq 0 ];then - service memcached restart &>> $EE_COMMAND_LOG - fi - fi - - if [ "$ee_param" = "opcache" ] || [ "$ee_param" = "all" ]; then - # Clean opcache - ee_lib_echo "Cleaning OPcache, please wait .... " - wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ - || ee_lib_error "Unable to clean OPcache, exit status = " $? - - fi - done + # ee clean + if [ $# -eq 0 ]; then + ee_lib_echo "Cleaning FastCGI cache, please wait .... " + if [ -d /var/run/nginx-cache/ ]; then + rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG + fi + fi + + # ee clean fastcgi|memcache|opcache + for ee_param in $@ ; do + + if [ "$ee_param" = "fastcgi" ] || [ "$ee_param" = "all" ]; then + # Clean fastcgi cache + ee_lib_echo "Cleaning FastCGI cache, please wait .... " + if [ -d /var/run/nginx-cache/ ]; then + rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG + fi + elif [ "$ee_param" = "memcache" ] || [ "$ee_param" = "all" ]; then + # Clean memcache + ee_lib_echo "Cleaning Memcache, please wait .... " + dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ + || ee_lib_error "Memcache not installed, exit status = " $? + if [ $? -eq 0 ];then + service memcached restart &>> $EE_COMMAND_LOG + fi + + elif [ "$ee_param" = "opcache" ] || [ "$ee_param" = "all" ]; then + # Clean opcache + ee_lib_echo "Cleaning OPcache, please wait .... " + wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ + || ee_lib_error "Unable to clean OPcache, exit status = " $? + + else + ee_lib_error "Invalid option selected, choose correct option, exit status = " $? + fi + done + } From 928ae3b7cefe1c7b411ccff954927a4003f3fd21 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Sep 2014 16:41:16 +0530 Subject: [PATCH 135/829] Fixed Managsieve Plugin issue --- src/modules/stack/install/mail/ee_mod_setup_sieve.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index 40cf3889..6c875b4f 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -28,7 +28,14 @@ function ee_mod_setup_sieve() || ee_lib_error "Unable to compile Sieve rules, exit status = " $? # Configure Roundcube - sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'sieverules',:" /var/www/roundcubemail/htdocs/config/config.inc.php \ + sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'managesieve',:" /var/www/roundcubemail/htdocs/config/config.inc.php \ || ee_lib_error "Unable to configure Sieve Roundcube plugin, exit status = " $? - echo "\$config['sieverules_port'] = 4190;" >> /var/www/roundcubemail/htdocs/config/config.inc.php + + # Configure ManageSieve Plugin + cp -v /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php.dist /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to configure ManageSieve Roundcube plugin, exit status = " $? + + sed -i "s:\$config\['managesieve_port'\] = null:\$config\['managesieve_port'\] = 4190:" /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php && \ + sed -i "s:/etc/dovecot/sieve/global:/var/lib/dovecot/sieve/default.sieve:" /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php \ + || ee_lib_error "Unable to configure ManageSieve Roundcube plugin, exit status = " $? } From 1dc22b16a10a732c701b6b0fc22094d2da731f54 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Sep 2014 17:13:38 +0530 Subject: [PATCH 136/829] Fixed Developer plugin permission issue --- src/modules/debug/ee_mod_debug_wp.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/debug/ee_mod_debug_wp.sh b/src/modules/debug/ee_mod_debug_wp.sh index 8c58ab91..1850b459 100644 --- a/src/modules/debug/ee_mod_debug_wp.sh +++ b/src/modules/debug/ee_mod_debug_wp.sh @@ -21,6 +21,11 @@ function ee_mod_debug_wp() cd /var/www/$EE_DOMAIN/htdocs/ && \ wp plugin --allow-root install developer &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to install developer plugin, exit status = " $? + + # Fix Developer plugin permissions + chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/$EE_DOMAIN/htdocs/wp-content/plugins/developer \ + || ee_lib_error "Unable to change ownership for developer plugin, exit status = " $? + else # Display message ee_lib_echo "WordPress debug log already enabled for $EE_DOMAIN" From 571ec38372e07e6518e816a171eed1f6ef75e6a9 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Sep 2014 17:27:50 +0530 Subject: [PATCH 137/829] Autocompletion for mailscanner --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 1efbbef1..aa2a1dd5 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -25,7 +25,7 @@ function EE_AUTO() ;; install|remove|purge) - COMPREPLY=( $( compgen -W '$(echo mail all web; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) + COMPREPLY=( $( compgen -W '$(echo mail all web mailscanner; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) return 0 ;; From 0bd29d880daba60c80af4bb3d34f0c1df0fc4dcd Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Sep 2014 19:06:49 +0530 Subject: [PATCH 138/829] Updated Update Script --- bin/update | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/update b/bin/update index 0dd1eccc..6616651f 100644 --- a/bin/update +++ b/bin/update @@ -441,6 +441,25 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Update EasyEngine current version EE_CURRENT_VERSION="2.1.0" fi + if [[ $EE_CURRENT_VERSION < 2.1.1 ]]; then + # Install WP-CLI + ee_ven_install_wpcli + + # Configure ManageSieve plugin + if [ -d /var/www/roundcubemail/htdocs ]; then + sed -i "/sieverules_port/d" /var/www/roundcubemail/htdocs/config/config.inc.php + sed -i "s/'sieverules'/'managesieve'/" /var/www/roundcubemail/htdocs/config/config.inc.php + + # Configure ManageSieve Plugin + cp -v /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php.dist /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to configure ManageSieve Roundcube plugin, exit status = " $? + + sed -i "s:\$config\['managesieve_port'\] = null:\$config\['managesieve_port'\] = 4190:" /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php && \ + sed -i "s:/etc/dovecot/sieve/global:/var/lib/dovecot/sieve/default.sieve:" /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php \ + || ee_lib_error "Unable to configure ManageSieve Roundcube plugin, exit status = " $? + + fi + fi # Restart service ee_lib_service nginx php5-fpm restart From 0e736a85975131c7e1d1f05317fdaebd99991356 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 15 Sep 2014 19:44:13 +0530 Subject: [PATCH 139/829] ee cd --- src/modules/site/ee_site_cd.sh | 1 + src/modules/stack/ee_mod_cache_clean.sh | 66 +++++++++++++------------ 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/modules/site/ee_site_cd.sh b/src/modules/site/ee_site_cd.sh index aecb4b45..e9bb486a 100644 --- a/src/modules/site/ee_site_cd.sh +++ b/src/modules/site/ee_site_cd.sh @@ -4,4 +4,5 @@ function ee_site_cd() { cd $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g') \ || ee_lib_error "Unable to change directory for $EE_DOMAIN, exit status = " $? + exec bash } \ No newline at end of file diff --git a/src/modules/stack/ee_mod_cache_clean.sh b/src/modules/stack/ee_mod_cache_clean.sh index 939feb26..54cfb2f8 100644 --- a/src/modules/stack/ee_mod_cache_clean.sh +++ b/src/modules/stack/ee_mod_cache_clean.sh @@ -4,41 +4,45 @@ function ee_mod_cache_clean() { # ee clean - if [ $# -eq 0 ]; then + if [ $# -eq 0 ]; then + ee_lib_echo "Cleaning FastCGI cache, please wait .... " + if [ -d /var/run/nginx-cache/ ]; then + rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG || ee_lib_error "Unable to clean FastCGI cache, exit status = " $? + ee_lib_echo "Ok." + fi + fi + + # ee clean fastcgi|memcache|opcache + for ee_param in $@ ; do + + if [ "$ee_param" = "fastcgi" ] || [ "$ee_param" = "all" ]; then + # Clean fastcgi cache ee_lib_echo "Cleaning FastCGI cache, please wait .... " if [ -d /var/run/nginx-cache/ ]; then - rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG + rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG || ee_lib_error "Unable to clean FastCGI cache, exit status = " $? + ee_lib_echo "Ok." fi - fi - - # ee clean fastcgi|memcache|opcache - for ee_param in $@ ; do - - if [ "$ee_param" = "fastcgi" ] || [ "$ee_param" = "all" ]; then - # Clean fastcgi cache - ee_lib_echo "Cleaning FastCGI cache, please wait .... " - if [ -d /var/run/nginx-cache/ ]; then - rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG - fi - elif [ "$ee_param" = "memcache" ] || [ "$ee_param" = "all" ]; then - # Clean memcache - ee_lib_echo "Cleaning Memcache, please wait .... " - dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ - || ee_lib_error "Memcache not installed, exit status = " $? - if [ $? -eq 0 ];then - service memcached restart &>> $EE_COMMAND_LOG - fi - - elif [ "$ee_param" = "opcache" ] || [ "$ee_param" = "all" ]; then - # Clean opcache - ee_lib_echo "Cleaning OPcache, please wait .... " - wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ - || ee_lib_error "Unable to clean OPcache, exit status = " $? - - else - ee_lib_error "Invalid option selected, choose correct option, exit status = " $? + elif [ "$ee_param" = "memcache" ] || [ "$ee_param" = "all" ]; then + # Clean memcache + ee_lib_echo "Cleaning Memcache, please wait .... " + dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ + || ee_lib_error "Memcache not installed, exit status = " $? + if [ $? -eq 0 ];then + service memcached restart &>> $EE_COMMAND_LOG || ee_lib_error "Unable to clean memcache, exit status = " $? + ee_lib_echo "Ok." fi - done + + elif [ "$ee_param" = "opcache" ] || [ "$ee_param" = "all" ]; then + # Clean opcache + ee_lib_echo "Cleaning OPcache, please wait .... " + wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ + || ee_lib_error "Unable to clean OPcache, exit status = " $? + ee_lib_echo "Ok." + + else + ee_lib_error "Invalid option selected, choose correct option, exit status = " $? + fi + done } From 2cc522667417cb2d3004f67c668d2f0f68847814 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 16 Sep 2014 14:40:55 +0530 Subject: [PATCH 140/829] ee site cd module --- src/modules/site/{ee_site_cd.sh => ee_mod_site_cd.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/modules/site/{ee_site_cd.sh => ee_mod_site_cd.sh} (100%) diff --git a/src/modules/site/ee_site_cd.sh b/src/modules/site/ee_mod_site_cd.sh similarity index 100% rename from src/modules/site/ee_site_cd.sh rename to src/modules/site/ee_mod_site_cd.sh From 299e5595e6c62b5952a8d7a19723838b4fad06b8 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 16 Sep 2014 14:44:38 +0530 Subject: [PATCH 141/829] ee cd -> ee site cd --- bin/easyengine | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 47699deb..8bb393b0 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -547,6 +547,21 @@ elif [ "$EE_FIRST" = "site" ]; then # tail -f log ee_mod_site_log ${@:3}|| ee_lib_error "Unable to check logs, exit status = " $? + #EasyEngine cd + elif [ "$EE_SECOND" = "cd" ]; then + # Check the website name is empty or not + EE_DOMAIN_CHECK=$EE_THIRD + ee_lib_check_domain + + #Check the website exist + ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ + || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? + + # Change Directory to $EE_DOMAIN webroot + if [ $? -eq 0 ]; then + ee_site_cd + fi + else ee_lib_echo "ee site commands:" ee_lib_echo_escape "\tlist\tList NGINX enabled website" @@ -669,21 +684,6 @@ elif [ "$EE_FIRST" = "secure" ]; then ee_lib_echo_escape "\t--ip\tUpdate whitelist IP address" fi -#EasyEngine cd -elif [ "$EE_FIRST" = "cd" ]; then - # Check the website name is empty or not - EE_DOMAIN_CHECK=$EE_SECOND - ee_lib_check_domain - - #Check the website exist - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - - # Change Directory to $EE_DOMAIN webroot - if [ $? -eq 0 ]; then - ee_site_cd - fi - # EasyEngine clean elif [ "$EE_FIRST" = "clean" ]; then ee_mod_cache_clean ${@:2} || ee_lib_error "Unable to clean cache = " $? From 365dc690b3ca19335b95f2b3f4b2ce7a0fb75856 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 17 Sep 2014 12:01:50 +0530 Subject: [PATCH 142/829] fix #312 --- src/modules/site/create/ee_mod_setup_domain.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/site/create/ee_mod_setup_domain.sh b/src/modules/site/create/ee_mod_setup_domain.sh index 9344c437..2fc8e622 100644 --- a/src/modules/site/create/ee_mod_setup_domain.sh +++ b/src/modules/site/create/ee_mod_setup_domain.sh @@ -24,6 +24,7 @@ function ee_mod_setup_domain() # Creating symbolic links for logs ee_lib_symbolic_link /var/log/nginx/$EE_DOMAIN.access.log /var/www/$EE_DOMAIN/logs/access.log ee_lib_symbolic_link /var/log/nginx/$EE_DOMAIN.error.log /var/www/$EE_DOMAIN/logs/error.log + ee_lib_symbolic_link /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log /var/www/$EE_DOMAIN/logs/debug.log else ee_lib_error "$EE_DOMAIN already exist, exit status = " $? fi From 7cbf65d681195080b3076138542e97eed3033072 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Sep 2014 12:04:07 +0530 Subject: [PATCH 143/829] Fixed Sieve Plugin issue --- bin/update | 15 --------------- .../stack/install/mail/ee_mod_setup_sieve.sh | 9 ++------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/bin/update b/bin/update index 6616651f..9da1d456 100644 --- a/bin/update +++ b/bin/update @@ -444,21 +444,6 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then if [[ $EE_CURRENT_VERSION < 2.1.1 ]]; then # Install WP-CLI ee_ven_install_wpcli - - # Configure ManageSieve plugin - if [ -d /var/www/roundcubemail/htdocs ]; then - sed -i "/sieverules_port/d" /var/www/roundcubemail/htdocs/config/config.inc.php - sed -i "s/'sieverules'/'managesieve'/" /var/www/roundcubemail/htdocs/config/config.inc.php - - # Configure ManageSieve Plugin - cp -v /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php.dist /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to configure ManageSieve Roundcube plugin, exit status = " $? - - sed -i "s:\$config\['managesieve_port'\] = null:\$config\['managesieve_port'\] = 4190:" /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php && \ - sed -i "s:/etc/dovecot/sieve/global:/var/lib/dovecot/sieve/default.sieve:" /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php \ - || ee_lib_error "Unable to configure ManageSieve Roundcube plugin, exit status = " $? - - fi fi # Restart service diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh index 6c875b4f..1e0b7dfb 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -28,14 +28,9 @@ function ee_mod_setup_sieve() || ee_lib_error "Unable to compile Sieve rules, exit status = " $? # Configure Roundcube - sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'managesieve',:" /var/www/roundcubemail/htdocs/config/config.inc.php \ + sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'sieverules',:" /var/www/roundcubemail/htdocs/config/config.inc.php \ || ee_lib_error "Unable to configure Sieve Roundcube plugin, exit status = " $? - # Configure ManageSieve Plugin - cp -v /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php.dist /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to configure ManageSieve Roundcube plugin, exit status = " $? + echo "\$config['sieverules_port'] = 4190;" >> /var/www/roundcubemail/htdocs/config/config.inc.php - sed -i "s:\$config\['managesieve_port'\] = null:\$config\['managesieve_port'\] = 4190:" /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php && \ - sed -i "s:/etc/dovecot/sieve/global:/var/lib/dovecot/sieve/default.sieve:" /var/www/roundcubemail/htdocs/plugins/managesieve/config.inc.php \ - || ee_lib_error "Unable to configure ManageSieve Roundcube plugin, exit status = " $? } From dea32668b8b4731919b55976bb54c1efa6563249 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Sep 2014 13:06:15 +0530 Subject: [PATCH 144/829] Optimized Update script and WP-CLI setup --- bin/update | 76 +++++++++++++----------------- src/vendor/ee_ven_install_wpcli.sh | 22 +++++---- 2 files changed, 45 insertions(+), 53 deletions(-) diff --git a/bin/update b/bin/update index 9da1d456..ae78248b 100644 --- a/bin/update +++ b/bin/update @@ -363,8 +363,8 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then fi # Update NGINX if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - nginx -v 2>&1 | grep 1.6.0 &>> $EE_UPDATE_LOG - if [ $? -ne 0 ]; then + ls /etc/apt/sources.list.d/brianmercer-nginx* &>> $EE_UPDATE_LOG + if [ $? -eq 0 ]; then rm /etc/apt/sources.list.d/brianmercer-nginx* # Add rtCamp nginx launchpad repository ee_lib_echo "Adding rtCamp NGINX launchpad repository, please wait..." @@ -395,57 +395,45 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then done fi - if [[ $EE_CURRENT_VERSION = 2.0.0 ]]; then - dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG - if [ $? -eq 0 ]; then - - # WP-CLI change the installation method - rm -rf /usr/share/easyengine/wp-cli /usr/share/wp-cli /usr/bin/wp /etc/bash_completion.d/wp-completion.bash + if [[ $EE_CURRENT_VERSION = 2.0.0 ]] || [[ $EE_CURRENT_VERSION = 2.0.1 ]]; then + sed -i 's/host =.*/grant-host = localhost/' /etc/easyengine/ee.conf - # Install WP-CLI - ee_ven_install_wpcli + # Add Vimbadmin rules + if [ -f /etc/nginx/sites-available/22222 ];then + ee_port=$(grep listen /etc/nginx/sites-available/22222 | awk '{ print $2 }') + cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG + if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then + sed -i "s/listen.*/listen $ee_port default_server ssl spdy;/" /etc/nginx/sites-available/22222 \ + || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? + elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then + # Dotdeb nginx repository doesn't support spdy + sed -i "s/listen.*/listen $ee_port default_server ssl;/" /etc/nginx/sites-available/22222 \ + || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? + fi fi - # Update EasyEngine current version - EE_CURRENT_VERSION="2.0.1" - fi - if [[ $EE_CURRENT_VERSION = 2.0.1 ]]; then - sed -i 's/host =.*/grant-host = localhost/' /etc/easyengine/ee.conf - fi - fi + if [ -d /var/www/22222/htdocs/db/anemometer ];then + # Download pt-query-advisor Fixed #189 + wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ + || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? + chmod 0755 /usr/bin/pt-query-advisor - if [[ $EE_CURRENT_VERSION < 2.1.0 ]];then - if [ -f /etc/nginx/sites-available/22222 ];then - ee_port=$(grep listen /etc/nginx/sites-available/22222 | awk '{ print $2 }') - cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - sed -i "s/listen.*/listen $ee_port default_server ssl spdy;/" /etc/nginx/sites-available/22222 \ - || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? - elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - # Dotdeb nginx repository doesn't support spdy - sed -i "s/listen.*/listen $ee_port default_server ssl;/" /etc/nginx/sites-available/22222 \ - || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? + # Enable pt-query-advisor plugin in Anemometer + sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ + || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $? fi - fi - if [ -d /var/www/22222/htdocs/db/anemometer ];then - # Download pt-query-advisor Fixed #189 - wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ - || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? - chmod 0755 /usr/bin/pt-query-advisor - - # Enable pt-query-advisor plugin in Anemometer - sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ - || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $? + + # Update EasyEngine current version + EE_CURRENT_VERSION="2.1.0" fi - # Update EasyEngine current version - EE_CURRENT_VERSION="2.1.0" - fi - if [[ $EE_CURRENT_VERSION < 2.1.1 ]]; then - # Install WP-CLI - ee_ven_install_wpcli + # if [[ $EE_CURRENT_VERSION = 2.1.0 ]]; then + # fi fi + # Update WP-CLI + ee_ven_install_wpcli + # Restart service ee_lib_service nginx php5-fpm restart diff --git a/src/vendor/ee_ven_install_wpcli.sh b/src/vendor/ee_ven_install_wpcli.sh index 0a1f5a07..e7dc1abe 100644 --- a/src/vendor/ee_ven_install_wpcli.sh +++ b/src/vendor/ee_ven_install_wpcli.sh @@ -2,16 +2,20 @@ function ee_ven_install_wpcli() { - if [ ! -f /usr/bin/wp ]; then - ee_lib_echo "Downloading WP-CLI, please wait..." - wget -qO /usr/bin/wp https://github.com/wp-cli/wp-cli/releases/download/v${EE_WP_CLI_VERSION}/wp-cli.phar \ - || ee_lib_error "Unable to download WP-CLI, exit status = " $? + dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_COMMAND_LOG + if [ $? -eq 0 ]; then + ee_wp_cli_current=$(wp --allow-root --info 2> /dev/null | grep 'WP-CLI' | grep version | awk '{print $3}') + if [[ $ee_wp_cli_current < $EE_WP_CLI_VERSION ]]; then + ee_lib_echo "Downloading WP-CLI, please wait..." + wget -qO /usr/bin/wp https://github.com/wp-cli/wp-cli/releases/download/v${EE_WP_CLI_VERSION}/wp-cli.phar \ + || ee_lib_error "Unable to download WP-CLI, exit status = " $? - # Executable permission - chmod a+x /usr/bin/wp \ - || ee_lib_error "Unable to set executable permission for wp-cli, exit status = " $? + # Executable permission + chmod a+x /usr/bin/wp \ + || ee_lib_error "Unable to set executable permission for wp-cli, exit status = " $? - # Download auto completion - wget -qO /etc/bash_completion.d/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/v${EE_WP_CLI_VERSION}/utils/wp-completion.bash + # Download auto completion + wget -qO /etc/bash_completion.d/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/v${EE_WP_CLI_VERSION}/utils/wp-completion.bash + fi fi } From 458efade3c0a151ed9098dd240ab184c2de326fc Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 17 Sep 2014 14:14:58 +0530 Subject: [PATCH 145/829] #312 Create symbolic link for debug.log only for WordPress specisifc websites --- src/modules/site/create/ee_mod_setup_domain.sh | 1 - src/modules/site/create/ee_mod_setup_wordpress.sh | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/site/create/ee_mod_setup_domain.sh b/src/modules/site/create/ee_mod_setup_domain.sh index 2fc8e622..9344c437 100644 --- a/src/modules/site/create/ee_mod_setup_domain.sh +++ b/src/modules/site/create/ee_mod_setup_domain.sh @@ -24,7 +24,6 @@ function ee_mod_setup_domain() # Creating symbolic links for logs ee_lib_symbolic_link /var/log/nginx/$EE_DOMAIN.access.log /var/www/$EE_DOMAIN/logs/access.log ee_lib_symbolic_link /var/log/nginx/$EE_DOMAIN.error.log /var/www/$EE_DOMAIN/logs/error.log - ee_lib_symbolic_link /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log /var/www/$EE_DOMAIN/logs/debug.log else ee_lib_error "$EE_DOMAIN already exist, exit status = " $? fi diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index 897e9fec..ec5e1a5c 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -10,6 +10,9 @@ function ee_mod_setup_wordpress() cd /var/www/$EE_DOMAIN/htdocs && wp --allow-root core download &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to download WordPress, exit status = " $? + # Symbolic link for debug.log + ee_lib_symbolic_link /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log /var/www/$EE_DOMAIN/logs/debug.log + # Database setup ee_mod_setup_database From 30aa8dde7c447603d55080cfc8e039792cc65c28 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 17 Sep 2014 15:37:50 +0530 Subject: [PATCH 146/829] code optimized --- bin/easyengine | 14 +++--- src/modules/ee_mod_clean.sh | 41 ++++++++++++++++ src/modules/site/ee_mod_site_cd.sh | 2 +- src/modules/site/ee_mod_site_log.sh | 37 +++++++------- src/modules/stack/ee_mod_cache_clean.sh | 48 ------------------- .../stack/install/ee_mod_repo_mysql.sh | 14 ++++++ 6 files changed, 81 insertions(+), 75 deletions(-) create mode 100644 src/modules/ee_mod_clean.sh delete mode 100644 src/modules/stack/ee_mod_cache_clean.sh create mode 100644 src/modules/stack/install/ee_mod_repo_mysql.sh diff --git a/bin/easyengine b/bin/easyengine index 8bb393b0..1c423449 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -46,7 +46,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # EasyEngine install if [ "$EE_SECOND" = "install" ]; then if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ]; then + if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then # Setup NGINX/PHP repository ee_mod_repo_$EE_THIRD @@ -544,16 +544,16 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_service nginx reload fi elif [ "$EE_SECOND" = "log" ]; then - # tail -f log - ee_mod_site_log ${@:3}|| ee_lib_error "Unable to check logs, exit status = " $? + # Display logs for websites + ee_mod_site_log ${@:3} - #EasyEngine cd + #EasyEngine cd elif [ "$EE_SECOND" = "cd" ]; then # Check the website name is empty or not EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain - #Check the website exist + # Check the website exist ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? @@ -684,9 +684,9 @@ elif [ "$EE_FIRST" = "secure" ]; then ee_lib_echo_escape "\t--ip\tUpdate whitelist IP address" fi -# EasyEngine clean +# Clean cache elif [ "$EE_FIRST" = "clean" ]; then - ee_mod_cache_clean ${@:2} || ee_lib_error "Unable to clean cache = " $? + ee_mod_clean ${@:2} # EasyEngine update diff --git a/src/modules/ee_mod_clean.sh b/src/modules/ee_mod_clean.sh new file mode 100644 index 00000000..11db8651 --- /dev/null +++ b/src/modules/ee_mod_clean.sh @@ -0,0 +1,41 @@ +# Clean NGINX FastCGI, Memcache, OPcache cache + +function ee_mod_clean() +{ + if [ "$@" = "" ] || [ "$@" = "fastcgi" ]; then + EE_CLEAN_FASTCGI="fastcgi" + elif [ "$@" = "memcache" ]; then + EE_CLEAN_MEMCACHE="memcache" + elif [ "$@" = "opcache" ]; then + EE_CLEAN_OPCACHE="opcache" + elif [ "$@" = "all" ]; then + EE_CLEAN_FASTCGI="fastcgi" + EE_CLEAN_MEMCACHE="memcache" + EE_CLEAN_OPCACHE="opcache" + fi + + if [ "$EE_CLEAN_FASTCGI" = "fastcgi" ]; then + ee_lib_echo "Cleaning NGINX FastCGI cache, please wait..." + if [ -d /var/run/nginx-cache/ ]; then + rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to clean FastCGI cache, exit status = " $? + fi + fi + + if [ "$EE_CLEAN_MEMCACHE" = "memcache" ]; then + dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ + || ee_lib_error "Memcache not installed, exit status = " $? + + if [ $? -eq 0 ]; then + ee_lib_echo "Cleaning Memcached, please wait..." + service memcached restart &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to restart memcached, exit status = " $? + fi + fi + + if [ "$EE_CLEAN_OPCACHE" = "memcache" ]; then + ee_lib_echo "Cleaning Memcached, please wait..." + wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ + || ee_lib_error "Unable to clean OPcache, exit status = " $? + fi +} \ No newline at end of file diff --git a/src/modules/site/ee_mod_site_cd.sh b/src/modules/site/ee_mod_site_cd.sh index e9bb486a..ffb21ce4 100644 --- a/src/modules/site/ee_mod_site_cd.sh +++ b/src/modules/site/ee_mod_site_cd.sh @@ -5,4 +5,4 @@ function ee_site_cd() cd $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g') \ || ee_lib_error "Unable to change directory for $EE_DOMAIN, exit status = " $? exec bash -} \ No newline at end of file +} diff --git a/src/modules/site/ee_mod_site_log.sh b/src/modules/site/ee_mod_site_log.sh index 5fe46082..7ab0558f 100644 --- a/src/modules/site/ee_mod_site_log.sh +++ b/src/modules/site/ee_mod_site_log.sh @@ -3,24 +3,23 @@ function ee_mod_site_log() { # Check if domain name passed - if [ $# -eq 0 ]; then - for ee_domain_name in $(ls /etc/nginx/sites-available/*); do - ee_log_path="$ee_log_path /var/log/nginx/$(basename $ee_domain_name).*.log" - done - else - for ee_domain_name in $@; do - - EE_DOMAIN_CHECK=$ee_domain_name - ee_lib_check_domain + if [ $# -eq 0 ]; then + for ee_domain_name in $(ls /etc/nginx/sites-available/*); do + ee_log_path="$ee_log_path /var/log/nginx/$(basename $ee_domain_name).*.log" + done + else + for ee_domain_name in $@; do + EE_DOMAIN_CHECK=$ee_domain_name + ee_lib_check_domain - # Check the website exist - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - - if [ $? -eq 0 ]; then - ee_log_path="$ee_log_path /var/log/nginx/$EE_DOMAIN.*.log" - fi - done - fi - tail -f ${ee_log_path} + # Check the website exist + ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ + || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? + + if [ $? -eq 0 ]; then + ee_log_path="$ee_log_path /var/log/nginx/$EE_DOMAIN.*.log" + fi + done + fi + tail -f ${ee_log_path} } diff --git a/src/modules/stack/ee_mod_cache_clean.sh b/src/modules/stack/ee_mod_cache_clean.sh deleted file mode 100644 index 54cfb2f8..00000000 --- a/src/modules/stack/ee_mod_cache_clean.sh +++ /dev/null @@ -1,48 +0,0 @@ -# Clean all cache - -function ee_mod_cache_clean() -{ - - # ee clean - if [ $# -eq 0 ]; then - ee_lib_echo "Cleaning FastCGI cache, please wait .... " - if [ -d /var/run/nginx-cache/ ]; then - rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG || ee_lib_error "Unable to clean FastCGI cache, exit status = " $? - ee_lib_echo "Ok." - fi - fi - - # ee clean fastcgi|memcache|opcache - for ee_param in $@ ; do - - if [ "$ee_param" = "fastcgi" ] || [ "$ee_param" = "all" ]; then - # Clean fastcgi cache - ee_lib_echo "Cleaning FastCGI cache, please wait .... " - if [ -d /var/run/nginx-cache/ ]; then - rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG || ee_lib_error "Unable to clean FastCGI cache, exit status = " $? - ee_lib_echo "Ok." - fi - elif [ "$ee_param" = "memcache" ] || [ "$ee_param" = "all" ]; then - # Clean memcache - ee_lib_echo "Cleaning Memcache, please wait .... " - dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ - || ee_lib_error "Memcache not installed, exit status = " $? - if [ $? -eq 0 ];then - service memcached restart &>> $EE_COMMAND_LOG || ee_lib_error "Unable to clean memcache, exit status = " $? - ee_lib_echo "Ok." - fi - - elif [ "$ee_param" = "opcache" ] || [ "$ee_param" = "all" ]; then - # Clean opcache - ee_lib_echo "Cleaning OPcache, please wait .... " - wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ - || ee_lib_error "Unable to clean OPcache, exit status = " $? - ee_lib_echo "Ok." - - else - ee_lib_error "Invalid option selected, choose correct option, exit status = " $? - fi - done - - -} diff --git a/src/modules/stack/install/ee_mod_repo_mysql.sh b/src/modules/stack/install/ee_mod_repo_mysql.sh new file mode 100644 index 00000000..1a913e3c --- /dev/null +++ b/src/modules/stack/install/ee_mod_repo_mysql.sh @@ -0,0 +1,14 @@ +# Setup Percona repository + +function ee_mod_repo_mysql() +{ + # Add Percona repository + ee_lib_echo "Adding Percona repository, please wait..." + echo "deb http://repo.percona.com/apt $(lsb_release -sc) main" > /etc/apt/sources.list.d/percona-$(lsb_release -sc).list \ + || ee_lib_error "Unable to add Percona repository, exit status = " $? + + # Fetch and install Percona GnuPG key + gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A && \ + gpg -a --export CD2EFD2A | sudo apt-key add - \ + || ee_lib_error "Unable to add Percona GnuPG key, exit status = " $? +} From 6fefea12ccebfc88ed37f962b83e17c1f6632f49 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 17 Sep 2014 16:01:09 +0530 Subject: [PATCH 147/829] added percona-mysql repo --- bin/easyengine | 3 ++- src/modules/ee_mod_clean.sh | 39 +++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 1c423449..d6931635 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -91,9 +91,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display success message ee_lib_echo "$EE_THIRD successfully installed" elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then - # Setup NGINX/PHP repository + # Setup NGINX/PHP/MySQL repository ee_mod_repo_nginx ee_mod_repo_php + ee_mod_repo_mysql # Fix GnuPG key ee_lib_gpg_key_fix diff --git a/src/modules/ee_mod_clean.sh b/src/modules/ee_mod_clean.sh index 11db8651..970521bf 100644 --- a/src/modules/ee_mod_clean.sh +++ b/src/modules/ee_mod_clean.sh @@ -2,27 +2,31 @@ function ee_mod_clean() { - if [ "$@" = "" ] || [ "$@" = "fastcgi" ]; then - EE_CLEAN_FASTCGI="fastcgi" - elif [ "$@" = "memcache" ]; then - EE_CLEAN_MEMCACHE="memcache" - elif [ "$@" = "opcache" ]; then - EE_CLEAN_OPCACHE="opcache" - elif [ "$@" = "all" ]; then - EE_CLEAN_FASTCGI="fastcgi" - EE_CLEAN_MEMCACHE="memcache" - EE_CLEAN_OPCACHE="opcache" - fi + for ee_clean in $@; do + if [ "$ee_clean" = "" ] || [ "$ee_clean" = "fastcgi" ]; then + ee_clean_fastcgi="fastcgi" + elif [ "$ee_clean" = "memcache" ]; then + ee_clean_memcache="memcache" + elif [ "$ee_clean" = "opcache" ]; then + ee_clean_opcache="opcache" + elif [ "$ee_clean" = "all" ]; then + ee_clean_fastcgi="fastcgi" + ee_clean_memcache="memcache" + ee_clean_opcache="opcache" + fi + done - if [ "$EE_CLEAN_FASTCGI" = "fastcgi" ]; then - ee_lib_echo "Cleaning NGINX FastCGI cache, please wait..." + # Clean NGINX FastCGI cache + if [ "$ee_clean_fastcgi" = "fastcgi" ]; then if [ -d /var/run/nginx-cache/ ]; then + ee_lib_echo "Cleaning NGINX FastCGI cache, please wait..." rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to clean FastCGI cache, exit status = " $? fi fi - - if [ "$EE_CLEAN_MEMCACHE" = "memcache" ]; then + + # Clean Memcache + if [ "$ee_clean_memcache" = "memcache" ]; then dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ || ee_lib_error "Memcache not installed, exit status = " $? @@ -33,9 +37,10 @@ function ee_mod_clean() fi fi - if [ "$EE_CLEAN_OPCACHE" = "memcache" ]; then + # Clean OPcache + if [ "$ee_clean_opcache" = "memcache" ]; then ee_lib_echo "Cleaning Memcached, please wait..." wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ || ee_lib_error "Unable to clean OPcache, exit status = " $? fi -} \ No newline at end of file +} From 6e47d6645ada0fc738bdcf1461fc42c7ca8dab30 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 17 Sep 2014 16:10:25 +0530 Subject: [PATCH 148/829] ee clean tweak --- src/modules/ee_mod_clean.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/ee_mod_clean.sh b/src/modules/ee_mod_clean.sh index 970521bf..6e29358e 100644 --- a/src/modules/ee_mod_clean.sh +++ b/src/modules/ee_mod_clean.sh @@ -13,6 +13,8 @@ function ee_mod_clean() ee_clean_fastcgi="fastcgi" ee_clean_memcache="memcache" ee_clean_opcache="opcache" + else + ee_lib_error "$ee_clean invalid option, exit status = " $? fi done @@ -24,7 +26,7 @@ function ee_mod_clean() || ee_lib_error "Unable to clean FastCGI cache, exit status = " $? fi fi - + # Clean Memcache if [ "$ee_clean_memcache" = "memcache" ]; then dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ @@ -38,8 +40,8 @@ function ee_mod_clean() fi # Clean OPcache - if [ "$ee_clean_opcache" = "memcache" ]; then - ee_lib_echo "Cleaning Memcached, please wait..." + if [ "$ee_clean_opcache" = "opcache" ]; then + ee_lib_echo "Cleaning OPcache, please wait..." wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ || ee_lib_error "Unable to clean OPcache, exit status = " $? fi From 7052910e67ba1b5bb8a5b5a8f2f20d9d7f189547 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Sep 2014 16:30:27 +0530 Subject: [PATCH 149/829] Fixed MySQL log file path --- src/modules/debug/ee_mod_debug_mysql.sh | 6 +++--- src/modules/stack/install/ee_mod_setup_mysql.sh | 1 - src/vendor/ee_ven_install_utils.sh | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modules/debug/ee_mod_debug_mysql.sh b/src/modules/debug/ee_mod_debug_mysql.sh index ca828c48..156614a5 100644 --- a/src/modules/debug/ee_mod_debug_mysql.sh +++ b/src/modules/debug/ee_mod_debug_mysql.sh @@ -10,7 +10,7 @@ function ee_mod_debug_mysql() mysql -e "set global slow_query_log = 'ON';" \ || ee_lib_error "Unable to setup slow_query_log, exit status = " $? - mysql -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" \ + mysql -e "set global slow_query_log_file = '/var/log/mysql/mysql-slow.log';" \ || ee_lib_error "Unable to setup slow_query_log_file, exit status = " $? mysql -e "set global long_query_time = 2;" \ @@ -24,7 +24,7 @@ function ee_mod_debug_mysql() fi # Debug message - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/mysql/slow.log" + EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/mysql/mysql-slow.log" elif [ "$EE_DEBUG" = "--stop" ]; then mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG if [ $? -eq 0 ]; then @@ -33,7 +33,7 @@ function ee_mod_debug_mysql() mysql -e "set global slow_query_log = 'OFF';" \ || ee_lib_error "Unable to setup slow_query_log, exit status = " $? - mysql -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" \ + mysql -e "set global slow_query_log_file = '/var/log/mysql/mysql-slow.log';" \ || ee_lib_error "Unable to setup slow_query_log_file, exit status = " $? mysql -e "set global long_query_time = 10;" \ diff --git a/src/modules/stack/install/ee_mod_setup_mysql.sh b/src/modules/stack/install/ee_mod_setup_mysql.sh index 9804d02b..5644ecda 100644 --- a/src/modules/stack/install/ee_mod_setup_mysql.sh +++ b/src/modules/stack/install/ee_mod_setup_mysql.sh @@ -8,6 +8,5 @@ function ee_mod_setup_mysql() grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG if [ $? -ne 0 ]; then sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf - sed -i "/\[mysqldump\]/i slow_query_log_file = /var/log/mysql/slow.log" /etc/mysql/my.cnf fi } diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index c37e827b..b211c71f 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -108,7 +108,7 @@ function ee_ven_install_utils() echo -e " pt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /etc/logrotate.d/mysql-server echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server echo -e " --history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server - echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server + echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /etc/logrotate.d/mysql-server echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server echo -e "}" >> /etc/logrotate.d/mysql-server else @@ -116,7 +116,7 @@ function ee_ven_install_utils() echo -e " pt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /etc/logrotate.d/mysql-server echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server echo -e " --review-history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server - echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/slow.log >> /etc/logrotate.d/mysql-server + echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /etc/logrotate.d/mysql-server echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server echo -e "}" >> /etc/logrotate.d/mysql-server fi From e84e63299b6cd7c8251a5bf7b26383c6ce0182d7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Sep 2014 16:39:20 +0530 Subject: [PATCH 150/829] Fixed EasyEngine log folder permissions --- bin/install | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/install b/bin/install index 4e83a263..81e8403c 100644 --- a/bin/install +++ b/bin/install @@ -82,12 +82,20 @@ function ee_lib_package_check() done } - # Pre checks to avoid later screw ups # Checking EasyEngine (ee) log directory if [ ! -d $EE_LOG_DIR ]; then ee_lib_echo "Creating EasyEngine (ee) log directory, please wait..." mkdir -p $EE_LOG_DIR || ee_lib_error "Unable to create log directory $EE_LOG_DIR, exit status = " $? + + # Create EasyEngine log files + touch /var/log/easyengine/ee.log /var/log/easyengine/install.log /var/log/easyengine/update.log /var/log/easyengine/error.log \ + || ee_lib_error "Unable to create EasyEngine log files in $EE_LOG_DIR, exit status = " $? + + # Keep EasyEngine log folder accessible to root only + chmod -R 700 /var/log/easyengine \ + || ee_lib_error "Unable to change permissions for EasyEngine log folder, exit status = " $? + fi # Install required packages From d0be35e13b395e7637667c712f1a54bb89f6848d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Sep 2014 17:12:38 +0530 Subject: [PATCH 151/829] Fixed Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9c2e332..a2166047 100644 --- a/.travis.yml +++ b/.travis.yml @@ -128,7 +128,7 @@ script: - sudo bash ee stack install mail -- sudo cat /var/log/easyengine/* +- sudo bash -c 'cat /var/log/easyengine/*' - sudo ls /var/www/ From ad10d5c30d91741c066f87456d4c98ede128e971 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 17 Sep 2014 18:06:20 +0530 Subject: [PATCH 152/829] #107 Fix percona-server-5.6 --- src/modules/site/ee_mod_site_cd.sh | 2 +- src/modules/stack/install/ee_mod_install_mysql.sh | 6 +++--- src/modules/stack/install/ee_mod_repo_mysql.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/site/ee_mod_site_cd.sh b/src/modules/site/ee_mod_site_cd.sh index ffb21ce4..40ced381 100644 --- a/src/modules/site/ee_mod_site_cd.sh +++ b/src/modules/site/ee_mod_site_cd.sh @@ -1,4 +1,4 @@ -#CD to Webroot +# Change directory to website root function ee_site_cd() { diff --git a/src/modules/stack/install/ee_mod_install_mysql.sh b/src/modules/stack/install/ee_mod_install_mysql.sh index ba16f87e..24f45bd1 100644 --- a/src/modules/stack/install/ee_mod_install_mysql.sh +++ b/src/modules/stack/install/ee_mod_install_mysql.sh @@ -13,8 +13,8 @@ ee_mod_install_mysql() if [ -n "$EE_PACKAGE_NAME" ]; then # Setting up MySQL password - debconf-set-selections <<< "mysql-server mysql-server/root_password password $ee_random" - debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ee_random" + debconf-set-selections <<< "percona-server-server-5.6 percona-server-server/root_password password $ee_random" + debconf-set-selections <<< "percona-server-server-5.6 percona-server-server/root_password_again password $ee_random" # Generate ~/.my.cnf echo -e "[client]\nuser=root\npassword=$ee_random" > ~/.my.cnf @@ -22,7 +22,7 @@ ee_mod_install_mysql() fi ee_lib_echo "Installing MySQL, please Wait..." - $EE_APT_GET install mysql-server mysqltuner percona-toolkit \ + $EE_APT_GET install percona-server-server-5.6 mysqltuner percona-toolkit \ || ee_lib_error "Unable to install MySQL, exit status = " $? # Download tuning-primer.sh diff --git a/src/modules/stack/install/ee_mod_repo_mysql.sh b/src/modules/stack/install/ee_mod_repo_mysql.sh index 1a913e3c..19542291 100644 --- a/src/modules/stack/install/ee_mod_repo_mysql.sh +++ b/src/modules/stack/install/ee_mod_repo_mysql.sh @@ -8,7 +8,7 @@ function ee_mod_repo_mysql() || ee_lib_error "Unable to add Percona repository, exit status = " $? # Fetch and install Percona GnuPG key - gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A && \ - gpg -a --export CD2EFD2A | sudo apt-key add - \ + gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A &>> $EE_COMMAND_LOG && \ + gpg -a --export CD2EFD2A | sudo apt-key add - &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to add Percona GnuPG key, exit status = " $? } From 25b963c89b946ae2edbcb804e866f8ab2fbf1217 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Sep 2014 18:16:49 +0530 Subject: [PATCH 153/829] Optimized code --- bin/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install b/bin/install index 81e8403c..51ae6944 100644 --- a/bin/install +++ b/bin/install @@ -89,7 +89,7 @@ if [ ! -d $EE_LOG_DIR ]; then mkdir -p $EE_LOG_DIR || ee_lib_error "Unable to create log directory $EE_LOG_DIR, exit status = " $? # Create EasyEngine log files - touch /var/log/easyengine/ee.log /var/log/easyengine/install.log /var/log/easyengine/update.log /var/log/easyengine/error.log \ + touch /var/log/easyengine/{ee.log,install.log,update.log,error.log} \ || ee_lib_error "Unable to create EasyEngine log files in $EE_LOG_DIR, exit status = " $? # Keep EasyEngine log folder accessible to root only From 4f9d8eebaaa105fc89ce9b3e31376c4d48b40353 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 17 Sep 2014 18:28:54 +0530 Subject: [PATCH 154/829] Added subdomain test --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a2166047..333673f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ script: - sudo bash ee site create site1.net --basic - sudo bash ee site create site1.org --wp --basic - sudo bash ee site create site1.in --basic --wp +- sudo bash ee site create subdomain.site1.in --basic --wp - sudo bash ee site create site2.com --wpsc - sudo bash ee site create site2.net --wp --wpsc From 5c8bb69f869274cc38966a18320189aa5200aaaf Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 17 Sep 2014 18:42:42 +0530 Subject: [PATCH 155/829] Better Display Message for Installing Percona Mysql --- src/modules/stack/install/ee_mod_install_mysql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/ee_mod_install_mysql.sh b/src/modules/stack/install/ee_mod_install_mysql.sh index 24f45bd1..97d6ee2d 100644 --- a/src/modules/stack/install/ee_mod_install_mysql.sh +++ b/src/modules/stack/install/ee_mod_install_mysql.sh @@ -21,7 +21,7 @@ ee_mod_install_mysql() fi - ee_lib_echo "Installing MySQL, please Wait..." + ee_lib_echo "Installing Percona MySQL, please Wait..." $EE_APT_GET install percona-server-server-5.6 mysqltuner percona-toolkit \ || ee_lib_error "Unable to install MySQL, exit status = " $? From 0f9db25c76789a32c0840c780105d9792ed575ce Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 18 Sep 2014 12:55:21 +0530 Subject: [PATCH 156/829] Fix message on mysql unable to install --- src/modules/stack/install/ee_mod_install_mysql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/ee_mod_install_mysql.sh b/src/modules/stack/install/ee_mod_install_mysql.sh index 97d6ee2d..23b877a5 100644 --- a/src/modules/stack/install/ee_mod_install_mysql.sh +++ b/src/modules/stack/install/ee_mod_install_mysql.sh @@ -23,7 +23,7 @@ ee_mod_install_mysql() ee_lib_echo "Installing Percona MySQL, please Wait..." $EE_APT_GET install percona-server-server-5.6 mysqltuner percona-toolkit \ - || ee_lib_error "Unable to install MySQL, exit status = " $? + || ee_lib_error "Unable to install Percona MySQL, exit status = " $? # Download tuning-primer.sh wget --no-check-certificate -cqO /usr/local/bin/tuning-primer.sh https://launchpadlibrarian.net/78745738/tuning-primer.sh From 4e6213bc66a86063d8f5275f2ddbc041107edb6f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 18 Sep 2014 14:05:31 +0530 Subject: [PATCH 157/829] ee clean Minor update --- src/modules/ee_mod_clean.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/ee_mod_clean.sh b/src/modules/ee_mod_clean.sh index 6e29358e..d3c0d09e 100644 --- a/src/modules/ee_mod_clean.sh +++ b/src/modules/ee_mod_clean.sh @@ -2,6 +2,10 @@ function ee_mod_clean() { + + if [ $# -eq 0 ]; then + ee_clean_fastcgi="fastcgi" + fi for ee_clean in $@; do if [ "$ee_clean" = "" ] || [ "$ee_clean" = "fastcgi" ]; then ee_clean_fastcgi="fastcgi" From 727dcd9eef45f5da60c93e935160efeb198ed222 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 15:06:50 +0530 Subject: [PATCH 158/829] Added slow log function --- src/vendor/ee_ven_install_utils.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index b211c71f..94e490b6 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -104,21 +104,23 @@ function ee_ven_install_utils() # Execute on MySQL log-rotation dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 if [ $? -eq 0 ]; then - sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server - echo -e " pt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /etc/logrotate.d/mysql-server - echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server - echo -e " --history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server - echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /etc/logrotate.d/mysql-server - echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server - echo -e "}" >> /etc/logrotate.d/mysql-server + echo -e "# Import MySQL slow log to Anememoter" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "function ee_lib_import_slow_log()\n{" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\tpt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--review D=slow_query_log,t=global_query_review \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--history D=slow_query_log,t=global_query_review_history \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t\tendscript" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "}" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh else - sed -i "/endscript/,/}/d" /etc/logrotate.d/mysql-server - echo -e " pt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /etc/logrotate.d/mysql-server - echo -e " --review D=slow_query_log,t=global_query_review \\" >> /etc/logrotate.d/mysql-server - echo -e " --review-history D=slow_query_log,t=global_query_review_history \\" >> /etc/logrotate.d/mysql-server - echo -e " --no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /etc/logrotate.d/mysql-server - echo -e "\t\tendscript" >> /etc/logrotate.d/mysql-server - echo -e "}" >> /etc/logrotate.d/mysql-server + echo -e "# Import MySQL slow log to Anememoter" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "function ee_lib_import_slow_log()\n{" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\tpt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--review-history D=slow_query_log,t=global_query_review \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--history D=slow_query_log,t=global_query_review_history \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t--no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "\t\tendscript" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh + echo -e "}" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh fi # Download pt-query-advisor Fixed #189 From 21e71535fce9ed86d7a49763006c3980854cea56 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 15:15:28 +0530 Subject: [PATCH 159/829] Imroved code --- src/vendor/ee_ven_install_utils.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index 94e490b6..e6cda729 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -101,7 +101,8 @@ function ee_ven_install_utils() sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php sed -i "/password/ s/''/'$ee_anemometer_pass'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php - # Execute on MySQL log-rotation + # Generate ee_lib_import_slow_log function + > /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 if [ $? -eq 0 ]; then echo -e "# Import MySQL slow log to Anememoter" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh @@ -110,7 +111,6 @@ function ee_ven_install_utils() echo -e "\t--review D=slow_query_log,t=global_query_review \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh echo -e "\t--history D=slow_query_log,t=global_query_review_history \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh echo -e "\t--no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\t\tendscript" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh echo -e "}" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh else echo -e "# Import MySQL slow log to Anememoter" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh @@ -119,7 +119,6 @@ function ee_ven_install_utils() echo -e "\t--review-history D=slow_query_log,t=global_query_review \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh echo -e "\t--history D=slow_query_log,t=global_query_review_history \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh echo -e "\t--no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\t\tendscript" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh echo -e "}" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh fi From 73323ab13267318bc800ee4755ea00b72959b3a5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 15:48:35 +0530 Subject: [PATCH 160/829] Added anmometer slow log import function --- src/lib/ee_lib_import_slow_log.sh | 17 +++++++++++++++++ src/vendor/ee_ven_install_utils.sh | 25 ++++--------------------- 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 src/lib/ee_lib_import_slow_log.sh diff --git a/src/lib/ee_lib_import_slow_log.sh b/src/lib/ee_lib_import_slow_log.sh new file mode 100644 index 00000000..3f6599f4 --- /dev/null +++ b/src/lib/ee_lib_import_slow_log.sh @@ -0,0 +1,17 @@ +# Import MySQL slow log to Anememoter + +function ee_lib_import_slow_log() +{ + + dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 + if [ $? -eq 0 ]; then + ee_anemometer_history=history + else + ee_anemometer_history=review-history + fi + + pt-query-digest --user=anemometer --password=anemometer_password \ + --review D=slow_query_log,t=global_query_review \ + --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ + --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$EE_MYSQL_GRANT_HOST\"" /var/log/mysql/mysql-slow.log +} diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index e6cda729..13ad8065 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -101,26 +101,9 @@ function ee_ven_install_utils() sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php sed -i "/password/ s/''/'$ee_anemometer_pass'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php - # Generate ee_lib_import_slow_log function - > /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 - if [ $? -eq 0 ]; then - echo -e "# Import MySQL slow log to Anememoter" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "function ee_lib_import_slow_log()\n{" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\tpt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\t--review D=slow_query_log,t=global_query_review \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\t--history D=slow_query_log,t=global_query_review_history \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\t--no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "}" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - else - echo -e "# Import MySQL slow log to Anememoter" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "function ee_lib_import_slow_log()\n{" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\tpt-query-digest --user=anemometer --password=$ee_anemometer_pass \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\t--review-history D=slow_query_log,t=global_query_review \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\t--history D=slow_query_log,t=global_query_review_history \\" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "\t--no-report --limit=0% --filter=\" \\\$event->{Bytes} = length(\\\$event->{arg}) and \\\$event->{hostname}="\\\"$EE_MYSQL_GRANT_HOST\\\"\" /var/log/mysql/mysql-slow.log >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - echo -e "}" >> /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh - fi + # Change Anemometer password in ee_lib_import_slow_log + sed -i "s/--password.*/--password=${ee_anemometer_pass} \\\/" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ + || ee_lib_error "Unable to change Anemometer password, exit status = " $? # Download pt-query-advisor Fixed #189 wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ @@ -129,7 +112,7 @@ function ee_ven_install_utils() # Enable pt-query-advisor plugin in Anemometer sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ - || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $? + || ee_lib_error "Unable to activate pt-query-advisor plugin, exit status = " $? fi fi From 7d82054327480ae5eb13c6231c8a46ed99fff9d6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 16:23:17 +0530 Subject: [PATCH 161/829] Added ee import-slow-log command --- bin/easyengine | 4 +++- src/lib/ee_lib_import_slow_log.sh | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index a9f49c6f..676e4f39 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -736,8 +736,10 @@ elif [ "$EE_FIRST" = "secure" ]; then # Clean cache elif [ "$EE_FIRST" = "clean" ]; then - ee_mod_clean ${@:2} + ee_mod_clean ${@:2} +elif [ "$EE_FIRST" = "import-slow-log"];then + ee_lib_import_slow_log # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then diff --git a/src/lib/ee_lib_import_slow_log.sh b/src/lib/ee_lib_import_slow_log.sh index 3f6599f4..9575fb08 100644 --- a/src/lib/ee_lib_import_slow_log.sh +++ b/src/lib/ee_lib_import_slow_log.sh @@ -3,15 +3,20 @@ function ee_lib_import_slow_log() { - dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 - if [ $? -eq 0 ]; then - ee_anemometer_history=history + if [ -d /var/www/22222/htdocs/db/anemometer ]; then + ee_lib_echo "Importing MySQL slow log, please wait..." + dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 + if [ $? -eq 0 ]; then + ee_anemometer_history=history + else + ee_anemometer_history=review-history + fi + + pt-query-digest --user=anemometer --password=anemometer_password \ + --review D=slow_query_log,t=global_query_review \ + --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ + --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$EE_MYSQL_GRANT_HOST\"" /var/log/mysql/mysql-slow.log else - ee_anemometer_history=review-history + ee_lib_echo_fail "Anememoter is not installed" fi - - pt-query-digest --user=anemometer --password=anemometer_password \ - --review D=slow_query_log,t=global_query_review \ - --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ - --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$EE_MYSQL_GRANT_HOST\"" /var/log/mysql/mysql-slow.log } From bb76937d7375b67015ec1956dafa0c029f200a0a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 16:42:08 +0530 Subject: [PATCH 162/829] Fixed typo --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 676e4f39..6fd3ae94 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -738,7 +738,7 @@ elif [ "$EE_FIRST" = "secure" ]; then elif [ "$EE_FIRST" = "clean" ]; then ee_mod_clean ${@:2} -elif [ "$EE_FIRST" = "import-slow-log"];then +elif [ "$EE_FIRST" = "import-slow-log" ];then ee_lib_import_slow_log # EasyEngine update From 111717e3de0fd5c1c9c39384fd7d3fd852bd7482 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 17:08:00 +0530 Subject: [PATCH 163/829] Improved code --- src/lib/ee_lib_import_slow_log.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/lib/ee_lib_import_slow_log.sh b/src/lib/ee_lib_import_slow_log.sh index 9575fb08..64cfa2b0 100644 --- a/src/lib/ee_lib_import_slow_log.sh +++ b/src/lib/ee_lib_import_slow_log.sh @@ -4,18 +4,22 @@ function ee_lib_import_slow_log() { if [ -d /var/www/22222/htdocs/db/anemometer ]; then - ee_lib_echo "Importing MySQL slow log, please wait..." - dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 - if [ $? -eq 0 ]; then - ee_anemometer_history=history + if [ -f /var/log/mysql/mysql-slow.log ]; then + ee_lib_echo "Importing MySQL slow log, please wait..." + dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 + if [ $? -eq 0 ]; then + ee_anemometer_history=history + else + ee_anemometer_history=review-history + fi + + pt-query-digest --user=anemometer --password=anemometer_password \ + --review D=slow_query_log,t=global_query_review \ + --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ + --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$EE_MYSQL_GRANT_HOST\"" /var/log/mysql/mysql-slow.log else - ee_anemometer_history=review-history + ee_lib_echo_fail "Failed to find MySQL slow log file, enable MySQL slow log" fi - - pt-query-digest --user=anemometer --password=anemometer_password \ - --review D=slow_query_log,t=global_query_review \ - --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ - --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$EE_MYSQL_GRANT_HOST\"" /var/log/mysql/mysql-slow.log else ee_lib_echo_fail "Anememoter is not installed" fi From 56997a21c912b20398f3b60d737c5f80a320ddf6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 19:03:45 +0530 Subject: [PATCH 164/829] Added crontab for Anemometer --- bin/easyengine | 1 + src/modules/debug/ee_mod_debug_mysql.sh | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 6fd3ae94..130cdca4 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -639,6 +639,7 @@ elif [ "$EE_FIRST" = "debug" ]; then [ "$ee_debug_args" = "--fpm" ] && EE_DEBUG_FPM=$ee_debug_args && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $EE_COMMAND_LOG [ "$ee_debug_args" = "--mysql" ] && EE_DEBUG_MYSQL=$ee_debug_args && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $EE_COMMAND_LOG [ "$ee_debug_args" = "--wp" ] && EE_DEBUG_WP=$ee_debug_args && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG + [ "${ee_debug_args%=*}" = "--import-slow-log-time" ] && EE_DEBUG_IMPORT_SLOW_LOG=$ee_debug_args && echo EE_DEBUG_IMPORT_SLOW_LOG = $EE_DEBUG_IMPORT_SLOW_LOG &>> $EE_COMMAND_LOG if [ "$ee_debug_args" != "debug" ] && [ "$ee_debug_args" != "-i" ] && [ "$ee_debug_args" != "--start" ] && [ "$ee_debug_args" != "--stop" ] && [ "$ee_debug_args" != "--nginx" ] && [ "$ee_debug_args" != "--rewrite" ] && [ "$ee_debug_args" != "--php" ] && [ "$ee_debug_args" != "--fpm" ] && [ "$ee_debug_args" != "--mysql" ] && [ "$ee_debug_args" != "--wp" ]; then ls /etc/nginx/sites-available/ | grep $ee_debug_args &>> $EE_COMMAND_LOG if [ $? -eq 0 ]; then diff --git a/src/modules/debug/ee_mod_debug_mysql.sh b/src/modules/debug/ee_mod_debug_mysql.sh index 156614a5..aa937432 100644 --- a/src/modules/debug/ee_mod_debug_mysql.sh +++ b/src/modules/debug/ee_mod_debug_mysql.sh @@ -18,6 +18,16 @@ function ee_mod_debug_mysql() mysql -e "set global log_queries_not_using_indexes = 'ON';" \ || ee_lib_error "Unable to setup log_queries_not_using_indexes, exit status = " $? + + # Set a cron for slow query log + if [ -z $EE_DEBUG_IMPORT_SLOW_LOG ]; then + ee_cron_time=${EE_DEBUG_IMPORT_SLOW_LOG##*=} + if [ "$ee_cron_time" = "" ] || [ ! $ee_cron_time =~ "^[0-9]+$" ] + ee_cron_time=5 + fi + crontab -l | sed '*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log' | crontab - + fi + else # Display message ee_lib_echo "MySQL slow log already enabled" From 855fabdafbf28ebfebf64215b6a027a3e7a276b3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 19:09:03 +0530 Subject: [PATCH 165/829] Fixed typo --- src/modules/debug/ee_mod_debug_mysql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/debug/ee_mod_debug_mysql.sh b/src/modules/debug/ee_mod_debug_mysql.sh index aa937432..5ced84b4 100644 --- a/src/modules/debug/ee_mod_debug_mysql.sh +++ b/src/modules/debug/ee_mod_debug_mysql.sh @@ -22,7 +22,7 @@ function ee_mod_debug_mysql() # Set a cron for slow query log if [ -z $EE_DEBUG_IMPORT_SLOW_LOG ]; then ee_cron_time=${EE_DEBUG_IMPORT_SLOW_LOG##*=} - if [ "$ee_cron_time" = "" ] || [ ! $ee_cron_time =~ "^[0-9]+$" ] + if [ "$ee_cron_time" = "" ] || [ ! $ee_cron_time =~ "^[0-9]+$" ]; then ee_cron_time=5 fi crontab -l | sed '*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log' | crontab - From 17cb8f5b2db7820f63520bdcaab309bb4b799152 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 19:16:00 +0530 Subject: [PATCH 166/829] Fixed varible not set --- src/modules/debug/ee_mod_debug_mysql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/debug/ee_mod_debug_mysql.sh b/src/modules/debug/ee_mod_debug_mysql.sh index 5ced84b4..d08f84f3 100644 --- a/src/modules/debug/ee_mod_debug_mysql.sh +++ b/src/modules/debug/ee_mod_debug_mysql.sh @@ -20,7 +20,7 @@ function ee_mod_debug_mysql() || ee_lib_error "Unable to setup log_queries_not_using_indexes, exit status = " $? # Set a cron for slow query log - if [ -z $EE_DEBUG_IMPORT_SLOW_LOG ]; then + if [ ! -z $EE_DEBUG_IMPORT_SLOW_LOG ]; then ee_cron_time=${EE_DEBUG_IMPORT_SLOW_LOG##*=} if [ "$ee_cron_time" = "" ] || [ ! $ee_cron_time =~ "^[0-9]+$" ]; then ee_cron_time=5 From 19ec4b5b663c83b1bc12810a25a986bff7996f5e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Sep 2014 20:15:55 +0530 Subject: [PATCH 167/829] Improved code --- src/modules/debug/ee_mod_debug_mysql.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/debug/ee_mod_debug_mysql.sh b/src/modules/debug/ee_mod_debug_mysql.sh index d08f84f3..d65fdc73 100644 --- a/src/modules/debug/ee_mod_debug_mysql.sh +++ b/src/modules/debug/ee_mod_debug_mysql.sh @@ -22,10 +22,8 @@ function ee_mod_debug_mysql() # Set a cron for slow query log if [ ! -z $EE_DEBUG_IMPORT_SLOW_LOG ]; then ee_cron_time=${EE_DEBUG_IMPORT_SLOW_LOG##*=} - if [ "$ee_cron_time" = "" ] || [ ! $ee_cron_time =~ "^[0-9]+$" ]; then - ee_cron_time=5 - fi - crontab -l | sed '*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log' | crontab - + [[ $ee_cron_time =~ ^-?[0-9]+$ ]] || ee_cron_time=5 + crontab -l | { cat; echo "*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log"; } | crontab - fi else From 33b014659b2c4f04e0ab53a01a7a829fd7a499ac Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Sep 2014 13:18:38 +0530 Subject: [PATCH 168/829] Fixes Various Anemometer issue --- src/lib/ee_lib_import_slow_log.sh | 2 +- src/vendor/ee_ven_install_utils.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/ee_lib_import_slow_log.sh b/src/lib/ee_lib_import_slow_log.sh index 64cfa2b0..09396db8 100644 --- a/src/lib/ee_lib_import_slow_log.sh +++ b/src/lib/ee_lib_import_slow_log.sh @@ -16,7 +16,7 @@ function ee_lib_import_slow_log() pt-query-digest --user=anemometer --password=anemometer_password \ --review D=slow_query_log,t=global_query_review \ --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ - --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"$EE_MYSQL_GRANT_HOST\"" /var/log/mysql/mysql-slow.log + --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"anemometer-mysql\"" /var/log/mysql/mysql-slow.log else ee_lib_echo_fail "Failed to find MySQL slow log file, enable MySQL slow log" fi diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index 13ad8065..63275b72 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -100,6 +100,11 @@ function ee_ven_install_utils() sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php sed -i "/password/ s/''/'$ee_anemometer_pass'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php + sed -i "s/'host' => 'localhost',/'host' => '$EE_MYSQL_HOST',/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php + + # Chane Anemometer Hostname in ee_lib_import_slow_log + sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ + || ee_lib_error "Unable to change Anemometer hostnameme, exit status = " $? # Change Anemometer password in ee_lib_import_slow_log sed -i "s/--password.*/--password=${ee_anemometer_pass} \\\/" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ From 2e2bb55d4af0bf6bfdab9a6e2f525933845ea789 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Sep 2014 13:28:28 +0530 Subject: [PATCH 169/829] Fixes Anemometer cron issue --- src/modules/debug/ee_mod_debug_mysql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/debug/ee_mod_debug_mysql.sh b/src/modules/debug/ee_mod_debug_mysql.sh index d65fdc73..0247cfd4 100644 --- a/src/modules/debug/ee_mod_debug_mysql.sh +++ b/src/modules/debug/ee_mod_debug_mysql.sh @@ -23,7 +23,7 @@ function ee_mod_debug_mysql() if [ ! -z $EE_DEBUG_IMPORT_SLOW_LOG ]; then ee_cron_time=${EE_DEBUG_IMPORT_SLOW_LOG##*=} [[ $ee_cron_time =~ ^-?[0-9]+$ ]] || ee_cron_time=5 - crontab -l | { cat; echo "*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log"; } | crontab - + crontab -l 2> /dev/null | { cat; echo -e "#EasyEgnine MySQL slow log\n*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log"; } | crontab - fi else From f8a5545561dea91b07b9b263246eb76a48db62e5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Sep 2014 13:42:40 +0530 Subject: [PATCH 170/829] Added cron deletion --- src/modules/debug/ee_mod_debug_mysql.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/debug/ee_mod_debug_mysql.sh b/src/modules/debug/ee_mod_debug_mysql.sh index 0247cfd4..ef0c6011 100644 --- a/src/modules/debug/ee_mod_debug_mysql.sh +++ b/src/modules/debug/ee_mod_debug_mysql.sh @@ -23,7 +23,7 @@ function ee_mod_debug_mysql() if [ ! -z $EE_DEBUG_IMPORT_SLOW_LOG ]; then ee_cron_time=${EE_DEBUG_IMPORT_SLOW_LOG##*=} [[ $ee_cron_time =~ ^-?[0-9]+$ ]] || ee_cron_time=5 - crontab -l 2> /dev/null | { cat; echo -e "#EasyEgnine MySQL slow log\n*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log"; } | crontab - + crontab -l 2> /dev/null | { cat; echo -e "#EasyEngine start MySQL slow log\n*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log\n#EasyEngine end MySQL slow log"; } | crontab - fi else @@ -48,6 +48,9 @@ function ee_mod_debug_mysql() || ee_lib_error "Unable to setup long_query_time, exit status = " $? mysql -e "set global log_queries_not_using_indexes = 'OFF';" + + # Delete EasyEngine crons + crontab -l | sed '/#EasyEngine start/,/#EasyEngine end/d' | crontab - else # Display message ee_lib_echo "MySQL slow log already disable" From a3273811a345cbc80cde8a7f27d1e4a429bb9b44 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Sep 2014 18:32:53 +0530 Subject: [PATCH 171/829] Added autocompletion for MySQL slow log, Fixes #310 --- config/bash_completion.d/ee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index aa2a1dd5..d21b1907 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -15,7 +15,7 @@ function EE_AUTO() # List of suggested words easyengine|ee) - COMPREPLY=( $(compgen -W '$(echo version help info update; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) + COMPREPLY=( $(compgen -W '$(echo version help info update import-slow-log; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) return 0 ;; @@ -65,6 +65,10 @@ function EE_AUTO() COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) return 0 ;; + --mysql) + COMPREPLY=( $(compgen -W '$(echo --import-slow-log-time=; cd /usr/local/ib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + return 0 + ;; --wp) if [ "$PREVIOUS3" = "create" ]; then From 55f068d21c4b244e3af72fd06592316e968e3d45 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Sep 2014 18:36:14 +0530 Subject: [PATCH 172/829] Fixed Typo --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index d21b1907..52cec1cb 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -61,7 +61,7 @@ function EE_AUTO() return 0 ;; - --nginx|--rewrite|--php|--fpm|--mysql) + --nginx|--rewrite|--php|--fpm) COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) return 0 ;; From 6231e3e4a9e3bacd39757908810f72107ed79270 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Sep 2014 18:40:15 +0530 Subject: [PATCH 173/829] Fixed Typo --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 52cec1cb..565130f5 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -66,7 +66,7 @@ function EE_AUTO() return 0 ;; --mysql) - COMPREPLY=( $(compgen -W '$(echo --import-slow-log-time=; cd /usr/local/ib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + COMPREPLY=( $(compgen -W '$(echo --import-slow-log-time=; cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) return 0 ;; From 2922b1a18f1b767b2e41bf940c43f5992630b056 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Sep 2014 18:59:50 +0530 Subject: [PATCH 174/829] Rename --import-slow-log-time to --import-slow-log-interval, Fixes #310 --- bin/easyengine | 2 +- config/bash_completion.d/ee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 130cdca4..f4352a75 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -639,7 +639,7 @@ elif [ "$EE_FIRST" = "debug" ]; then [ "$ee_debug_args" = "--fpm" ] && EE_DEBUG_FPM=$ee_debug_args && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $EE_COMMAND_LOG [ "$ee_debug_args" = "--mysql" ] && EE_DEBUG_MYSQL=$ee_debug_args && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $EE_COMMAND_LOG [ "$ee_debug_args" = "--wp" ] && EE_DEBUG_WP=$ee_debug_args && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG - [ "${ee_debug_args%=*}" = "--import-slow-log-time" ] && EE_DEBUG_IMPORT_SLOW_LOG=$ee_debug_args && echo EE_DEBUG_IMPORT_SLOW_LOG = $EE_DEBUG_IMPORT_SLOW_LOG &>> $EE_COMMAND_LOG + [ "${ee_debug_args%=*}" = "--import-slow-log-interval" ] && EE_DEBUG_IMPORT_SLOW_LOG=$ee_debug_args && echo EE_DEBUG_IMPORT_SLOW_LOG = $EE_DEBUG_IMPORT_SLOW_LOG &>> $EE_COMMAND_LOG if [ "$ee_debug_args" != "debug" ] && [ "$ee_debug_args" != "-i" ] && [ "$ee_debug_args" != "--start" ] && [ "$ee_debug_args" != "--stop" ] && [ "$ee_debug_args" != "--nginx" ] && [ "$ee_debug_args" != "--rewrite" ] && [ "$ee_debug_args" != "--php" ] && [ "$ee_debug_args" != "--fpm" ] && [ "$ee_debug_args" != "--mysql" ] && [ "$ee_debug_args" != "--wp" ]; then ls /etc/nginx/sites-available/ | grep $ee_debug_args &>> $EE_COMMAND_LOG if [ $? -eq 0 ]; then diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 565130f5..60829e64 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -66,7 +66,7 @@ function EE_AUTO() return 0 ;; --mysql) - COMPREPLY=( $(compgen -W '$(echo --import-slow-log-time=; cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + COMPREPLY=( $(compgen -W '$(echo --import-slow-log-interval=; cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) return 0 ;; From 7dca8fe692551a488be96f754fd0b1c6161e56a7 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 22 Sep 2014 17:05:53 +0530 Subject: [PATCH 175/829] ee site update password command --- bin/easyengine | 15 +++++++++ .../update/ee_mod_site_update_password.sh | 33 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/modules/site/update/ee_mod_site_update_password.sh diff --git a/bin/easyengine b/bin/easyengine index f4352a75..3bfdca74 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -593,6 +593,21 @@ elif [ "$EE_FIRST" = "site" ]; then # Execute: service nginx reload ee_lib_service nginx reload fi + elif [ "$EE_SECOND" = "update" ]; then + # Check the website name is empty or not + EE_DOMAIN_CHECK=$EE_THIRD + EE_SITE_UPDATE_OPTION=$EE_FOURTH + ee_lib_check_domain + + # Check the website exist + ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ + || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? + + EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + + if [ "$EE_SITE_UPDATE_OPTION" = "--password" ]; then + ee_mod_site_update_password + fi elif [ "$EE_SECOND" = "log" ]; then # Display logs for websites ee_mod_site_log ${@:3} diff --git a/src/modules/site/update/ee_mod_site_update_password.sh b/src/modules/site/update/ee_mod_site_update_password.sh new file mode 100644 index 00000000..bd7d6a47 --- /dev/null +++ b/src/modules/site/update/ee_mod_site_update_password.sh @@ -0,0 +1,33 @@ +# Update WordPress user password + +ee_mod_site_update_password() +{ + local ee_wp_user ee_wp_pass + + cd $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g') \ + || ee_lib_error "Unable to change directory for $EE_DOMAIN, exit status = " $? + + wp --allow-root core version &>> /dev/null \ + || ee_lib_error "Error: $EE_DOMAIN does not seem to be a WordPress install, exit status = " $? + + if [ $? -eq 0 ]; then + read -p "Provide WordPress user name [admin]: " ee_wp_user + if [[ $ee_wp_user = "" ]]; then + ee_wp_user=admin + fi + + # Check WordPress user exist or not + wp --allow-root user list --fields=user_login | grep $ee_wp_user &>> /dev/null + if [ $? -eq 0 ]; then + read -sp "Provide password for $ee_wp_user user: " ee_wp_pass + echo + if [[ ${#ee_wp_pass} -ge 8 ]]; then + wp --allow-root user update $ee_wp_user --user_pass=$ee_wp_pass &>> $EE_COMMAND_LOG + else + ee_lib_error "Password Unchanged. Hint : Your password must be 8 characters long, exit status = " $? + fi + else + ee_lib_error "Invalid WordPress user $ee_wp_user for $EE_DOMAIN, exit status = " $? + fi + fi +} From 7f3a63dfac46cdd373b5227e5c5bab64f8f25e0f Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 22 Sep 2014 18:10:17 +0530 Subject: [PATCH 176/829] Deny Directly access for .sql files --- config/nginx/common/locations.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx/common/locations.conf b/config/nginx/common/locations.conf index c506f2bc..d6495a85 100644 --- a/config/nginx/common/locations.conf +++ b/config/nginx/common/locations.conf @@ -32,7 +32,7 @@ location ~ /\. { } # Deny backup extensions & log files -location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp)$ { +location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp|sql)$ { deny all; access_log off; log_not_found off; From f5c5659387dbb3447cb71bd17420f07c558059f2 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 22 Sep 2014 18:45:33 +0530 Subject: [PATCH 177/829] Fixed #315 --- src/modules/site/update/ee_mod_site_update_password.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_site_update_password.sh b/src/modules/site/update/ee_mod_site_update_password.sh index bd7d6a47..f1d4f1a0 100644 --- a/src/modules/site/update/ee_mod_site_update_password.sh +++ b/src/modules/site/update/ee_mod_site_update_password.sh @@ -17,7 +17,7 @@ ee_mod_site_update_password() fi # Check WordPress user exist or not - wp --allow-root user list --fields=user_login | grep $ee_wp_user &>> /dev/null + wp --allow-root user list --fields=user_login | grep ${ee_wp_user}$ &>> /dev/null if [ $? -eq 0 ]; then read -sp "Provide password for $ee_wp_user user: " ee_wp_pass echo From dbd4c7b4601fb8afd46692f23f2685dfdc0b630d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 22 Sep 2014 19:09:51 +0530 Subject: [PATCH 178/829] Fixed percona-mysql remove/purge and also log mysqladmin ping messages --- bin/easyengine | 2 +- bin/update | 2 +- src/modules/stack/install/ee_mod_install_mysql.sh | 6 +++--- src/modules/stack/remove/ee_mod_remove_mysql.sh | 6 +++--- src/vendor/ee_ven_install_utils.sh | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 3bfdca74..9a3fa10d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -140,7 +140,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Check required Packages are installed or not dpkg --get-selections | grep -v deinstall | grep nginx > /dev/null \ && dpkg --get-selections | grep -v deinstall | grep php5-fpm > /dev/null \ - && mysqladmin ping &> /dev/null \ + && mysqladmin ping &>> $EE_COMMAND_LOG \ && dpkg --get-selections | grep -v deinstall | grep postfix > /dev/null if [ $? -ne 0 ];then ee_lib_error "Failed to find NGINX PHP MySQL Postfix, exit status=" 1 diff --git a/bin/update b/bin/update index ae78248b..5136b981 100644 --- a/bin/update +++ b/bin/update @@ -325,7 +325,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then || ee_lib_error "Unable to add xdebug settings for debug pool, exit status = " $? fi - dpkg --get-selections | grep -v deinstall | grep mysql-server &>> $EE_UPDATE_LOG + mysqladmin ping &> /dev/null &>> $EE_UPDATE_LOG if [ $? -eq 0 ]; then ee_lib_echo "Installing percona-toolkit package, please wait..." apt-get -y install percona-toolkit \ diff --git a/src/modules/stack/install/ee_mod_install_mysql.sh b/src/modules/stack/install/ee_mod_install_mysql.sh index 23b877a5..c3f9242f 100644 --- a/src/modules/stack/install/ee_mod_install_mysql.sh +++ b/src/modules/stack/install/ee_mod_install_mysql.sh @@ -5,10 +5,10 @@ ee_mod_install_mysql() # Random characters local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - # Check MySQL is installed or not - ee_lib_package_check mysql-server + # Check Percona MySQL is installed or not + ee_lib_package_check percona-server-server-5.6 - # If MySQL is not installed + # If Percona MySQL is not installed # Then set random MySQL password for root user if [ -n "$EE_PACKAGE_NAME" ]; then diff --git a/src/modules/stack/remove/ee_mod_remove_mysql.sh b/src/modules/stack/remove/ee_mod_remove_mysql.sh index 628bc9e6..e018baf5 100644 --- a/src/modules/stack/remove/ee_mod_remove_mysql.sh +++ b/src/modules/stack/remove/ee_mod_remove_mysql.sh @@ -2,9 +2,9 @@ function ee_mod_remove_mysql() { - ee_lib_echo "$EE_SECOND MySQL package, please wait..." - $EE_APT_GET $EE_SECOND mysql-server mysqltuner percona-toolkit \ - || ee_lib_error "Unable to $EE_SECOND MySQL, exit status = " $? + ee_lib_echo "$EE_SECOND Percona MySQL package, please wait..." + $EE_APT_GET $EE_SECOND percona-server-server-5.6 mysqltuner percona-toolkit \ + || ee_lib_error "Unable to $EE_SECOND Percona MySQL, exit status = " $? # Remove tuning-primer.sh rm -f /usr/local/bin/tuning-primer.sh diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index 63275b72..c40a63e1 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -70,7 +70,7 @@ function ee_ven_install_utils() # phpinfo() echo -e "" &>> /var/www/22222/htdocs/php/info.php fi - mysqladmin ping &> /dev/null + mysqladmin ping &>> $EE_COMMAND_LOG if [ $? -eq 0 ]; then # Setup Anemometer if [ ! -d /var/www/22222/htdocs/db/anemometer ]; then From a9770ec063825c6e0a44c4e9fcfbf24dfde70ab9 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 22 Sep 2014 20:06:17 +0530 Subject: [PATCH 179/829] Percona setup message updated --- src/modules/stack/install/ee_mod_setup_mysql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/ee_mod_setup_mysql.sh b/src/modules/stack/install/ee_mod_setup_mysql.sh index 5644ecda..d40ccdc6 100644 --- a/src/modules/stack/install/ee_mod_setup_mysql.sh +++ b/src/modules/stack/install/ee_mod_setup_mysql.sh @@ -2,7 +2,7 @@ function ee_mod_setup_mysql() { - ee_lib_echo "Setting up MySQL, please wait..." + ee_lib_echo "Setting up Percona MySQL, please wait..." # Setting wait_timeout = 30 & interactive_timeout = 60 grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG From 55111e582176d3297099d863d89b8b36b7257925 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Sep 2014 12:50:17 +0530 Subject: [PATCH 180/829] purge mysql-server or percona-server --- src/modules/stack/remove/ee_mod_remove_mysql.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/stack/remove/ee_mod_remove_mysql.sh b/src/modules/stack/remove/ee_mod_remove_mysql.sh index e018baf5..9f9215c1 100644 --- a/src/modules/stack/remove/ee_mod_remove_mysql.sh +++ b/src/modules/stack/remove/ee_mod_remove_mysql.sh @@ -2,8 +2,14 @@ function ee_mod_remove_mysql() { + dpkg --get-selections | grep -v deinstall | grep mysql-server &>> $EE_COMMAND_LOG + if [ $? -eq 0 ]; then + ee_mysql_server=mysql-server + else + ee_mysql_server=percona-server-server-5.6 + fi ee_lib_echo "$EE_SECOND Percona MySQL package, please wait..." - $EE_APT_GET $EE_SECOND percona-server-server-5.6 mysqltuner percona-toolkit \ + $EE_APT_GET $EE_SECOND $ee_mysql_server mysqltuner percona-toolkit \ || ee_lib_error "Unable to $EE_SECOND Percona MySQL, exit status = " $? # Remove tuning-primer.sh From 6299e5e3015fec3dcd07378716927b7209d03af1 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Sep 2014 16:38:26 +0530 Subject: [PATCH 181/829] Removed Default http Auth --- src/modules/secure/ee_mod_secure_auth.sh | 17 ++++++++++------- src/modules/stack/install/ee_mod_setup_nginx.sh | 5 ----- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/modules/secure/ee_mod_secure_auth.sh b/src/modules/secure/ee_mod_secure_auth.sh index b8281793..a76514a8 100644 --- a/src/modules/secure/ee_mod_secure_auth.sh +++ b/src/modules/secure/ee_mod_secure_auth.sh @@ -3,23 +3,26 @@ function ee_mod_secure_auth() { local ee_http_auth_user ee_http_auth_pass + + # Random characters + local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - read -p "Provide HTTP authentication user name [easyengine]: " ee_http_auth_user - read -sp "Provide HTTP authentication password [easyengine]: " ee_http_auth_pass + read -p "Provide HTTP authentication user name [$(git config user.name)]: " ee_http_auth_user + read -sp "Provide HTTP authentication password [$ee_random]: " ee_http_auth_pass echo - # If enter is pressed, set easyengine + # If enter is pressed, set git config user.name if [[ $ee_http_auth_user = "" ]]; then - ee_http_auth_user=easyengine + ee_http_auth_user=$(git config user.email) fi if [[ $ee_http_auth_pass = "" ]]; then - ee_http_auth_pass=easyengine + ee_http_auth_pass=$ee_random fi # Add HTTP authentication details - ee_lib_echo "HTTP authentication username: $ee_http_auth_user" &>> $EE_COMMAND_LOG - ee_lib_echo "HTTP authentication password: $ee_http_auth_pass" &>> $EE_COMMAND_LOG + ee_lib_echo "HTTP authentication username: $ee_http_auth_user" + ee_lib_echo "HTTP authentication password: $ee_http_auth_pass" # Generate htpasswd-ee file printf "$ee_http_auth_user:$(openssl passwd -crypt $ee_http_auth_pass 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh index a439f4ef..75943cde 100644 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ b/src/modules/stack/install/ee_mod_setup_nginx.sh @@ -94,9 +94,4 @@ function ee_mod_setup_nginx() sed -i "/deny/i $(echo allow $ee_whitelist_ip_address\;)" /etc/nginx/common/acl.conf done fi - - # Set easyengine:easyengine as default http authentication - if [ ! -f /etc/nginx/htpasswd-ee ]; then - printf "easyengine:$(openssl passwd -crypt easyengine 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null - fi } From 47f18bd20c971989a4747e22b30487135467d9cb Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Sep 2014 17:02:36 +0530 Subject: [PATCH 182/829] minor update --- src/modules/secure/ee_mod_secure_auth.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/secure/ee_mod_secure_auth.sh b/src/modules/secure/ee_mod_secure_auth.sh index a76514a8..1440eae6 100644 --- a/src/modules/secure/ee_mod_secure_auth.sh +++ b/src/modules/secure/ee_mod_secure_auth.sh @@ -13,7 +13,7 @@ function ee_mod_secure_auth() # If enter is pressed, set git config user.name if [[ $ee_http_auth_user = "" ]]; then - ee_http_auth_user=$(git config user.email) + ee_http_auth_user=$(git config user.name) fi if [[ $ee_http_auth_pass = "" ]]; then @@ -21,8 +21,9 @@ function ee_mod_secure_auth() fi # Add HTTP authentication details - ee_lib_echo "HTTP authentication username: $ee_http_auth_user" - ee_lib_echo "HTTP authentication password: $ee_http_auth_pass" + echo + ee_lib_echo_info "HTTP authentication username: $ee_http_auth_user" + ee_lib_echo_info "HTTP authentication password: $ee_http_auth_pass" # Generate htpasswd-ee file printf "$ee_http_auth_user:$(openssl passwd -crypt $ee_http_auth_pass 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null From 3560013aa8b541778588b05049fe0e60d49dd52a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Sep 2014 17:03:15 +0530 Subject: [PATCH 183/829] Change Default WordPress username to harshadyeola --- config/easyengine/ee.conf | 2 +- src/modules/site/create/ee_mod_setup_wordpress.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/easyengine/ee.conf b/config/easyengine/ee.conf index d34a2e21..74d68b20 100644 --- a/config/easyengine/ee.conf +++ b/config/easyengine/ee.conf @@ -12,6 +12,6 @@ [wordpress] prefix = false - user = admin + user = password = email = diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index ec5e1a5c..20250ffb 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -66,7 +66,7 @@ function ee_mod_setup_wordpress() # WordPress default user: admin EE_WP_USER=$($EE_CONFIG_GET wordpress.user) if [[ $EE_WP_USER = "" ]]; then - EE_WP_USER=admin + EE_WP_USER=$(git config user.name) fi # WordPress default user: admin From c5e6384abfc8cd1493f22a11c97ac30c605366b5 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Sep 2014 18:40:44 +0530 Subject: [PATCH 184/829] Change the way EasyEngine Set WordPress username and email --- .../site/create/ee_mod_setup_wordpress.sh | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index 20250ffb..e2aaf116 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -10,9 +10,6 @@ function ee_mod_setup_wordpress() cd /var/www/$EE_DOMAIN/htdocs && wp --allow-root core download &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to download WordPress, exit status = " $? - # Symbolic link for debug.log - ee_lib_symbolic_link /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log /var/www/$EE_DOMAIN/logs/debug.log - # Database setup ee_mod_setup_database @@ -63,22 +60,44 @@ function ee_mod_setup_wordpress() a "$(curl -sL https://api.wordpress.org/secret-key/1.1/salt/)" . w \ | ed -s /var/www/$EE_DOMAIN/wp-config.php - # WordPress default user: admin + # Set WordPress username + # First get WordPress username from /etc/easyengine/ee.conf file EE_WP_USER=$($EE_CONFIG_GET wordpress.user) + if [[ $EE_WP_USER = "" ]]; then - EE_WP_USER=$(git config user.name) + git config user.name &>> $EE_COMMAND_LOG + if [ $? -eq 0 ]; then + # Set WordPress username from git config user.name + EE_WP_USER=$(git config user.name) + else + while [ -z $EE_WP_USER ]; do + # Ask user to provide WordPress username + read -p "Enter WordPress username: " EE_WP_USER + done + fi fi - # WordPress default user: admin + # Set WordPress password EE_WP_PASS=$($EE_CONFIG_GET wordpress.password) if [[ $EE_WP_PASS = "" ]]; then EE_WP_PASS=$ee_random fi - # WordPress default email: `git config user.email` + # Set WordPress email + # First get WordPress email from /etc/easyengine/ee.conf file EE_WP_EMAIL=$($EE_CONFIG_GET wordpress.email) + if [[ $EE_WP_EMAIL = "" ]]; then - EE_WP_EMAIL=$(git config user.email) + git config user.email &>> $EE_COMMAND_LOG + if [ $? -eq 0 ]; then + # Set WordPress email from git config user.email + EE_WP_EMAIL=$(git config user.email) + else + while [ -z $EE_WP_EMAIL ]; do + # Ask user to provide WordPress email + read -p "Enter WordPress email: " EE_WP_EMAIL + done + fi fi # Create WordPress tables From 3a1fc4bec619b23a80f5afd5b4c7fefccc3173c6 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Sep 2014 19:09:14 +0530 Subject: [PATCH 185/829] added WordPress username setup conditions message --- src/modules/site/create/ee_mod_setup_wordpress.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index e2aaf116..fb4a2ef8 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -72,6 +72,7 @@ function ee_mod_setup_wordpress() else while [ -z $EE_WP_USER ]; do # Ask user to provide WordPress username + ee_lib_echo "Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods and the @ symbol." read -p "Enter WordPress username: " EE_WP_USER done fi From 665e605abe943236ab972140e0d37dfcffbfc417 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Sep 2014 13:17:22 +0530 Subject: [PATCH 186/829] ee stack install merged in ee site create --- bin/easyengine | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 9a3fa10d..b58b841d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -438,6 +438,36 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_CACHE_OPTION=--basic fi + if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_package_check $EE_NGINX_PACKAGE + if [ "$EE_PACKAGE_NAME" != "" ]; then + ee stack install nginx + fi + fi + if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_package_check php5-common php5-mysqlnd php5-xmlrpc \ + php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ + php5-memcache memcached php5-geoip + if [ "$EE_PACKAGE_NAME" != "" ]; then + ee stack install php + fi + fi + if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + mysqladmin ping &>> $EE_COMMAND_LOG + if [ $? -eq 0 ]; then + ee stack install mysql + fi + fi + + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_ven_install_wpcli + fi + + ee_lib_package_check postfix + if [ "$EE_PACKAGE_NAME" != "" ]; then + ee stack install postfix + fi + # Lets create HTML|PHP|MySQL website if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then # Configure variable From 8d49f0768890d0924e49bcaed0c03fd5dc2c7b83 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Sep 2014 13:22:59 +0530 Subject: [PATCH 187/829] minor update --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index b58b841d..9ee92b17 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -454,7 +454,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then mysqladmin ping &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then + if [ $? -ne 0 ]; then ee stack install mysql fi fi From 0c89b7d620e5b6533e8c3e981807ec6fd7acbd72 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Sep 2014 14:56:31 +0530 Subject: [PATCH 188/829] Fixed EasyEngine exit status --- bin/easyengine | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 9ee92b17..e2d7e98d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -441,7 +441,7 @@ elif [ "$EE_FIRST" = "site" ]; then if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_lib_package_check $EE_NGINX_PACKAGE if [ "$EE_PACKAGE_NAME" != "" ]; then - ee stack install nginx + ee stack install nginx || fi fi if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -807,3 +807,4 @@ fi } EasyEngine $@ | tee -ai $EE_COMMAND_LOG +exit ${PIPESTATUS[0]} From be32e8fc0c5f3955119abc23c017f52799a6fe44 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Sep 2014 15:33:06 +0530 Subject: [PATCH 189/829] minor update --- bin/easyengine | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index e2d7e98d..925697c4 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -441,7 +441,10 @@ elif [ "$EE_FIRST" = "site" ]; then if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_lib_package_check $EE_NGINX_PACKAGE if [ "$EE_PACKAGE_NAME" != "" ]; then - ee stack install nginx || + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install nginx || exit $? fi fi if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -449,13 +452,19 @@ elif [ "$EE_FIRST" = "site" ]; then php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ php5-memcache memcached php5-geoip if [ "$EE_PACKAGE_NAME" != "" ]; then - ee stack install php + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install php || exit $? fi fi if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then mysqladmin ping &>> $EE_COMMAND_LOG if [ $? -ne 0 ]; then - ee stack install mysql + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install mysql || exit $? fi fi @@ -465,7 +474,10 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_package_check postfix if [ "$EE_PACKAGE_NAME" != "" ]; then - ee stack install postfix + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install postfix || exit $? fi # Lets create HTML|PHP|MySQL website @@ -807,4 +819,17 @@ fi } EasyEngine $@ | tee -ai $EE_COMMAND_LOG + + +# If any command fails its return non-zero exit code [EasyEngine $@] +# But when failed command piped then its [EasyEngine $@] exit status +# is suppress by next piped command [| tee -ai $EE_COMMAND_LOG] + +# Example: +# (call | tee -ai example.log); echo $? +# 0 + +# (call | tee -ai example.log; exit ${PIPESTATUS[0]}); echo $? +# 127 + exit ${PIPESTATUS[0]} From 75bcf6cd23f3ba82e7cd333877b2dd9532a25491 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Sep 2014 15:38:17 +0530 Subject: [PATCH 190/829] RAM based optimization done --- src/lib/ee_lib_ram.sh | 2 +- src/modules/stack/install/ee_mod_setup_php.sh | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh index 3144140d..a6b24461 100644 --- a/src/lib/ee_lib_ram.sh +++ b/src/lib/ee_lib_ram.sh @@ -42,4 +42,4 @@ function ee_lib_ram() EE_MEMCACHE_SIZE="2048" EE_PHP_MAX_CHILDREN="100" fi -} \ No newline at end of file +} diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh index 944ae0d4..3e477c83 100644 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ b/src/modules/stack/install/ee_mod_setup_php.sh @@ -31,7 +31,7 @@ function ee_mod_setup_php() # Adjust php5-fpm pool sed -i "s/;pm.max_requests/pm.max_requests/" /etc/php5/fpm/pool.d/www.conf - sed -i "s/pm.max_children = 5/pm.max_children = 100/" /etc/php5/fpm/pool.d/www.conf + sed -i "s/pm.max_children = 5/pm.max_children = ${EE_PHP_MAX_CHILDREN}/" /etc/php5/fpm/pool.d/www.conf sed -i "s/pm.start_servers = 2/pm.start_servers = 20/" /etc/php5/fpm/pool.d/www.conf sed -i "s/pm.min_spare_servers = 1/pm.min_spare_servers = 10/" /etc/php5/fpm/pool.d/www.conf sed -i "s/pm.max_spare_servers = 3/pm.max_spare_servers = 30/" /etc/php5/fpm/pool.d/www.conf @@ -66,5 +66,16 @@ function ee_mod_setup_php() wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz /usr/share/GeoIP/GeoIPCity.dat http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat - fi + + # Setup Zend OpCache as per RAM + grep memory_consumption /etc/php5/fpm/conf.d/05-opcache.ini &> /dev/null + if [ $? -ne 0]; then + sed -i "s/zend_extension=opcache.so/zend_extension=opcache.so\nopcache.memory_consumption=${EE_OPCACHE_SIZE}\nopcache.max_accelerated_files=50000/" /etc/php5/fpm/conf.d/05-opcache.ini \ + || ee_lib_error "Unable to change opcache.memory_consumption, exit status = " $? + fi + + # Setup PHP Memcache as per RAM + sed "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \ + || ee_lib_error "Unable to change Memcache memory value, exit status = " $? + fi } From 4be63ff437eddd44d3ab253454052a5648a6b662 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Sep 2014 15:48:32 +0530 Subject: [PATCH 191/829] Fixed Typo --- src/modules/stack/install/ee_mod_setup_php.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh index 3e477c83..597e8da0 100644 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ b/src/modules/stack/install/ee_mod_setup_php.sh @@ -69,7 +69,7 @@ function ee_mod_setup_php() # Setup Zend OpCache as per RAM grep memory_consumption /etc/php5/fpm/conf.d/05-opcache.ini &> /dev/null - if [ $? -ne 0]; then + if [ $? -ne 0 ]; then sed -i "s/zend_extension=opcache.so/zend_extension=opcache.so\nopcache.memory_consumption=${EE_OPCACHE_SIZE}\nopcache.max_accelerated_files=50000/" /etc/php5/fpm/conf.d/05-opcache.ini \ || ee_lib_error "Unable to change opcache.memory_consumption, exit status = " $? fi From ff1d13d4d7e6e571eda5c3642a3358314681076d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Sep 2014 15:48:45 +0530 Subject: [PATCH 192/829] Fixed Typo --- src/modules/stack/install/ee_mod_setup_php.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh index 597e8da0..eb9a82b0 100644 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ b/src/modules/stack/install/ee_mod_setup_php.sh @@ -75,7 +75,7 @@ function ee_mod_setup_php() fi # Setup PHP Memcache as per RAM - sed "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \ + sed -i "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \ || ee_lib_error "Unable to change Memcache memory value, exit status = " $? fi } From 8398888139a71fae2a2259848ce08b929d30982c Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 24 Sep 2014 16:10:29 +0530 Subject: [PATCH 193/829] Added in logs file --- src/modules/site/create/ee_mod_setup_wordpress.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index fb4a2ef8..f388b5b8 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -65,7 +65,7 @@ function ee_mod_setup_wordpress() EE_WP_USER=$($EE_CONFIG_GET wordpress.user) if [[ $EE_WP_USER = "" ]]; then - git config user.name &>> $EE_COMMAND_LOG + git config user.name &>> /dev/null if [ $? -eq 0 ]; then # Set WordPress username from git config user.name EE_WP_USER=$(git config user.name) @@ -89,7 +89,7 @@ function ee_mod_setup_wordpress() EE_WP_EMAIL=$($EE_CONFIG_GET wordpress.email) if [[ $EE_WP_EMAIL = "" ]]; then - git config user.email &>> $EE_COMMAND_LOG + git config user.email &>> /dev/null if [ $? -eq 0 ]; then # Set WordPress email from git config user.email EE_WP_EMAIL=$(git config user.email) @@ -101,6 +101,9 @@ function ee_mod_setup_wordpress() fi fi + # Let's log WordPress username/password/email + echo -e "EE_WP_USER = $EE_WP_USER \nEE_WP_PASS = $EE_WP_PASS \nEE_WP_EMAIL = $EE_WP_EMAIL" &>> $EE_COMMAND_LOG + # Create WordPress tables ee_lib_echo "Setting up WordPress, please wait..." cd /var/www/$EE_DOMAIN/htdocs \ From 0ee913f9ebf4ba9b298e72b462e422b963e1b403 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 24 Sep 2014 16:23:13 +0530 Subject: [PATCH 194/829] Fixed wp-cli username whitespace issue --- src/modules/site/create/ee_mod_setup_wordpress.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index f388b5b8..46cd724a 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -110,7 +110,7 @@ function ee_mod_setup_wordpress() || ee_lib_error "Unable to change directory to install WordPress, exit status = " $? wp core install --allow-root --url=$EE_WWW_DOMAIN --title="$EE_WWW_DOMAIN" \ - --admin_name=$EE_WP_USER --admin_password=$EE_WP_PASS --admin_email=$EE_WP_EMAIL &>> $EE_COMMAND_LOG \ + --admin_name="$EE_WP_USER" --admin_password=$EE_WP_PASS --admin_email=$EE_WP_EMAIL &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to create WordPress tables for $EE_DOMAIN, exit status = " $? # Update WordPress permalink structure day and postname From b66931c73ced7ebf8d274b2eb25dfe4605ace905 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Sep 2014 17:08:18 +0530 Subject: [PATCH 195/829] setup my.cnf for percona mysql-server --- src/modules/stack/install/ee_mod_setup_mysql.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/stack/install/ee_mod_setup_mysql.sh b/src/modules/stack/install/ee_mod_setup_mysql.sh index d40ccdc6..e6b9793a 100644 --- a/src/modules/stack/install/ee_mod_setup_mysql.sh +++ b/src/modules/stack/install/ee_mod_setup_mysql.sh @@ -5,8 +5,7 @@ function ee_mod_setup_mysql() ee_lib_echo "Setting up Percona MySQL, please wait..." # Setting wait_timeout = 30 & interactive_timeout = 60 - grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf + if [ ! -f /etc/mysql/my.cnf ]; then + echo -e "[mysqld] \nwait_timeout = 30 \ninteractive_timeout = 60" &>> /etc/mysql/my.cnf fi } From bf3be1fd87114b42bfdfda9eb2abe94e5ef31484 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Sep 2014 17:46:29 +0530 Subject: [PATCH 196/829] ee info for installed packages only --- src/lib/ee_lib_mysql_info.sh | 37 ++++++++------- src/lib/ee_lib_nginx_info.sh | 41 +++++++++------- src/lib/ee_lib_php_info.sh | 92 +++++++++++++++++++----------------- 3 files changed, 92 insertions(+), 78 deletions(-) diff --git a/src/lib/ee_lib_mysql_info.sh b/src/lib/ee_lib_mysql_info.sh index 0108d6c2..6e4706de 100644 --- a/src/lib/ee_lib_mysql_info.sh +++ b/src/lib/ee_lib_mysql_info.sh @@ -2,21 +2,26 @@ function ee_lib_mysql_info() { - local ee_mysql_version=$(mysql -V | awk '{print($5)}' | cut -d ',' -f1) - local ee_mysql_port=$(mysql -e "show variables" | grep ^port | awk '{print($2)}') - local ee_mysql_socket=$(mysql -e "show variables" | grep "^socket" | awk '{print($2)}') - local ee_mysql_data_dir=$(mysql -e "show variables" | grep datadir | awk '{print($2)}') - local ee_mysql_wait_timeout=$(mysql -e "show variables" | grep ^wait_timeout | awk '{print($2)}') - local ee_mysql_interactive_timeout=$(mysql -e "show variables" | grep ^interactive_timeout | awk '{print($2)}') - local ee_mysql_max_connections=$(mysql -e "show variables" | grep "^max_connections" | awk '{print($2)}') - local ee_mysql_max_used_connections=$(mysql -e "show global status" | grep Max_used_connections | awk '{print($2)}') + mysqladmin ping &>> $EE_COMMAND_LOG + if [ $? -ne 0 ]; then + local ee_mysql_version=$(mysql -V | awk '{print($5)}' | cut -d ',' -f1) + local ee_mysql_port=$(mysql -e "show variables" | grep ^port | awk '{print($2)}') + local ee_mysql_socket=$(mysql -e "show variables" | grep "^socket" | awk '{print($2)}') + local ee_mysql_data_dir=$(mysql -e "show variables" | grep datadir | awk '{print($2)}') + local ee_mysql_wait_timeout=$(mysql -e "show variables" | grep ^wait_timeout | awk '{print($2)}') + local ee_mysql_interactive_timeout=$(mysql -e "show variables" | grep ^interactive_timeout | awk '{print($2)}') + local ee_mysql_max_connections=$(mysql -e "show variables" | grep "^max_connections" | awk '{print($2)}') + local ee_mysql_max_used_connections=$(mysql -e "show global status" | grep Max_used_connections | awk '{print($2)}') - ee_lib_echo - ee_lib_echo "MySQL ($ee_mysql_version) on $EE_MYSQL_HOST:" - ee_lib_echo_escape "port\t\t\t\t \033[37m$ee_mysql_port" - ee_lib_echo_escape "wait_timeout\t\t\t \033[37m$ee_mysql_wait_timeout" - ee_lib_echo_escape "interactive_timeout\t\t \033[37m$ee_mysql_interactive_timeout" - ee_lib_echo_escape "max_used_connections\t\t \033[37m$ee_mysql_max_used_connections/$ee_mysql_max_connections" - ee_lib_echo_escape "datadir\t\t\t\t \033[37m$ee_mysql_data_dir" - ee_lib_echo_escape "socket\t\t\t\t \033[37m$ee_mysql_socket" + ee_lib_echo + ee_lib_echo "MySQL ($ee_mysql_version) on $EE_MYSQL_HOST:" + ee_lib_echo_escape "port\t\t\t\t \033[37m$ee_mysql_port" + ee_lib_echo_escape "wait_timeout\t\t\t \033[37m$ee_mysql_wait_timeout" + ee_lib_echo_escape "interactive_timeout\t\t \033[37m$ee_mysql_interactive_timeout" + ee_lib_echo_escape "max_used_connections\t\t \033[37m$ee_mysql_max_used_connections/$ee_mysql_max_connections" + ee_lib_echo_escape "datadir\t\t\t\t \033[37m$ee_mysql_data_dir" + ee_lib_echo_escape "socket\t\t\t\t \033[37m$ee_mysql_socket" + else + ee_lib_echo "MYSQL not installed" + fi } diff --git a/src/lib/ee_lib_nginx_info.sh b/src/lib/ee_lib_nginx_info.sh index 96257980..7d568b56 100644 --- a/src/lib/ee_lib_nginx_info.sh +++ b/src/lib/ee_lib_nginx_info.sh @@ -2,23 +2,28 @@ function ee_lib_nginx_info() { - local ee_nginx_version=$(nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2 | cut -d'/' -f2) - local ee_nginx_user=$(grep ^user /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_nginx_processes=$(grep worker_processes /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_nginx_connections=$(grep worker_connections /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_nginx_keep_alive=$(grep keepalive_timeout /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_fastcgi_timeout=$(grep fastcgi_read_timeout /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_clinet_max_body_size=$(grep client_max_body_size /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_nginx_allowed_ip_add=$(grep ^allow /etc/nginx/common/acl.conf | cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' ') + ee_lib_package_check $EE_NGINX_PACKAGE + if [ "$EE_PACKAGE_NAME" != "" ]; then + local ee_nginx_version=$(nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2 | cut -d'/' -f2) + local ee_nginx_user=$(grep ^user /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) + local ee_nginx_processes=$(grep worker_processes /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) + local ee_nginx_connections=$(grep worker_connections /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) + local ee_nginx_keep_alive=$(grep keepalive_timeout /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) + local ee_fastcgi_timeout=$(grep fastcgi_read_timeout /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) + local ee_clinet_max_body_size=$(grep client_max_body_size /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) + local ee_nginx_allowed_ip_add=$(grep ^allow /etc/nginx/common/acl.conf | cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' ') - ee_lib_echo - ee_lib_echo - ee_lib_echo "NGINX ($ee_nginx_version):" - ee_lib_echo_escape "user\t\t\t\t \033[37m$ee_nginx_user" - ee_lib_echo_escape "worker_processes\t\t \033[37m$ee_nginx_processes" - ee_lib_echo_escape "worker_connections\t\t \033[37m$ee_nginx_connections" - ee_lib_echo_escape "keepalive_timeout\t\t \033[37m$ee_nginx_keep_alive" - ee_lib_echo_escape "fastcgi_read_timeout\t\t \033[37m$ee_fastcgi_timeout" - ee_lib_echo_escape "client_max_body_size\t\t \033[37m$ee_clinet_max_body_size" - ee_lib_echo_escape "allow\t\t\t\t \033[37m$ee_nginx_allowed_ip_add" + ee_lib_echo + ee_lib_echo + ee_lib_echo "NGINX ($ee_nginx_version):" + ee_lib_echo_escape "user\t\t\t\t \033[37m$ee_nginx_user" + ee_lib_echo_escape "worker_processes\t\t \033[37m$ee_nginx_processes" + ee_lib_echo_escape "worker_connections\t\t \033[37m$ee_nginx_connections" + ee_lib_echo_escape "keepalive_timeout\t\t \033[37m$ee_nginx_keep_alive" + ee_lib_echo_escape "fastcgi_read_timeout\t\t \033[37m$ee_fastcgi_timeout" + ee_lib_echo_escape "client_max_body_size\t\t \033[37m$ee_clinet_max_body_size" + ee_lib_echo_escape "allow\t\t\t\t \033[37m$ee_nginx_allowed_ip_add" + else + ee_lib_echo "NGINX not installed" + fi } diff --git a/src/lib/ee_lib_php_info.sh b/src/lib/ee_lib_php_info.sh index 03c4f3f0..eca18548 100644 --- a/src/lib/ee_lib_php_info.sh +++ b/src/lib/ee_lib_php_info.sh @@ -1,52 +1,56 @@ # PHP information function ee_lib_php_info() { - #Collect information from php.ini - local ee_php_version=$(php -v | head -n1 | cut -d' ' -f2 | cut -d'+' -f1) - local ee_php_memory=$(grep ^memory_limit /etc/php5/fpm/php.ini | awk '{print $3}') - local ee_php_expose=$(grep ^expose_php /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) - local ee_php_post_max_size=$(grep post_max_size /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) - local ee_php_upload_max_filesize=$(grep upload_max_filesize /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) - local ee_php_max_execution_time=$(grep max_execution_time /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) + ee_lib_package_check php5-fpm + if [ "$EE_PACKAGE_NAME" != "" ]; then + #Collect information from php.ini + local ee_php_version=$(php -v | head -n1 | cut -d' ' -f2 | cut -d'+' -f1) + local ee_php_memory=$(grep ^memory_limit /etc/php5/fpm/php.ini | awk '{print $3}') + local ee_php_expose=$(grep ^expose_php /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) + local ee_php_post_max_size=$(grep post_max_size /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) + local ee_php_upload_max_filesize=$(grep upload_max_filesize /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) + local ee_php_max_execution_time=$(grep max_execution_time /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) - ee_lib_echo - ee_lib_echo "PHP ($ee_php_version):" - ee_lib_echo_escape "user\t\t\t\t \033[37m$EE_PHP_USER" - ee_lib_echo_escape "expose_php\t\t\t \033[37m$ee_php_expose" - ee_lib_echo_escape "memory_limit\t\t\t \033[37m$ee_php_memory" - ee_lib_echo_escape "post_max_size\t\t\t \033[37m$ee_php_post_max_size" - ee_lib_echo_escape "upload_max_filesize\t\t \033[37m$ee_php_upload_max_filesize" - ee_lib_echo_escape "max_execution_time\t\t \033[37m$ee_php_max_execution_time" - - - #Collect information from $ee_php_pool and debug.conf - for ee_php_pool in www.conf debug.conf;do - local ee_php_ping_path=$(grep ^ping.path /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_status_path=$(grep ^pm.status_path /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_process_manager=$(grep "^pm =" /etc/php5/fpm/pool.d/$ee_php_pool | awk '{print $3}') - local ee_php_max_requests=$(grep ^pm.max_requests /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_max_children=$(grep ^pm.max_children /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_start_servers=$(grep ^pm.start_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_min_spare_servers=$(grep ^pm.min_spare_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_max_spare_servers=$(grep ^pm.max_spare_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_request_terminate_timeout=$(grep ^request_terminate_timeout /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_xdebug_check=$( grep "php_admin_flag\[xdebug.profiler_enable_trigger\]" /etc/php5/fpm/pool.d/$ee_php_pool | grep on &> /dev/null && echo on || echo off) - local ee_php_listen=$(grep '^listen =' /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - ee_lib_echo - ee_lib_echo "Information about $ee_php_pool" - ee_lib_echo_escape "ping.path\t\t\t \033[37m$ee_php_ping_path" - ee_lib_echo_escape "pm.status_path\t\t\t \033[37m$ee_php_status_path" - ee_lib_echo_escape "process_manager\t\t\t \033[37m$ee_php_process_manager" - ee_lib_echo_escape "pm.max_requests\t\t\t \033[37m$ee_php_max_requests" - ee_lib_echo_escape "pm.max_children\t\t\t \033[37m$ee_php_max_children" - ee_lib_echo_escape "pm.start_servers\t\t \033[37m$ee_php_start_servers" - ee_lib_echo_escape "pm.min_spare_servers\t\t \033[37m$ee_php_min_spare_servers" - ee_lib_echo_escape "pm.max_spare_servers\t\t \033[37m$ee_php_max_spare_servers" - ee_lib_echo_escape "request_terminate_timeout\t \033[37m$ee_php_request_terminate_timeout" - ee_lib_echo_escape "xdebug.profiler_enable_trigger\t \033[37m$ee_xdebug_check" - ee_lib_echo_escape "listen\t\t\t\t \033[37m$ee_php_listen" - done + ee_lib_echo "PHP ($ee_php_version):" + ee_lib_echo_escape "user\t\t\t\t \033[37m$EE_PHP_USER" + ee_lib_echo_escape "expose_php\t\t\t \033[37m$ee_php_expose" + ee_lib_echo_escape "memory_limit\t\t\t \033[37m$ee_php_memory" + ee_lib_echo_escape "post_max_size\t\t\t \033[37m$ee_php_post_max_size" + ee_lib_echo_escape "upload_max_filesize\t\t \033[37m$ee_php_upload_max_filesize" + ee_lib_echo_escape "max_execution_time\t\t \033[37m$ee_php_max_execution_time" + + #Collect information from $ee_php_pool and debug.conf + for ee_php_pool in www.conf debug.conf;do + local ee_php_ping_path=$(grep ^ping.path /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + local ee_php_status_path=$(grep ^pm.status_path /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + local ee_php_process_manager=$(grep "^pm =" /etc/php5/fpm/pool.d/$ee_php_pool | awk '{print $3}') + local ee_php_max_requests=$(grep ^pm.max_requests /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + local ee_php_max_children=$(grep ^pm.max_children /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + local ee_php_start_servers=$(grep ^pm.start_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + local ee_php_min_spare_servers=$(grep ^pm.min_spare_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + local ee_php_max_spare_servers=$(grep ^pm.max_spare_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + local ee_php_request_terminate_timeout=$(grep ^request_terminate_timeout /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + local ee_xdebug_check=$( grep "php_admin_flag\[xdebug.profiler_enable_trigger\]" /etc/php5/fpm/pool.d/$ee_php_pool | grep on &> /dev/null && echo on || echo off) + local ee_php_listen=$(grep '^listen =' /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) + + ee_lib_echo + ee_lib_echo "Information about $ee_php_pool" + ee_lib_echo_escape "ping.path\t\t\t \033[37m$ee_php_ping_path" + ee_lib_echo_escape "pm.status_path\t\t\t \033[37m$ee_php_status_path" + ee_lib_echo_escape "process_manager\t\t\t \033[37m$ee_php_process_manager" + ee_lib_echo_escape "pm.max_requests\t\t\t \033[37m$ee_php_max_requests" + ee_lib_echo_escape "pm.max_children\t\t\t \033[37m$ee_php_max_children" + ee_lib_echo_escape "pm.start_servers\t\t \033[37m$ee_php_start_servers" + ee_lib_echo_escape "pm.min_spare_servers\t\t \033[37m$ee_php_min_spare_servers" + ee_lib_echo_escape "pm.max_spare_servers\t\t \033[37m$ee_php_max_spare_servers" + ee_lib_echo_escape "request_terminate_timeout\t \033[37m$ee_php_request_terminate_timeout" + ee_lib_echo_escape "xdebug.profiler_enable_trigger\t \033[37m$ee_xdebug_check" + ee_lib_echo_escape "listen\t\t\t\t \033[37m$ee_php_listen" + done + else + ee_lib_echo "PHP not installed" + fi } From 3b8edfbae4e0f8f556e2102a6205abf13ac30415 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Sep 2014 17:48:25 +0530 Subject: [PATCH 197/829] Fixes #307 --- bin/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/install b/bin/install index 51ae6944..298129ef 100644 --- a/bin/install +++ b/bin/install @@ -226,6 +226,9 @@ if [ -z "$GIT_USER_EMAIL" ];then echo "git config user.email = $(git config user.email)" &>> $EE_INSTALL_LOG fi +# Add eeupdate command to /etc/bash.bashrc +echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup http://rt.cx/eeup && sudo bash eeup\"" /etc/bash.bashrc + # Enable EasyEngine (ee) auto completion echo ee_lib_echo "For EasyEngine (ee) auto completion, run the following command" | tee -ai $EE_INSTALL_LOG From bd66b19ae871b253c42da80131fda91a4186e6d9 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Sep 2014 17:57:01 +0530 Subject: [PATCH 198/829] Fixed Typo --- bin/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install b/bin/install index 298129ef..563b6879 100644 --- a/bin/install +++ b/bin/install @@ -227,7 +227,7 @@ if [ -z "$GIT_USER_EMAIL" ];then fi # Add eeupdate command to /etc/bash.bashrc -echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup http://rt.cx/eeup && sudo bash eeup\"" /etc/bash.bashrc +echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup http://rt.cx/eeup && sudo bash eeup\"" >> /etc/bash.bashrc # Enable EasyEngine (ee) auto completion echo From 7b436a30fd97dafd563e078de2abef32fda6aa36 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Sep 2014 18:01:43 +0530 Subject: [PATCH 199/829] minor update --- src/lib/ee_lib_mysql_info.sh | 2 +- src/lib/ee_lib_nginx_info.sh | 2 +- src/lib/ee_lib_php_info.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/ee_lib_mysql_info.sh b/src/lib/ee_lib_mysql_info.sh index 6e4706de..d35a1fa6 100644 --- a/src/lib/ee_lib_mysql_info.sh +++ b/src/lib/ee_lib_mysql_info.sh @@ -3,7 +3,7 @@ function ee_lib_mysql_info() { mysqladmin ping &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then + if [ $? -eq 0 ]; then local ee_mysql_version=$(mysql -V | awk '{print($5)}' | cut -d ',' -f1) local ee_mysql_port=$(mysql -e "show variables" | grep ^port | awk '{print($2)}') local ee_mysql_socket=$(mysql -e "show variables" | grep "^socket" | awk '{print($2)}') diff --git a/src/lib/ee_lib_nginx_info.sh b/src/lib/ee_lib_nginx_info.sh index 7d568b56..0214fc80 100644 --- a/src/lib/ee_lib_nginx_info.sh +++ b/src/lib/ee_lib_nginx_info.sh @@ -3,7 +3,7 @@ function ee_lib_nginx_info() { ee_lib_package_check $EE_NGINX_PACKAGE - if [ "$EE_PACKAGE_NAME" != "" ]; then + if [ "$EE_PACKAGE_NAME" = "" ]; then local ee_nginx_version=$(nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2 | cut -d'/' -f2) local ee_nginx_user=$(grep ^user /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) local ee_nginx_processes=$(grep worker_processes /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) diff --git a/src/lib/ee_lib_php_info.sh b/src/lib/ee_lib_php_info.sh index eca18548..48500c60 100644 --- a/src/lib/ee_lib_php_info.sh +++ b/src/lib/ee_lib_php_info.sh @@ -2,7 +2,7 @@ function ee_lib_php_info() { ee_lib_package_check php5-fpm - if [ "$EE_PACKAGE_NAME" != "" ]; then + if [ "$EE_PACKAGE_NAME" = "" ]; then #Collect information from php.ini local ee_php_version=$(php -v | head -n1 | cut -d' ' -f2 | cut -d'+' -f1) local ee_php_memory=$(grep ^memory_limit /etc/php5/fpm/php.ini | awk '{print $3}') From 3918ea213aa749b284d24930937becfb71435ddc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Sep 2014 18:26:02 +0530 Subject: [PATCH 200/829] Fixed Update Issue on Debian 6 --- bin/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install b/bin/install index 563b6879..e813e107 100644 --- a/bin/install +++ b/bin/install @@ -227,7 +227,7 @@ if [ -z "$GIT_USER_EMAIL" ];then fi # Add eeupdate command to /etc/bash.bashrc -echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup http://rt.cx/eeup && sudo bash eeup\"" >> /etc/bash.bashrc +echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup --no-check-certificate http://rt.cx/eeup && sudo bash eeup\"" >> /etc/bash.bashrc # Enable EasyEngine (ee) auto completion echo From f3f3b595ca216438c0452f32171a832425788f4b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Sep 2014 19:08:26 +0530 Subject: [PATCH 201/829] Fixed Opcache Debian 6 issue --- src/modules/stack/install/ee_mod_setup_php.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh index eb9a82b0..59c643e5 100644 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ b/src/modules/stack/install/ee_mod_setup_php.sh @@ -68,10 +68,12 @@ function ee_mod_setup_php() mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat # Setup Zend OpCache as per RAM - grep memory_consumption /etc/php5/fpm/conf.d/05-opcache.ini &> /dev/null - if [ $? -ne 0 ]; then - sed -i "s/zend_extension=opcache.so/zend_extension=opcache.so\nopcache.memory_consumption=${EE_OPCACHE_SIZE}\nopcache.max_accelerated_files=50000/" /etc/php5/fpm/conf.d/05-opcache.ini \ - || ee_lib_error "Unable to change opcache.memory_consumption, exit status = " $? + if [ -f /etc/php5/fpm/conf.d/05-opcache.ini ]; then + grep memory_consumption /etc/php5/fpm/conf.d/05-opcache.ini &> /dev/null + if [ $? -ne 0 ]; then + sed -i "s/zend_extension=opcache.so/zend_extension=opcache.so\nopcache.memory_consumption=${EE_OPCACHE_SIZE}\nopcache.max_accelerated_files=50000/" /etc/php5/fpm/conf.d/05-opcache.ini \ + || ee_lib_error "Unable to change opcache.memory_consumption, exit status = " $? + fi fi # Setup PHP Memcache as per RAM From 7d5a095351c0073e6b877dd6f56e8d15cd2bd15a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 25 Sep 2014 15:34:51 +0530 Subject: [PATCH 202/829] Fixes #301 --- src/modules/stack/install/ee_mod_setup_php.sh | 6 ++++++ src/vendor/ee_ven_install_phpmyadmin.sh | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh index 59c643e5..f44720d9 100644 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ b/src/modules/stack/install/ee_mod_setup_php.sh @@ -79,5 +79,11 @@ function ee_mod_setup_php() # Setup PHP Memcache as per RAM sed -i "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \ || ee_lib_error "Unable to change Memcache memory value, exit status = " $? + + # Resolve php session Error Ref: #302 + chmod a+t+w /var/lib/php5 && + chmod go-r /var/lib/php5 \ + || ee_lib_error "Unable to setup PHP session error permissions, exit status = " $? + fi } diff --git a/src/vendor/ee_ven_install_phpmyadmin.sh b/src/vendor/ee_ven_install_phpmyadmin.sh index 64cd4bac..60d66b3f 100644 --- a/src/vendor/ee_ven_install_phpmyadmin.sh +++ b/src/vendor/ee_ven_install_phpmyadmin.sh @@ -4,7 +4,9 @@ function ee_ven_install_phpmyadmin() { if [ ! -d /var/www/22222/htdocs/db/pma ]; then - # Setup phpMyAdmin + local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1) + + # Setup phpMyAdmin directory mkdir -p /var/www/22222/htdocs/db/pma/ \ || ee_lib_error "Unable to create phpMyAdmin directory: /var/www/22222/htdocs/db/pma/, exit status = " $? @@ -20,5 +22,12 @@ function ee_ven_install_phpmyadmin() # Remove unwanted files rm -f /var/www/22222/htdocs/db/pma/pma.tar.gz + # Setup phpMyAdmin + cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND LOG \ + || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? + + sed -i "s/a8b7c6d/$ee_random/" /var/www/22222/htdocs/db/pma/config.inc.php \ + || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? + fi } From 0945b64bce3f65b7506a794329c82663d9d6ee1f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 25 Sep 2014 15:50:52 +0530 Subject: [PATCH 203/829] Fixes typo --- src/vendor/ee_ven_install_phpmyadmin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vendor/ee_ven_install_phpmyadmin.sh b/src/vendor/ee_ven_install_phpmyadmin.sh index 60d66b3f..5e0ba0e3 100644 --- a/src/vendor/ee_ven_install_phpmyadmin.sh +++ b/src/vendor/ee_ven_install_phpmyadmin.sh @@ -23,7 +23,7 @@ function ee_ven_install_phpmyadmin() rm -f /var/www/22222/htdocs/db/pma/pma.tar.gz # Setup phpMyAdmin - cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND LOG \ + cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? sed -i "s/a8b7c6d/$ee_random/" /var/www/22222/htdocs/db/pma/config.inc.php \ From 5509cf112c6660575d569de566eab5d6973263f3 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 26 Sep 2014 15:36:00 +0530 Subject: [PATCH 204/829] Fixed git config user.name Mitesh Shah and update curl to wget for ee installation --- bin/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install b/bin/install index e813e107..8ff84d53 100644 --- a/bin/install +++ b/bin/install @@ -23,7 +23,7 @@ function ee_lib_echo_fail() # Checking permissions if [[ $EUID -ne 0 ]]; then ee_lib_echo_fail "Sudo privilege required..." - ee_lib_echo_fail "Uses: curl -sL rt.cx/ee | sudo bash" + ee_lib_echo_fail "Uses: wget -qO ee rt.cx/ee && sudo bash ee" exit 1 fi @@ -211,7 +211,7 @@ if [ -z "$GIT_USER_NAME" ]; then if [[ $GIT_USER_NAME = "" ]]; then GIT_USER_NAME=$(whoami) fi - git config --global user.name $GIT_USER_NAME + git config --global user.name "${GIT_USER_NAME}" echo "git config user.name = $(git config user.name)" &>> $EE_INSTALL_LOG fi From 705bc0beec5b209e6ce8cfcde29ea24f433916ea Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 26 Sep 2014 16:11:52 +0530 Subject: [PATCH 205/829] Fixed Change password for 'user name' ee site update example.com --password --- src/modules/site/update/ee_mod_site_update_password.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_site_update_password.sh b/src/modules/site/update/ee_mod_site_update_password.sh index f1d4f1a0..f8055b57 100644 --- a/src/modules/site/update/ee_mod_site_update_password.sh +++ b/src/modules/site/update/ee_mod_site_update_password.sh @@ -22,7 +22,7 @@ ee_mod_site_update_password() read -sp "Provide password for $ee_wp_user user: " ee_wp_pass echo if [[ ${#ee_wp_pass} -ge 8 ]]; then - wp --allow-root user update $ee_wp_user --user_pass=$ee_wp_pass &>> $EE_COMMAND_LOG + wp --allow-root user update "${ee_wp_user}" --user_pass=$ee_wp_pass &>> $EE_COMMAND_LOG else ee_lib_error "Password Unchanged. Hint : Your password must be 8 characters long, exit status = " $? fi From 1424f5349e8edd1f09ebb421b4b8c778badaeca8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Sep 2014 19:06:25 +0530 Subject: [PATCH 206/829] Added SWAP creation function --- src/lib/ee_lib_ram.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh index a6b24461..be49e400 100644 --- a/src/lib/ee_lib_ram.sh +++ b/src/lib/ee_lib_ram.sh @@ -11,11 +11,13 @@ function ee_lib_ram() EE_MEMCACHE_SIZE="64" EE_PHP_MAX_CHILDREN="10" EE_SETUP_MAILSCANNER="no" + EE_SWAP="1024" # RAM > 512MB and RAM < 1024MB elif [ $EE_TOTAL_RAM -gt 512 ] && [ $EE_TOTAL_RAM -le 1024 ]; then EE_OPCACHE_SIZE="128" EE_MEMCACHE_SIZE="128" EE_PHP_MAX_CHILDREN="10" + EE_SWAP="1024" # RAM > 1024MB and RAM < 2048MB elif [ $EE_TOTAL_RAM -gt 1024 ] && [ $EE_TOTAL_RAM -le 2048 ]; then EE_OPCACHE_SIZE="256" From 16cc9218ba121562314547ba2b842f202483a881 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Sep 2014 19:06:25 +0530 Subject: [PATCH 207/829] Added SWAP creation function --- src/lib/ee_lib_create_swap.sh | 23 +++++++++++++++++++++++ src/lib/ee_lib_ram.sh | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 src/lib/ee_lib_create_swap.sh diff --git a/src/lib/ee_lib_create_swap.sh b/src/lib/ee_lib_create_swap.sh new file mode 100644 index 00000000..91f50c7b --- /dev/null +++ b/src/lib/ee_lib_create_swap.sh @@ -0,0 +1,23 @@ +# EasyEngine Swap creation + +function ee_lib_create_swap() +{ + # Use dd command to create SWAP + # Swap Parameters: + # Location: /swapfile + # Block Size: 1024 + dd if=/dev/zero of=/swapfile bs=1024 count=1024k \ + || ee_lib_error "Unable to generate /swapfile, exit status = " $? + + # Create it as a Swap + mkswap /swapfile \ + || ee_lib_error "Unable to create swapfile, exit status = " $? + + # On the Swap + swapon /swapfile \ + || ee_lib_error "Unable to on Swap, exit status = " $? + + # Add entry into /etc/fstab + echo "/swapfile none swap sw 0 0" >> /etc/fstab \ + || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $?" +} diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh index a6b24461..be49e400 100644 --- a/src/lib/ee_lib_ram.sh +++ b/src/lib/ee_lib_ram.sh @@ -11,11 +11,13 @@ function ee_lib_ram() EE_MEMCACHE_SIZE="64" EE_PHP_MAX_CHILDREN="10" EE_SETUP_MAILSCANNER="no" + EE_SWAP="1024" # RAM > 512MB and RAM < 1024MB elif [ $EE_TOTAL_RAM -gt 512 ] && [ $EE_TOTAL_RAM -le 1024 ]; then EE_OPCACHE_SIZE="128" EE_MEMCACHE_SIZE="128" EE_PHP_MAX_CHILDREN="10" + EE_SWAP="1024" # RAM > 1024MB and RAM < 2048MB elif [ $EE_TOTAL_RAM -gt 1024 ] && [ $EE_TOTAL_RAM -le 2048 ]; then EE_OPCACHE_SIZE="256" From 767e77a467471468b8a75122180444ddf33d7fdf Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Sep 2014 19:18:39 +0530 Subject: [PATCH 208/829] Fixed Typo --- src/lib/ee_lib_create_swap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_create_swap.sh b/src/lib/ee_lib_create_swap.sh index 91f50c7b..84c7c5e4 100644 --- a/src/lib/ee_lib_create_swap.sh +++ b/src/lib/ee_lib_create_swap.sh @@ -19,5 +19,5 @@ function ee_lib_create_swap() # Add entry into /etc/fstab echo "/swapfile none swap sw 0 0" >> /etc/fstab \ - || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $?" + || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $? } From b59f942efb41b9dd5f2a3b1f786c130a4c887d91 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Sep 2014 19:23:47 +0530 Subject: [PATCH 209/829] Improced Code --- src/lib/ee_lib_create_swap.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/ee_lib_create_swap.sh b/src/lib/ee_lib_create_swap.sh index 84c7c5e4..37cae5de 100644 --- a/src/lib/ee_lib_create_swap.sh +++ b/src/lib/ee_lib_create_swap.sh @@ -6,15 +6,15 @@ function ee_lib_create_swap() # Swap Parameters: # Location: /swapfile # Block Size: 1024 - dd if=/dev/zero of=/swapfile bs=1024 count=1024k \ + dd if=/dev/zero of=/swapfile bs=1024 count=1024k &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to generate /swapfile, exit status = " $? # Create it as a Swap - mkswap /swapfile \ + mkswap /swapfile &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to create swapfile, exit status = " $? # On the Swap - swapon /swapfile \ + swapon /swapfile &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to on Swap, exit status = " $? # Add entry into /etc/fstab From 07845f9e248f1c156c4cb20bafc4954e931c1ecf Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Sep 2014 19:35:23 +0530 Subject: [PATCH 210/829] Improved Functions --- src/lib/ee_lib_create_swap.sh | 35 ++++++++++++++++++++--------------- src/lib/ee_lib_ram.sh | 3 ++- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/lib/ee_lib_create_swap.sh b/src/lib/ee_lib_create_swap.sh index 37cae5de..05cb98b8 100644 --- a/src/lib/ee_lib_create_swap.sh +++ b/src/lib/ee_lib_create_swap.sh @@ -2,22 +2,27 @@ function ee_lib_create_swap() { - # Use dd command to create SWAP - # Swap Parameters: - # Location: /swapfile - # Block Size: 1024 - dd if=/dev/zero of=/swapfile bs=1024 count=1024k &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to generate /swapfile, exit status = " $? + if [ $EE_TOTAL_RAM -le 512 ]; then + if [ $EE_TOTAL_SWAP -le $EE_SWAP ];then - # Create it as a Swap - mkswap /swapfile &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to create swapfile, exit status = " $? + # Use dd command to create SWAP + # Swap Parameters: + # Location: /swapfile + # Block Size: 1024 + dd if=/dev/zero of=/swapfile bs=1024 count=1024k &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to generate /swapfile, exit status = " $? - # On the Swap - swapon /swapfile &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to on Swap, exit status = " $? + # Create it as a Swap + mkswap /swapfile &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to create swapfile, exit status = " $? - # Add entry into /etc/fstab - echo "/swapfile none swap sw 0 0" >> /etc/fstab \ - || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $? + # On the Swap + swapon /swapfile &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to on Swap, exit status = " $? + + # Add entry into /etc/fstab + echo "/swapfile none swap sw 0 0" >> /etc/fstab \ + || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $? + fi + fi } diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh index be49e400..cc9c9120 100644 --- a/src/lib/ee_lib_ram.sh +++ b/src/lib/ee_lib_ram.sh @@ -2,8 +2,9 @@ function ee_lib_ram() { - # Detect RAM of System + # Detect RAM and SWAP of System readonly EE_TOTAL_RAM=$(free -m | grep -i Mem | awk '{ print $2 }') + readonly EE_TOTAL_SWAP=$(free -m | grep -i Swap | awk '{ print $2 }') # RAM < 512MB if [ $EE_TOTAL_RAM -le 512 ]; then From 266ee3e45f2ca073bd2e040f9ce4318b90732382 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Sep 2014 19:36:25 +0530 Subject: [PATCH 211/829] Addded create SWAP function --- bin/easyengine | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/easyengine b/bin/easyengine index 925697c4..18ec9bfe 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -47,6 +47,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then if [ "$EE_SECOND" = "install" ]; then # Detect RAM of system and initialize the variables. ee_lib_ram + ee_lib_create_swap if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then # Setup NGINX/PHP repository From 8b079100c6a159533e810fb5c97ea87d7b780ec3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Sep 2014 19:42:21 +0530 Subject: [PATCH 212/829] Display message --- src/lib/ee_lib_create_swap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/ee_lib_create_swap.sh b/src/lib/ee_lib_create_swap.sh index 05cb98b8..732c526b 100644 --- a/src/lib/ee_lib_create_swap.sh +++ b/src/lib/ee_lib_create_swap.sh @@ -9,6 +9,7 @@ function ee_lib_create_swap() # Swap Parameters: # Location: /swapfile # Block Size: 1024 + ee_lib_echo "Adding 1GB swapfile" dd if=/dev/zero of=/swapfile bs=1024 count=1024k &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to generate /swapfile, exit status = " $? From 1794292b575ca4f579d0993cf245a18150757c64 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Sep 2014 19:43:33 +0530 Subject: [PATCH 213/829] Better Display Message --- src/lib/ee_lib_create_swap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_create_swap.sh b/src/lib/ee_lib_create_swap.sh index 732c526b..c18ca87b 100644 --- a/src/lib/ee_lib_create_swap.sh +++ b/src/lib/ee_lib_create_swap.sh @@ -9,7 +9,7 @@ function ee_lib_create_swap() # Swap Parameters: # Location: /swapfile # Block Size: 1024 - ee_lib_echo "Adding 1GB swapfile" + ee_lib_echo "Adding 1GB swapfile, please wait..." dd if=/dev/zero of=/swapfile bs=1024 count=1024k &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to generate /swapfile, exit status = " $? From 40b7d85b64e7e6884a7ac20630ae98b77cdd2bec Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 29 Sep 2014 11:59:26 +0530 Subject: [PATCH 214/829] Reverted Percona Mysql setup script --- src/modules/stack/install/ee_mod_setup_mysql.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/ee_mod_setup_mysql.sh b/src/modules/stack/install/ee_mod_setup_mysql.sh index e6b9793a..d40ccdc6 100644 --- a/src/modules/stack/install/ee_mod_setup_mysql.sh +++ b/src/modules/stack/install/ee_mod_setup_mysql.sh @@ -5,7 +5,8 @@ function ee_mod_setup_mysql() ee_lib_echo "Setting up Percona MySQL, please wait..." # Setting wait_timeout = 30 & interactive_timeout = 60 - if [ ! -f /etc/mysql/my.cnf ]; then - echo -e "[mysqld] \nwait_timeout = 30 \ninteractive_timeout = 60" &>> /etc/mysql/my.cnf + grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG + if [ $? -ne 0 ]; then + sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf fi } From 5d1e98d3e63bb72ad0984a59e8c1661653140235 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 29 Sep 2014 15:31:50 +0530 Subject: [PATCH 215/829] Improved Swap creation --- src/lib/ee_lib_create_swap.sh | 12 ++++++------ src/lib/ee_lib_ram.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/ee_lib_create_swap.sh b/src/lib/ee_lib_create_swap.sh index c18ca87b..3fde4dc8 100644 --- a/src/lib/ee_lib_create_swap.sh +++ b/src/lib/ee_lib_create_swap.sh @@ -7,22 +7,22 @@ function ee_lib_create_swap() # Use dd command to create SWAP # Swap Parameters: - # Location: /swapfile + # Location: /ee-swapfile # Block Size: 1024 ee_lib_echo "Adding 1GB swapfile, please wait..." - dd if=/dev/zero of=/swapfile bs=1024 count=1024k &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to generate /swapfile, exit status = " $? + dd if=/dev/zero of=/ee-swapfile bs=1024 count=1024k &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to generate /ee-swapfile, exit status = " $? # Create it as a Swap - mkswap /swapfile &>> $EE_COMMAND_LOG \ + mkswap /ee-swapfile &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to create swapfile, exit status = " $? # On the Swap - swapon /swapfile &>> $EE_COMMAND_LOG \ + swapon /ee-swapfile &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to on Swap, exit status = " $? # Add entry into /etc/fstab - echo "/swapfile none swap sw 0 0" >> /etc/fstab \ + echo "/ee-swapfile none swap sw 0 0" >> /etc/fstab \ || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $? fi fi diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh index cc9c9120..b96d9bef 100644 --- a/src/lib/ee_lib_ram.sh +++ b/src/lib/ee_lib_ram.sh @@ -4,7 +4,7 @@ function ee_lib_ram() { # Detect RAM and SWAP of System readonly EE_TOTAL_RAM=$(free -m | grep -i Mem | awk '{ print $2 }') - readonly EE_TOTAL_SWAP=$(free -m | grep -i Swap | awk '{ print $2 }') + readonly EE_TOTAL_SWAP=$(free -m --si | grep -i Swap | awk '{ print $2 }') # RAM < 512MB if [ $EE_TOTAL_RAM -le 512 ]; then From 58c9932ccc68b572281354b6bbc9221cd3a3d71a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 29 Sep 2014 15:49:41 +0530 Subject: [PATCH 216/829] Fix #311 ee debug autocompletion improved --- config/bash_completion.d/ee | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 60829e64..4806df1d 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -1,5 +1,17 @@ # EasyEngine auto complete +function ee_single() +{ + for (( j=0; j<${#COMP_WORDS[@]}; j++ )); do + for (( i=0; i<${#COMPREPLY[@]}; i++ )); do + if [[ ${COMP_WORDS[COMP_CWORD-j]} == ${COMPREPLY[i]} ]]; then + rem=( ${COMP_WORDS[COMP_CWORD-j]} ); + COMPREPLY=( "${COMPREPLY[@]/$rem" ) + fi + done + done +} + function EE_AUTO() { # Get current word @@ -15,7 +27,7 @@ function EE_AUTO() # List of suggested words easyengine|ee) - COMPREPLY=( $(compgen -W '$(echo version help info update import-slow-log; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) + COMPREPLY=( $(compgen -W '$(echo version help info update; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) return 0 ;; @@ -61,12 +73,9 @@ function EE_AUTO() return 0 ;; - --nginx|--rewrite|--php|--fpm) + --nginx|--rewrite|--php|--fpm|--mysql) COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) - return 0 - ;; - --mysql) - COMPREPLY=( $(compgen -W '$(echo --import-slow-log-interval=; cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + ee_single return 0 ;; @@ -75,12 +84,15 @@ function EE_AUTO() COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) ) else COMPREPLY=( $(compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | grep -v wp | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + ee_single fi return 0 ;; --stop) + COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)' -- $CURRENT ) ) + ee_single return 0 ;; From 94bc2177b073a0e5b9e0ab687cdc4ea3348a5563 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 29 Sep 2014 16:09:23 +0530 Subject: [PATCH 217/829] config/bash_completion.d/ee --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 4806df1d..9f69d761 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -6,7 +6,7 @@ function ee_single() for (( i=0; i<${#COMPREPLY[@]}; i++ )); do if [[ ${COMP_WORDS[COMP_CWORD-j]} == ${COMPREPLY[i]} ]]; then rem=( ${COMP_WORDS[COMP_CWORD-j]} ); - COMPREPLY=( "${COMPREPLY[@]/$rem" ) + COMPREPLY=( "${COMPREPLY[@]/$rem}" ) fi done done From b09c827a4c182109d50e4ac5a58809a41f8e1699 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 29 Sep 2014 16:51:27 +0530 Subject: [PATCH 218/829] Fixed SWAP issue of Debian 6 --- bin/easyengine | 2 +- src/lib/ee_lib_ram.sh | 2 +- src/lib/{ee_lib_create_swap.sh => ee_lib_swap.sh} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename src/lib/{ee_lib_create_swap.sh => ee_lib_swap.sh} (89%) diff --git a/bin/easyengine b/bin/easyengine index 18ec9bfe..4b6d1e38 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -47,7 +47,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then if [ "$EE_SECOND" = "install" ]; then # Detect RAM of system and initialize the variables. ee_lib_ram - ee_lib_create_swap + ee_lib_swap if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then # Setup NGINX/PHP repository diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh index b96d9bef..cc9c9120 100644 --- a/src/lib/ee_lib_ram.sh +++ b/src/lib/ee_lib_ram.sh @@ -4,7 +4,7 @@ function ee_lib_ram() { # Detect RAM and SWAP of System readonly EE_TOTAL_RAM=$(free -m | grep -i Mem | awk '{ print $2 }') - readonly EE_TOTAL_SWAP=$(free -m --si | grep -i Swap | awk '{ print $2 }') + readonly EE_TOTAL_SWAP=$(free -m | grep -i Swap | awk '{ print $2 }') # RAM < 512MB if [ $EE_TOTAL_RAM -le 512 ]; then diff --git a/src/lib/ee_lib_create_swap.sh b/src/lib/ee_lib_swap.sh similarity index 89% rename from src/lib/ee_lib_create_swap.sh rename to src/lib/ee_lib_swap.sh index 3fde4dc8..5f9edba0 100644 --- a/src/lib/ee_lib_create_swap.sh +++ b/src/lib/ee_lib_swap.sh @@ -1,6 +1,6 @@ # EasyEngine Swap creation -function ee_lib_create_swap() +function ee_lib_swap() { if [ $EE_TOTAL_RAM -le 512 ]; then if [ $EE_TOTAL_SWAP -le $EE_SWAP ];then @@ -10,7 +10,7 @@ function ee_lib_create_swap() # Location: /ee-swapfile # Block Size: 1024 ee_lib_echo "Adding 1GB swapfile, please wait..." - dd if=/dev/zero of=/ee-swapfile bs=1024 count=1024k &>> $EE_COMMAND_LOG \ + dd if=/dev/zero of=/ee-swapfile bs=1024 count=1048k &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to generate /ee-swapfile, exit status = " $? # Create it as a Swap From 851b4e39ec67c159c13a1d92de5ed6d1ee63dd0b Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 29 Sep 2014 19:57:23 +0530 Subject: [PATCH 219/829] ee update modified --- bin/easyengine | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 18ec9bfe..df823ea7 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -802,8 +802,8 @@ elif [ "$EE_FIRST" = "import-slow-log" ];then # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then - ee_lib_echo "Please set/use following alias to update EasyEngine (ee)" - echo "alias eeupdate=\"wget -qO eeup http://rt.cx/eeup && sudo bash eeup\"" + ee_lib_echo "Updating EasyEngine (ee), please wait..." + wget --no-check-certificate -qO eeup http://rt.cx/eeup && sudo bash eeup else ee_lib_echo "EasyEngine (ee) commands:" From 1277000bf510260f590c9b323b48b9bba809f5fa Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 30 Sep 2014 11:48:49 +0530 Subject: [PATCH 220/829] Added ee stack install admin-tools --- bin/easyengine | 70 ++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index db820c83..108a5be5 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -93,41 +93,45 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display success message ee_lib_echo "$EE_THIRD successfully installed" - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then - # Setup NGINX/PHP/MySQL repository - ee_mod_repo_nginx - ee_mod_repo_php - ee_mod_repo_mysql - - # Fix GnuPG key - ee_lib_gpg_key_fix - - # Execute: apt-get update - ee_lib_apt_get_update - - # Install NGINX/PHP/MySQL/Postfix package - ee_mod_install_nginx - ee_mod_install_php - ee_mod_install_mysql - ee_mod_install_postfix - - # Setup NGINX/PHP/MySQL - ee_mod_setup_nginx - ee_mod_setup_php - ee_mod_setup_mysql - - # Restart NGINX/MySQL/Postfix - ee_lib_service nginx php5-fpm mysql restart - - # Initialize Git - ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git" + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin-tools" ] || [ "$EE_THIRD" = "all" ]; then + if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then + # Setup NGINX/PHP/MySQL repository + ee_mod_repo_nginx + ee_mod_repo_php + ee_mod_repo_mysql - # Install Adminer/phpMyAdmin/WP-CLI/Utils - ee_ven_install_adminer - ee_ven_install_phpmyadmin - ee_ven_install_wpcli - ee_ven_install_utils + # Fix GnuPG key + ee_lib_gpg_key_fix + + # Execute: apt-get update + ee_lib_apt_get_update + # Install NGINX/PHP/MySQL/Postfix package + ee_mod_install_nginx + ee_mod_install_php + ee_mod_install_mysql + ee_mod_install_postfix + + # Setup NGINX/PHP/MySQL + ee_mod_setup_nginx + ee_mod_setup_php + ee_mod_setup_mysql + + # Restart NGINX/MySQL/Postfix + ee_lib_service nginx php5-fpm mysql restart + + # Initialize Git + ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git" + + # Install WP-CLI + ee_ven_install_wpcli + fi + if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin-tools" ] || [ "$EE_THIRD" = "all" ]; then + # Install Adminer/phpMyAdmin/Utils + ee_ven_install_adminer + ee_ven_install_phpmyadmin + ee_ven_install_utils + fi # Display success message if [ "$EE_THIRD" != "all" ];then ee_lib_echo "Successfully installed web server packages" From e7f72015515ef70ff8a5f12efea821600eb0e6a5 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 30 Sep 2014 12:37:21 +0530 Subject: [PATCH 221/829] Added ee stack remove remove/purge admin --- bin/easyengine | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 108a5be5..d4e1c387 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -126,7 +126,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Install WP-CLI ee_ven_install_wpcli fi - if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin-tools" ] || [ "$EE_THIRD" = "all" ]; then + if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then # Install Adminer/phpMyAdmin/Utils ee_ven_install_adminer ee_ven_install_phpmyadmin @@ -134,7 +134,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then fi # Display success message if [ "$EE_THIRD" != "all" ];then - ee_lib_echo "Successfully installed web server packages" + ee_lib_echo "Successfully installed $([ "$EE_THIRD" != "" ] && echo $EE_THIRD || echo "web" ) server packages" ee_lib_echo "Create your first WordPress site powered by NGINX using:" ee_lib_echo_info "ee site create example.com --wp" fi @@ -245,27 +245,32 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then elif [ "$EE_SECOND" = "purge" ];then ee_lib_echo "$EE_THIRD successfully purged" fi - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then - # Remove/Purge NGINX/PHP/MySQL/Postfix package - ee_mod_remove_nginx - ee_mod_remove_php - ee_mod_remove_mysql - ee_mod_remove_postfix - - # Install Adminer/phpMyAdmin/WP-CLI/Utils - ee_ven_remove_adminer - ee_ven_remove_phpmyadmin - ee_ven_remove_wpcli - ee_ven_remove_utils + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then + if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then + # Remove/Purge NGINX/PHP/MySQL/Postfix package + ee_mod_remove_nginx + ee_mod_remove_php + ee_mod_remove_mysql + ee_mod_remove_postfix + + # Remove/Purge WP-CLI + ee_ven_remove_wpcli + fi + if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then + # Remove/Purge Adminer/phpMyAdmin/Utils + ee_ven_remove_adminer + ee_ven_remove_phpmyadmin + ee_ven_remove_utils + fi # Execute: apt-get autoremove ee_lib_autoremove # Display success message if [ "$EE_SECOND" = "remove" ];then - ee_lib_echo "Successfully removed web packages" + ee_lib_echo "Successfully removed $([ "$EE_THIRD" != "" ] && echo $EE_THIRD || echo "web" ) packages" elif [ "$EE_SECOND" = "purge" ];then - ee_lib_echo "Successfully purged web packages" + ee_lib_echo "Successfully purged $EE_THIRD packages" fi fi if [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "mail" ];then From c50670095faf8dc97272aaa115e0eea2ef66caf4 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 30 Sep 2014 12:59:27 +0530 Subject: [PATCH 222/829] minor update --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index d4e1c387..28597c8c 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -93,7 +93,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display success message ee_lib_echo "$EE_THIRD successfully installed" - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin-tools" ] || [ "$EE_THIRD" = "all" ]; then + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then # Setup NGINX/PHP/MySQL repository ee_mod_repo_nginx From 4fde4810c09da109223f89cd85460e3977860516 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 30 Sep 2014 14:27:54 +0530 Subject: [PATCH 223/829] Upgraded Roundcube Version to 1.0.3 --- src/lib/ee_lib_variables.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 67eca071..89a17394 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -10,7 +10,7 @@ readonly EE_WP_CLI_VERSION='0.17.0' readonly EE_ADMINER_VERSION='4.1.0' # Roundcube Version -readonly EE_ROUNDCUBE_VERSION='1.0.2' +readonly EE_ROUNDCUBE_VERSION='1.0.3' # ViMbAdmin Version readonly EE_VIMBADMIN_VERSION='3.0.10' From 332db3bb953173011c42a97b5cd09addfd8c0734 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 30 Sep 2014 14:46:50 +0530 Subject: [PATCH 224/829] Minor Update --- bin/easyengine | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 28597c8c..e0d4a416 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -135,8 +135,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display success message if [ "$EE_THIRD" != "all" ];then ee_lib_echo "Successfully installed $([ "$EE_THIRD" != "" ] && echo $EE_THIRD || echo "web" ) server packages" - ee_lib_echo "Create your first WordPress site powered by NGINX using:" - ee_lib_echo_info "ee site create example.com --wp" + if [ "$EE_THIRD" != "admin" ];then + ee_lib_echo "Create your first WordPress site powered by NGINX using:" + ee_lib_echo_info "ee site create example.com --wp" + fi fi fi # EasyEngine mail server setup From 3fd34913796994b38019c9a6ad5a1f9c5bc64027 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 1 Oct 2014 12:35:10 +0530 Subject: [PATCH 225/829] Minor Update on check stack packages --- bin/easyengine | 38 +++++--------------------- src/lib/ee_lib_stack_packages.sh | 46 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 src/lib/ee_lib_stack_packages.sh diff --git a/bin/easyengine b/bin/easyengine index e0d4a416..07de81b5 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -451,47 +451,21 @@ elif [ "$EE_FIRST" = "site" ]; then fi if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_package_check $EE_NGINX_PACKAGE - if [ "$EE_PACKAGE_NAME" != "" ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install nginx || exit $? - fi + ee_lib_stack_packages nginx + fi if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_package_check php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached php5-geoip - if [ "$EE_PACKAGE_NAME" != "" ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install php || exit $? - fi + ee_lib_stack_packages php fi if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - mysqladmin ping &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install mysql || exit $? - fi + ee_lib_stack_packages mysql fi if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_ven_install_wpcli fi - - ee_lib_package_check postfix - if [ "$EE_PACKAGE_NAME" != "" ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install postfix || exit $? - fi - + ee_lib_stack_packages postfix + # Lets create HTML|PHP|MySQL website if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then # Configure variable diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh new file mode 100644 index 00000000..619f4475 --- /dev/null +++ b/src/lib/ee_lib_stack_packages.sh @@ -0,0 +1,46 @@ +# Check the specified package is installed or not + +function ee_lib_stack_packages() +{ + local ee_stack_package + + for ee_stack_package in $@;do + # Check NGINX installed & install if not + if [ "$ee_stack_package" = "nginx" ] + ee_lib_package_check $EE_NGINX_PACKAGE + if [ "$EE_PACKAGE_NAME" != "" ]; then + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install nginx || exit $? + fi + # Check PHP installed & install if not + elif [ "$ee_stack_package" = "php" ]; then + ee_lib_package_check php5-fpm + if [ "$EE_PACKAGE_NAME" != "" ]; then + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install php || exit $? + fi + # Check MySQL installed & install if not + elif [ "$ee_stack_package" = "mysql" ]; then + mysqladmin ping &>> $EE_COMMAND_LOG + if [ $? -ne 0 ]; then + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install mysql || exit $? + fi + # Check Postfix installed & install if not + elif [ "$ee_stack_package" = "postfix" ]; then + ee_lib_package_check postfix + if [ "$EE_PACKAGE_NAME" != "" ]; then + # The following command creates its own sub-shell + # and our ee_lib_error function only exit from that sub-shell + # so we need to exit from parent shell also + ee stack install postfix || exit $? + fi + fi + done +} From 07a75672b2a8f693d8fd4b78990899403c934960 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 1 Oct 2014 12:56:05 +0530 Subject: [PATCH 226/829] HTTP auth details now hidden from screen --- bin/update | 8 +++++++- src/modules/secure/ee_mod_secure_auth.sh | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/update b/bin/update index 5136b981..709b291a 100644 --- a/bin/update +++ b/bin/update @@ -427,7 +427,13 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then EE_CURRENT_VERSION="2.1.0" fi - # if [[ $EE_CURRENT_VERSION = 2.1.0 ]]; then + if [[ $EE_CURRENT_VERSION = 2.1.0 ]]; then + + + # Update EasyEngine current version + EE_CURRENT_VERSION="2.1.0" + fi + # if [[ $EE_CURRENT_VERSION = 2.2.0 ]]; then # fi fi diff --git a/src/modules/secure/ee_mod_secure_auth.sh b/src/modules/secure/ee_mod_secure_auth.sh index 1440eae6..daffcbad 100644 --- a/src/modules/secure/ee_mod_secure_auth.sh +++ b/src/modules/secure/ee_mod_secure_auth.sh @@ -22,8 +22,8 @@ function ee_mod_secure_auth() # Add HTTP authentication details echo - ee_lib_echo_info "HTTP authentication username: $ee_http_auth_user" - ee_lib_echo_info "HTTP authentication password: $ee_http_auth_pass" + ee_lib_echo "HTTP authentication username: $ee_http_auth_user" &>> $EE_COMMAND_LOG + ee_lib_echo "HTTP authentication password: $ee_http_auth_pass" &>> $EE_COMMAND_LOG # Generate htpasswd-ee file printf "$ee_http_auth_user:$(openssl passwd -crypt $ee_http_auth_pass 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null From 4d4d68fd1705b73fdb75dfa90727bfb5de05a6e1 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 1 Oct 2014 13:15:11 +0530 Subject: [PATCH 227/829] syntax correction --- src/lib/ee_lib_stack_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index 619f4475..a75f18b3 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -6,7 +6,7 @@ function ee_lib_stack_packages() for ee_stack_package in $@;do # Check NGINX installed & install if not - if [ "$ee_stack_package" = "nginx" ] + if [ "$ee_stack_package" = "nginx" ]; then ee_lib_package_check $EE_NGINX_PACKAGE if [ "$EE_PACKAGE_NAME" != "" ]; then # The following command creates its own sub-shell From 18e55ebbce161e1b11945f7a08f98a0d16f31a5d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 3 Oct 2014 19:51:56 +0530 Subject: [PATCH 228/829] Fix #103 --- bin/easyengine | 163 +++++++++++++++++- .../site/update/ee_mod_update_domain.sh | 18 ++ 2 files changed, 177 insertions(+), 4 deletions(-) create mode 100644 src/modules/site/update/ee_mod_update_domain.sh diff --git a/bin/easyengine b/bin/easyengine index 07de81b5..1d8ceb50 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -452,7 +452,6 @@ elif [ "$EE_FIRST" = "site" ]; then if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_lib_stack_packages nginx - fi if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_lib_stack_packages php @@ -622,19 +621,175 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_service nginx reload fi elif [ "$EE_SECOND" = "update" ]; then - # Check the website name is empty or not + # Configure variables EE_DOMAIN_CHECK=$EE_THIRD EE_SITE_UPDATE_OPTION=$EE_FOURTH + EE_SITE_CACHE_OPTION=$EE_FIFTH + ee_lib_check_domain # Check the website exist ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) - if [ "$EE_SITE_UPDATE_OPTION" = "--password" ]; then ee_mod_site_update_password + else + # Auto switch options + if [ "$EE_SITE_UPDATE_OPTION" = "--basic" ] || [ "$EE_SITE_UPDATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpfc" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then + EE_SITE_UPDATE_OPTION=$EE_FIFTH + EE_SITE_CACHE_OPTION=$EE_FOURTH + else + EE_SITE_UPDATE_OPTION=--wp + EE_SITE_CACHE_OPTION=$EE_FOURTH + fi + fi + # WordPresss subdirectory variables + if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdirectory" ]; then + EE_SITE_UPDATE_OPTION="--wpsubdir" + EE_NETWORK_ACTIVATE="--network" + fi + # WordPress sub-domain variables + if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + EE_SITE_UPDATE_OPTION="--wpsubdomain" + EE_NETWORK_ACTIVATE="--network" + EE_WP_SUBDOMAIN="--subdomains" + fi + # Use default whenever possible + if [ "$EE_SITE_UPDATE_OPTION" = "" ]; then + EE_SITE_UPDATE_OPTION=--html + fi + # For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION + if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_UPDATE_OPTION" != "--html" ] && [ "$EE_SITE_UPDATE_OPTION" != "--php" ] && [ "$EE_SITE_UPDATE_OPTION" != "--mysql" ]; then + EE_SITE_CACHE_OPTION=--basic + fi + + EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + if [ "$EE_SITE_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ]; then + EE_NGINX_CONF=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/basic.conf + elif [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + EE_NGINX_CONF=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf + fi + fi + + # Install required + if [ "$EE_SITE_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_stack_packages nginx + fi + if [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_stack_packages php + fi + if [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_stack_packages mysql + fi + + if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + ee_ven_install_wpcli + fi + ee_lib_stack_packages postfix + + # Lets update HTML|PHP|MySQL website + if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then + + if [[ "$EE_SITE_UPDATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ] \ + || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + # Update NGINX + ee_mod_update_domain + fi + + if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + ee_mod_setup_wordpress + fi + + if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + ee_mod_setup_network + fi + + if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + # Install WordPress plugins + ee_mod_plugin_nginx_helper + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_mod_plugin_w3tc + fi + # Setup MySQL database + if [[ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then + ee_mod_setup_database + + # Add Database Information On ee-config.php + echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ + &>> /var/www/$EE_DOMAIN/ee-config.php + fi + elif [ "$EE_SITE_CURRENT_OPTION" = "WP SINGLE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ]; then + + if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WP SINGLE" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]] \ + || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + # Update NGINX + ee_mod_update_domain + fi + if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + ee_mod_setup_network + fi + if [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]]; then + ee_mod_plugin_wpsc + fi + if [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]]; then + ee_mod_plugin_w3tc + fi + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ]; then + if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ]] \ + || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + # Update NGINX + ee_mod_update_domain + fi + if [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]]; then + ee_mod_plugin_wpsc + fi + if [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]]; then + ee_mod_plugin_w3tc + fi + + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ]]; then + # Update NGINX + ee_mod_update_domain + fi + if [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ]]; then + ee_mod_plugin_wpsc + fi + if [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ]] \ + || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]]; then + ee_mod_plugin_w3tc + fi + fi + # Adjust permission + ee_lib_permissions + + # Git commit + ee_lib_git /etc/nginx/ "$EE_DOMAIN updated with $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION options" + + # Display Success Message + ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" fi elif [ "$EE_SECOND" = "log" ]; then # Display logs for websites diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh new file mode 100644 index 00000000..6bd955a8 --- /dev/null +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -0,0 +1,18 @@ +# Update Domain setup + +function ee_mod_update_domain() +{ + # Creating $EE_DOMAIN + ee_lib_echo "Updating $EE_DOMAIN, please wait..." + + sed "s/example.com/$EE_DOMAIN/g" \ + /usr/share/easyengine/nginx/$EE_NGINX_CONF \ + > /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration file for $EE_DOMAIN, exit status = " $? + + # Creating symbolic link + ee_lib_echo "Creating symbolic link for $EE_DOMAIN" + if [ ! -e /etc/nginx/sites-enabled/$EE_DOMAIN ]; then + ee_lib_symbolic_link /etc/nginx/sites-available/$EE_DOMAIN /etc/nginx/sites-enabled/ + fi +} From 67d3d441b7bbed3293823929f7b73bed5923e3f7 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 3 Oct 2014 19:56:42 +0530 Subject: [PATCH 229/829] http auth default password set to random --- src/modules/stack/install/ee_mod_setup_nginx.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh index 75943cde..fc3c4b6c 100644 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ b/src/modules/stack/install/ee_mod_setup_nginx.sh @@ -3,6 +3,7 @@ function ee_mod_setup_nginx() { local ee_whitelist_ip_address + local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) ee_lib_echo "Setting up NGINX, please wait..." @@ -94,4 +95,9 @@ function ee_mod_setup_nginx() sed -i "/deny/i $(echo allow $ee_whitelist_ip_address\;)" /etc/nginx/common/acl.conf done fi + + # Set easyengine:easyengine as default http authentication + if [ ! -f /etc/nginx/htpasswd-ee ]; then + printf "easyengine:$(openssl passwd -crypt $ee_random 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null + fi } From 1f23d39d30774d052d48b4a56b69d7f41d78930a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 6 Oct 2014 12:45:53 +0530 Subject: [PATCH 230/829] Minor Update --- bin/easyengine | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 1d8ceb50..e3d2f08d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -726,10 +726,10 @@ elif [ "$EE_FIRST" = "site" ]; then echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ &>> /var/www/$EE_DOMAIN/ee-config.php fi - elif [ "$EE_SITE_CURRENT_OPTION" = "WP SINGLE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ]; then - if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WP SINGLE" ]] \ + if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE BASIC" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]] \ From 03f9e31796cacf361ed90233dec93445696db9bc Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 6 Oct 2014 14:21:41 +0530 Subject: [PATCH 231/829] minor syntax update --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index e3d2f08d..db50b6d4 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -693,7 +693,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Lets update HTML|PHP|MySQL website if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - if [[ "$EE_SITE_UPDATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ] \ + if [[ "$EE_SITE_UPDATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then # Update NGINX ee_mod_update_domain From 17d7cd6424ed9b27d34e7bc82879f60ad053d881 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 6 Oct 2014 16:36:32 +0530 Subject: [PATCH 232/829] Minor bug fix --- bin/easyengine | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index db50b6d4..72ceb422 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -748,12 +748,11 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_plugin_w3tc fi elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ]; then + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ]] \ - || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ]]; then # Update NGINX ee_mod_update_domain fi @@ -766,7 +765,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ]] \ @@ -781,6 +780,8 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]]; then ee_mod_plugin_w3tc fi + else + ee_lib_error "Invalid update parameters, Use proper parameters, exit status =" $? fi # Adjust permission ee_lib_permissions From efec452156eed4f7368dca5747344de0bb99ba97 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 6 Oct 2014 18:53:54 +0530 Subject: [PATCH 233/829] cache update code optimized --- bin/easyengine | 37 +++++-------------- .../site/update/ee_mod_update_cache.sh | 30 +++++++++++++++ 2 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 src/modules/site/update/ee_mod_update_cache.sh diff --git a/bin/easyengine b/bin/easyengine index 72ceb422..1101a1f0 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -712,12 +712,8 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_plugin_nginx_helper fi - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_mod_plugin_w3tc - fi + ee_mod_update_cache + # Setup MySQL database if [[ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then ee_mod_setup_database @@ -740,13 +736,9 @@ elif [ "$EE_FIRST" = "site" ]; then if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network fi - if [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]]; then - ee_mod_plugin_wpsc - fi - if [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]]; then - ee_mod_plugin_w3tc - fi + + ee_mod_update_cache + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ]] \ @@ -756,13 +748,8 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX ee_mod_update_domain fi - if [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]]; then - ee_mod_plugin_wpsc - fi - if [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]]; then - ee_mod_plugin_w3tc - fi + + ee_mod_update_cache elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then @@ -773,13 +760,9 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX ee_mod_update_domain fi - if [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ]]; then - ee_mod_plugin_wpsc - fi - if [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]]; then - ee_mod_plugin_w3tc - fi + + ee_mod_update_cache + else ee_lib_error "Invalid update parameters, Use proper parameters, exit status =" $? fi diff --git a/src/modules/site/update/ee_mod_update_cache.sh b/src/modules/site/update/ee_mod_update_cache.sh new file mode 100644 index 00000000..7e80d4b3 --- /dev/null +++ b/src/modules/site/update/ee_mod_update_cache.sh @@ -0,0 +1,30 @@ +# Update Cache + +function ee_mod_update_cache() +{ + cd /var/www/$EE_DOMAIN/htdocs/ + + if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." + wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG + fi + + if [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + ee_lib_echo "Unnstalling WP Super Cache plugin, please wait..." + wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG + fi + + if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + + if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]&& [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" || "$EE_SITE_CACHE_OPTION" = "--w3tc" ]]; then + ee_mod_plugin_w3tc + fi +} From 5d30962a399e74692c16f43261d49503d4ca0f2a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 6 Oct 2014 19:09:04 +0530 Subject: [PATCH 234/829] minor update --- bin/easyengine | 4 ++-- src/modules/site/update/ee_mod_update_cache.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 1101a1f0..e507a5c8 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -674,7 +674,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi fi - # Install required + # Install required packages if [ "$EE_SITE_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then ee_lib_stack_packages nginx fi @@ -748,7 +748,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX ee_mod_update_domain fi - + ee_mod_update_cache elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ diff --git a/src/modules/site/update/ee_mod_update_cache.sh b/src/modules/site/update/ee_mod_update_cache.sh index 7e80d4b3..a8c31f69 100644 --- a/src/modules/site/update/ee_mod_update_cache.sh +++ b/src/modules/site/update/ee_mod_update_cache.sh @@ -24,7 +24,7 @@ function ee_mod_update_cache() if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]&& [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" || "$EE_SITE_CACHE_OPTION" = "--w3tc" ]]; then + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" || "$EE_SITE_CACHE_OPTION" = "--w3tc" ]]; then ee_mod_plugin_w3tc fi } From e9566cfe27a4f35d3e64fc3f0d86aa0343adb8cc Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 6 Oct 2014 19:47:34 +0530 Subject: [PATCH 235/829] minor update --- bin/easyengine | 12 ++++++++++++ src/modules/site/update/ee_mod_update_cache.sh | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index e507a5c8..87738911 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -722,6 +722,15 @@ elif [ "$EE_FIRST" = "site" ]; then echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ &>> /var/www/$EE_DOMAIN/ee-config.php fi + + if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + # Display WordPress credential + echo + ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" + ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" + echo + fi + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ]; then @@ -768,6 +777,9 @@ elif [ "$EE_FIRST" = "site" ]; then fi # Adjust permission ee_lib_permissions + + # Execute: service nginx reload + ee_lib_service nginx reload # Git commit ee_lib_git /etc/nginx/ "$EE_DOMAIN updated with $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION options" diff --git a/src/modules/site/update/ee_mod_update_cache.sh b/src/modules/site/update/ee_mod_update_cache.sh index a8c31f69..d53ecdce 100644 --- a/src/modules/site/update/ee_mod_update_cache.sh +++ b/src/modules/site/update/ee_mod_update_cache.sh @@ -17,13 +17,13 @@ function ee_mod_update_cache() wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG fi - if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then ee_mod_plugin_wpsc fi - if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ + if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" || "$EE_SITE_CACHE_OPTION" = "--w3tc" ]]; then ee_mod_plugin_w3tc fi From 0e0e4edd80c4deba8ab793f91854e8e11154b590 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 6 Oct 2014 19:51:39 +0530 Subject: [PATCH 236/829] minor update --- bin/easyengine | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 87738911..45bdcd90 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -741,6 +741,8 @@ elif [ "$EE_FIRST" = "site" ]; then || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then # Update NGINX ee_mod_update_domain + else + ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network @@ -756,6 +758,8 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ]]; then # Update NGINX ee_mod_update_domain + else + ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi ee_mod_update_cache @@ -768,6 +772,8 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ]]; then # Update NGINX ee_mod_update_domain + else + ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi ee_mod_update_cache From 44027ad2d1042e22d8322233466b9bfc3d56a04a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 6 Oct 2014 20:26:41 +0530 Subject: [PATCH 237/829] Minor update --- src/modules/site/update/ee_mod_update_domain.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index 6bd955a8..f0d482d0 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -9,10 +9,4 @@ function ee_mod_update_domain() /usr/share/easyengine/nginx/$EE_NGINX_CONF \ > /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration file for $EE_DOMAIN, exit status = " $? - - # Creating symbolic link - ee_lib_echo "Creating symbolic link for $EE_DOMAIN" - if [ ! -e /etc/nginx/sites-enabled/$EE_DOMAIN ]; then - ee_lib_symbolic_link /etc/nginx/sites-available/$EE_DOMAIN /etc/nginx/sites-enabled/ - fi } From 388b1822240bcf852ca12a2d20cba9c984d94a7c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 7 Oct 2014 19:30:02 +0530 Subject: [PATCH 238/829] modified update domain way --- .../site/update/ee_mod_update_domain.sh | 85 +++++++++++++++++-- 1 file changed, 80 insertions(+), 5 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index f0d482d0..b63bd90a 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -4,9 +4,84 @@ function ee_mod_update_domain() { # Creating $EE_DOMAIN ee_lib_echo "Updating $EE_DOMAIN, please wait..." - - sed "s/example.com/$EE_DOMAIN/g" \ - /usr/share/easyengine/nginx/$EE_NGINX_CONF \ - > /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration file for $EE_DOMAIN, exit status = " $? + if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then + EE_SITE_CURRENT_CONF=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") + EE_SITE_UPDATE_CONF=$(head -n1 $EE_NGINX_CONF | grep "NGINX CONFIGURATION") + EE_SITE_CONF="/etc/nginx/sites-available/$EE_DOMAIN" + + # Update Head Line of NGINX conf + sed -i 's/$EE_SITE_CURRENT_CONF/$EE_SITE_UPDATE_CONF/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + + # Update Head Line of NGINX conf file + if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE"] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI"] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE"];then + sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" $EE_SITE_CONF && \ + sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' $EE_SITE_CONF && \ + sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' $EE_SITE_CONF && \ + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + # Update NGINX conf for HTML site + if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then + sed -i 's/access\.log/access.log rt_cache/' $EE_SITE_CONF && \ + sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [[ "$EE_SITE_UPDATE_OPTION" = "--php" || "$EE_SITE_UPDATE_OPTION" = "--mysql" ]]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + # Update NGINX conf from BASIC CACHE to WPFC|W3TC|WPSC CACHE + elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/php.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/php.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/php.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + # Update NGINX conf from W3TC CACHE to BASIC|WPSC|WPFC CACHE + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/w3tc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + # Update NGINX conf from WPFC CACHE to BASIC|W3TC|WPSC CACHE + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/wpfc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + # Update NGINX conf from WPSC CACHE to BASIC|W3TC|WPFC CACHE + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/wpsc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + fi + + # Update NGINX conf from HTML|PHP|MYSQL to wp|wpsubdir|wpsubdomain + if [[ "$EE_SITE_UPDATE_OPTION" = "--wp" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]] \ + && [[ "$EE_SITE_CURRENT_OPTION" = "HTML" || "$EE_SITE_CURRENT_OPTION" = "PHP" || "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + else + ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? + fi } From 3b6995adc7add2a1c1d3dcccf55dc38db57e981b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 8 Oct 2014 13:11:14 +0530 Subject: [PATCH 239/829] Reuse code and comment codes --- bin/easyengine | 150 ++++++------------ src/modules/site/ee_mod_site_option.sh | 34 ++++ .../site/update/ee_mod_update_domain.sh | 46 +++--- 3 files changed, 107 insertions(+), 123 deletions(-) create mode 100644 src/modules/site/ee_mod_site_option.sh diff --git a/bin/easyengine b/bin/easyengine index 45bdcd90..b8a12e55 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -45,12 +45,13 @@ elif [ "$EE_FIRST" = "info" ];then elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # EasyEngine install if [ "$EE_SECOND" = "install" ]; then - # Detect RAM of system and initialize the variables. + # EasyEngine RAM based settings ee_lib_ram + # EasyEngine Swap creation ee_lib_swap if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then - # Setup NGINX/PHP repository + # Setup NGINX/PHP/Percona MySQL repository ee_mod_repo_$EE_THIRD # Fix GnuPG key @@ -93,9 +94,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display success message ee_lib_echo "$EE_THIRD successfully installed" - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "admin" ] ; then if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then - # Setup NGINX/PHP/MySQL repository + # Setup NGINX/PHP/Percona MySQL repository ee_mod_repo_nginx ee_mod_repo_php ee_mod_repo_mysql @@ -126,12 +127,11 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Install WP-CLI ee_ven_install_wpcli fi - if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then - # Install Adminer/phpMyAdmin/Utils - ee_ven_install_adminer - ee_ven_install_phpmyadmin - ee_ven_install_utils - fi + # Install Adminer/phpMyAdmin/Utils + ee_ven_install_adminer + ee_ven_install_phpmyadmin + ee_ven_install_utils + # Display success message if [ "$EE_THIRD" != "all" ];then ee_lib_echo "Successfully installed $([ "$EE_THIRD" != "" ] && echo $EE_THIRD || echo "web" ) server packages" @@ -247,7 +247,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then elif [ "$EE_SECOND" = "purge" ];then ee_lib_echo "$EE_THIRD successfully purged" fi - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "admin" ] ; then if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then # Remove/Purge NGINX/PHP/MySQL/Postfix package ee_mod_remove_nginx @@ -258,12 +258,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Remove/Purge WP-CLI ee_ven_remove_wpcli fi - if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then - # Remove/Purge Adminer/phpMyAdmin/Utils - ee_ven_remove_adminer - ee_ven_remove_phpmyadmin - ee_ven_remove_utils - fi + # Remove/Purge Adminer/phpMyAdmin/Utils + ee_ven_remove_adminer + ee_ven_remove_phpmyadmin + ee_ven_remove_utils # Execute: apt-get autoremove ee_lib_autoremove @@ -420,49 +418,27 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION=$EE_FIFTH - # Auto switch options - if [ "$EE_SITE_CREATE_OPTION" = "--basic" ] || [ "$EE_SITE_CREATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_CREATE_OPTION=$EE_FIFTH - EE_SITE_CACHE_OPTION=$EE_FOURTH - else - EE_SITE_CREATE_OPTION=--wp - EE_SITE_CACHE_OPTION=$EE_FOURTH - fi - fi - # WordPresss subdirectory variables - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then - EE_SITE_CREATE_OPTION="--wpsubdir" - EE_NETWORK_ACTIVATE="--network" - fi - # WordPress sub-domain variables - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_CREATE_OPTION="--wpsubdomain" - EE_NETWORK_ACTIVATE="--network" - EE_WP_SUBDOMAIN="--subdomains" - fi - # Use default whenever possible - if [ "$EE_SITE_CREATE_OPTION" = "" ]; then - EE_SITE_CREATE_OPTION=--html - fi - # For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION - if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - EE_SITE_CACHE_OPTION=--basic - fi + # Auto switch site options + ee_mod_site_option if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install NGINX Packages ee_lib_stack_packages nginx fi if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install PHP Packages ee_lib_stack_packages php fi if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install Percona MySQL Packages ee_lib_stack_packages mysql fi if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Install WP-CLI ee_ven_install_wpcli fi + # Check & Install Postfix Packages ee_lib_stack_packages postfix # Lets create HTML|PHP|MySQL website @@ -623,69 +599,43 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_SECOND" = "update" ]; then # Configure variables EE_DOMAIN_CHECK=$EE_THIRD - EE_SITE_UPDATE_OPTION=$EE_FOURTH + EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION=$EE_FIFTH + # Check the website name is empty or not ee_lib_check_domain # Check the website exist ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - if [ "$EE_SITE_UPDATE_OPTION" = "--password" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then ee_mod_site_update_password else - # Auto switch options - if [ "$EE_SITE_UPDATE_OPTION" = "--basic" ] || [ "$EE_SITE_UPDATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_UPDATE_OPTION=$EE_FIFTH - EE_SITE_CACHE_OPTION=$EE_FOURTH - else - EE_SITE_UPDATE_OPTION=--wp - EE_SITE_CACHE_OPTION=$EE_FOURTH - fi - fi - # WordPresss subdirectory variables - if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdirectory" ]; then - EE_SITE_UPDATE_OPTION="--wpsubdir" - EE_NETWORK_ACTIVATE="--network" - fi - # WordPress sub-domain variables - if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_UPDATE_OPTION="--wpsubdomain" - EE_NETWORK_ACTIVATE="--network" - EE_WP_SUBDOMAIN="--subdomains" - fi - # Use default whenever possible - if [ "$EE_SITE_UPDATE_OPTION" = "" ]; then - EE_SITE_UPDATE_OPTION=--html - fi - # For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION - if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_UPDATE_OPTION" != "--html" ] && [ "$EE_SITE_UPDATE_OPTION" != "--php" ] && [ "$EE_SITE_UPDATE_OPTION" != "--mysql" ]; then - EE_SITE_CACHE_OPTION=--basic - fi + # Auto switch site options + ee_mod_site_option EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) - if [ "$EE_SITE_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ]; then - EE_NGINX_CONF=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/basic.conf - elif [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/basic.conf + elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - EE_NGINX_CONF=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf + EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf fi fi # Install required packages - if [ "$EE_SITE_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_lib_stack_packages nginx fi - if [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_lib_stack_packages php fi - if [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_lib_stack_packages mysql fi - if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_ven_install_wpcli fi ee_lib_stack_packages postfix @@ -693,21 +643,21 @@ elif [ "$EE_FIRST" = "site" ]; then # Lets update HTML|PHP|MySQL website if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - if [[ "$EE_SITE_UPDATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ - || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + if [[ "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ + || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then # Update NGINX ee_mod_update_domain fi - if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then ee_mod_setup_wordpress fi - if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network fi - if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then # Install WordPress plugins ee_mod_plugin_nginx_helper fi @@ -715,7 +665,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_update_cache # Setup MySQL database - if [[ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then + if [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then ee_mod_setup_database # Add Database Information On ee-config.php @@ -723,7 +673,7 @@ elif [ "$EE_FIRST" = "site" ]; then &>> /var/www/$EE_DOMAIN/ee-config.php fi - if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then # Display WordPress credential echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" @@ -738,20 +688,20 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]] \ - || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then # Update NGINX ee_mod_update_domain else - ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi - if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network fi ee_mod_update_cache elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ]] \ @@ -759,13 +709,13 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX ee_mod_update_domain else - ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi ee_mod_update_cache elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ]] \ @@ -773,7 +723,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX ee_mod_update_domain else - ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi ee_mod_update_cache @@ -788,7 +738,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_service nginx reload # Git commit - ee_lib_git /etc/nginx/ "$EE_DOMAIN updated with $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION options" + ee_lib_git /etc/nginx/ "$EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" # Display Success Message ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh new file mode 100644 index 00000000..fd1b4d39 --- /dev/null +++ b/src/modules/site/ee_mod_site_option.sh @@ -0,0 +1,34 @@ +# Auto switch site options + +if [ "$EE_SITE_CREATE_OPTION" = "--basic" ] || [ "$EE_SITE_CREATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpfc" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then + EE_SITE_CREATE_OPTION=$EE_FIFTH + EE_SITE_CACHE_OPTION=$EE_FOURTH + else + EE_SITE_CREATE_OPTION=--wp + EE_SITE_CACHE_OPTION=$EE_FOURTH + fi +fi + +# WordPresss subdirectory variables +if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then + EE_SITE_CREATE_OPTION="--wpsubdir" + EE_NETWORK_ACTIVATE="--network" +fi + +# WordPress sub-domain variables +if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + EE_SITE_CREATE_OPTION="--wpsubdomain" + EE_NETWORK_ACTIVATE="--network" + EE_WP_SUBDOMAIN="--subdomains" +fi + +# Use default whenever possible +if [ "$EE_SITE_CREATE_OPTION" = "" ]; then + EE_SITE_CREATE_OPTION=--html +fi + +# For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION +if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then + EE_SITE_CACHE_OPTION=--basic +fi diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index b63bd90a..f23a1afc 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -10,10 +10,10 @@ function ee_mod_update_domain() EE_SITE_CONF="/etc/nginx/sites-available/$EE_DOMAIN" # Update Head Line of NGINX conf - sed -i 's/$EE_SITE_CURRENT_CONF/$EE_SITE_UPDATE_CONF/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/$EE_SITE_CURRENT_CONF/$EE_SITE_UPDATE_CONF/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? # Update Head Line of NGINX conf file - if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] \ + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE"] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI"] \ @@ -21,65 +21,65 @@ function ee_mod_update_domain() sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" $EE_SITE_CONF && \ sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' $EE_SITE_CONF && \ sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' $EE_SITE_CONF && \ - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf for HTML site if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then sed -i 's/access\.log/access.log rt_cache/' $EE_SITE_CONF && \ - sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [[ "$EE_SITE_UPDATE_OPTION" = "--php" || "$EE_SITE_UPDATE_OPTION" = "--mysql" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [[ "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from BASIC CACHE to WPFC|W3TC|WPSC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/php.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/php.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/php.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from W3TC CACHE to BASIC|WPSC|WPFC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/w3tc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from WPFC CACHE to BASIC|W3TC|WPSC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpfc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from WPSC CACHE to BASIC|W3TC|WPFC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpsc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpsc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi fi # Update NGINX conf from HTML|PHP|MYSQL to wp|wpsubdir|wpsubdomain - if [[ "$EE_SITE_UPDATE_OPTION" = "--wp" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]] \ + if [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]] \ && [[ "$EE_SITE_CURRENT_OPTION" = "HTML" || "$EE_SITE_CURRENT_OPTION" = "PHP" || "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi else ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? From 6111e4e52f516ac3d952a41377b7528655811b0b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 8 Oct 2014 13:36:08 +0530 Subject: [PATCH 240/829] Reuse code and comment codes --- bin/easyengine | 70 ++++++------------- src/lib/ee_lib_stack_packages.sh | 2 +- src/modules/site/ee_mod_site_packages.sh | 21 ++++++ .../site/update/ee_mod_update_cache.sh | 4 +- .../site/update/ee_mod_update_plugins.sh | 30 ++++++++ 5 files changed, 77 insertions(+), 50 deletions(-) create mode 100644 src/modules/site/ee_mod_site_packages.sh create mode 100644 src/modules/site/update/ee_mod_update_plugins.sh diff --git a/bin/easyengine b/bin/easyengine index b8a12e55..416f34b6 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -421,25 +421,8 @@ elif [ "$EE_FIRST" = "site" ]; then # Auto switch site options ee_mod_site_option - if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install NGINX Packages - ee_lib_stack_packages nginx - fi - if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install PHP Packages - ee_lib_stack_packages php - fi - if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install Percona MySQL Packages - ee_lib_stack_packages mysql - fi - - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Install WP-CLI - ee_ven_install_wpcli - fi - # Check & Install Postfix Packages - ee_lib_stack_packages postfix + # Install required packages + ee_mod_site_packages # Lets create HTML|PHP|MySQL website if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then @@ -609,6 +592,7 @@ elif [ "$EE_FIRST" = "site" ]; then ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? + # Update WordPress user password if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then ee_mod_site_update_password else @@ -625,44 +609,34 @@ elif [ "$EE_FIRST" = "site" ]; then fi # Install required packages - if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_stack_packages nginx - fi - if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_stack_packages php - fi - if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_stack_packages mysql - fi - - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_ven_install_wpcli - fi - ee_lib_stack_packages postfix + ee_mod_site_packages # Lets update HTML|PHP|MySQL website if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then + # Update NGINX configuration for $EE_DOMAIN if [[ "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - # Update NGINX ee_mod_update_domain fi + # Setup WordPress if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then ee_mod_setup_wordpress fi + # Setup WordPress Network if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network fi + # Install WordPress plugins if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - # Install WordPress plugins ee_mod_plugin_nginx_helper fi - ee_mod_update_cache + # Update cache plugins + ee_mod_update_plugins # Setup MySQL database if [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then @@ -689,16 +663,17 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]] \ || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - # Update NGINX + # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi + # Setup WordPress Network if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network fi - - ee_mod_update_cache + # Update cache plugins + ee_mod_update_plugins elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then @@ -706,13 +681,13 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ]]; then - # Update NGINX + # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi - - ee_mod_update_cache + # Update cache plugins + ee_mod_update_plugins elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -720,13 +695,13 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ]]; then - # Update NGINX + # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi - - ee_mod_update_cache + # Update cache plugins + ee_mod_update_plugins else ee_lib_error "Invalid update parameters, Use proper parameters, exit status =" $? @@ -747,7 +722,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Display logs for websites ee_mod_site_log ${@:3} - #EasyEngine cd + # EasyEngine cd elif [ "$EE_SECOND" = "cd" ]; then # Check the website name is empty or not EE_DOMAIN_CHECK=$EE_THIRD @@ -885,10 +860,11 @@ elif [ "$EE_FIRST" = "secure" ]; then ee_lib_echo_escape "\t--ip\tUpdate whitelist IP address" fi -# Clean cache +# Clean NGINX FastCGI, Memcache, OPcache cache elif [ "$EE_FIRST" = "clean" ]; then ee_mod_clean ${@:2} +# Import MySQL slow log to Anememoter elif [ "$EE_FIRST" = "import-slow-log" ];then ee_lib_import_slow_log diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index a75f18b3..39d6eaa4 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -1,4 +1,4 @@ -# Check the specified package is installed or not +# Check & Install Packages function ee_lib_stack_packages() { diff --git a/src/modules/site/ee_mod_site_packages.sh b/src/modules/site/ee_mod_site_packages.sh new file mode 100644 index 00000000..edf448cf --- /dev/null +++ b/src/modules/site/ee_mod_site_packages.sh @@ -0,0 +1,21 @@ +# Install required packages + +if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install NGINX Packages + ee_lib_stack_packages nginx +fi +if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install PHP Packages + ee_lib_stack_packages php +fi +if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install Percona MySQL Packages + ee_lib_stack_packages mysql +fi + +if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Install WP-CLI + ee_ven_install_wpcli +fi +# Check & Install Postfix Packages +ee_lib_stack_packages postfix diff --git a/src/modules/site/update/ee_mod_update_cache.sh b/src/modules/site/update/ee_mod_update_cache.sh index d53ecdce..38eec6d7 100644 --- a/src/modules/site/update/ee_mod_update_cache.sh +++ b/src/modules/site/update/ee_mod_update_cache.sh @@ -1,6 +1,6 @@ -# Update Cache +# Update cache plugins -function ee_mod_update_cache() +function ee_mod_update_plugins() { cd /var/www/$EE_DOMAIN/htdocs/ diff --git a/src/modules/site/update/ee_mod_update_plugins.sh b/src/modules/site/update/ee_mod_update_plugins.sh new file mode 100644 index 00000000..38eec6d7 --- /dev/null +++ b/src/modules/site/update/ee_mod_update_plugins.sh @@ -0,0 +1,30 @@ +# Update cache plugins + +function ee_mod_update_plugins() +{ + cd /var/www/$EE_DOMAIN/htdocs/ + + if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." + wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG + fi + + if [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + ee_lib_echo "Unnstalling WP Super Cache plugin, please wait..." + wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG + fi + + if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + + if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" || "$EE_SITE_CACHE_OPTION" = "--w3tc" ]]; then + ee_mod_plugin_w3tc + fi +} From 7913f07e50196f8ece67201a1b0e68f3dd071503 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 14:45:32 +0530 Subject: [PATCH 241/829] site backup and mysql site update code --- bin/easyengine | 16 +++++++++--- src/modules/site/ee_mod_site_backup.sh | 25 +++++++++++++++++++ .../site/update/ee_mod_update_domain.sh | 7 +++++- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 src/modules/site/ee_mod_site_backup.sh diff --git a/bin/easyengine b/bin/easyengine index 416f34b6..95763feb 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -614,6 +614,10 @@ elif [ "$EE_FIRST" = "site" ]; then # Lets update HTML|PHP|MySQL website if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then + # Git commit + ee_lib_git /etc/nginx/ "Before $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" + ee_mod_site_backup + # Update NGINX configuration for $EE_DOMAIN if [[ "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then @@ -622,6 +626,9 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup WordPress if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then + if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then + EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + fi ee_mod_setup_wordpress fi @@ -655,6 +662,7 @@ elif [ "$EE_FIRST" = "site" ]; then echo fi + # Lets update WprdPress Single sites elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ]; then @@ -666,7 +674,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + ee_lib_error "Website already with $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION, exit status" $? fi # Setup WordPress Network if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -675,6 +683,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update cache plugins ee_mod_update_plugins + # Lets update WprdPress multi sites with subdirectory elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ]] \ @@ -684,11 +693,12 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + ee_lib_error "Website already with $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION, exit status" $? fi # Update cache plugins ee_mod_update_plugins + # Lets update WprdPress multi sites with subdomain elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ]] \ @@ -698,7 +708,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + ee_lib_error "Website already with $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION, exit status" $? fi # Update cache plugins ee_mod_update_plugins diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh new file mode 100644 index 00000000..4c667363 --- /dev/null +++ b/src/modules/site/ee_mod_site_backup.sh @@ -0,0 +1,25 @@ +# Backup NGINX configuration & Database & Webroot + +function ee_mod_site_backup() +{ + # Backup directory setup + local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') + if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs ] || [ ! -d $ee_webroot/backup/nginx ] || [ ! -d $ee_webroot/backup/db ] ; then + mkdir -p $ee_webroot/backup/{htdocs,nginx,db} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? + fi + + # Move htdocs + if [ "$EE_SITE_CURRENT_OPTION" = "HTML"] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL"] || [ "$EE_SITE_CURRENT_OPTION" = "PHP"]; then + mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y") + mkdir -p $ee_webroot/htdocs + fi + + # Backup $EE_DOMAIN NGINX configuration + cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +"%m-%d-%y").conf.bak + + # Database backup + if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then + local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +"%m-%d-%y").sql.bak + fi +} diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index f23a1afc..0d61f888 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -1,7 +1,12 @@ -# Update Domain setup +# Update NGINX configuration for $EE_DOMAIN function ee_mod_update_domain() { + # Git commit + ee_lib_git /etc/nginx/ "Before $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" + # Backup NGINX configuration & Database & Webroot + ee_mod_site_backup + # Creating $EE_DOMAIN ee_lib_echo "Updating $EE_DOMAIN, please wait..." if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then From 7fbdefc8a4749dc0d02d9d43f342641724f7c3ba Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 15:05:58 +0530 Subject: [PATCH 242/829] functions created --- src/modules/site/ee_mod_site_option.sh | 57 +++++++++++++----------- src/modules/site/ee_mod_site_packages.sh | 40 +++++++++-------- 2 files changed, 52 insertions(+), 45 deletions(-) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index fd1b4d39..4c7f0e55 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -1,34 +1,37 @@ # Auto switch site options -if [ "$EE_SITE_CREATE_OPTION" = "--basic" ] || [ "$EE_SITE_CREATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_CREATE_OPTION=$EE_FIFTH - EE_SITE_CACHE_OPTION=$EE_FOURTH - else - EE_SITE_CREATE_OPTION=--wp - EE_SITE_CACHE_OPTION=$EE_FOURTH +function ee_mod_site_option() +{ + if [ "$EE_SITE_CREATE_OPTION" = "--basic" ] || [ "$EE_SITE_CREATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpfc" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then + EE_SITE_CREATE_OPTION=$EE_FIFTH + EE_SITE_CACHE_OPTION=$EE_FOURTH + else + EE_SITE_CREATE_OPTION=--wp + EE_SITE_CACHE_OPTION=$EE_FOURTH + fi fi -fi -# WordPresss subdirectory variables -if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then - EE_SITE_CREATE_OPTION="--wpsubdir" - EE_NETWORK_ACTIVATE="--network" -fi + # WordPresss subdirectory variables + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then + EE_SITE_CREATE_OPTION="--wpsubdir" + EE_NETWORK_ACTIVATE="--network" + fi -# WordPress sub-domain variables -if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_CREATE_OPTION="--wpsubdomain" - EE_NETWORK_ACTIVATE="--network" - EE_WP_SUBDOMAIN="--subdomains" -fi + # WordPress sub-domain variables + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + EE_SITE_CREATE_OPTION="--wpsubdomain" + EE_NETWORK_ACTIVATE="--network" + EE_WP_SUBDOMAIN="--subdomains" + fi -# Use default whenever possible -if [ "$EE_SITE_CREATE_OPTION" = "" ]; then - EE_SITE_CREATE_OPTION=--html -fi + # Use default whenever possible + if [ "$EE_SITE_CREATE_OPTION" = "" ]; then + EE_SITE_CREATE_OPTION=--html + fi -# For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION -if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - EE_SITE_CACHE_OPTION=--basic -fi + # For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION + if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then + EE_SITE_CACHE_OPTION=--basic + fi +} diff --git a/src/modules/site/ee_mod_site_packages.sh b/src/modules/site/ee_mod_site_packages.sh index edf448cf..76421c93 100644 --- a/src/modules/site/ee_mod_site_packages.sh +++ b/src/modules/site/ee_mod_site_packages.sh @@ -1,21 +1,25 @@ -# Install required packages -if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install NGINX Packages - ee_lib_stack_packages nginx -fi -if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install PHP Packages - ee_lib_stack_packages php -fi -if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install Percona MySQL Packages +function ee_mod_site_packages() +{ + # Install required packages + + if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install NGINX Packages + ee_lib_stack_packages nginx + fi + if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install PHP Packages + ee_lib_stack_packages php + fi + if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Check & Install Percona MySQL Packages ee_lib_stack_packages mysql -fi + fi -if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Install WP-CLI - ee_ven_install_wpcli -fi -# Check & Install Postfix Packages -ee_lib_stack_packages postfix + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Install WP-CLI + ee_ven_install_wpcli + fi + # Check & Install Postfix Packages + ee_lib_stack_packages postfix +} From 279c2391ce0eaf379849ff27706b9571f64039b9 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 15:25:51 +0530 Subject: [PATCH 243/829] minor bug fixes --- src/modules/site/ee_mod_site_backup.sh | 4 ++-- src/modules/site/ee_mod_site_packages.sh | 1 + src/modules/site/update/ee_mod_update_domain.sh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index 4c667363..ec7f33bc 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -4,13 +4,13 @@ function ee_mod_site_backup() { # Backup directory setup local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') - if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs ] || [ ! -d $ee_webroot/backup/nginx ] || [ ! -d $ee_webroot/backup/db ] ; then + if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs ] || [ ! -d $ee_webroot/backup/nginx ] || [ ! -d $ee_webroot/backup/db ]; then mkdir -p $ee_webroot/backup/{htdocs,nginx,db} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? fi # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML"] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL"] || [ "$EE_SITE_CURRENT_OPTION" = "PHP"]; then - mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y") + mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi diff --git a/src/modules/site/ee_mod_site_packages.sh b/src/modules/site/ee_mod_site_packages.sh index 76421c93..9cf69368 100644 --- a/src/modules/site/ee_mod_site_packages.sh +++ b/src/modules/site/ee_mod_site_packages.sh @@ -1,3 +1,4 @@ +# Install Required Packages while site create function ee_mod_site_packages() { diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index 0d61f888..e482fa9e 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -11,11 +11,11 @@ function ee_mod_update_domain() ee_lib_echo "Updating $EE_DOMAIN, please wait..." if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then EE_SITE_CURRENT_CONF=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") - EE_SITE_UPDATE_CONF=$(head -n1 $EE_NGINX_CONF | grep "NGINX CONFIGURATION") + EE_SITE_UPDATE_CONF=$(head -n1 /usr/share/easyengine/nginx/$EE_NGINX_CONF | grep "NGINX CONFIGURATION") EE_SITE_CONF="/etc/nginx/sites-available/$EE_DOMAIN" # Update Head Line of NGINX conf - sed -i 's/$EE_SITE_CURRENT_CONF/$EE_SITE_UPDATE_CONF/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i "s'$EE_SITE_CURRENT_CONF'$EE_SITE_UPDATE_CONF'" $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? # Update Head Line of NGINX conf file if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ From f082ceeb5391f8ae4f66ac23fc5439443db43a05 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 15:37:05 +0530 Subject: [PATCH 244/829] if block syntax update --- src/modules/site/ee_mod_site_backup.sh | 2 +- .../site/update/ee_mod_update_domain.sh | 52 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index ec7f33bc..c3b34147 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -9,7 +9,7 @@ function ee_mod_site_backup() fi # Move htdocs - if [ "$EE_SITE_CURRENT_OPTION" = "HTML"] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL"] || [ "$EE_SITE_CURRENT_OPTION" = "PHP"]; then + if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index e482fa9e..64a6a30b 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -8,14 +8,14 @@ function ee_mod_update_domain() ee_mod_site_backup # Creating $EE_DOMAIN - ee_lib_echo "Updating $EE_DOMAIN, please wait..." + ee_lib_echo "Updating $EE_DOMAIN, please wait ..." if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then EE_SITE_CURRENT_CONF=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") EE_SITE_UPDATE_CONF=$(head -n1 /usr/share/easyengine/nginx/$EE_NGINX_CONF | grep "NGINX CONFIGURATION") - EE_SITE_CONF="/etc/nginx/sites-available/$EE_DOMAIN" + EE_SITE_NGINX_CONF="/etc/nginx/sites-available/$EE_DOMAIN" # Update Head Line of NGINX conf - sed -i "s'$EE_SITE_CURRENT_CONF'$EE_SITE_UPDATE_CONF'" $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i "s'$EE_SITE_CURRENT_CONF'$EE_SITE_UPDATE_CONF'" $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? # Update Head Line of NGINX conf file if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ @@ -23,68 +23,68 @@ function ee_mod_update_domain() && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE"] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI"] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE"];then - sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" $EE_SITE_CONF && \ - sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' $EE_SITE_CONF && \ - sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' $EE_SITE_CONF && \ - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" $EE_SITE_NGINX_CONF && \ + sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' $EE_SITE_NGINX_CONF && \ + sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' $EE_SITE_NGINX_CONF && \ + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf for HTML site if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then - sed -i 's/access\.log/access.log rt_cache/' $EE_SITE_CONF && \ - sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/access\.log/access.log rt_cache/' $EE_SITE_NGINX_CONF && \ + sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [[ "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from BASIC CACHE to WPFC|W3TC|WPSC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/php.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/wpfc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/php.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/wpsc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/php.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/w3tc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from W3TC CACHE to BASIC|WPSC|WPFC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/w3tc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/php.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from WPFC CACHE to BASIC|W3TC|WPSC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpfc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/php.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from WPSC CACHE to BASIC|W3TC|WPFC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpsc.conf/include common\/php.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpsc.conf/include common\/php.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi fi # Update NGINX conf from HTML|PHP|MYSQL to wp|wpsubdir|wpsubdomain if [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]] \ && [[ "$EE_SITE_CURRENT_OPTION" = "HTML" || "$EE_SITE_CURRENT_OPTION" = "PHP" || "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi else ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? From d78a2c0456535a23189865779e1004f85a6ea2fb Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 16:22:04 +0530 Subject: [PATCH 245/829] mysql site update code --- bin/easyengine | 2 ++ src/modules/site/create/ee_mod_setup_wordpress.sh | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 95763feb..548fa0e8 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -628,6 +628,8 @@ elif [ "$EE_FIRST" = "site" ]; then if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) fi ee_mod_setup_wordpress fi diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index 46cd724a..15901a98 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -11,7 +11,11 @@ function ee_mod_setup_wordpress() || ee_lib_error "Unable to download WordPress, exit status = " $? # Database setup - ee_mod_setup_database + # if EE_DB_NAME, EE_DB_USER, EE_DB_PASS are empty then setup database for new site + # else current mysql site is to be updated + if [ "EE_DB_NAME" = "" ] && [ "EE_DB_USER" = "" ] && [ "EE_DB_PASS" = "" ]; then + ee_mod_setup_database + fi # Default WordPress prefix or custom prefix if [ $($EE_CONFIG_GET wordpress.prefix) == "true" ];then From 235f89c5dd23b05993db04c5072bf885d8aa52eb Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 16:25:52 +0530 Subject: [PATCH 246/829] date format updated --- src/modules/site/ee_mod_site_backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index c3b34147..f0069816 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -10,7 +10,7 @@ function ee_mod_site_backup() # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then - mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? + mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y:") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi From d576326c5e3cd8fe1fc14854f2e1350f3fb65470 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 16:34:05 +0530 Subject: [PATCH 247/829] date format updated and output to log file --- src/modules/site/ee_mod_site_backup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index f0069816..debd8553 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -10,16 +10,16 @@ function ee_mod_site_backup() # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then - mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y:") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? + mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y::%T") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi # Backup $EE_DOMAIN NGINX configuration - cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +"%m-%d-%y").conf.bak + cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +"%m-%d-%y::%T").conf.bak &>> $EE_COMMAND_LOG # Database backup if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +"%m-%d-%y").sql.bak + mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +"%m-%d-%y::%T").sql.bak &>> $EE_COMMAND_LOG fi } From 3aace037f94be102edec15a21ca99e36fec4e441 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 17:23:54 +0530 Subject: [PATCH 248/829] updated autocomplete and minor bug fix --- config/bash_completion.d/ee | 10 +++++----- src/modules/site/create/ee_mod_setup_wordpress.sh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 9f69d761..baf5dad3 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -27,7 +27,7 @@ function EE_AUTO() # List of suggested words easyengine|ee) - COMPREPLY=( $(compgen -W '$(echo version help info update; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) + COMPREPLY=( $(compgen -W '$(echo clean version help info update; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) return 0 ;; @@ -42,7 +42,7 @@ function EE_AUTO() ;; site) - COMPREPLY=( $( compgen -W '$(echo disable enable list show; command find /usr/local/lib/easyengine/modules/site -maxdepth 1 -type d -printf "%P " 2> /dev/null; cd /usr/local/lib/easyengine/modules/site/; find -type f | grep site | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null)' -- $CURRENT ) ) + COMPREPLY=( $( compgen -W '$(echo cd create delete disable edit enable info list log show update;)' -- $CURRENT ) ) return 0 ;; @@ -51,7 +51,7 @@ function EE_AUTO() return 0 ;; - info|enable|edit|show|delete) + info|enable|edit|show|delete|cd|log) if [ "$PREVIOUS2" = "site" ]; then COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)' -- $CURRENT ) ) fi @@ -80,7 +80,7 @@ function EE_AUTO() ;; --wp) - if [ "$PREVIOUS3" = "create" ]; then + if [ "$PREVIOUS3" = "create" ] || [ "$PREVIOUS3" = "update" ]; then COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) ) else COMPREPLY=( $(compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | grep -v wp | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) @@ -102,7 +102,7 @@ function EE_AUTO() ;; *) - if [ "$PREVIOUS2" = "create" ]; then + if [ "$PREVIOUS2" = "create" ] || [ "$PREVIOUS2" = "update" ]; then COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "delete" ]; then COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) ) diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index 15901a98..8f282095 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -13,7 +13,7 @@ function ee_mod_setup_wordpress() # Database setup # if EE_DB_NAME, EE_DB_USER, EE_DB_PASS are empty then setup database for new site # else current mysql site is to be updated - if [ "EE_DB_NAME" = "" ] && [ "EE_DB_USER" = "" ] && [ "EE_DB_PASS" = "" ]; then + if [ "$EE_DB_NAME" = "" ] && [ "$EE_DB_USER" = "" ] && [ "$EE_DB_PASS" = "" ]; then ee_mod_setup_database fi From 2b60683d0d4d7d9e01240fbfb3e48c6b8d17dc17 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 17:33:48 +0530 Subject: [PATCH 249/829] update nginx conf bug fixed --- .../site/update/ee_mod_update_domain.sh | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index 64a6a30b..c2dc9a32 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -45,39 +45,39 @@ function ee_mod_update_domain() elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/php.conf/include common\/wpfc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/php.conf/include common\/wpsc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/php.conf/include common\/w3tc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/php.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from W3TC CACHE to BASIC|WPSC|WPFC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/w3tc.conf/include common\/php.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/w3tc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from WPFC CACHE to BASIC|W3TC|WPSC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpfc.conf/include common\/php.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update NGINX conf from WPSC CACHE to BASIC|W3TC|WPFC CACHE elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpsc.conf/include common\/php.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpsc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi fi From 84f967674d54af44e7c6d1157d7de07e7e1812c2 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 18:11:41 +0530 Subject: [PATCH 250/829] updated messages and cache change code --- bin/easyengine | 2 +- .../site/update/ee_mod_update_cache.sh | 30 ------------------- .../site/update/ee_mod_update_domain.sh | 2 +- .../site/update/ee_mod_update_plugins.sh | 5 ++-- 4 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 src/modules/site/update/ee_mod_update_cache.sh diff --git a/bin/easyengine b/bin/easyengine index 548fa0e8..0961b9cd 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -725,7 +725,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_service nginx reload # Git commit - ee_lib_git /etc/nginx/ "$EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" + ee_lib_git /etc/nginx/ "After ee site update: $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" # Display Success Message ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" diff --git a/src/modules/site/update/ee_mod_update_cache.sh b/src/modules/site/update/ee_mod_update_cache.sh deleted file mode 100644 index 38eec6d7..00000000 --- a/src/modules/site/update/ee_mod_update_cache.sh +++ /dev/null @@ -1,30 +0,0 @@ -# Update cache plugins - -function ee_mod_update_plugins() -{ - cd /var/www/$EE_DOMAIN/htdocs/ - - if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." - wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG - fi - - if [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - ee_lib_echo "Unnstalling WP Super Cache plugin, please wait..." - wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG - fi - - if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - - if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" || "$EE_SITE_CACHE_OPTION" = "--w3tc" ]]; then - ee_mod_plugin_w3tc - fi -} diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index c2dc9a32..3ef5bfb0 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -3,7 +3,7 @@ function ee_mod_update_domain() { # Git commit - ee_lib_git /etc/nginx/ "Before $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" + ee_lib_git /etc/nginx/ "Before ee site update: $EE_DOMAIN running on $EE_SITE_CURRENT_OPTION" # Backup NGINX configuration & Database & Webroot ee_mod_site_backup diff --git a/src/modules/site/update/ee_mod_update_plugins.sh b/src/modules/site/update/ee_mod_update_plugins.sh index 38eec6d7..b50df163 100644 --- a/src/modules/site/update/ee_mod_update_plugins.sh +++ b/src/modules/site/update/ee_mod_update_plugins.sh @@ -6,14 +6,15 @@ function ee_mod_update_plugins() if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--basic" || "$EE_SITE_CACHE_OPTION" = "--wpsc" ]]; then ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG fi if [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - ee_lib_echo "Unnstalling WP Super Cache plugin, please wait..." + ee_lib_echo "Unistalling WP Super Cache plugin, please wait..." + wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG fi From 62b6633b08471c47d1190e21731e582a3dfe26f8 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 18:18:28 +0530 Subject: [PATCH 251/829] updated autocomplete for ee site update --- config/bash_completion.d/ee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index baf5dad3..a2e94e70 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -102,8 +102,10 @@ function EE_AUTO() ;; *) - if [ "$PREVIOUS2" = "create" ] || [ "$PREVIOUS2" = "update" ]; then + if [ "$PREVIOUS2" = "create" ]; then COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) + elif [ "$PREVIOUS2" = "update" ]; then + COMPREPLY=( $( compgen -W "--wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "delete" ]; then COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) ) fi From 04db54a6f88bdd76bf6b820d8452b11080c27794 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 19:05:45 +0530 Subject: [PATCH 252/829] fixed http 418 I'm teapot error --- config/bash_completion.d/ee | 2 +- src/modules/site/update/ee_mod_update_domain.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index a2e94e70..1d17b66a 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -105,7 +105,7 @@ function EE_AUTO() if [ "$PREVIOUS2" = "create" ]; then COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "update" ]; then - COMPREPLY=( $( compgen -W "--wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) + COMPREPLY=( $( compgen -W "--php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "delete" ]; then COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) ) fi diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index 3ef5bfb0..5bc92606 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -31,7 +31,8 @@ function ee_mod_update_domain() # Update NGINX conf for HTML site if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then sed -i 's/access\.log/access.log rt_cache/' $EE_SITE_NGINX_CONF && \ - sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/index index.html index.htm;$/d' $EE_SITE_NGINX_CONF && \ + sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [[ "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]]; then sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then From bb527469f625b414a673b1f3353e067ccff79637 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 19:19:54 +0530 Subject: [PATCH 253/829] added message while backup --- src/modules/site/ee_mod_site_backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index debd8553..f763fa73 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -10,15 +10,18 @@ function ee_mod_site_backup() # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then + ee_lib_echo "Creating Webroot backup for $EE_DOMAIN before updating ..." mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y::%T") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi + ee_lib_echo "Creating NGINX configuration backup for $EE_DOMAIN before updating ..." # Backup $EE_DOMAIN NGINX configuration cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +"%m-%d-%y::%T").conf.bak &>> $EE_COMMAND_LOG # Database backup if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then + ee_lib_echo "Creating Database backup for $EE_DOMAIN before updating ..." local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +"%m-%d-%y::%T").sql.bak &>> $EE_COMMAND_LOG fi From def4a9dc2d45b9f463b24df3523a6c1cf832b882 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 8 Oct 2014 19:42:12 +0530 Subject: [PATCH 254/829] line 23: [: missing ] error --- src/modules/site/update/ee_mod_update_domain.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index 5bc92606..a6f0d1cb 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -20,9 +20,9 @@ function ee_mod_update_domain() # Update Head Line of NGINX conf file if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE"] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI"] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE"];then + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ];then sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" $EE_SITE_NGINX_CONF && \ sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' $EE_SITE_NGINX_CONF && \ sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' $EE_SITE_NGINX_CONF && \ From 4a7e66ada78824b1156eb08fa69246f656336d5c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 11:56:37 +0530 Subject: [PATCH 255/829] fixed bug binary operator expected --- bin/easyengine | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 0961b9cd..ddf8f2b3 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -627,9 +627,10 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup WordPress if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) + EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) + EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) + mv $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//')/{ee-config.php,backup/db/ee-config-$(date +"%m-%d-%y::%T").php.bak} &>> $EE_COMMAND_LOG fi ee_mod_setup_wordpress fi @@ -664,9 +665,11 @@ elif [ "$EE_FIRST" = "site" ]; then echo fi - # Lets update WprdPress Single sites + # Lets update WordPress Single sites + # WordPress Single sites can only be updated to multisites or with different cache options elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ]; then + || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ + && [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE BASIC" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]] \ @@ -686,7 +689,8 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_update_plugins # Lets update WprdPress multi sites with subdirectory - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ + # WordPress multi sites with subdirectory can only update cache + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]] \ @@ -700,7 +704,8 @@ elif [ "$EE_FIRST" = "site" ]; then # Update cache plugins ee_mod_update_plugins - # Lets update WprdPress multi sites with subdomain + # Lets update WordPress multi sites with subdomain + # WordPress multi sites with subdomain can only update cache elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ]] \ @@ -716,7 +721,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_update_plugins else - ee_lib_error "Invalid update parameters, Use proper parameters, exit status =" $? + ee_lib_error "$EE_SITE_CURRENT_OPTION Website cannot be updated to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi # Adjust permission ee_lib_permissions From 18873aef6f594775793b8e2f266f773d972fa25d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 12:54:33 +0530 Subject: [PATCH 256/829] Change logic to display success message --- bin/easyengine | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index ddf8f2b3..c867e662 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -92,8 +92,6 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_install_$EE_THIRD fi - # Display success message - ee_lib_echo "$EE_THIRD successfully installed" elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "admin" ] ; then if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then # Setup NGINX/PHP/Percona MySQL repository @@ -131,16 +129,8 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_install_adminer ee_ven_install_phpmyadmin ee_ven_install_utils - - # Display success message - if [ "$EE_THIRD" != "all" ];then - ee_lib_echo "Successfully installed $([ "$EE_THIRD" != "" ] && echo $EE_THIRD || echo "web" ) server packages" - if [ "$EE_THIRD" != "admin" ];then - ee_lib_echo "Create your first WordPress site powered by NGINX using:" - ee_lib_echo_info "ee site create example.com --wp" - fi - fi fi + # EasyEngine mail server setup if [ "$EE_THIRD" = "mail" ] || [ "$EE_THIRD" = "all" ];then @@ -204,7 +194,6 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_echo_escape "Configure ViMbAdmin:\thttps://$(hostname -f):22222/vimbadmin" ee_lib_echo_escape "Security Salt:\t\t${ee_security_salt}\n" - ee_lib_echo "Successfully installed mail server packages" elif [ "$EE_THIRD" = "mailscanner" ]; then dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null @@ -220,9 +209,16 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_service nginx postfix dovecot amavis restart - ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Installed Mail Scanner" - ee_lib_echo "Successfully installed mail scanner packages" + ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Installed Mail Scanner Packages" + fi + + # Display HTTP Authentication details + if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then + ee_lib_echo_info "HTTP Authentication username: $EE_HTTP_AUTH_USER" + ee_lib_echo_info "HTTP Authentication password: $EE_HTTP_AUTH_PASS" fi + # Display success message + ee_lib_echo "$EE_THIRD successfully installed" # EasyEngine remove/purge elif [ "$EE_SECOND" = "remove" ] || [ "$EE_SECOND" = "purge" ]; then From 8f140f4dd33d9a3d3eecc86a70456a511d1bfdf3 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 12:55:15 +0530 Subject: [PATCH 257/829] Display HTTP AUTH details --- src/modules/secure/ee_mod_secure_auth.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/modules/secure/ee_mod_secure_auth.sh b/src/modules/secure/ee_mod_secure_auth.sh index daffcbad..d7ffa005 100644 --- a/src/modules/secure/ee_mod_secure_auth.sh +++ b/src/modules/secure/ee_mod_secure_auth.sh @@ -2,29 +2,27 @@ function ee_mod_secure_auth() { - local ee_http_auth_user ee_http_auth_pass - # Random characters local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - read -p "Provide HTTP authentication user name [$(git config user.name)]: " ee_http_auth_user - read -sp "Provide HTTP authentication password [$ee_random]: " ee_http_auth_pass + read -p "Provide HTTP authentication user name [$(git config user.name)]: " EE_HTTP_AUTH_USER + read -sp "Provide HTTP authentication password [$ee_random]: " EE_HTTP_AUTH_PASS echo # If enter is pressed, set git config user.name - if [[ $ee_http_auth_user = "" ]]; then - ee_http_auth_user=$(git config user.name) + if [[ $EE_HTTP_AUTH_USER = "" ]]; then + EE_HTTP_AUTH_USER=$(git config user.name) fi - if [[ $ee_http_auth_pass = "" ]]; then - ee_http_auth_pass=$ee_random + if [[ $EE_HTTP_AUTH_PASS = "" ]]; then + EE_HTTP_AUTH_PASS=$ee_random fi # Add HTTP authentication details echo - ee_lib_echo "HTTP authentication username: $ee_http_auth_user" &>> $EE_COMMAND_LOG - ee_lib_echo "HTTP authentication password: $ee_http_auth_pass" &>> $EE_COMMAND_LOG + ee_lib_echo "HTTP authentication username: $EE_HTTP_AUTH_USER" &>> $EE_COMMAND_LOG + ee_lib_echo "HTTP authentication password: $EE_HTTP_AUTH_PASS" &>> $EE_COMMAND_LOG # Generate htpasswd-ee file - printf "$ee_http_auth_user:$(openssl passwd -crypt $ee_http_auth_pass 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null + printf "$EE_HTTP_AUTH_USER:$(openssl passwd -crypt $EE_HTTP_AUTH_PASS 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null } From 0d5b7c254842bb488067ab82f820e9af01450f8b Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 12:57:35 +0530 Subject: [PATCH 258/829] Change logic to display remove/purge message --- bin/easyengine | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index c867e662..b5febbf0 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -237,12 +237,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_ven_remove_$EE_THIRD fi - # Display success message - if [ "$EE_SECOND" = "remove" ];then - ee_lib_echo "$EE_THIRD successfully removed" - elif [ "$EE_SECOND" = "purge" ];then - ee_lib_echo "$EE_THIRD successfully purged" - fi + elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "admin" ] ; then if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then # Remove/Purge NGINX/PHP/MySQL/Postfix package @@ -261,13 +256,6 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Execute: apt-get autoremove ee_lib_autoremove - - # Display success message - if [ "$EE_SECOND" = "remove" ];then - ee_lib_echo "Successfully removed $([ "$EE_THIRD" != "" ] && echo $EE_THIRD || echo "web" ) packages" - elif [ "$EE_SECOND" = "purge" ];then - ee_lib_echo "Successfully purged $EE_THIRD packages" - fi fi if [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "mail" ];then # Remove Dovecot @@ -290,12 +278,6 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_git /etc/nginx "Removed Mail Server" - # Display success message - if [ "$EE_SECOND" = "remove" ];then - ee_lib_echo "Successfully removed mail server packages" - elif [ "$EE_SECOND" = "purge" ];then - ee_lib_echo "Successfully purged mail server packages" - fi elif [ "$EE_THIRD" = "mailscanner" ]; then # Remove Amavis ee_mod_remove_mailscaner @@ -306,13 +288,13 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_service nginx postfix dovecot restart ee_lib_git /etc/postfix "Removed mailscanner" - - # Display success message - if [ "$EE_SECOND" = "remove" ];then - ee_lib_echo "Successfully removed Mail Scanner packages" - elif [ "$EE_SECOND" = "purge" ];then - ee_lib_echo "Successfully purged Mail Scanner packages" - fi + fi + + # Display success message + if [ "$EE_SECOND" = "remove" ];then + ee_lib_echo "$EE_THIRD successfully removed" + elif [ "$EE_SECOND" = "purge" ];then + ee_lib_echo "$EE_THIRD successfully purged" fi elif [ "$EE_SECOND" = "status" ]; then From d71b57f8bff5c394804d1266ab36b3235d993c4f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 13:43:15 +0530 Subject: [PATCH 259/829] ee site update,log,cd clean doc --- docs/man/ee.8 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/man/ee.8 b/docs/man/ee.8 index d36a25bd..56590b20 100644 --- a/docs/man/ee.8 +++ b/docs/man/ee.8 @@ -13,6 +13,8 @@ ee site [ list | info | show | enable | disable | edit ] [ example.com ] .TP ee site create example.com [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] .TP +ee site update example.com [ --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] +.TP ee site delete example.com [--db | --files | --all | --no-prompt ] .TP ee debug [ -i | --nginx | --rewrite | --php | --fpm | --mysql ] [ --stop ] @@ -85,6 +87,14 @@ Display easyengine (ee) help. .B site .br .TP +.B cd [ example.com ] +.br + Change directory to webroot of specified site +.TP +.B log [ example.com ] +.br + monitor access and error logs for site specified +.TP .B list [ enable | available ] .br Lists all available sites from /etc/nginx/sites-enabled/ @@ -126,6 +136,12 @@ Display easyengine (ee) help. .br create static site with html only. .TP +.B update [ example.com ] [ --html | --php | --mysql | --wp | --w3tc |--wpfc ] +.br + Update new site according to given options. If no options provided +.br + update site with html only. +.TP .B delete [ example.com ] [--no-prompt ] [ --db | --files ] .br Delete site i.e webroot, database, ad configuration permenantly. @@ -149,6 +165,12 @@ Display easyengine (ee) help. .B secure [ --auth | --port ] .br Update security settings. +.TP +.B clean [ fastcgi | opcache | memcache | all ] +.br + Clean NGINX fastCGI cache, Opcache, Memcache. +.br + Clean NGINX fastCGI cache if no option specified. .SH ARGUMENTS .TP .B -i From 6daf7020c5d02a64f64eaaf5685c287a0a6039ab Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 13:44:15 +0530 Subject: [PATCH 260/829] ee-config/wp-config.php backup script updated --- bin/easyengine | 7 +++---- src/lib/ee_lib_variables.sh | 3 +++ src/modules/site/ee_mod_site_backup.sh | 9 ++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index b5febbf0..322dfffb 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -605,10 +605,9 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup WordPress if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) - EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) - EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/ee-config.php/' 2> /dev/null) | cut -d"'" -f4) - mv $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//')/{ee-config.php,backup/db/ee-config-$(date +"%m-%d-%y::%T").php.bak} &>> $EE_COMMAND_LOG + EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) fi ee_mod_setup_wordpress fi diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 89a17394..cac25593 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -15,6 +15,9 @@ readonly EE_ROUNDCUBE_VERSION='1.0.3' # ViMbAdmin Version readonly EE_VIMBADMIN_VERSION='3.0.10' +# EasyEngine Date variable for backup +readonly EE_DATE=$(date +%d%b%Y%H%M%S) + EE_COMMAND_LOG=/var/log/easyengine/ee.log readonly EE_LOG_DIR=/var/log/easyengine readonly EE_ERROR_LOG=/var/log/easyengine/error.log diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index f763fa73..21b55f2f 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -11,18 +11,21 @@ function ee_mod_site_backup() # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then ee_lib_echo "Creating Webroot backup for $EE_DOMAIN before updating ..." - mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/htdocs-$(date +"%m-%d-%y::%T") || ee_lib_error "Unable to create $ee_webroot/htdocs backup, exit status =" $? + mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/$(date +%d%b%Y%H%M%S)/ || ee_lib_error "Unable to move $ee_webroot/htdocs to backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi ee_lib_echo "Creating NGINX configuration backup for $EE_DOMAIN before updating ..." # Backup $EE_DOMAIN NGINX configuration - cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +"%m-%d-%y::%T").conf.bak &>> $EE_COMMAND_LOG + cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +%d%b%Y%H%M%S).conf.bak &>> $EE_COMMAND_LOG # Database backup if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then ee_lib_echo "Creating Database backup for $EE_DOMAIN before updating ..." local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +"%m-%d-%y::%T").sql.bak &>> $EE_COMMAND_LOG + mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +%d%b%Y%H%M%S).sql.bak &>> $EE_COMMAND_LOG + + # Move ee-config.php and wp-config.php + mv $ee_webroot/*-config.php $ee_webroot/backup/htdocs/$(date +%d%b%Y%H%M%S)/ || ee_lib_error "Unable to move $ee_webroot/*-config.php to backup, exit status =" $? fi } From 42c53162b8ed5c204f1f48eae911923c68a32c99 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 14:03:51 +0530 Subject: [PATCH 261/829] modified backup process logic --- src/modules/site/ee_mod_site_backup.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index 21b55f2f..71ac351f 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -2,6 +2,7 @@ function ee_mod_site_backup() { + # Backup directory setup local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs ] || [ ! -d $ee_webroot/backup/nginx ] || [ ! -d $ee_webroot/backup/db ]; then @@ -11,21 +12,21 @@ function ee_mod_site_backup() # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then ee_lib_echo "Creating Webroot backup for $EE_DOMAIN before updating ..." - mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/$(date +%d%b%Y%H%M%S)/ || ee_lib_error "Unable to move $ee_webroot/htdocs to backup, exit status =" $? + mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/htdocs to backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi ee_lib_echo "Creating NGINX configuration backup for $EE_DOMAIN before updating ..." # Backup $EE_DOMAIN NGINX configuration - cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$(date +%d%b%Y%H%M%S).conf.bak &>> $EE_COMMAND_LOG + cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$EE_DATE.conf.bak &>> $EE_COMMAND_LOG # Database backup if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then ee_lib_echo "Creating Database backup for $EE_DOMAIN before updating ..." local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$(date +%d%b%Y%H%M%S).sql.bak &>> $EE_COMMAND_LOG + mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$EE_DATE.sql.bak &>> $EE_COMMAND_LOG # Move ee-config.php and wp-config.php - mv $ee_webroot/*-config.php $ee_webroot/backup/htdocs/$(date +%d%b%Y%H%M%S)/ || ee_lib_error "Unable to move $ee_webroot/*-config.php to backup, exit status =" $? + mv $ee_webroot/*-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/*-config.php to backup, exit status =" $? fi } From 78bb1491d8f5d4cc00c33d26cbba67f035d70cd2 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 14:37:56 +0530 Subject: [PATCH 262/829] http auth default credential update --- src/modules/stack/install/ee_mod_setup_nginx.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh index fc3c4b6c..963475fd 100644 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ b/src/modules/stack/install/ee_mod_setup_nginx.sh @@ -96,8 +96,11 @@ function ee_mod_setup_nginx() done fi - # Set easyengine:easyengine as default http authentication + # Generate htpasswd-ee file if [ ! -f /etc/nginx/htpasswd-ee ]; then - printf "easyengine:$(openssl passwd -crypt $ee_random 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null + # Use same variable name as used in ee_mod_secure_auth function + EE_HTTP_AUTH_USER=easyengine + EE_HTTP_AUTH_PASS=$ee_random + printf "$EE_HTTP_AUTH_USER:$(openssl passwd -crypt $EE_HTTP_AUTH_PASS 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null fi } From 57324511e04254c62953c2f12c1d627b416fcca5 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 14:58:58 +0530 Subject: [PATCH 263/829] bug fixed site update mysql to --mysql --- bin/easyengine | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 322dfffb..86d7e804 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -592,14 +592,13 @@ elif [ "$EE_FIRST" = "site" ]; then # Lets update HTML|PHP|MySQL website if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - # Git commit - ee_lib_git /etc/nginx/ "Before $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" - ee_mod_site_backup # Update NGINX configuration for $EE_DOMAIN if [[ "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then ee_mod_update_domain + else + ee_lib_error "Website already with $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION, exit status" $? fi # Setup WordPress From ad25d033cd3760d024cb804336a821f513429c4c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 15:03:10 +0530 Subject: [PATCH 264/829] messages updated --- bin/easyengine | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 86d7e804..6862e3ae 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -598,7 +598,7 @@ elif [ "$EE_FIRST" = "site" ]; then || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then ee_mod_update_domain else - ee_lib_error "Website already with $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION, exit status" $? + ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status" $? fi # Setup WordPress @@ -655,7 +655,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "Website already with $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION, exit status" $? + ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status" $? fi # Setup WordPress Network if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -675,7 +675,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "Website already with $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION, exit status" $? + ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status" $? fi # Update cache plugins ee_mod_update_plugins @@ -691,7 +691,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "Website already with $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION, exit status" $? + ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status" $? fi # Update cache plugins ee_mod_update_plugins From 624963ae80e2b96f338cb0075c8bfdcea936384e Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 15:16:27 +0530 Subject: [PATCH 265/829] minor update --- src/modules/site/ee_mod_site_backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index 71ac351f..d53b75b1 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -6,7 +6,7 @@ function ee_mod_site_backup() # Backup directory setup local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs ] || [ ! -d $ee_webroot/backup/nginx ] || [ ! -d $ee_webroot/backup/db ]; then - mkdir -p $ee_webroot/backup/{htdocs,nginx,db} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? + mkdir -p $ee_webroot/backup/{htdocs/$EE_DATE,nginx,db} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? fi # Move htdocs From 583b017a4234a3b946da6f69029b9f3766f8806f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 15:47:39 +0530 Subject: [PATCH 266/829] minor update --- src/modules/site/ee_mod_site_backup.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index d53b75b1..f74bc522 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -26,7 +26,11 @@ function ee_mod_site_backup() local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$EE_DATE.sql.bak &>> $EE_COMMAND_LOG - # Move ee-config.php and wp-config.php - mv $ee_webroot/*-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/*-config.php to backup, exit status =" $? + # Move ee-config.php and copy wp-config.php to backup + if [ -f $ee_webroot/ee-config.php ] + mv $ee_webroot/ee-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/ee-config.php to backup, exit status =" $? + else + cp $ee_webroot/wp-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/ee-config.php to backup, exit status =" $? + fi fi } From b6bff0dc295b2e15c084afac53c77d3a5870c9e4 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 15:52:14 +0530 Subject: [PATCH 267/829] minor update --- src/modules/site/ee_mod_site_backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index f74bc522..a7191315 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -27,7 +27,7 @@ function ee_mod_site_backup() mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$EE_DATE.sql.bak &>> $EE_COMMAND_LOG # Move ee-config.php and copy wp-config.php to backup - if [ -f $ee_webroot/ee-config.php ] + if [ -f $ee_webroot/ee-config.php ]; then mv $ee_webroot/ee-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/ee-config.php to backup, exit status =" $? else cp $ee_webroot/wp-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/ee-config.php to backup, exit status =" $? From b197b83c8535b11e6bc12b6555dae9c3c0fdb90a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 16:03:39 +0530 Subject: [PATCH 268/829] backup directory structure updated --- src/modules/site/ee_mod_site_backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index a7191315..b1201e5c 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -5,7 +5,7 @@ function ee_mod_site_backup() # Backup directory setup local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') - if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs ] || [ ! -d $ee_webroot/backup/nginx ] || [ ! -d $ee_webroot/backup/db ]; then + if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs/$EE_DATE ] || [ ! -d $ee_webroot/backup/nginx ] || [ ! -d $ee_webroot/backup/db ]; then mkdir -p $ee_webroot/backup/{htdocs/$EE_DATE,nginx,db} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? fi From 933338fda7148c3cb02972d0759e1542f1e91efe Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 16:15:42 +0530 Subject: [PATCH 269/829] database backup code updated --- src/modules/site/ee_mod_site_backup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index b1201e5c..408813c6 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -24,7 +24,8 @@ function ee_mod_site_backup() if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then ee_lib_echo "Creating Database backup for $EE_DOMAIN before updating ..." local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$EE_DATE.sql.bak &>> $EE_COMMAND_LOG + mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$EE_DATE.sql.bak \ + || ee_lib_error "Unable to dump ${ee_db_name}, exit status =" $? # Move ee-config.php and copy wp-config.php to backup if [ -f $ee_webroot/ee-config.php ]; then From bd652feaf3c06d59554b6d9bb7c2d6219ea8bd02 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 16:42:28 +0530 Subject: [PATCH 270/829] error messages updated --- bin/easyengine | 2 +- src/modules/site/ee_mod_site_backup.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 6862e3ae..7857d9c0 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -697,7 +697,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_update_plugins else - ee_lib_error "$EE_SITE_CURRENT_OPTION Website cannot be updated to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + ee_lib_error "Invalid update option, exit status =" $? fi # Adjust permission ee_lib_permissions diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index 408813c6..88b28d38 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -11,27 +11,27 @@ function ee_mod_site_backup() # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then - ee_lib_echo "Creating Webroot backup for $EE_DOMAIN before updating ..." + ee_lib_echo "Creating Webroot backup for $EE_DOMAIN, please wait..." mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/htdocs to backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi - ee_lib_echo "Creating NGINX configuration backup for $EE_DOMAIN before updating ..." + ee_lib_echo "Creating NGINX configuration backup for $EE_DOMAIN, please wait..." # Backup $EE_DOMAIN NGINX configuration - cp -av /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$EE_DATE.conf.bak &>> $EE_COMMAND_LOG + cp /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$EE_DATE.conf &>> $EE_COMMAND_LOG # Database backup if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then - ee_lib_echo "Creating Database backup for $EE_DOMAIN before updating ..." + ee_lib_echo "Creating Database backup for $EE_DOMAIN, please wait..." local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$EE_DATE.sql.bak \ + mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$EE_DATE.sql \ || ee_lib_error "Unable to dump ${ee_db_name}, exit status =" $? # Move ee-config.php and copy wp-config.php to backup if [ -f $ee_webroot/ee-config.php ]; then mv $ee_webroot/ee-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/ee-config.php to backup, exit status =" $? else - cp $ee_webroot/wp-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/ee-config.php to backup, exit status =" $? + cp $ee_webroot/wp-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/wp-config.php to backup, exit status =" $? fi fi } From 7b46e44b01b98d5e6bfaf1db28fa900a143e73c6 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 17:06:10 +0530 Subject: [PATCH 271/829] updated manpages --- docs/man/ee.8 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/man/ee.8 b/docs/man/ee.8 index 56590b20..cf0821f0 100644 --- a/docs/man/ee.8 +++ b/docs/man/ee.8 @@ -89,11 +89,11 @@ Display easyengine (ee) help. .TP .B cd [ example.com ] .br - Change directory to webroot of specified site + Change directory to webroot of specified site in subshell. .TP .B log [ example.com ] .br - monitor access and error logs for site specified + monitor access and error logs for site specified. .TP .B list [ enable | available ] .br @@ -130,17 +130,15 @@ Display easyengine (ee) help. .br Edit NGINX configuration of site. .TP -.B create [ example.com ] [ --html | --php | --mysql | --wp | --w3tc |--wpfc ] +.B create [ example.com ] [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] .br Create new site according to given options. If no options provided .br create static site with html only. .TP -.B update [ example.com ] [ --html | --php | --mysql | --wp | --w3tc |--wpfc ] +.B update [ example.com ] [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] .br - Update new site according to given options. If no options provided -.br - update site with html only. + Update site configuration according to specified options. .TP .B delete [ example.com ] [--no-prompt ] [ --db | --files ] .br @@ -294,6 +292,9 @@ Report bugs at .B Manish .I \ .br +.B Gaurav +.I \ +.br .B Harshad .I \ .SH "SEE ALSO" From 10a7ae0c49b21c596b3c1056da0f3ec3c261d0c3 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 17:21:54 +0530 Subject: [PATCH 272/829] autcompletion script updated --- bin/easyengine | 8 ++++---- config/bash_completion.d/ee | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 7857d9c0..2b7086fb 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -598,7 +598,7 @@ elif [ "$EE_FIRST" = "site" ]; then || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then ee_mod_update_domain else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status" $? + ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? fi # Setup WordPress @@ -655,7 +655,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status" $? + ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? fi # Setup WordPress Network if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -675,7 +675,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status" $? + ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? fi # Update cache plugins ee_mod_update_plugins @@ -691,7 +691,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status" $? + ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? fi # Update cache plugins ee_mod_update_plugins diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 1d17b66a..e6acf6a3 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -51,7 +51,7 @@ function EE_AUTO() return 0 ;; - info|enable|edit|show|delete|cd|log) + info|enable|edit|show|delete|cd|log|update) if [ "$PREVIOUS2" = "site" ]; then COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)' -- $CURRENT ) ) fi From 2a1cd994da143c911cf97cb15a63746947f0be8a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 9 Oct 2014 17:53:14 +0530 Subject: [PATCH 273/829] updated travis commands --- .travis.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.travis.yml b/.travis.yml index 333673f3..4134bbf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -127,6 +127,27 @@ script: - sudo bash ee debug - sudo bash ee debug --stop +- sudo bash ee site create 1.com --html +- sudo bash ee site create 2.com --php +- sudo bash ee site create 3.com --mysql + +- sudo bash ee site update 1.com --wp +- sudo bash ee site update 2.com --wpsubdir +- sudo bash ee site update 3.com --wpsubdomain + + +- sudo bash ee site update site1.com --wp --wpfc +- sudo bash ee site update site1.com --wp --w3tc +- sudo bash ee site update site1.com --wp --wpsc + +- sudo bash ee site update site5.com --wpsubdir --wpfc +- sudo bash ee site update site5.com --wpsubdir --w3tc +- sudo bash ee site update site5.com --wpsubdir --wpsc + +- sudo bash ee site update site9.com --wpsubdom --wpfc +- sudo bash ee site update site9.com --wpsubdom --w3tc +- sudo bash ee site update site9.com --wpsubdom --wpsc + - sudo bash ee stack install mail - sudo bash -c 'cat /var/log/easyengine/*' From 3fd9e2ff7c611ca58d165955bb316735ec70788f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 10 Oct 2014 11:17:08 +0530 Subject: [PATCH 274/829] updated messages --- src/modules/site/ee_mod_site_backup.sh | 12 ++++++------ src/modules/site/update/ee_mod_update_domain.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index 88b28d38..81dded0c 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -5,26 +5,26 @@ function ee_mod_site_backup() # Backup directory setup local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') - if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs/$EE_DATE ] || [ ! -d $ee_webroot/backup/nginx ] || [ ! -d $ee_webroot/backup/db ]; then + if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs/$EE_DATE ] || [ ! -d $ee_webroot/backup/nginx/$EE_DATE ] || [ ! -d $ee_webroot/backup/db/$EE_DATE ]; then mkdir -p $ee_webroot/backup/{htdocs/$EE_DATE,nginx,db} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? fi # Move htdocs if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then - ee_lib_echo "Creating Webroot backup for $EE_DOMAIN, please wait..." + ee_lib_echo "Backup webroot at $ee_webroot/backup/htdocs/$EE_DATE/, please wait..." mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/htdocs to backup, exit status =" $? mkdir -p $ee_webroot/htdocs fi - ee_lib_echo "Creating NGINX configuration backup for $EE_DOMAIN, please wait..." + ee_lib_echo "Backup NGINX configuration at $ee_webroot/backup/nginx/$EE_DATE/, please wait..." # Backup $EE_DOMAIN NGINX configuration - cp /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/${EE_DOMAIN}-$EE_DATE.conf &>> $EE_COMMAND_LOG + cp /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/$EE_DATE/ &>> $EE_COMMAND_LOG # Database backup if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then - ee_lib_echo "Creating Database backup for $EE_DOMAIN, please wait..." local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - mysqldump $ee_db_name > $ee_webroot/backup/db/${ee_db_name}-$EE_DATE.sql \ + ee_lib_echo "Backup Database $ee_db_name at $ee_webroot/backup/db/$EE_DATE/, please wait..." + mysqldump $ee_db_name > $ee_webroot/backup/db/$EE_DATE/${ee_db_name}.sql \ || ee_lib_error "Unable to dump ${ee_db_name}, exit status =" $? # Move ee-config.php and copy wp-config.php to backup diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh index a6f0d1cb..00d4224c 100644 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ b/src/modules/site/update/ee_mod_update_domain.sh @@ -8,7 +8,7 @@ function ee_mod_update_domain() ee_mod_site_backup # Creating $EE_DOMAIN - ee_lib_echo "Updating $EE_DOMAIN, please wait ..." + ee_lib_echo "Updating $EE_DOMAIN, please wait..." if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then EE_SITE_CURRENT_CONF=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") EE_SITE_UPDATE_CONF=$(head -n1 /usr/share/easyengine/nginx/$EE_NGINX_CONF | grep "NGINX CONFIGURATION") From a38041aeff9211917496c97664e75da94b0d2e47 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 10 Oct 2014 11:58:51 +0530 Subject: [PATCH 275/829] minor update --- src/modules/site/ee_mod_site_backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index 81dded0c..f4268a34 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -6,7 +6,7 @@ function ee_mod_site_backup() # Backup directory setup local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs/$EE_DATE ] || [ ! -d $ee_webroot/backup/nginx/$EE_DATE ] || [ ! -d $ee_webroot/backup/db/$EE_DATE ]; then - mkdir -p $ee_webroot/backup/{htdocs/$EE_DATE,nginx,db} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? + mkdir -p $ee_webroot/backup/{htdocs/$EE_DATE,nginx/$EE_DATE,db/$EE_DATE} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? fi # Move htdocs From 4df5c267751d90dd00b8bb1443f64b7ee503049f Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 10 Oct 2014 12:44:49 +0530 Subject: [PATCH 276/829] Fix wget command for geoip --- src/modules/stack/install/ee_mod_setup_php.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh index f44720d9..a0ae1e7a 100644 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ b/src/modules/stack/install/ee_mod_setup_php.sh @@ -63,7 +63,7 @@ function ee_mod_setup_php() ee_lib_echo "Downloading GeoIP Database, please wait..." mkdir -p /usr/share/GeoIP - wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz /usr/share/GeoIP/GeoIPCity.dat http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz + wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat @@ -81,9 +81,8 @@ function ee_mod_setup_php() || ee_lib_error "Unable to change Memcache memory value, exit status = " $? # Resolve php session Error Ref: #302 - chmod a+t+w /var/lib/php5 && - chmod go-r /var/lib/php5 \ - || ee_lib_error "Unable to setup PHP session error permissions, exit status = " $? - + #chmod a+t+w /var/lib/php5 && + #chmod go-r /var/lib/php5 \ + #|| ee_lib_error "Unable to setup PHP session error permissions, exit status = " $? fi } From 1b973534365d21566272a05dae9d8cb6da4a40e8 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 10 Oct 2014 14:28:32 +0530 Subject: [PATCH 277/829] Display HTTP Auth after site create, bug fix, easyengine version update --- bin/easyengine | 11 +++++++++++ src/lib/ee_lib_package_check.sh | 4 ++++ src/lib/ee_lib_stack_packages.sh | 2 ++ src/lib/ee_lib_variables.sh | 2 +- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 2b7086fb..ffb6ed0d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -427,6 +427,11 @@ elif [ "$EE_FIRST" = "site" ]; then # Git commit ee_lib_git /etc/nginx/ "$EE_DOMAIN created with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" + # Display Http Auth credentials + if [ "$EE_DISPLAY" = "true" ]; then + ee_lib_echo_info "HTTP Authentication username: easyengine" + ee_lib_echo_info "HTTP Authentication password: $(grep "HTTP Authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" + fi # Display Success Message ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -471,6 +476,12 @@ elif [ "$EE_FIRST" = "site" ]; then # Execute: service nginx reload ee_lib_service nginx reload + # Display Http Auth credentials + if [ "$EE_DISPLAY" = "true" ]; then + ee_lib_echo_info "HTTP Authentication username: easyengine" + ee_lib_echo_info "HTTP Authentication password: $(grep "HTTP Authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" + fi + # Display WordPress credential echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" diff --git a/src/lib/ee_lib_package_check.sh b/src/lib/ee_lib_package_check.sh index 0529e3a9..2ada9565 100644 --- a/src/lib/ee_lib_package_check.sh +++ b/src/lib/ee_lib_package_check.sh @@ -2,6 +2,10 @@ function ee_lib_package_check() { + # If nginx is not installed and php is installed + # ee site create example.com --wp is tries to installl php as $EE_PACKAGE_NAME=nginx-custom + EE_PACKAGE_NAME="" + local ee_package for ee_package in $@;do diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index 39d6eaa4..30017404 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -9,6 +9,8 @@ function ee_lib_stack_packages() if [ "$ee_stack_package" = "nginx" ]; then ee_lib_package_check $EE_NGINX_PACKAGE if [ "$EE_PACKAGE_NAME" != "" ]; then + # Export EE_DISPLAY variable to Display ee http auth after site creation. + export EE_DISPLAY=true # The following command creates its own sub-shell # and our ee_lib_error function only exit from that sub-shell # so we need to exit from parent shell also diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index cac25593..ebe20fce 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -1,7 +1,7 @@ # Define global variables # EasyEngine version -readonly EE_VERSION='2.1.0' +readonly EE_VERSION='2.2.0' # WP-CLI version readonly EE_WP_CLI_VERSION='0.17.0' From 2d1bed454039c1f980ed3d3c41a3cf0d63a95350 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 10 Oct 2014 14:50:44 +0530 Subject: [PATCH 278/829] added comments --- bin/easyengine | 1 + src/modules/site/ee_mod_site_log.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index ffb6ed0d..02806925 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -615,6 +615,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup WordPress if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then + # Sets EE_DB_NAME, EE_DB_USER, EE_DB_PASS variables, so that same database can be used while updating MYSQL site to any WordPress site EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) diff --git a/src/modules/site/ee_mod_site_log.sh b/src/modules/site/ee_mod_site_log.sh index 7ab0558f..95cf7a62 100644 --- a/src/modules/site/ee_mod_site_log.sh +++ b/src/modules/site/ee_mod_site_log.sh @@ -2,6 +2,8 @@ function ee_mod_site_log() { + # Sets ee_log_path to empty, so that it should not use its previous values + local ee_log_path="" # Check if domain name passed if [ $# -eq 0 ]; then for ee_domain_name in $(ls /etc/nginx/sites-available/*); do From 7a22fa74314165089146b70f62717c7b328ab69c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 10 Oct 2014 15:27:25 +0530 Subject: [PATCH 279/829] http auth default credentials added --- src/modules/stack/install/ee_mod_setup_nginx.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh index 963475fd..f2482aa1 100644 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ b/src/modules/stack/install/ee_mod_setup_nginx.sh @@ -101,6 +101,10 @@ function ee_mod_setup_nginx() # Use same variable name as used in ee_mod_secure_auth function EE_HTTP_AUTH_USER=easyengine EE_HTTP_AUTH_PASS=$ee_random + echo + ee_lib_echo "HTTP authentication username: $EE_HTTP_AUTH_USER" &>> $EE_COMMAND_LOG + ee_lib_echo "HTTP authentication password: $EE_HTTP_AUTH_PASS" &>> $EE_COMMAND_LOG + printf "$EE_HTTP_AUTH_USER:$(openssl passwd -crypt $EE_HTTP_AUTH_PASS 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null fi } From 27f1aa986271b2938147c0c574754188a7e9d7c0 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 10 Oct 2014 15:30:03 +0530 Subject: [PATCH 280/829] display http auth once while site create --- bin/easyengine | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 02806925..0632ec6f 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -214,8 +214,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display HTTP Authentication details if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then + if [ "$EE_DISPLAY" != "true" ]; then ee_lib_echo_info "HTTP Authentication username: $EE_HTTP_AUTH_USER" ee_lib_echo_info "HTTP Authentication password: $EE_HTTP_AUTH_PASS" + fi fi # Display success message ee_lib_echo "$EE_THIRD successfully installed" From 845616d265a83bdf4a1a8aa4c0634ed520ec2b1c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 10 Oct 2014 15:43:19 +0530 Subject: [PATCH 281/829] Remove PHP session issue code --- src/modules/stack/install/ee_mod_setup_php.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh index a0ae1e7a..46d6cc54 100644 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ b/src/modules/stack/install/ee_mod_setup_php.sh @@ -80,9 +80,5 @@ function ee_mod_setup_php() sed -i "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \ || ee_lib_error "Unable to change Memcache memory value, exit status = " $? - # Resolve php session Error Ref: #302 - #chmod a+t+w /var/lib/php5 && - #chmod go-r /var/lib/php5 \ - #|| ee_lib_error "Unable to setup PHP session error permissions, exit status = " $? fi } From 282115ce4f7838e5ae0d8e4eb11ae5b3a59d1531 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 10 Oct 2014 16:20:20 +0530 Subject: [PATCH 282/829] Fix typo --- bin/easyengine | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 0632ec6f..00011c2a 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -212,11 +212,11 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Installed Mail Scanner Packages" fi - # Display HTTP Authentication details + # Display HTTP authentication details if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then if [ "$EE_DISPLAY" != "true" ]; then - ee_lib_echo_info "HTTP Authentication username: $EE_HTTP_AUTH_USER" - ee_lib_echo_info "HTTP Authentication password: $EE_HTTP_AUTH_PASS" + ee_lib_echo_info "HTTP authentication username: $EE_HTTP_AUTH_USER" + ee_lib_echo_info "HTTP authentication password: $EE_HTTP_AUTH_PASS" fi fi # Display success message @@ -431,8 +431,8 @@ elif [ "$EE_FIRST" = "site" ]; then # Display Http Auth credentials if [ "$EE_DISPLAY" = "true" ]; then - ee_lib_echo_info "HTTP Authentication username: easyengine" - ee_lib_echo_info "HTTP Authentication password: $(grep "HTTP Authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" + ee_lib_echo_info "HTTP authentication username: easyengine" + ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" fi # Display Success Message ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" @@ -480,8 +480,8 @@ elif [ "$EE_FIRST" = "site" ]; then # Display Http Auth credentials if [ "$EE_DISPLAY" = "true" ]; then - ee_lib_echo_info "HTTP Authentication username: easyengine" - ee_lib_echo_info "HTTP Authentication password: $(grep "HTTP Authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" + ee_lib_echo_info "HTTP authentication username: easyengine" + ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" fi # Display WordPress credential From 3e6c5f5cb735dc67265a2b17bb448189f0c7828e Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 10 Oct 2014 16:25:35 +0530 Subject: [PATCH 283/829] Check /etc/mysql/my.cnf --- src/modules/stack/install/ee_mod_setup_mysql.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/stack/install/ee_mod_setup_mysql.sh b/src/modules/stack/install/ee_mod_setup_mysql.sh index d40ccdc6..b83ffd8a 100644 --- a/src/modules/stack/install/ee_mod_setup_mysql.sh +++ b/src/modules/stack/install/ee_mod_setup_mysql.sh @@ -5,8 +5,12 @@ function ee_mod_setup_mysql() ee_lib_echo "Setting up Percona MySQL, please wait..." # Setting wait_timeout = 30 & interactive_timeout = 60 - grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf + if [ ! -f /etc/mysql/my.cnf ]; then + echo -e "[mysqld] \nwait_timeout = 30 \ninteractive_timeout = 60" > /etc/mysql/my.cnf + else + grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG + if [ $? -ne 0 ]; then + sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf + fi fi } From b4469a7e8a7f9a23b710bb18f196ccef5555a096 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 10 Oct 2014 16:43:19 +0530 Subject: [PATCH 284/829] Fixed http auth display --- bin/easyengine | 6 ++++++ src/modules/stack/install/ee_mod_setup_nginx.sh | 2 ++ 2 files changed, 8 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 00011c2a..e5417862 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -220,6 +220,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then fi fi # Display success message + if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ]; then + EE_THIRD="Web packages" + fi ee_lib_echo "$EE_THIRD successfully installed" # EasyEngine remove/purge @@ -293,6 +296,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then fi # Display success message + if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ]; then + EE_THIRD="Web packages" + fi if [ "$EE_SECOND" = "remove" ];then ee_lib_echo "$EE_THIRD successfully removed" elif [ "$EE_SECOND" = "purge" ];then diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh index f2482aa1..53d6139b 100644 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ b/src/modules/stack/install/ee_mod_setup_nginx.sh @@ -98,6 +98,8 @@ function ee_mod_setup_nginx() # Generate htpasswd-ee file if [ ! -f /etc/nginx/htpasswd-ee ]; then + # Export EE_DISPLAY variable to Display ee http auth after site creation. + export EE_DISPLAY=true # Use same variable name as used in ee_mod_secure_auth function EE_HTTP_AUTH_USER=easyengine EE_HTTP_AUTH_PASS=$ee_random From 212374c778723918e325249add7ed1dffbc63ed1 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 10 Oct 2014 18:17:05 +0530 Subject: [PATCH 285/829] Fix HTTP AUTH message display --- bin/easyengine | 6 +++--- src/lib/ee_lib_stack_packages.sh | 2 +- src/modules/stack/install/ee_mod_setup_nginx.sh | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index e5417862..362791a5 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -214,7 +214,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Display HTTP authentication details if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then - if [ "$EE_DISPLAY" != "true" ]; then + if [ "$EE_DISPLAY" = "true" ]; then ee_lib_echo_info "HTTP authentication username: $EE_HTTP_AUTH_USER" ee_lib_echo_info "HTTP authentication password: $EE_HTTP_AUTH_PASS" fi @@ -436,7 +436,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_git /etc/nginx/ "$EE_DOMAIN created with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" # Display Http Auth credentials - if [ "$EE_DISPLAY" = "true" ]; then + if [ "$EE_DISPLAY" = "false" ]; then ee_lib_echo_info "HTTP authentication username: easyengine" ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" fi @@ -485,7 +485,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_service nginx reload # Display Http Auth credentials - if [ "$EE_DISPLAY" = "true" ]; then + if [ "$EE_DISPLAY" = "false" ]; then ee_lib_echo_info "HTTP authentication username: easyengine" ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" fi diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index 30017404..332fd1f9 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -10,7 +10,7 @@ function ee_lib_stack_packages() ee_lib_package_check $EE_NGINX_PACKAGE if [ "$EE_PACKAGE_NAME" != "" ]; then # Export EE_DISPLAY variable to Display ee http auth after site creation. - export EE_DISPLAY=true + export EE_DISPLAY=false # The following command creates its own sub-shell # and our ee_lib_error function only exit from that sub-shell # so we need to exit from parent shell also diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh index 53d6139b..b280d4dc 100644 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ b/src/modules/stack/install/ee_mod_setup_nginx.sh @@ -99,7 +99,9 @@ function ee_mod_setup_nginx() # Generate htpasswd-ee file if [ ! -f /etc/nginx/htpasswd-ee ]; then # Export EE_DISPLAY variable to Display ee http auth after site creation. - export EE_DISPLAY=true + if [ -z $EE_DISPLAY ]; then + export EE_DISPLAY=true + fi # Use same variable name as used in ee_mod_secure_auth function EE_HTTP_AUTH_USER=easyengine EE_HTTP_AUTH_PASS=$ee_random From e234edabc340a0488b41f1fa83361880b29f5b0b Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 13 Oct 2014 13:50:09 +0530 Subject: [PATCH 286/829] Updated Command Usage guide --- bin/easyengine | 10 +++++++--- config/bash_completion.d/ee | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 362791a5..be8a4718 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -311,9 +311,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_service nginx php5-fpm mysql postfix $EE_SECOND else ee_lib_echo "ee stack commands:" - ee_lib_echo_escape "\tinstall\tInstall NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI and Utils" - ee_lib_echo_escape "\tremove\tRemove NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI and Utils" - ee_lib_echo_escape "\tpurge\tPurge NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI and Utils" + ee_lib_echo_escape "\tinstall\tInstall NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI , Utils, Mailscanner and Admin tools" + ee_lib_echo_escape "\tremove\tRemove NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI, Utils, Mailscanner and Admin tools" + ee_lib_echo_escape "\tpurge\tPurge NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI, Utils, Mailscanner and Admin tools" ee_lib_echo_escape "\tstatus\tDisplay system status information" ee_lib_echo_escape "\tstart\tStart NGINX, PHP5, MySQL and Postfix service" ee_lib_echo_escape "\tstop\tStop NGINX, PHP5, MySQL and Postfix service" @@ -752,6 +752,7 @@ elif [ "$EE_FIRST" = "site" ]; then else ee_lib_echo "ee site commands:" + ee_lib_echo_escape "\tcd\tSwitch to website root directory" ee_lib_echo_escape "\tlist\tList NGINX enabled website" ee_lib_echo_escape "\tinfo\tDisplay information about given website" ee_lib_echo_escape "\tshow\tDisplay NGINX configuration for given website" @@ -760,6 +761,8 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_escape "\tedit\tEdit NGINX configuration for given website" ee_lib_echo_escape "\tcreate\tCreate new HTML, PHP, MySQL or WordPress website" ee_lib_echo_escape "\tdelete\tDelete existing website" + ee_lib_echo_escape "\tlog\tMonitor access and error logs for single or multiple websites" + ee_lib_echo_escape "\tupdate\tupdate current website" fi # EasyEngine debug @@ -891,6 +894,7 @@ else ee_lib_echo_escape "\tversion\tDisplay EasyEngine (ee) version" ee_lib_echo_escape "\thelp\tDisplay EasyEngine (ee) man page" ee_lib_echo_escape "\tinfo\tDisplay Information about NGINX, PHP5, MySQL" + ee_lib_echo_escape "\tclean\tClean Nginx FastCGI cache/OPcache/Memcache/all cache" ee_lib_echo_escape "\tstack\tInstall/Remove/Purge NGINX, PHP, MySQL, Postfix" ee_lib_echo_escape "\tsite\tPerform various site specific operation" ee_lib_echo_escape "\tdebug\tPerform various debugging operation" diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index e6acf6a3..b0253c33 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -27,7 +27,7 @@ function EE_AUTO() # List of suggested words easyengine|ee) - COMPREPLY=( $(compgen -W '$(echo clean version help info update; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) + COMPREPLY=( $(compgen -W '$(echo clean version help info update import-slow-log; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) return 0 ;; @@ -37,7 +37,12 @@ function EE_AUTO() ;; install|remove|purge) - COMPREPLY=( $( compgen -W '$(echo mail all web mailscanner; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) + COMPREPLY=( $( compgen -W '$(echo mail all web mailscanner admin; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) + return 0 + ;; + + clean) + COMPREPLY=( $( compgen -W '$(echo cd fastcgi memcache opcache all;)' -- $CURRENT ) ) return 0 ;; @@ -69,7 +74,7 @@ function EE_AUTO() ;; debug) - COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + COMPREPLY=( $(compgen -W '$(echo --import-slow-log-interval; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) return 0 ;; From 1cda4debdaec3fa911534aaefeeb9a080ea50242 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 13 Oct 2014 14:10:15 +0530 Subject: [PATCH 287/829] Updated update script and Fixed some typo --- bin/update | 66 ++++++++++++++++++++++++++++++ src/lib/ee_lib_import_slow_log.sh | 2 +- src/vendor/ee_ven_install_utils.sh | 2 +- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/bin/update b/bin/update index 709b291a..bd5cd422 100644 --- a/bin/update +++ b/bin/update @@ -428,8 +428,74 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then fi if [[ $EE_CURRENT_VERSION = 2.1.0 ]]; then + + #Change permission of EasyEngine log folder + chmod -R 700 /var/log/easyengine \ + || ee_lib_error "Unable to change permissions for EasyEngine log folder, exit status = " $? + #RAM based optimization settings + ee_lib_ram + if [ -f /etc/php5/fpm/pool.d/www.conf ]; then + sed -i "s/pm.max_children = .*/pm.max_children = ${EE_PHP_MAX_CHILDREN}/" /etc/php5/fpm/pool.d/www.conf + fi + + # Setup Zend OpCache as per RAM + if [ -f /etc/php5/fpm/conf.d/05-opcache.ini ]; then + grep memory_consumption /etc/php5/fpm/conf.d/05-opcache.ini &> /dev/null + if [ $? -ne 0 ]; then + sed -i "s/zend_extension=opcache.so/zend_extension=opcache.so\nopcache.memory_consumption=${EE_OPCACHE_SIZE}\nopcache.max_accelerated_files=50000/" /etc/php5/fpm/conf.d/05-opcache.ini \ + || ee_lib_error "Unable to change opcache.memory_consumption, exit status = " $? + fi + fi + + # Setup PHP Memcache as per RAM + if [ -f /etc/memcached.conf ]; then + sed -i "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \ + || ee_lib_error "Unable to change Memcache memory value, exit status = " $? + fi + + # Add PHP GeoIP module + dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG + if [ $? -eq 0 ]; then + ee_lib_echo "Downloading GeoIP Database, please wait..." + mkdir -p /usr/share/GeoIP + wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz + gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz + mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat + $EE_APT_GET install php5-geoip + fi + + # Change Anemometer login details + if [ -d /var/www/22222/htdocs/db/anemometer ]; then + ee_anemometer_pass=$(grep "password=" /etc/logrotate.d/mysql-server | cut -d"=" -f3 ) + ee_anemometer_pass=$(echo ${ee_anemometer_pass::-2}) + + # Change Anemometer Hostname in ee_lib_import_slow_log + sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ + || ee_lib_error "Unable to change Anemometer hostnameme, exit status = " $? + + # Change Anemometer password in ee_lib_import_slow_log + sed -i "s/--password.*/--password=${ee_anemometer_pass} \\\/" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ + || ee_lib_error "Unable to change Anemometer password, exit status = " $? + fi + + # Fix PhpMyAdmin config issue + if [ -d /var/www/22222/htdocs/db/pma ]; then + local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1) + + if [ ! -f /var/www/22222/htdocs/db/pma/config.inc.php ]; then + cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND_LOG + || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? + fi + + sed -i "s/a8b7c6d/$ee_random/" /var/www/22222/htdocs/db/pma/config.inc.php \ + || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? + fi + + # Add eeupdate command to bash.bashrc + echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup --no-check-certificate http://rt.cx/eeup && sudo bash eeup\"" >> /etc/bash.bashrc + # Update EasyEngine current version EE_CURRENT_VERSION="2.1.0" fi diff --git a/src/lib/ee_lib_import_slow_log.sh b/src/lib/ee_lib_import_slow_log.sh index 09396db8..cfa41c72 100644 --- a/src/lib/ee_lib_import_slow_log.sh +++ b/src/lib/ee_lib_import_slow_log.sh @@ -21,6 +21,6 @@ function ee_lib_import_slow_log() ee_lib_echo_fail "Failed to find MySQL slow log file, enable MySQL slow log" fi else - ee_lib_echo_fail "Anememoter is not installed" + ee_lib_echo_fail "Anemometer is not installed" fi } diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index c40a63e1..260dad69 100644 --- a/src/vendor/ee_ven_install_utils.sh +++ b/src/vendor/ee_ven_install_utils.sh @@ -102,7 +102,7 @@ function ee_ven_install_utils() sed -i "/password/ s/''/'$ee_anemometer_pass'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php sed -i "s/'host' => 'localhost',/'host' => '$EE_MYSQL_HOST',/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php - # Chane Anemometer Hostname in ee_lib_import_slow_log + # Change Anemometer Hostname in ee_lib_import_slow_log sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ || ee_lib_error "Unable to change Anemometer hostnameme, exit status = " $? From f4ee7df1f87f7d5a897de688009f7b247fae919f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 13 Oct 2014 14:28:54 +0530 Subject: [PATCH 288/829] Fixed Typo --- bin/update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/update b/bin/update index bd5cd422..4200a0c7 100644 --- a/bin/update +++ b/bin/update @@ -485,7 +485,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1) if [ ! -f /var/www/22222/htdocs/db/pma/config.inc.php ]; then - cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND_LOG + cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? fi From 1267d48a17f351698a6c3a61e9cc673fb52b18e3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 13 Oct 2014 14:30:29 +0530 Subject: [PATCH 289/829] Fixed Update Version --- bin/update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/update b/bin/update index 4200a0c7..13bd3c94 100644 --- a/bin/update +++ b/bin/update @@ -497,7 +497,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup --no-check-certificate http://rt.cx/eeup && sudo bash eeup\"" >> /etc/bash.bashrc # Update EasyEngine current version - EE_CURRENT_VERSION="2.1.0" + EE_CURRENT_VERSION="2.2.0" fi # if [[ $EE_CURRENT_VERSION = 2.2.0 ]]; then # fi From 912e0bbaa7576025b32923bc5737208fc47f0aba Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 13 Oct 2014 14:32:39 +0530 Subject: [PATCH 290/829] Fixed 'local: can only be used in a function' --- bin/update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/update b/bin/update index 13bd3c94..358cd801 100644 --- a/bin/update +++ b/bin/update @@ -482,7 +482,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Fix PhpMyAdmin config issue if [ -d /var/www/22222/htdocs/db/pma ]; then - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1) + ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1) if [ ! -f /var/www/22222/htdocs/db/pma/config.inc.php ]; then cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND_LOG \ From 75cbef4a72d5a1366c8047c5d01901b8ba474f63 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 13 Oct 2014 15:02:25 +0530 Subject: [PATCH 291/829] Updated EasyEngine update command message --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index be8a4718..3120bb3d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -886,7 +886,7 @@ elif [ "$EE_FIRST" = "import-slow-log" ];then # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then - ee_lib_echo "Updating EasyEngine (ee), please wait..." + ee_lib_echo "Checking EasyEngine(ee) update, please wait..." wget --no-check-certificate -qO eeup http://rt.cx/eeup && sudo bash eeup else From 076457fca7c31f1106c097ff9e66b5a38fbc8498 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 13 Oct 2014 15:06:57 +0530 Subject: [PATCH 292/829] Minor update --- bin/update | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/update b/bin/update index 358cd801..6a2c781b 100644 --- a/bin/update +++ b/bin/update @@ -429,11 +429,11 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then if [[ $EE_CURRENT_VERSION = 2.1.0 ]]; then - #Change permission of EasyEngine log folder + # Change permission of EasyEngine log folder chmod -R 700 /var/log/easyengine \ || ee_lib_error "Unable to change permissions for EasyEngine log folder, exit status = " $? - #RAM based optimization settings + # RAM based optimization settings ee_lib_ram if [ -f /etc/php5/fpm/pool.d/www.conf ]; then @@ -458,12 +458,12 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Add PHP GeoIP module dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG if [ $? -eq 0 ]; then + $EE_APT_GET install php5-geoip ee_lib_echo "Downloading GeoIP Database, please wait..." mkdir -p /usr/share/GeoIP wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat - $EE_APT_GET install php5-geoip fi # Change Anemometer login details From d6f12d8fa112a7529b619564c1d53d97507028a9 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 13 Oct 2014 15:21:26 +0530 Subject: [PATCH 293/829] Removed ee update code from bash.bashrc --- bin/install | 3 --- bin/update | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bin/install b/bin/install index 8ff84d53..5238f341 100644 --- a/bin/install +++ b/bin/install @@ -226,9 +226,6 @@ if [ -z "$GIT_USER_EMAIL" ];then echo "git config user.email = $(git config user.email)" &>> $EE_INSTALL_LOG fi -# Add eeupdate command to /etc/bash.bashrc -echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup --no-check-certificate http://rt.cx/eeup && sudo bash eeup\"" >> /etc/bash.bashrc - # Enable EasyEngine (ee) auto completion echo ee_lib_echo "For EasyEngine (ee) auto completion, run the following command" | tee -ai $EE_INSTALL_LOG diff --git a/bin/update b/bin/update index 6a2c781b..ac9c212a 100644 --- a/bin/update +++ b/bin/update @@ -492,10 +492,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then sed -i "s/a8b7c6d/$ee_random/" /var/www/22222/htdocs/db/pma/config.inc.php \ || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? fi - - # Add eeupdate command to bash.bashrc - echo -e "#EasyEngine Update Command\nalias eeupdate=\"wget -qO eeup --no-check-certificate http://rt.cx/eeup && sudo bash eeup\"" >> /etc/bash.bashrc - + # Update EasyEngine current version EE_CURRENT_VERSION="2.2.0" fi From 5ef2011dac8bb243aabe736194dc4f55f439bf63 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 13 Oct 2014 16:15:43 +0530 Subject: [PATCH 294/829] Minor update --- config/bash_completion.d/ee | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index b0253c33..1dd15a0b 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -79,10 +79,15 @@ function EE_AUTO() ;; --nginx|--rewrite|--php|--fpm|--mysql) - COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + if [ "$PREVIOUS" = "--mysql" ]; then + COMPREPLY=( $(compgen -W '$(echo --import-slow-log-interval; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + else + COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + fi ee_single - return 0 - ;; + return 0 + ;; + --wp) if [ "$PREVIOUS3" = "create" ] || [ "$PREVIOUS3" = "update" ]; then From 756e0be2cc26e756f6af4bec1eb99ca07ea0a53f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 13 Oct 2014 16:39:47 +0530 Subject: [PATCH 295/829] Fixed Anemometer slow issue in Debain 6 --- bin/update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/update b/bin/update index ac9c212a..7eb0c836 100644 --- a/bin/update +++ b/bin/update @@ -469,7 +469,7 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Change Anemometer login details if [ -d /var/www/22222/htdocs/db/anemometer ]; then ee_anemometer_pass=$(grep "password=" /etc/logrotate.d/mysql-server | cut -d"=" -f3 ) - ee_anemometer_pass=$(echo ${ee_anemometer_pass::-2}) + ee_anemometer_pass=$(echo $ee_anemometer_pass | rev | cut -c 3- | rev) # Change Anemometer Hostname in ee_lib_import_slow_log sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ From a1578f8b94d53bbed0d9fbf157f1ba38df93b77c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 13 Oct 2014 20:52:22 +0530 Subject: [PATCH 296/829] Changelog for EasyEngine 2.2.0 --- CHANGELOG.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6f61bb5d..12625741 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,18 @@ +v 2.2.0 - Oct 13, 2014 +- Percona Mysql 5.6 support on Fresh installation. #107 +- RAM Based Optimization for PHP5-FPM,OpCache and Memcache +- Introduced following new commands for + - ee site cd example.com # Change Directory to example.com Webroot + - ee site log example.com # Real time log monitoring for example.com access and error logs + - ee site update example.com # update example.com cache and convert site + - ee clean # Clean cache NGINX FastCGI, Memcache, OPcache. +- Change WordPress user password easily ( ee site update example.com --password) #315 +- Added PHP5-GeoIP Support +- Auto Swap creation for low RAM servers. +- Fixed Better autocompletion feature. Fixed #311. +- Fixed phpMyAdmin (blowfish_secret) error #301 +- Simplified way to update EasyEngine. #307 + v 2.1.0 - Sept 3, 2014 - Added Mail Server Package installation #65 - Fixed incorrect log file path during debug #299 From 2de9b90311ad1b109c7fa6b7e7f93031436b97aa Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 14 Oct 2014 11:47:07 +0530 Subject: [PATCH 298/829] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 14a6d443..6a76186b 100644 --- a/README.md +++ b/README.md @@ -16,21 +16,21 @@ EasyEngine (ee) is a linux shell-script collection, which makes it easy to manag ```bash wget -qO ee rt.cx/ee && sudo bash ee # install easyengine -ee stack install # install nginx, php, mysql, postfix -ee site create example.com --wp # create example.com and install wordpress on it +ee site create example.com --wp # Install required packages & setup WordPress on example.com ``` ## Update EasyEngine -To update the EasyEngine, please set following alias in your `~/.bashrc` +Update Procedure for EasyEngine 2.2.0 and next versions: ```bash -alias eeupdate="wget -qO eeup http://rt.cx/eeup && sudo bash eeup" +ee update ``` -Now Update EasyEngine using command: + +Update Procedure For EasyEngine 2.1.0 and previous versions: ```bash -eeupdate +wget -qO eeup http://rt.cx/eeup && sudo bash eeup ``` ## More Site Creation Commands From a9d05821c4a7952a620f14aae5069d2d386a1c15 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 14 Oct 2014 12:00:35 +0530 Subject: [PATCH 299/829] Fixed Git function in update script --- bin/update | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/bin/update b/bin/update index 7eb0c836..552bd02b 100644 --- a/bin/update +++ b/bin/update @@ -33,22 +33,24 @@ function ee_lib_error() function ee_lib_git() { for ee_git_dir in ${@:1:$(($#-1))}; do - # Change directory - cd $ee_git_dir || ee_lib_error "Unable to change directory $ee_git_dir, exit status = " $? - - # Check .git - if [ ! -d .git ]; then - # ee_lib_echo "Initialize Git on ${ee_git_dir}" - git init &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to initialize Git on $ee_git_dir, exit status = " $? - fi + if [ -d $ee_git_dir ]; then + # Change directory + cd $ee_git_dir + + # Check .git + if [ ! -d .git ]; then + # ee_lib_echo "Initialize Git on ${ee_git_dir}" + git init &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to initialize Git on $ee_git_dir, exit status = " $? + fi - # Check for untracked files - if [ $(git status -s | wc -l) -ne 0 ]; then - # Add files in Git version control - ee_lib_echo "Git commit on $ee_git_dir, please wait..." - git add --all && git commit -am "${@: -1}" &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to Git commit on $ee_git_dir, exit status = " $? + # Check for untracked files + if [ $(git status -s | wc -l) -ne 0 ]; then + # Add files in Git version control + ee_lib_echo "Git commit on $ee_git_dir, please wait..." + git add --all && git commit -am "${@: -1}" &>> $EE_COMMAND_LOG \ + || ee_lib_error "Unable to Git commit on $ee_git_dir, exit status = " $? + fi fi done } From 9d1981fa2817e9209d67a6cbb523f75a6eda8d0c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 14 Oct 2014 16:42:13 +0530 Subject: [PATCH 300/829] Fix autocomplete for ee debug --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 1dd15a0b..7015fc94 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -74,7 +74,7 @@ function EE_AUTO() ;; debug) - COMPREPLY=( $(compgen -W '$(echo --import-slow-log-interval; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) + COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) return 0 ;; From 5c0d319ba021d975812cc89ad57f26ece5fceaed Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Tue, 14 Oct 2014 16:04:18 -0700 Subject: [PATCH 301/829] Fixed site deletion when using external MySQL host --- src/modules/site/delete/ee_mod_delete_database.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/site/delete/ee_mod_delete_database.sh b/src/modules/site/delete/ee_mod_delete_database.sh index 9fa59443..dcd7e825 100644 --- a/src/modules/site/delete/ee_mod_delete_database.sh +++ b/src/modules/site/delete/ee_mod_delete_database.sh @@ -12,6 +12,11 @@ function ee_mod_delete_database() local ee_db_host=$(grep DB_HOST /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) ee_lib_echo_escape " DB_NAME = $ee_db_name \n DB_USER = $ee_db_user \n DB_HOST = $ee_db_host" + if [ "$EE_MYSQL_GRANT_HOST" != "localhost" ]; then + # If MySQL grant host is set, use that value instead + ee_db_host=$EE_MYSQL_GRANT_HOST + fi + if [ "$1" = "--no-prompt" ];then # Delete database without any prompt local ee_prompt="y" From 43a873d11f6622044362ce9aaa468b83760399f8 Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Tue, 14 Oct 2014 16:28:59 -0700 Subject: [PATCH 302/829] Typo when deleting non-existent site. --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 3120bb3d..481b4678 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -541,7 +541,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Check the $EE_DOMAIN exist or not if [ ! -f /etc/nginx/sites-available/$EE_DOMAIN ]; then - ee_lib_error "$EE_DOMAIN not exist, exit status = " $? + ee_lib_error "$EE_DOMAIN does not exist, exit status = " $? fi # Use default whenever possible From 40da78df76023495d50e539ba97198553ac502a7 Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Wed, 15 Oct 2014 11:36:27 +0530 Subject: [PATCH 303/829] Update update script --- bin/update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/update b/bin/update index 552bd02b..bf990cef 100644 --- a/bin/update +++ b/bin/update @@ -40,7 +40,7 @@ function ee_lib_git() # Check .git if [ ! -d .git ]; then # ee_lib_echo "Initialize Git on ${ee_git_dir}" - git init &>> $EE_COMMAND_LOG \ + git init &>> $EE_UPDATE_LOG \ || ee_lib_error "Unable to initialize Git on $ee_git_dir, exit status = " $? fi @@ -48,7 +48,7 @@ function ee_lib_git() if [ $(git status -s | wc -l) -ne 0 ]; then # Add files in Git version control ee_lib_echo "Git commit on $ee_git_dir, please wait..." - git add --all && git commit -am "${@: -1}" &>> $EE_COMMAND_LOG \ + git add --all && git commit -am "${@: -1}" &>> $EE_UPDATE_LOG \ || ee_lib_error "Unable to Git commit on $ee_git_dir, exit status = " $? fi fi From 02372e291708aba6b95ec047f98ac302653ba471 Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Wed, 15 Oct 2014 08:16:02 -0700 Subject: [PATCH 304/829] Use Global Grant Host variable instead of local. Dialog is updated to show Grant Host during deletion process. --- src/modules/site/delete/ee_mod_delete_database.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/modules/site/delete/ee_mod_delete_database.sh b/src/modules/site/delete/ee_mod_delete_database.sh index dcd7e825..290c2331 100644 --- a/src/modules/site/delete/ee_mod_delete_database.sh +++ b/src/modules/site/delete/ee_mod_delete_database.sh @@ -10,12 +10,7 @@ function ee_mod_delete_database() local ee_db_user=$(grep DB_USER /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) local ee_db_pass=$(grep DB_PASS /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) local ee_db_host=$(grep DB_HOST /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) - ee_lib_echo_escape " DB_NAME = $ee_db_name \n DB_USER = $ee_db_user \n DB_HOST = $ee_db_host" - - if [ "$EE_MYSQL_GRANT_HOST" != "localhost" ]; then - # If MySQL grant host is set, use that value instead - ee_db_host=$EE_MYSQL_GRANT_HOST - fi + ee_lib_echo_escape " DB_NAME = $ee_db_name \n DB_USER = $ee_db_user \n DB_HOST = $ee_db_host \n GRANT_HOST = $EE_MYSQL_GRANT_HOST" if [ "$1" = "--no-prompt" ];then # Delete database without any prompt @@ -35,7 +30,7 @@ function ee_mod_delete_database() # Never drop root user if [ "$ee_db_user" != "root" ]; then # Drop database user - mysql -e "drop user '$ee_db_user'@'$ee_db_host'" \ + mysql -e "drop user '$ee_db_user'@'$EE_MYSQL_GRANT_HOST'" \ || ee_lib_error "Unable to drop database user $ee_db_user, exit status = " $? # Flush privileges mysql -e "flush privileges" \ From 6a97a7f2b9a8364aeca27c299ad9269d75f066f9 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 16 Oct 2014 12:21:39 +0530 Subject: [PATCH 305/829] Added 'ee site delete to travis' --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4134bbf8..fb41793c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -148,6 +148,11 @@ script: - sudo bash ee site update site9.com --wpsubdom --w3tc - sudo bash ee site update site9.com --wpsubdom --wpsc + +- sudo ee site delete site12.com --no-prompt +- sudo ee site delete site12.net --no-prompt +- sudo ee site delete site12.org --no-prompt + - sudo bash ee stack install mail - sudo bash -c 'cat /var/log/easyengine/*' From 41fbd0c8f67c000018a29054242a613d62282f08 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 16 Oct 2014 13:04:55 +0530 Subject: [PATCH 306/829] Updated Version to 2.2.1 --- src/lib/ee_lib_variables.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index ebe20fce..1d6eaf83 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -1,7 +1,7 @@ # Define global variables # EasyEngine version -readonly EE_VERSION='2.2.0' +readonly EE_VERSION='2.2.1' # WP-CLI version readonly EE_WP_CLI_VERSION='0.17.0' From 3b71b98a34d1a0ede525112d6cc84cad7afb085e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 16 Oct 2014 14:44:36 +0530 Subject: [PATCH 307/829] Changed Anemometer password update globally in update script --- bin/update | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/bin/update b/bin/update index bf990cef..7f982adf 100644 --- a/bin/update +++ b/bin/update @@ -81,6 +81,16 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then || ee_lib_error "Unable to install required packages, exit status = " $? fi + # Get Anemometer password + if [ -d /var/www/22222/htdocs/db/anemometer ]; then + if [ -f /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh ]; then + ee_anemometer_pass=$(grep "\-\-password" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh | cut -d"=" -f3 ) + else + ee_anemometer_pass=$(grep "password=" /etc/logrotate.d/mysql-server | cut -d"=" -f3 ) + fi + ee_anemometer_pass=$(echo $ee_anemometer_pass | rev | cut -c 3- | rev) + fi + # Git backup ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "EasyEngine version $EE_CURRENT_VERSION" @@ -468,20 +478,6 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat fi - # Change Anemometer login details - if [ -d /var/www/22222/htdocs/db/anemometer ]; then - ee_anemometer_pass=$(grep "password=" /etc/logrotate.d/mysql-server | cut -d"=" -f3 ) - ee_anemometer_pass=$(echo $ee_anemometer_pass | rev | cut -c 3- | rev) - - # Change Anemometer Hostname in ee_lib_import_slow_log - sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ - || ee_lib_error "Unable to change Anemometer hostnameme, exit status = " $? - - # Change Anemometer password in ee_lib_import_slow_log - sed -i "s/--password.*/--password=${ee_anemometer_pass} \\\/" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ - || ee_lib_error "Unable to change Anemometer password, exit status = " $? - fi - # Fix PhpMyAdmin config issue if [ -d /var/www/22222/htdocs/db/pma ]; then ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1) @@ -504,7 +500,18 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Update WP-CLI ee_ven_install_wpcli - + + # Set Anemometer password + if [ -d /var/www/22222/htdocs/db/anemometer ]; then + # Change Anemometer Hostname in ee_lib_import_slow_log + sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ + || ee_lib_error "Unable to change Anemometer hostnameme, exit status = " $? + + # Change Anemometer password in ee_lib_import_slow_log + sed -i "s/--password.*/--password=${ee_anemometer_pass} \\\/" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ + || ee_lib_error "Unable to change Anemometer password, exit status = " $? + fi + # Restart service ee_lib_service nginx php5-fpm restart From 889b68ec71dd85ac135be6da4f717be51f4a2752 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 16 Oct 2014 15:40:06 +0530 Subject: [PATCH 308/829] Updated Changelog --- CHANGELOG.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 12625741..796c2b4a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,8 @@ +v 2.2.1 - Oct 16,2014 +- Fixed update script issue for remote MySQL #323 +- Fixed remote MySQL delete user issue by @brennentsmith #324 +- Improved auto-completion + v 2.2.0 - Oct 13, 2014 - Percona Mysql 5.6 support on Fresh installation. #107 - RAM Based Optimization for PHP5-FPM,OpCache and Memcache From 8d3f182a2b49205b7c7235d2c9abc6b486ec9167 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 16 Oct 2014 16:05:53 +0530 Subject: [PATCH 309/829] fixed ee update --- bin/easyengine | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 481b4678..d07995fb 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -886,8 +886,8 @@ elif [ "$EE_FIRST" = "import-slow-log" ];then # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then - ee_lib_echo "Checking EasyEngine(ee) update, please wait..." - wget --no-check-certificate -qO eeup http://rt.cx/eeup && sudo bash eeup + ee_lib_echo "Run following command to update EasyEngine" + ee_lib_echo_info "wget --no-check-certificate -qO eeup http://rt.cx/eeup && sudo bash eeup" else ee_lib_echo "EasyEngine (ee) commands:" From 41a9f0f6786cf7df9438a70164134703b9a4ddb2 Mon Sep 17 00:00:00 2001 From: Harshad Yeola Date: Fri, 17 Oct 2014 12:02:06 +0530 Subject: [PATCH 310/829] Update README.md --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 6a76186b..23acb4a7 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,8 @@ ee site create example.com --wp # Install required packages & setup Wor ## Update EasyEngine -Update Procedure for EasyEngine 2.2.0 and next versions: -```bash -ee update -``` - -Update Procedure For EasyEngine 2.1.0 and previous versions: +Update Procedure For EasyEngine ```bash wget -qO eeup http://rt.cx/eeup && sudo bash eeup From b3030f53f940a55b34d9f80ddc4ff3cb53f9e130 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 17 Oct 2014 14:11:20 +0530 Subject: [PATCH 311/829] Update Back up directory structure --- src/modules/site/ee_mod_site_backup.sh | 36 +++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index f4268a34..347a00a7 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -5,33 +5,39 @@ function ee_mod_site_backup() # Backup directory setup local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') - if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs/$EE_DATE ] || [ ! -d $ee_webroot/backup/nginx/$EE_DATE ] || [ ! -d $ee_webroot/backup/db/$EE_DATE ]; then - mkdir -p $ee_webroot/backup/{htdocs/$EE_DATE,nginx/$EE_DATE,db/$EE_DATE} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? + if [ ! -d $ee_webroot/backup/$EE_DATE ]; then + mkdir -p $ee_webroot/backup/$EE_DATE || ee_lib_error "Fail to create backup directory, exit status =" $? fi + ee_lib_echo "Backup location: $ee_webroot/backup/$EE_DATE" + ee_lib_echo "Backup NGINX configuration, please wait..." + # Backup $EE_DOMAIN NGINX configuration + cp /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/$EE_DATE/ \ + || ee_lib_error "Failed: Backup NGINX configuration, exit status =" $? + # Move htdocs - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then - ee_lib_echo "Backup webroot at $ee_webroot/backup/htdocs/$EE_DATE/, please wait..." - mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/htdocs to backup, exit status =" $? - mkdir -p $ee_webroot/htdocs + if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then + ee_lib_echo "Backup webroot, please wait..." + mv $ee_webroot/htdocs $ee_webroot/backup/$EE_DATE/ \ + || ee_lib_error "Failed: Backup webroot, exit status =" $? + ee_lib_echo "Setting up webroot, please wait..." + mkdir -p $ee_webroot/htdocs || ee_lib_error "Failed: Setting up webroot, exit status =" $? fi - ee_lib_echo "Backup NGINX configuration at $ee_webroot/backup/nginx/$EE_DATE/, please wait..." - # Backup $EE_DOMAIN NGINX configuration - cp /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/$EE_DATE/ &>> $EE_COMMAND_LOG - # Database backup if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - ee_lib_echo "Backup Database $ee_db_name at $ee_webroot/backup/db/$EE_DATE/, please wait..." - mysqldump $ee_db_name > $ee_webroot/backup/db/$EE_DATE/${ee_db_name}.sql \ - || ee_lib_error "Unable to dump ${ee_db_name}, exit status =" $? + ee_lib_echo "Backup Database, please wait..." + mysqldump $ee_db_name > $ee_webroot/backup/$EE_DATE/${ee_db_name}.sql \ + || ee_lib_error "Failed: Backup Database, exit status =" $? # Move ee-config.php and copy wp-config.php to backup if [ -f $ee_webroot/ee-config.php ]; then - mv $ee_webroot/ee-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/ee-config.php to backup, exit status =" $? + mv $ee_webroot/ee-config.php $ee_webroot/backup/$EE_DATE/ \ + || ee_lib_error "Failed: Backup ee-config.php, exit status =" $? else - cp $ee_webroot/wp-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/wp-config.php to backup, exit status =" $? + cp $ee_webroot/wp-config.php $ee_webroot/backup/$EE_DATE/ \ + || ee_lib_error "Failed: Backup wp-config.php, exit status =" $? fi fi } From 1fad15aeecd8ff85b27a4814df9392375e1d7258 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 15:24:45 +0530 Subject: [PATCH 312/829] Removed extra check for wp-cli as now ee site create already install all the required packages --- bin/easyengine | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index d07995fb..16a8d2cb 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -444,9 +444,6 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - # Cross check WP-CLI installed or not - wp --allow-root --info &>> $EE_COMMAND_LOG \ - || ee_lib_error "WP-CLI not found, exit status = " $? # Configure variable EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf From 04a87d4a876a35d2e02f1c07f664324ec55e53ac Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 18:08:50 +0530 Subject: [PATCH 313/829] Optimise ee site update code --- bin/easyengine | 227 ++++-------------- .../site/create/ee_mod_plugin_settings.sh | 35 +++ .../site/create/ee_mod_setup_wordpress.sh | 17 ++ .../site/update/ee_mod_update_domain.sh | 93 ------- .../site/update/ee_mod_update_nginx.sh | 129 ++++++++++ 5 files changed, 226 insertions(+), 275 deletions(-) create mode 100644 src/modules/site/create/ee_mod_plugin_settings.sh delete mode 100644 src/modules/site/update/ee_mod_update_domain.sh create mode 100644 src/modules/site/update/ee_mod_update_nginx.sh diff --git a/bin/easyengine b/bin/easyengine index 16a8d2cb..27e0aed6 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -456,22 +456,6 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup WordPress ee_mod_setup_wordpress - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi - - # Install WordPress plugins - ee_mod_plugin_nginx_helper - - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_mod_plugin_w3tc - fi - # Adjust permission ee_lib_permissions @@ -493,38 +477,8 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo - # Configure WordPress plugin settings - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=wpsupercache" - else - ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=wpsupercache" - fi - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=nginx" - else - ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=nginx" - fi - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" - else - ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/admin.php?page=w3tc_general" - fi - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_lib_echo_escape "Page Cache:\t\tDisable" - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - ee_lib_echo_escape "Page Cache:\t\tDisk Enhanced" - fi - ee_lib_echo_escape "Database Cache:\t\tMemcached" - ee_lib_echo_escape "Object Cache:\t\tMemcached" - ee_lib_echo_escape "Browser Cache:\t\tDisable" - fi + # Display WordPress cache plugin settings + ee_mod_plugin_settings # Display Success Message ee_lib_echo_info "Successfully created new website: http://$EE_WWW_DOMAIN" @@ -582,155 +536,64 @@ elif [ "$EE_FIRST" = "site" ]; then # Check the website name is empty or not ee_lib_check_domain - # Check the website exist + # Auto switch site options + ee_mod_site_option + + # Let's use variable name as per action + # EE_SITE_CREATE_OPTION=$EE_SITE_CREATE_OPTION + + # Check the website exist or not ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? + || ee_lib_error "The $EE_DOMAIN does not exist, exit status = " $? - # Update WordPress user password - if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then - ee_mod_site_update_password - else - # Auto switch site options - ee_mod_site_option - - EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) - if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/basic.conf - elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf - fi - fi + # Find out information about current NGINX configuration + EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + + # Lets update HTML|PHP website + #if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then + if [[ "$EE_SITE_CURRENT_OPTION" = "HTML" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_OPTION" = "PHP" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then + # Let's take backup first + ee_mod_site_backup # Install required packages ee_mod_site_packages - # Lets update HTML|PHP|MySQL website - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - - - # Update NGINX configuration for $EE_DOMAIN - if [[ "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ - || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - ee_mod_update_domain - else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? - fi - - # Setup WordPress - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - # Sets EE_DB_NAME, EE_DB_USER, EE_DB_PASS variables, so that same database can be used while updating MYSQL site to any WordPress site - EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - fi - ee_mod_setup_wordpress - fi - - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi - - # Install WordPress plugins - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - ee_mod_plugin_nginx_helper - fi + # Let's start update + ee_mod_update_nginx - # Update cache plugins - ee_mod_update_plugins - - # Setup MySQL database - if [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then - ee_mod_setup_database - - # Add Database Information On ee-config.php - echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ - &>> /var/www/$EE_DOMAIN/ee-config.php - fi + # Setup MySQL database + if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + ee_mod_setup_database - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - # Display WordPress credential - echo - ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" - ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" - echo - fi + # Add Database Information On ee-config.php + echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ + &>> /var/www/$EE_DOMAIN/ee-config.php + fi - # Lets update WordPress Single sites - # WordPress Single sites can only be updated to multisites or with different cache options - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ - && [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then - - if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE BASIC" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]] \ - || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - # Update NGINX configuration for $EE_DOMAIN - ee_mod_update_domain - else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? - fi - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi - # Update cache plugins - ee_mod_update_plugins - - # Lets update WprdPress multi sites with subdirectory - # WordPress multi sites with subdirectory can only update cache - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ]]; then - # Update NGINX configuration for $EE_DOMAIN - ee_mod_update_domain - else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? - fi - # Update cache plugins - ee_mod_update_plugins - - # Lets update WordPress multi sites with subdomain - # WordPress multi sites with subdomain can only update cache - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ]]; then - # Update NGINX configuration for $EE_DOMAIN - ee_mod_update_domain - else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? - fi - # Update cache plugins - ee_mod_update_plugins + # Setup WordPress + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + # Setup WordPress + ee_mod_setup_wordpress - else - ee_lib_error "Invalid update option, exit status =" $? + # Display WordPress cache plugin settings + ee_mod_plugin_settings fi - # Adjust permission - ee_lib_permissions + fi - # Execute: service nginx reload - ee_lib_service nginx reload + # Adjust permission + ee_lib_permissions + + # Execute: service nginx reload + ee_lib_service nginx reload - # Git commit - ee_lib_git /etc/nginx/ "After ee site update: $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" + # Git commit + ee_lib_git /etc/nginx/ "After ee site update: $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" - # Display Success Message - ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" - fi + # Display Success Message + ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SECOND" = "log" ]; then - # Display logs for websites - ee_mod_site_log ${@:3} + # Display logs for websites + ee_mod_site_log ${@:3} # EasyEngine cd elif [ "$EE_SECOND" = "cd" ]; then diff --git a/src/modules/site/create/ee_mod_plugin_settings.sh b/src/modules/site/create/ee_mod_plugin_settings.sh new file mode 100644 index 00000000..e59347be --- /dev/null +++ b/src/modules/site/create/ee_mod_plugin_settings.sh @@ -0,0 +1,35 @@ +# Display WordPress cache plugin settings + +function ee_mod_plugin_settings() { + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=wpsupercache" + else + ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=wpsupercache" + fi + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=nginx" + else + ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=nginx" + fi + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" + else + ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/admin.php?page=w3tc_general" + fi + if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_lib_echo_escape "Page Cache:\t\tDisable" + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + ee_lib_echo_escape "Page Cache:\t\tDisk Enhanced" + fi + ee_lib_echo_escape "Database Cache:\t\tMemcached" + ee_lib_echo_escape "Object Cache:\t\tMemcached" + ee_lib_echo_escape "Browser Cache:\t\tDisable" + fi +} diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index 8f282095..80547d7c 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -121,4 +121,21 @@ function ee_mod_setup_wordpress() ee_lib_echo "Updating WordPress permalink, please wait..." wp rewrite structure --allow-root /%year%/%monthnum%/%day%/%postname%/ &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to update WordPress permalink for $EE_DOMAIN, exit status = " $? + + # Setup WordPress Network + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_mod_setup_network + fi + + # Install WordPress plugins + ee_mod_plugin_nginx_helper + + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_mod_plugin_w3tc + fi + } diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh deleted file mode 100644 index 00d4224c..00000000 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ /dev/null @@ -1,93 +0,0 @@ -# Update NGINX configuration for $EE_DOMAIN - -function ee_mod_update_domain() -{ - # Git commit - ee_lib_git /etc/nginx/ "Before ee site update: $EE_DOMAIN running on $EE_SITE_CURRENT_OPTION" - # Backup NGINX configuration & Database & Webroot - ee_mod_site_backup - - # Creating $EE_DOMAIN - ee_lib_echo "Updating $EE_DOMAIN, please wait..." - if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then - EE_SITE_CURRENT_CONF=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") - EE_SITE_UPDATE_CONF=$(head -n1 /usr/share/easyengine/nginx/$EE_NGINX_CONF | grep "NGINX CONFIGURATION") - EE_SITE_NGINX_CONF="/etc/nginx/sites-available/$EE_DOMAIN" - - # Update Head Line of NGINX conf - sed -i "s'$EE_SITE_CURRENT_CONF'$EE_SITE_UPDATE_CONF'" $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - - # Update Head Line of NGINX conf file - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ];then - sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" $EE_SITE_NGINX_CONF && \ - sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' $EE_SITE_NGINX_CONF && \ - sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' $EE_SITE_NGINX_CONF && \ - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf for HTML site - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then - sed -i 's/access\.log/access.log rt_cache/' $EE_SITE_NGINX_CONF && \ - sed -i '/index index.html index.htm;$/d' $EE_SITE_NGINX_CONF && \ - sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [[ "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf from BASIC CACHE to WPFC|W3TC|WPSC CACHE - elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/php.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/php.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/php.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf from W3TC CACHE to BASIC|WPSC|WPFC CACHE - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/w3tc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf from WPFC CACHE to BASIC|W3TC|WPSC CACHE - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpfc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf from WPSC CACHE to BASIC|W3TC|WPFC CACHE - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpsc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - fi - - # Update NGINX conf from HTML|PHP|MYSQL to wp|wpsubdir|wpsubdomain - if [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]] \ - && [[ "$EE_SITE_CURRENT_OPTION" = "HTML" || "$EE_SITE_CURRENT_OPTION" = "PHP" || "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - else - ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? - fi -} diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh new file mode 100644 index 00000000..d27bcbb2 --- /dev/null +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -0,0 +1,129 @@ +# Update NGINX configuration for $EE_DOMAIN + +function ee_mod_update_nginx() +{ + # Find out information about current NGINX configuration + EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + + # Git commit + ee_lib_git /etc/nginx/ "Before ee site update: $EE_DOMAIN running on $EE_SITE_CURRENT_OPTION" + + # Update NGINX configuration + ee_lib_echo "Updating $EE_DOMAIN, please wait..." + + if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then + # Find out current NGINX configuration header + ee_nginx_current_header=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") + + # Update NGINX configuration header + if [ "$EE_SITE_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ]; then + ee_nginx_conf=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/basic.conf + elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_nginx_conf=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf + fi + ee_nginx_update_header=$(head -n1 /usr/share/easyengine/nginx/$ee_nginx_conf | grep "NGINX CONFIGURATION") + + # Update Head Line of NGINX conf + sed -i "s'$ee_nginx_current_header'$ee_nginx_update_header'" /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + + # Update NGINX conf for HTML site + if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then + sed -i 's/access\.log/access.log rt_cache/' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/index index.html index.htm;$/d' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + + # Update HTML to PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) options + if [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || ; then + sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + # Update HTML to --wpsc (--wp/--wpsubdir/--wpsubdomain) options + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + # Update HTML to --w3tc (--wp/--wpsubdir/--wpsubdomain) options + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + # Update HTML to --wpfc (--wp/--wpsubdir/--wpsubdomain) options + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + + # Update PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) to --wpsc --w3tc --wpfc options + elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/php.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/php.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/php.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + + # Update --wpsc (--wp/--wpsubdir/--wpsubdomain) to --basic --w3tc --wpfc options + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/wpsc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + + + # Update --w3tc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --wpfc options + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/w3tc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + + # Update --wpfc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --w3tc options + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/wpfc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + fi + + # Add WordPress common file wpcommon.conf for HTML PHP & MYSQL sites + if [[ "$EE_SITE_CURRENT_OPTION" = "HTML" || "$EE_SITE_CURRENT_OPTION" = "PHP" || "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]] && \ + [[ "$EE_SITE_UPDATE_OPTION" = "--wp" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + + # Update server_name for HTML PHP MYSQL WP (single site) only + # Don't execute for WordPress Multisite + if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] \ + && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]; then + + sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + else + ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? + fi +} From 6cd6c901a38bad614fe554567dfefeb5aa1c1c1b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 18:21:41 +0530 Subject: [PATCH 314/829] Fixed if statement --- src/modules/site/update/ee_mod_update_nginx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index d27bcbb2..697e96dd 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -34,7 +34,7 @@ function ee_mod_update_nginx() || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) options - if [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || ; then + if [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to --wpsc (--wp/--wpsubdir/--wpsubdomain) options From 856631efc7861a04dd7b24a916d2f76ddf4b383a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 18:25:36 +0530 Subject: [PATCH 315/829] Minor fix --- src/modules/site/update/ee_mod_update_nginx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index 697e96dd..ea96b827 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -75,7 +75,7 @@ function ee_mod_update_nginx() elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - + fi # Update --w3tc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --wpfc options elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then From 859122c03340a6e1cd8195956ba93fbac050ba8a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 19:03:25 +0530 Subject: [PATCH 316/829] Minor fix and echo values --- .travis.yml | 15 ---------- bin/easyengine | 30 +++++++++++++------ .../site/update/ee_mod_update_nginx.sh | 3 ++ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb41793c..e96328bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -133,21 +133,6 @@ script: - sudo bash ee site update 1.com --wp - sudo bash ee site update 2.com --wpsubdir -- sudo bash ee site update 3.com --wpsubdomain - - -- sudo bash ee site update site1.com --wp --wpfc -- sudo bash ee site update site1.com --wp --w3tc -- sudo bash ee site update site1.com --wp --wpsc - -- sudo bash ee site update site5.com --wpsubdir --wpfc -- sudo bash ee site update site5.com --wpsubdir --w3tc -- sudo bash ee site update site5.com --wpsubdir --wpsc - -- sudo bash ee site update site9.com --wpsubdom --wpfc -- sudo bash ee site update site9.com --wpsubdom --w3tc -- sudo bash ee site update site9.com --wpsubdom --wpsc - - sudo ee site delete site12.com --no-prompt - sudo ee site delete site12.net --no-prompt diff --git a/bin/easyengine b/bin/easyengine index 27e0aed6..2841cee0 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -549,6 +549,13 @@ elif [ "$EE_FIRST" = "site" ]; then # Find out information about current NGINX configuration EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + # Detect current website type and cache + if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then + EE_SITE_TYPE="--html" + elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then + EE_SITE_TYPE="--php" + fi + # Lets update HTML|PHP website #if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then if [[ "$EE_SITE_CURRENT_OPTION" = "HTML" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_OPTION" = "PHP" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then @@ -579,18 +586,23 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_plugin_settings fi fi + + if [ "$EE_SITE_TYPE" != "$EE_SITE_CREATE_OPTION" ]; then + # Adjust permission + ee_lib_permissions - # Adjust permission - ee_lib_permissions - - # Execute: service nginx reload - ee_lib_service nginx reload + # Execute: service nginx reload + ee_lib_service nginx reload - # Git commit - ee_lib_git /etc/nginx/ "After ee site update: $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" + # Git commit + ee_lib_git /etc/nginx/ "After ee site update: $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" + + # Display Success Message + ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" + else + ee_lib_error "Invalid option, exit status = " $? + fi - # Display Success Message - ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SECOND" = "log" ]; then # Display logs for websites ee_mod_site_log ${@:3} diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index ea96b827..7eda98ff 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -23,6 +23,9 @@ function ee_mod_update_nginx() fi ee_nginx_update_header=$(head -n1 /usr/share/easyengine/nginx/$ee_nginx_conf | grep "NGINX CONFIGURATION") + # Echo values + echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_UPDATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nee_nginx_conf = $ee_nginx_conf" &>> $EE_COMMAND_LOG + # Update Head Line of NGINX conf sed -i "s'$ee_nginx_current_header'$ee_nginx_update_header'" /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? From 0273eb893548a0f302683f5257eab78e9cc69c53 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 19:11:23 +0530 Subject: [PATCH 317/829] Fix variable name --- .../site/update/ee_mod_update_nginx.sh | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index 7eda98ff..3ecd9af5 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -16,106 +16,106 @@ function ee_mod_update_nginx() ee_nginx_current_header=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") # Update NGINX configuration header - if [ "$EE_SITE_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ]; then - ee_nginx_conf=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/basic.conf + if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + ee_nginx_conf=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/basic.conf elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_nginx_conf=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf + ee_nginx_conf=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf fi ee_nginx_update_header=$(head -n1 /usr/share/easyengine/nginx/$ee_nginx_conf | grep "NGINX CONFIGURATION") # Echo values - echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_UPDATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nee_nginx_conf = $ee_nginx_conf" &>> $EE_COMMAND_LOG + echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nee_nginx_conf = $ee_nginx_conf" &>> $EE_COMMAND_LOG # Update Head Line of NGINX conf - sed -i "s'$ee_nginx_current_header'$ee_nginx_update_header'" /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i "s'$ee_nginx_current_header'$ee_nginx_update_header'" /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? # Update NGINX conf for HTML site if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then sed -i 's/access\.log/access.log rt_cache/' /etc/nginx/sites-available/$EE_DOMAIN && \ sed -i '/index index.html index.htm;$/d' /etc/nginx/sites-available/$EE_DOMAIN && \ sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) options - if [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to --wpsc (--wp/--wpsubdir/--wpsubdomain) options elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to --w3tc (--wp/--wpsubdir/--wpsubdomain) options elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to --wpfc (--wp/--wpsubdir/--wpsubdomain) options elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi # Update PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) to --wpsc --w3tc --wpfc options elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then sed -i 's/include common\/php.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then sed -i 's/include common\/php.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then sed -i 's/include common\/php.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi # Update --wpsc (--wp/--wpsubdir/--wpsubdomain) to --basic --w3tc --wpfc options elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then sed -i 's/include common\/wpsc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi # Update --w3tc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --wpfc options elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then sed -i 's/include common\/w3tc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi # Update --wpfc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --w3tc options elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then sed -i 's/include common\/wpfc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? fi fi # Add WordPress common file wpcommon.conf for HTML PHP & MYSQL sites if [[ "$EE_SITE_CURRENT_OPTION" = "HTML" || "$EE_SITE_CURRENT_OPTION" = "PHP" || "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]] && \ - [[ "$EE_SITE_UPDATE_OPTION" = "--wp" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi # Update server_name for HTML PHP MYSQL WP (single site) only # Don't execute for WordPress Multisite - if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] \ + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] \ @@ -124,7 +124,7 @@ function ee_mod_update_nginx() sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" /etc/nginx/sites-available/$EE_DOMAIN && \ sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' /etc/nginx/sites-available/$EE_DOMAIN && \ sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi else ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? From 41d01807ee2bb0c4ba414f9f7603bd98765f9ae3 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 19:17:36 +0530 Subject: [PATCH 318/829] Update echo message --- src/modules/site/update/ee_mod_update_nginx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index 3ecd9af5..970319d3 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -24,7 +24,7 @@ function ee_mod_update_nginx() ee_nginx_update_header=$(head -n1 /usr/share/easyengine/nginx/$ee_nginx_conf | grep "NGINX CONFIGURATION") # Echo values - echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nee_nginx_conf = $ee_nginx_conf" &>> $EE_COMMAND_LOG + echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nee_nginx_update_header = $ee_nginx_update_header" &>> $EE_COMMAND_LOG # Update Head Line of NGINX conf sed -i "s'$ee_nginx_current_header'$ee_nginx_update_header'" /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? From 4348fcea6ff6d2a1d23fed18a04593f4ea05dc78 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 19:41:50 +0530 Subject: [PATCH 319/829] Minor update --- src/modules/site/update/ee_mod_update_nginx.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index 970319d3..ce1f6132 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -32,8 +32,8 @@ function ee_mod_update_nginx() # Update NGINX conf for HTML site if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then sed -i 's/access\.log/access.log rt_cache/' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/index index.html index.htm;$/d' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html;' /etc/nginx/sites-available/$EE_DOMAIN \ + sed -i '/index index.html index.htm;$/c \\tindex index.php index.htm index.html;' $EE_SITE_NGINX_CONF && \ + sed -i '/location \/ {/,/}/d ' $EE_SITE_NGINX_CONF \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) options From 8ed6ef8d242425dde588ab1d57565cf731633583 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 19:49:04 +0530 Subject: [PATCH 320/829] Minor update --- src/modules/site/update/ee_mod_update_nginx.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index ce1f6132..4aaba0f9 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -32,8 +32,8 @@ function ee_mod_update_nginx() # Update NGINX conf for HTML site if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then sed -i 's/access\.log/access.log rt_cache/' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/index index.html index.htm;$/c \\tindex index.php index.htm index.html;' $EE_SITE_NGINX_CONF && \ - sed -i '/location \/ {/,/}/d ' $EE_SITE_NGINX_CONF \ + sed -i '/index index.html index.htm;$/c \\tindex index.php index.htm index.html;' $/etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/location \/ {/,/}/d ' $/etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) options From 63ae3d12c108065e063b19be3c458db900fc040a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 19:51:10 +0530 Subject: [PATCH 321/829] Minor update --- src/modules/site/update/ee_mod_update_nginx.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index 4aaba0f9..1a6c5fc4 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -32,8 +32,8 @@ function ee_mod_update_nginx() # Update NGINX conf for HTML site if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then sed -i 's/access\.log/access.log rt_cache/' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/index index.html index.htm;$/c \\tindex index.php index.htm index.html;' $/etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/location \/ {/,/}/d ' $/etc/nginx/sites-available/$EE_DOMAIN \ + sed -i '/index index.html index.htm;$/c \\tindex index.php index.htm index.html;' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/location \/ {/,/}/d ' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? # Update HTML to PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) options From 5201f285408c38646d3e564c5c0c8107a868e526 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 20:03:41 +0530 Subject: [PATCH 322/829] Display WordPress Credentials After update HTML PHP webistes --- bin/easyengine | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 2841cee0..b39acecc 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -582,6 +582,12 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup WordPress ee_mod_setup_wordpress + # Display WordPress credential + echo + ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" + ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" + echo + # Display WordPress cache plugin settings ee_mod_plugin_settings fi From b0c75b4ab541e17e0021cbdd163fe4290552da9a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 20:23:56 +0530 Subject: [PATCH 323/829] ee site update mysql optimised --- bin/easyengine | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index b39acecc..43c208e3 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -587,7 +587,33 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo - + + # Display WordPress cache plugin settings + ee_mod_plugin_settings + elif [[ "$EE_SITE_CURRENT_OPTION" = "MYSQL" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + # Let's take backup first + ee_mod_site_backup + + # Install required packages + ee_mod_site_packages + + # Let's start update + ee_mod_update_nginx + + # Use same database for WordPress + EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + + # Setup WordPress + ee_mod_setup_wordpress + + # Display WordPress credential + echo + ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" + ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" + echo + # Display WordPress cache plugin settings ee_mod_plugin_settings fi From fc7e242127530ab28c39f4a4c5017ba93e3b3f65 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 20:29:47 +0530 Subject: [PATCH 324/829] ee site update mysql optimised --- bin/easyengine | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 43c208e3..f491d67c 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -554,6 +554,8 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_TYPE="--html" elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then EE_SITE_TYPE="--php" + elif [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then + EE_SITE_TYPE="--mysql" fi # Lets update HTML|PHP website From 4b9c63000cee810aea5b4ea346d239a371ec61ac Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 20:36:06 +0530 Subject: [PATCH 325/829] ee site update mysql optimised --- bin/easyengine | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index f491d67c..21cf0fd6 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -592,35 +592,37 @@ elif [ "$EE_FIRST" = "site" ]; then # Display WordPress cache plugin settings ee_mod_plugin_settings - elif [[ "$EE_SITE_CURRENT_OPTION" = "MYSQL" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then - # Let's take backup first - ee_mod_site_backup + fi + #if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] + elif [[ "$EE_SITE_CURRENT_OPTION" = "MYSQL" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + # Let's take backup first + ee_mod_site_backup - # Install required packages - ee_mod_site_packages + # Install required packages + ee_mod_site_packages - # Let's start update - ee_mod_update_nginx + # Let's start update + ee_mod_update_nginx - # Use same database for WordPress - EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + # Use same database for WordPress + EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - # Setup WordPress - ee_mod_setup_wordpress + # Setup WordPress + ee_mod_setup_wordpress - # Display WordPress credential - echo - ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" - ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" - echo + # Display WordPress credential + echo + ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" + ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" + echo - # Display WordPress cache plugin settings - ee_mod_plugin_settings - fi + # Display WordPress cache plugin settings + ee_mod_plugin_settings fi + if [ "$EE_SITE_TYPE" != "$EE_SITE_CREATE_OPTION" ]; then # Adjust permission ee_lib_permissions From cdb8e60b5ab7df41fdb3c3c4e7ace80f7b75bbfa Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 20:36:15 +0530 Subject: [PATCH 326/829] ee site update mysql optimised --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 21cf0fd6..f2fd1969 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -593,7 +593,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Display WordPress cache plugin settings ee_mod_plugin_settings fi - #if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] + # if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] elif [[ "$EE_SITE_CURRENT_OPTION" = "MYSQL" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then # Let's take backup first ee_mod_site_backup From 67c74be191fad8308366c2d9bc2b08e2abb733b1 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 17 Oct 2014 20:43:35 +0530 Subject: [PATCH 327/829] Display DB information when update mysql websites --- src/modules/site/create/ee_mod_setup_wordpress.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index 80547d7c..e91d7a1d 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -15,6 +15,9 @@ function ee_mod_setup_wordpress() # else current mysql site is to be updated if [ "$EE_DB_NAME" = "" ] && [ "$EE_DB_USER" = "" ] && [ "$EE_DB_PASS" = "" ]; then ee_mod_setup_database + else + # Display when run ee site update mysql.com --wp + echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS \nEE_MYSQL_HOST = $EE_MYSQL_HOST \nEE_MYSQL_GRANT_HOST = $EE_MYSQL_GRANT_HOST" &>> $EE_COMMAND_LOG fi # Default WordPress prefix or custom prefix From d51752f3bca444b527ad80c3658296c54371cd9f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 20 Oct 2014 11:44:23 +0530 Subject: [PATCH 328/829] Optimized ee site update wp code --- bin/easyengine | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index f2fd1969..f9dbd74c 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -620,6 +620,30 @@ elif [ "$EE_FIRST" = "site" ]; then # Display WordPress cache plugin settings ee_mod_plugin_settings + elif [[ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" || "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" || "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" || "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ]] \ + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + # Let's take backup first + ee_mod_site_backup + + # Let's start update + ee_mod_update_nginx + + # Setup WordPress Network + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_mod_setup_network + fi + + if [[ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" && "$EE_SITE_CACHE_OPTION" != "--basic" ]]; then + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_mod_plugin_w3tc + fi + else + ee_mod_update_plugins + fi fi From 266a721bc750c6829b526bd45341dfd43dda3b8e Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 20 Oct 2014 17:07:02 +0530 Subject: [PATCH 329/829] minor update --- bin/easyengine | 2 +- .../site/update/ee_mod_update_plugins.sh | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index f9dbd74c..764fee95 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -632,7 +632,7 @@ elif [ "$EE_FIRST" = "site" ]; then if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network fi - + # Let's Update cache plugins if [[ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" && "$EE_SITE_CACHE_OPTION" != "--basic" ]]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then ee_mod_plugin_wpsc diff --git a/src/modules/site/update/ee_mod_update_plugins.sh b/src/modules/site/update/ee_mod_update_plugins.sh index b50df163..8a7ce7f0 100644 --- a/src/modules/site/update/ee_mod_update_plugins.sh +++ b/src/modules/site/update/ee_mod_update_plugins.sh @@ -4,28 +4,35 @@ function ee_mod_update_plugins() { cd /var/www/$EE_DOMAIN/htdocs/ + # Uninstall W3TC plugin in case converting site to --basic | --wpsc if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--basic" || "$EE_SITE_CACHE_OPTION" = "--wpsc" ]]; then + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] \ + && [[ "$EE_SITE_CACHE_OPTION" = "--basic" || "$EE_SITE_CACHE_OPTION" = "--wpsc" ]]; then ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG fi - - if [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + # Uninstall WPSC plugin in case converting site to --basic | --w3tc | --wpfc + if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] \ + || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then ee_lib_echo "Unistalling WP Super Cache plugin, please wait..." wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG fi + # Install wpsc plugin in case updating site to --wpsc if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then ee_mod_plugin_wpsc + ee_mod_plugin_settings fi + # Install w3tc plugin in case updating site to --w3tc | --wpfc if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" || "$EE_SITE_CACHE_OPTION" = "--w3tc" ]]; then + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] \ + || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] \ + && [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" || "$EE_SITE_CACHE_OPTION" = "--wpfc" ]]; then ee_mod_plugin_w3tc + ee_mod_plugin_settings fi } From 26af71a12b796a696034b4b941eaeab511cb2fb4 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 20 Oct 2014 19:00:22 +0530 Subject: [PATCH 330/829] ee site update for wordpress --- bin/easyengine | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 764fee95..4763beae 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -556,11 +556,21 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_TYPE="--php" elif [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then EE_SITE_TYPE="--mysql" + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ]; then + EE_SITE_TYPE="--wp --basic" + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ]; then + EE_SITE_TYPE="--wp --wpsc" + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ]; then + EE_SITE_TYPE="--wp --w3tc" + elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ]; then + EE_SITE_TYPE="--wp --wpfc" fi + # Let's log site current option + ee_lib_echo_escape "EE_SITE_TYPE = $EE_SITE_TYPE \nEE_SITE_UPDATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION" &>> $EE_COMMAND_LOG + # Lets update HTML|PHP website - #if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then - if [[ "$EE_SITE_CURRENT_OPTION" = "HTML" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_OPTION" = "PHP" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then + if [[ "$EE_SITE_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then # Let's take backup first ee_mod_site_backup @@ -593,8 +603,8 @@ elif [ "$EE_FIRST" = "site" ]; then # Display WordPress cache plugin settings ee_mod_plugin_settings fi - # if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] - elif [[ "$EE_SITE_CURRENT_OPTION" = "MYSQL" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + + elif [[ "$EE_SITE_TYPE" = "--mysql" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then # Let's take backup first ee_mod_site_backup @@ -620,11 +630,15 @@ elif [ "$EE_FIRST" = "site" ]; then # Display WordPress cache plugin settings ee_mod_plugin_settings - elif [[ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" || "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" || "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" || "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ]] \ - && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + + elif [[ "$EE_SITE_TYPE" = "--wp --basic" || "$EE_SITE_TYPE" = "--wp --wpsc" || "$EE_SITE_TYPE" = "--wp --w3tc" || "$EE_SITE_TYPE" = "--wp --wpfc" ]] \ + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then # Let's take backup first ee_mod_site_backup + # Install required packages + ee_mod_site_packages + # Let's start update ee_mod_update_nginx @@ -632,18 +646,20 @@ elif [ "$EE_FIRST" = "site" ]; then if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network fi - # Let's Update cache plugins - if [[ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" && "$EE_SITE_CACHE_OPTION" != "--basic" ]]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_mod_plugin_w3tc - fi - else - ee_mod_update_plugins + # Install WordPress plugins + ee_mod_plugin_nginx_helper + + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_mod_plugin_w3tc fi + + # Display WordPress cache plugin settings + ee_mod_plugin_settings fi From 6e58f5e8a031a6c8ab4c1371c35529b9d79dd7c8 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 11:48:31 +0530 Subject: [PATCH 331/829] Fix ee site create wp.com --wp to ee site update wp.com --wp --- bin/easyengine | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 4763beae..cc8aa48d 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -547,30 +547,34 @@ elif [ "$EE_FIRST" = "site" ]; then || ee_lib_error "The $EE_DOMAIN does not exist, exit status = " $? # Find out information about current NGINX configuration - EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + EE_SITE_CURRENT_TYPE=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) # Detect current website type and cache - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then - EE_SITE_TYPE="--html" - elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then - EE_SITE_TYPE="--php" - elif [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - EE_SITE_TYPE="--mysql" - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ]; then - EE_SITE_TYPE="--wp --basic" - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ]; then - EE_SITE_TYPE="--wp --wpsc" - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ]; then - EE_SITE_TYPE="--wp --w3tc" - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ]; then - EE_SITE_TYPE="--wp --wpfc" + if [ "$EE_SITE_CURRENT_TYPE" = "HTML" ]; then + EE_SITE_CURRENT_TYPE="--html" + elif [ "$EE_SITE_CURRENT_TYPE" = "PHP" ]; then + EE_SITE_CURRENT_TYPE="--php" + elif [ "$EE_SITE_CURRENT_TYPE" = "MYSQL" ]; then + EE_SITE_CURRENT_TYPE="--mysql" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE BASIC" ]; then + EE_SITE_CURRENT_TYPE="--wp" + EE_SITE_CURRENT_CACHE="--basic" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE WP SUPER CACHE" ]; then + EE_SITE_CURRENT_TYPE="--wp" + EE_SITE_CURRENT_CACHE="--wpsc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_TYPE="--wp" + EE_SITE_CURRENT_CACHE="--w3tc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ]; then + EE_SITE_CURRENT_TYPE="--wp" + EE_SITE_CURRENT_CACHE="--wpfc" fi # Let's log site current option - ee_lib_echo_escape "EE_SITE_TYPE = $EE_SITE_TYPE \nEE_SITE_UPDATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION" &>> $EE_COMMAND_LOG + ee_lib_echo_escape "EE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \nEE_SITE_CURRENT_CACHE = $EE_SITE_CURRENT_CACHE \nEE_SITE_UPDATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION" &>> $EE_COMMAND_LOG # Lets update HTML|PHP website - if [[ "$EE_SITE_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then + if [[ "$EE_SITE_CURRENT_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then # Let's take backup first ee_mod_site_backup @@ -604,7 +608,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_plugin_settings fi - elif [[ "$EE_SITE_TYPE" = "--mysql" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + elif [[ "$EE_SITE_CURRENT_TYPE" = "--mysql" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then # Let's take backup first ee_mod_site_backup @@ -631,7 +635,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Display WordPress cache plugin settings ee_mod_plugin_settings - elif [[ "$EE_SITE_TYPE" = "--wp --basic" || "$EE_SITE_TYPE" = "--wp --wpsc" || "$EE_SITE_TYPE" = "--wp --w3tc" || "$EE_SITE_TYPE" = "--wp --wpfc" ]] \ + elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp" && "$EE_SITE_CURRENT_CACHE" != "$EE_SITE_CACHE_OPTION" ]] \ && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then # Let's take backup first ee_mod_site_backup @@ -663,7 +667,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi - if [ "$EE_SITE_TYPE" != "$EE_SITE_CREATE_OPTION" ]; then + if [ "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_CREATE_OPTION" ]; then # Adjust permission ee_lib_permissions @@ -675,8 +679,6 @@ elif [ "$EE_FIRST" = "site" ]; then # Display Success Message ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" - else - ee_lib_error "Invalid option, exit status = " $? fi elif [ "$EE_SECOND" = "log" ]; then From 9f4628779e04b01c121f26bb100062f03119ac5a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 13:16:44 +0530 Subject: [PATCH 332/829] Fix ee update logic --- bin/easyengine | 174 ++++++++++------------- src/modules/site/update/ee_mod_update.sh | 67 +++++++++ 2 files changed, 145 insertions(+), 96 deletions(-) create mode 100644 src/modules/site/update/ee_mod_update.sh diff --git a/bin/easyengine b/bin/easyengine index cc8aa48d..13f08b24 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -556,118 +556,98 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_CURRENT_TYPE="--php" elif [ "$EE_SITE_CURRENT_TYPE" = "MYSQL" ]; then EE_SITE_CURRENT_TYPE="--mysql" + # Single WordPress elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE BASIC" ]; then - EE_SITE_CURRENT_TYPE="--wp" - EE_SITE_CURRENT_CACHE="--basic" + EE_SITE_CURRENT_TYPE="--wp --basic" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE WP SUPER CACHE" ]; then - EE_SITE_CURRENT_TYPE="--wp" - EE_SITE_CURRENT_CACHE="--wpsc" + EE_SITE_CURRENT_TYPE="--wp --wpsc" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE W3 TOTAL CACHE" ]; then - EE_SITE_CURRENT_TYPE="--wp" - EE_SITE_CURRENT_CACHE="--w3tc" + EE_SITE_CURRENT_TYPE="--wp --w3tc" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ]; then - EE_SITE_CURRENT_TYPE="--wp" - EE_SITE_CURRENT_CACHE="--wpfc" + EE_SITE_CURRENT_TYPE="--wp --wpfc" + # WordPress subdirectory + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR BASIC" ]; then + EE_SITE_CURRENT_TYPE="--wpsubdir --basic" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR WP SUPER CACHE" ]; then + EE_SITE_CURRENT_TYPE="--wpsubdir --wpsc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_TYPE="--wpsubdir --w3tc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ]; then + EE_SITE_CURRENT_TYPE="--wpsubdir --wpfc" + # WordPress subdomain + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN BASIC" ]; then + EE_SITE_CURRENT_TYPE="--wpsubdomain --basic" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + EE_SITE_CURRENT_TYPE="--wpsubdomain --wpsc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_TYPE="--wpsubdomain --w3tc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ]; then + EE_SITE_CURRENT_TYPE="--wpsubdomain --wpfc" + fi + + # Detect update website type and cache + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + EE_SITE_UPDATE_TYPE="--wp --basic" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + EE_SITE_UPDATE_TYPE="--wp --wpsc" + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + EE_SITE_UPDATE_TYPE="--wp --w3tc" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + EE_SITE_UPDATE_TYPE="--wp --wpfc" + fi + elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdir --basic" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdir --wpsc" + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdir --w3tc" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdir --wpfc" + fi + elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdomain --basic" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdomain --wpsc" + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdomain --w3tc" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdomain --wpfc" + fi fi # Let's log site current option - ee_lib_echo_escape "EE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \nEE_SITE_CURRENT_CACHE = $EE_SITE_CURRENT_CACHE \nEE_SITE_UPDATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION" &>> $EE_COMMAND_LOG + ee_lib_echo_escape "EE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG # Lets update HTML|PHP website if [[ "$EE_SITE_CURRENT_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then - # Let's take backup first - ee_mod_site_backup - - # Install required packages - ee_mod_site_packages - - # Let's start update - ee_mod_update_nginx - - # Setup MySQL database - if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - ee_mod_setup_database - - # Add Database Information On ee-config.php - echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ - &>> /var/www/$EE_DOMAIN/ee-config.php - fi - - # Setup WordPress - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Setup WordPress - ee_mod_setup_wordpress - - # Display WordPress credential - echo - ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" - ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" - echo - - # Display WordPress cache plugin settings - ee_mod_plugin_settings - fi + # Lets call update function + ee_mod_update elif [[ "$EE_SITE_CURRENT_TYPE" = "--mysql" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then - # Let's take backup first - ee_mod_site_backup - - # Install required packages - ee_mod_site_packages - - # Let's start update - ee_mod_update_nginx - - # Use same database for WordPress - EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - - # Setup WordPress - ee_mod_setup_wordpress - - # Display WordPress credential - echo - ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" - ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" - echo - - # Display WordPress cache plugin settings - ee_mod_plugin_settings + # Lets call update function + ee_mod_update - elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp" && "$EE_SITE_CURRENT_CACHE" != "$EE_SITE_CACHE_OPTION" ]] \ - && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then - # Let's take backup first - ee_mod_site_backup - - # Install required packages - ee_mod_site_packages - - # Let's start update - ee_mod_update_nginx - - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi - - # Install WordPress plugins - ee_mod_plugin_nginx_helper - - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_mod_plugin_w3tc - fi - - # Display WordPress cache plugin settings - ee_mod_plugin_settings + elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" ]] \ + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CURRENT_TYPE" != "EE_SITE_UPDATE_TYPE" ]]; then + # Lets call update function + ee_mod_update + + elif [[ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" ]] \ + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" && "$EE_SITE_CURRENT_TYPE" != "EE_SITE_UPDATE_TYPE" ]]; then + # Lets call update function + ee_mod_update + + elif [[ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]] \ + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CURRENT_TYPE" != "EE_SITE_UPDATE_TYPE" ]]; then + # Lets call update function + ee_mod_update fi - if [ "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_CREATE_OPTION" ]; then + if [ "$EE_MOD_UPDATE" = "success" ]; then # Adjust permission ee_lib_permissions @@ -679,6 +659,8 @@ elif [ "$EE_FIRST" = "site" ]; then # Display Success Message ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" + else + ee_lib_error "Invalid option, exit status = " $? fi elif [ "$EE_SECOND" = "log" ]; then diff --git a/src/modules/site/update/ee_mod_update.sh b/src/modules/site/update/ee_mod_update.sh new file mode 100644 index 00000000..b72d42b6 --- /dev/null +++ b/src/modules/site/update/ee_mod_update.sh @@ -0,0 +1,67 @@ +# Update Websites + +function ee_mod_update() { + # Let's take backup first + ee_mod_site_backup + + # Install required packages + ee_mod_site_packages + + # Let's start update + ee_mod_update_nginx + + # Setup MySQL database for HTML|PHP websites + if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + ee_mod_setup_database + + # Add Database Information On ee-config.php + echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ + &>> /var/www/$EE_DOMAIN/ee-config.php + fi + + # Use same database when update MySQL website to WordPress + if [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ]; then + # Use same database for WordPress + EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + fi + + # Setup WordPress + if [[ "$EE_SITE_CURRENT_TYPE" != "--wp" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain" ]] && + [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then + # Setup WordPress + ee_mod_setup_wordpress + + # Display WordPress credential + echo + ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" + ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" + echo + + # Display WordPress cache plugin settings + ee_mod_plugin_settings + else + # Setup WordPress Network + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_mod_setup_network + fi + + # Install WordPress plugins + ee_mod_plugin_nginx_helper + + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_mod_plugin_w3tc + fi + + # Display WordPress cache plugin settings + ee_mod_plugin_settings + fi + + # Use this variable to detect and change ownership, reload nginx, + EE_MOD_UPDATE="success" +} \ No newline at end of file From 34b044491f6da81f7a0c6ce47f4861f60cd0b07b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 14:00:32 +0530 Subject: [PATCH 333/829] Minor fix --- src/modules/site/update/ee_mod_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update.sh b/src/modules/site/update/ee_mod_update.sh index b72d42b6..8790cd52 100644 --- a/src/modules/site/update/ee_mod_update.sh +++ b/src/modules/site/update/ee_mod_update.sh @@ -41,7 +41,7 @@ function ee_mod_update() { # Display WordPress cache plugin settings ee_mod_plugin_settings - else + elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain" ]] # Setup WordPress Network if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network From 01b4d1ca1c46c323f7aa3baf5f831bdc72072386 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 14:08:02 +0530 Subject: [PATCH 334/829] Minor fix --- src/modules/site/update/ee_mod_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update.sh b/src/modules/site/update/ee_mod_update.sh index 8790cd52..a558677e 100644 --- a/src/modules/site/update/ee_mod_update.sh +++ b/src/modules/site/update/ee_mod_update.sh @@ -41,7 +41,7 @@ function ee_mod_update() { # Display WordPress cache plugin settings ee_mod_plugin_settings - elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain" ]] + elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain" ]]; then # Setup WordPress Network if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network From fa1904892592a9eca1fa90f25070433f01e2599f Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 14:45:41 +0530 Subject: [PATCH 335/829] Minor fix --- bin/easyengine | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 13f08b24..19456b35 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -631,17 +631,17 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_update elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" ]] \ - && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CURRENT_TYPE" != "EE_SITE_UPDATE_TYPE" ]]; then + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function ee_mod_update elif [[ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" ]] \ - && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" && "$EE_SITE_CURRENT_TYPE" != "EE_SITE_UPDATE_TYPE" ]]; then + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function ee_mod_update elif [[ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]] \ - && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CURRENT_TYPE" != "EE_SITE_UPDATE_TYPE" ]]; then + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function ee_mod_update fi From 8f8a5cf8751aef407525ecf1cae78b9909d621e9 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 15:16:06 +0530 Subject: [PATCH 336/829] Minor fix --- src/modules/site/update/ee_mod_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/site/update/ee_mod_update.sh b/src/modules/site/update/ee_mod_update.sh index a558677e..ec5caaab 100644 --- a/src/modules/site/update/ee_mod_update.sh +++ b/src/modules/site/update/ee_mod_update.sh @@ -28,7 +28,7 @@ function ee_mod_update() { fi # Setup WordPress - if [[ "$EE_SITE_CURRENT_TYPE" != "--wp" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain" ]] && + if [[ "$EE_SITE_CURRENT_TYPE" != "--wp --basic" || "$EE_SITE_CURRENT_TYPE" != "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" != "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" != "--wp --wpfc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]] && [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then # Setup WordPress ee_mod_setup_wordpress @@ -41,7 +41,7 @@ function ee_mod_update() { # Display WordPress cache plugin settings ee_mod_plugin_settings - elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain" ]]; then + elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]]; then # Setup WordPress Network if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network From 7e6bf666f30010431aa981fc1a7189da15e527ee Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 15:53:30 +0530 Subject: [PATCH 337/829] Minor fix --- src/modules/site/update/ee_mod_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update.sh b/src/modules/site/update/ee_mod_update.sh index ec5caaab..12c77475 100644 --- a/src/modules/site/update/ee_mod_update.sh +++ b/src/modules/site/update/ee_mod_update.sh @@ -28,7 +28,7 @@ function ee_mod_update() { fi # Setup WordPress - if [[ "$EE_SITE_CURRENT_TYPE" != "--wp --basic" || "$EE_SITE_CURRENT_TYPE" != "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" != "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" != "--wp --wpfc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]] && + if [[ "$EE_SITE_CURRENT_TYPE" != "--wp --basic" && "$EE_SITE_CURRENT_TYPE" != "--wp --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wp --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wp --wpfc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]] && [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then # Setup WordPress ee_mod_setup_wordpress From eb6f93386764d63c168f2872490cd9ea60d9a5ec Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 16:42:21 +0530 Subject: [PATCH 338/829] Fix WordPress multisite update --- bin/easyengine | 12 ++++++------ ..._mod_update.sh => ee_mod_update_website.sh} | 18 +++++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) rename src/modules/site/update/{ee_mod_update.sh => ee_mod_update_website.sh} (79%) diff --git a/bin/easyengine b/bin/easyengine index 19456b35..78453a46 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -624,30 +624,30 @@ elif [ "$EE_FIRST" = "site" ]; then # Lets update HTML|PHP website if [[ "$EE_SITE_CURRENT_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then # Lets call update function - ee_mod_update + ee_mod_update_website elif [[ "$EE_SITE_CURRENT_TYPE" = "--mysql" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then # Lets call update function - ee_mod_update + ee_mod_update_website elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" ]] \ && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function - ee_mod_update + ee_mod_update_website elif [[ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" ]] \ && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function - ee_mod_update + ee_mod_update_website elif [[ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]] \ && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function - ee_mod_update + ee_mod_update_website fi - if [ "$EE_MOD_UPDATE" = "success" ]; then + if [ "$EE_UPDATE_WEBSITE" = "success" ]; then # Adjust permission ee_lib_permissions diff --git a/src/modules/site/update/ee_mod_update.sh b/src/modules/site/update/ee_mod_update_website.sh similarity index 79% rename from src/modules/site/update/ee_mod_update.sh rename to src/modules/site/update/ee_mod_update_website.sh index 12c77475..148b7342 100644 --- a/src/modules/site/update/ee_mod_update.sh +++ b/src/modules/site/update/ee_mod_update_website.sh @@ -1,6 +1,6 @@ # Update Websites -function ee_mod_update() { +function ee_mod_update_website() { # Let's take backup first ee_mod_site_backup @@ -19,7 +19,7 @@ function ee_mod_update() { &>> /var/www/$EE_DOMAIN/ee-config.php fi - # Use same database when update MySQL website to WordPress + # Use same database when update MySQL website updated to WordPress if [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ]; then # Use same database for WordPress EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) @@ -27,7 +27,7 @@ function ee_mod_update() { EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) fi - # Setup WordPress + # Setup/Install WordPress for HTML|PHP|MySQL websites if [[ "$EE_SITE_CURRENT_TYPE" != "--wp --basic" && "$EE_SITE_CURRENT_TYPE" != "--wp --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wp --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wp --wpfc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]] && [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then # Setup WordPress @@ -41,10 +41,14 @@ function ee_mod_update() { # Display WordPress cache plugin settings ee_mod_plugin_settings + + # Update WordPress Websites elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]]; then - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network + # Setup WordPress Network for --wp websites + if [[ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_mod_setup_network + fi fi # Install WordPress plugins @@ -63,5 +67,5 @@ function ee_mod_update() { fi # Use this variable to detect and change ownership, reload nginx, - EE_MOD_UPDATE="success" + EE_UPDATE_WEBSITE="success" } \ No newline at end of file From 1f39e8efd281d12a14c5c1f8a693ba6647a34596 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 17:04:52 +0530 Subject: [PATCH 339/829] Kick out for invalid cache options --- src/modules/site/ee_mod_site_option.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index 4c7f0e55..bc1ba4ee 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -12,6 +12,11 @@ function ee_mod_site_option() fi fi + # Kick out for invalid cache option + if [ "$EE_SITE_CACHE_OPTION" != "--basic" ] || [ "$EE_SITE_CACHE_OPTION" != "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" != "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" != "--wpfc" ]; then + ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? + fi + # WordPresss subdirectory variables if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then EE_SITE_CREATE_OPTION="--wpsubdir" From 5abf8d451b0066230048f2f6a4fd7ecdbfee4cdf Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 17:16:12 +0530 Subject: [PATCH 340/829] Kick out for invalid cache options --- src/modules/site/ee_mod_site_option.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index bc1ba4ee..bf096ba6 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -12,11 +12,6 @@ function ee_mod_site_option() fi fi - # Kick out for invalid cache option - if [ "$EE_SITE_CACHE_OPTION" != "--basic" ] || [ "$EE_SITE_CACHE_OPTION" != "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" != "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" != "--wpfc" ]; then - ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? - fi - # WordPresss subdirectory variables if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then EE_SITE_CREATE_OPTION="--wpsubdir" @@ -39,4 +34,9 @@ function ee_mod_site_option() if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then EE_SITE_CACHE_OPTION=--basic fi + + # Kick out for invalid cache option + if [[ "$EE_SITE_CACHE_OPTION" != "--basic" || "$EE_SITE_CACHE_OPTION" != "--wpsc" || "$EE_SITE_CACHE_OPTION" != "--w3tc" || "$EE_SITE_CACHE_OPTION" != "--wpfc" ]] && [[ "$EE_SITE_CREATE_OPTION" != "--html" || "$EE_SITE_CREATE_OPTION" != "--php" || "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? + fi } From 14715e239969195a33ae427973c13d069f339db0 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 21 Oct 2014 17:47:55 +0530 Subject: [PATCH 341/829] Kick out for invalid cache options --- src/modules/site/ee_mod_site_option.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index bf096ba6..3fff8d35 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -36,7 +36,7 @@ function ee_mod_site_option() fi # Kick out for invalid cache option - if [[ "$EE_SITE_CACHE_OPTION" != "--basic" || "$EE_SITE_CACHE_OPTION" != "--wpsc" || "$EE_SITE_CACHE_OPTION" != "--w3tc" || "$EE_SITE_CACHE_OPTION" != "--wpfc" ]] && [[ "$EE_SITE_CREATE_OPTION" != "--html" || "$EE_SITE_CREATE_OPTION" != "--php" || "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + if [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? fi } From bb4d878f482df19947f1c0741e851156e2adf268 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 15:30:31 +0530 Subject: [PATCH 342/829] Fix plugin delete --- bin/easyengine | 35 ++++++++++++++++--- .../site/update/ee_mod_update_website.sh | 25 ++++++++++--- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 78453a46..ac5b523c 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -558,34 +558,59 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_CURRENT_TYPE="--mysql" # Single WordPress elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE BASIC" ]; then + EE_SITE_CURRENT_WP="--wp" + EE_SITE_CURRENT_CACHE="--basic" EE_SITE_CURRENT_TYPE="--wp --basic" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE WP SUPER CACHE" ]; then + EE_SITE_CURRENT_WP="--wp" + EE_SITE_CURRENT_CACHE="--wpsc" EE_SITE_CURRENT_TYPE="--wp --wpsc" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_WP="--wp" + EE_SITE_CURRENT_CACHE="--w3tc" EE_SITE_CURRENT_TYPE="--wp --w3tc" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ]; then + EE_SITE_CURRENT_WP="--wp" + EE_SITE_CURRENT_CACHE="--wpfc" EE_SITE_CURRENT_TYPE="--wp --wpfc" # WordPress subdirectory elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR BASIC" ]; then + EE_SITE_CURRENT_WP="--wpsubdir" + EE_SITE_CURRENT_CACHE="--basic" EE_SITE_CURRENT_TYPE="--wpsubdir --basic" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR WP SUPER CACHE" ]; then + EE_SITE_CURRENT_WP="--wpsubdir" + EE_SITE_CURRENT_CACHE="--wpsc" EE_SITE_CURRENT_TYPE="--wpsubdir --wpsc" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_WP="--wpsubdir" + EE_SITE_CURRENT_CACHE="--w3tc" EE_SITE_CURRENT_TYPE="--wpsubdir --w3tc" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ]; then + EE_SITE_CURRENT_WP="--wpsubdir" + EE_SITE_CURRENT_CACHE="--wpfc" EE_SITE_CURRENT_TYPE="--wpsubdir --wpfc" # WordPress subdomain elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN BASIC" ]; then + EE_SITE_CURRENT_WP="--wpsubdomain" + EE_SITE_CURRENT_CACHE="--basic" EE_SITE_CURRENT_TYPE="--wpsubdomain --basic" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + EE_SITE_CURRENT_WP="--wpsubdomain" + EE_SITE_CURRENT_CACHE="--wpsc" EE_SITE_CURRENT_TYPE="--wpsubdomain --wpsc" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_WP="--wpsubdomain" + EE_SITE_CURRENT_CACHE="--w3tc" EE_SITE_CURRENT_TYPE="--wpsubdomain --w3tc" elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ]; then + EE_SITE_CURRENT_WP="--wpsubdomain" + EE_SITE_CURRENT_CACHE="--wpfc" EE_SITE_CURRENT_TYPE="--wpsubdomain --wpfc" fi # Detect update website type and cache + # Single WordPress if [ "$EE_SITE_CREATE_OPTION" = "--wp" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then EE_SITE_UPDATE_TYPE="--wp --basic" @@ -596,6 +621,7 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then EE_SITE_UPDATE_TYPE="--wp --wpfc" fi + # WordPress subdirectory elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then EE_SITE_UPDATE_TYPE="--wpsubdir --basic" @@ -606,6 +632,7 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then EE_SITE_UPDATE_TYPE="--wpsubdir --wpfc" fi + # WordPress subdomain elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then EE_SITE_UPDATE_TYPE="--wpsubdomain --basic" @@ -619,7 +646,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi # Let's log site current option - ee_lib_echo_escape "EE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG + ee_lib_echo_escape "EE_SITE_CURRENT_WP = $EE_SITE_CURRENT_WP \nEE_SITE_CURRENT_CACHE = $EE_SITE_CURRENT_CACHE \nEE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG # Lets update HTML|PHP website if [[ "$EE_SITE_CURRENT_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then @@ -630,17 +657,17 @@ elif [ "$EE_FIRST" = "site" ]; then # Lets call update function ee_mod_update_website - elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" ]] \ + elif [[ "$EE_SITE_CURRENT_WP" = "--wp" ]] \ && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function ee_mod_update_website - elif [[ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" ]] \ + elif [[ "$EE_SITE_CURRENT_WP" = "--wpsubdir" ]] \ && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function ee_mod_update_website - elif [[ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]] \ + elif [[ "$EE_SITE_CURRENT_WP" = "--wpsubdomain" ]] \ && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then # Lets call update function ee_mod_update_website diff --git a/src/modules/site/update/ee_mod_update_website.sh b/src/modules/site/update/ee_mod_update_website.sh index 148b7342..f9c72b9b 100644 --- a/src/modules/site/update/ee_mod_update_website.sh +++ b/src/modules/site/update/ee_mod_update_website.sh @@ -28,7 +28,7 @@ function ee_mod_update_website() { fi # Setup/Install WordPress for HTML|PHP|MySQL websites - if [[ "$EE_SITE_CURRENT_TYPE" != "--wp --basic" && "$EE_SITE_CURRENT_TYPE" != "--wp --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wp --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wp --wpfc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]] && + if [[ "$EE_SITE_CURRENT_TYPE" = "--html" || "$EE_SITE_CURRENT_TYPE" = "--php" || "$EE_SITE_CURRENT_TYPE" = "--mysql" ]] && [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then # Setup WordPress ee_mod_setup_wordpress @@ -43,16 +43,33 @@ function ee_mod_update_website() { ee_mod_plugin_settings # Update WordPress Websites - elif [[ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" || "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]]; then + elif [[ "$EE_SITE_CURRENT_WP" = "--wp" || "$EE_SITE_CURRENT_WP" = "--wpsubdir" || "$EE_SITE_CURRENT_WP" = "--wpsubdomain" ]]; then # Setup WordPress Network for --wp websites - if [[ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" && "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]]; then + if [[ "$EE_SITE_CURRENT_WP" = "--wp" ]]; then if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_mod_setup_network fi fi + # Uninstall unwanted plugins + # Current site type: --wp --wpsc + # Update site type: --wpsubdomain --wpsc + # Only delete plugin when current cache is --wpsc and update cache is not --wpsc + if [[ "$EE_SITE_CURRENT_CACHE" = "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--wpsc" ]]; then + ee_lib_echo "Unistalling WP Super Cache plugin, please wait..." + wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG + fi + + # Delete plugin when current cache is --w3tc|--wpfc and update cache is not --w3tc|--wpfc + if [[ "$EE_SITE_CURRENT_CACHE" = "--w3tc" || "$EE_SITE_CURRENT_CACHE" = "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then + ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." + wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG + fi + # Install WordPress plugins - ee_mod_plugin_nginx_helper + # As nginx-helper is installed all type of WordPress + # We don't need to install it again + #ee_mod_plugin_nginx_helper if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then ee_mod_plugin_wpsc From 211a7183b6bcb77287707ab8095eabd85d110af2 Mon Sep 17 00:00:00 2001 From: Onur Demir Date: Wed, 22 Oct 2014 13:22:38 +0300 Subject: [PATCH 343/829] Update wpsc.conf The typo fix --- config/nginx/common/wpsc.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx/common/wpsc.conf b/config/nginx/common/wpsc.conf index ccbb4216..3605189d 100644 --- a/config/nginx/common/wpsc.conf +++ b/config/nginx/common/wpsc.conf @@ -24,7 +24,7 @@ if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_lo # Use cached or actual file if they exists, Otherwise pass request to WordPress location / { - try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php$args; + try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args; } location ~ \.php$ { From 0611668ac389be7d16aad23009c5f45a12417fb8 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 16:13:37 +0530 Subject: [PATCH 344/829] Fixed invalid options --- src/modules/site/update/ee_mod_update_website.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/site/update/ee_mod_update_website.sh b/src/modules/site/update/ee_mod_update_website.sh index f9c72b9b..ec8c5420 100644 --- a/src/modules/site/update/ee_mod_update_website.sh +++ b/src/modules/site/update/ee_mod_update_website.sh @@ -56,12 +56,14 @@ function ee_mod_update_website() { # Update site type: --wpsubdomain --wpsc # Only delete plugin when current cache is --wpsc and update cache is not --wpsc if [[ "$EE_SITE_CURRENT_CACHE" = "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--wpsc" ]]; then + cd /var/www/$EE_DOMAIN/htdocs/ ee_lib_echo "Unistalling WP Super Cache plugin, please wait..." wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG fi # Delete plugin when current cache is --w3tc|--wpfc and update cache is not --w3tc|--wpfc - if [[ "$EE_SITE_CURRENT_CACHE" = "--w3tc" || "$EE_SITE_CURRENT_CACHE" = "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then + if [[ "$EE_SITE_CURRENT_CACHE" = "--w3tc" || "$EE_SITE_CURRENT_CACHE" = "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then + cd /var/www/$EE_DOMAIN/htdocs/ ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG fi @@ -71,11 +73,11 @@ function ee_mod_update_website() { # We don't need to install it again #ee_mod_plugin_nginx_helper - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + if [ "$EE_SITE_CURRENT_CACHE" != "--wpsc" && "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then ee_mod_plugin_wpsc fi - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + if [[ "$EE_SITE_CURRENT_CACHE" != "--w3tc" || "$EE_SITE_CURRENT_CACHE" != "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" || "$EE_SITE_CACHE_OPTION" = "--wpfc" ]]; then ee_mod_plugin_w3tc fi From 65b02a40a2a7b68f6c9d8a9ef6e939253d33e8f4 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 16:14:52 +0530 Subject: [PATCH 345/829] Fixed invalid options --- src/modules/site/ee_mod_site_option.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index 3fff8d35..843d732c 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -36,7 +36,9 @@ function ee_mod_site_option() fi # Kick out for invalid cache option - if [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then + if [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then + ee_lib_error "Invalid website type $EE_SITE_CACHE_OPTION, exit status = " $? + elif [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? fi } From 8a5f84a28595920adbc66827265d811e9c054692 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 16:30:56 +0530 Subject: [PATCH 346/829] Fix if syntax error --- src/modules/site/update/ee_mod_update_website.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update_website.sh b/src/modules/site/update/ee_mod_update_website.sh index ec8c5420..7c876f9f 100644 --- a/src/modules/site/update/ee_mod_update_website.sh +++ b/src/modules/site/update/ee_mod_update_website.sh @@ -73,7 +73,7 @@ function ee_mod_update_website() { # We don't need to install it again #ee_mod_plugin_nginx_helper - if [ "$EE_SITE_CURRENT_CACHE" != "--wpsc" && "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + if [[ "$EE_SITE_CURRENT_CACHE" != "--wpsc" && "$EE_SITE_CACHE_OPTION" = "--wpsc" ]]; then ee_mod_plugin_wpsc fi From 59324da2d843cda4ae7f0810e2640cef80a6270c Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 16:39:39 +0530 Subject: [PATCH 347/829] Fixed w3tc plugin install for --wpfc to --w3tc update --- src/modules/site/update/ee_mod_update_website.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update_website.sh b/src/modules/site/update/ee_mod_update_website.sh index 7c876f9f..17224714 100644 --- a/src/modules/site/update/ee_mod_update_website.sh +++ b/src/modules/site/update/ee_mod_update_website.sh @@ -77,7 +77,7 @@ function ee_mod_update_website() { ee_mod_plugin_wpsc fi - if [[ "$EE_SITE_CURRENT_CACHE" != "--w3tc" || "$EE_SITE_CURRENT_CACHE" != "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" || "$EE_SITE_CACHE_OPTION" = "--wpfc" ]]; then + if [[ "$EE_SITE_CURRENT_CACHE" != "--w3tc" && "$EE_SITE_CURRENT_CACHE" != "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" || "$EE_SITE_CACHE_OPTION" = "--wpfc" ]]; then ee_mod_plugin_w3tc fi From 7d10a64c7fad05d5d4a60aa9841975d632cca926 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 16:48:12 +0530 Subject: [PATCH 348/829] Fix message --- src/modules/site/ee_mod_site_option.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index 843d732c..822ebf91 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -37,7 +37,7 @@ function ee_mod_site_option() # Kick out for invalid cache option if [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then - ee_lib_error "Invalid website type $EE_SITE_CACHE_OPTION, exit status = " $? + ee_lib_error "Invalid website type $EE_SITE_CREATE_OPTION, exit status = " $? elif [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? fi From 89dcbe1022e6ebe9c7583053ac78dcf56f8e12ff Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 16:59:23 +0530 Subject: [PATCH 349/829] Fix invalid cache option for HTML PHP and MYSQL website --- src/modules/site/ee_mod_site_option.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index 822ebf91..8774cc98 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -38,6 +38,8 @@ function ee_mod_site_option() # Kick out for invalid cache option if [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then ee_lib_error "Invalid website type $EE_SITE_CREATE_OPTION, exit status = " $? + elif [[ "$EE_SITE_CREATE_OPTION" = "--html" && "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CREATE_OPTION" = "--mysql" ]] && [ -n "$EE_SITE_CREATE_OPTION" ]; then + ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION for $EE_SITE_CREATE_OPTION website, exit status = " $? elif [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? fi From 2f8570c578832a916405d796fe0ed67ecffc21d2 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 16:59:47 +0530 Subject: [PATCH 350/829] Fix invalid cache option for HTML PHP and MYSQL website --- src/modules/site/ee_mod_site_option.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index 8774cc98..4a2b7a7e 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -38,7 +38,7 @@ function ee_mod_site_option() # Kick out for invalid cache option if [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then ee_lib_error "Invalid website type $EE_SITE_CREATE_OPTION, exit status = " $? - elif [[ "$EE_SITE_CREATE_OPTION" = "--html" && "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CREATE_OPTION" = "--mysql" ]] && [ -n "$EE_SITE_CREATE_OPTION" ]; then + elif [[ "$EE_SITE_CREATE_OPTION" = "--html" || "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]] && [ -n "$EE_SITE_CREATE_OPTION" ]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION for $EE_SITE_CREATE_OPTION website, exit status = " $? elif [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? From b6b82a8803153f3f5484220c92a03a90a001841a Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 17:22:39 +0530 Subject: [PATCH 351/829] Remove unwanted file --- .../site/update/ee_mod_update_plugins.sh | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/modules/site/update/ee_mod_update_plugins.sh diff --git a/src/modules/site/update/ee_mod_update_plugins.sh b/src/modules/site/update/ee_mod_update_plugins.sh deleted file mode 100644 index 8a7ce7f0..00000000 --- a/src/modules/site/update/ee_mod_update_plugins.sh +++ /dev/null @@ -1,38 +0,0 @@ -# Update cache plugins - -function ee_mod_update_plugins() -{ - cd /var/www/$EE_DOMAIN/htdocs/ - - # Uninstall W3TC plugin in case converting site to --basic | --wpsc - if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] \ - && [[ "$EE_SITE_CACHE_OPTION" = "--basic" || "$EE_SITE_CACHE_OPTION" = "--wpsc" ]]; then - ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." - wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG - fi - # Uninstall WPSC plugin in case converting site to --basic | --w3tc | --wpfc - if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - ee_lib_echo "Unistalling WP Super Cache plugin, please wait..." - - wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG - fi - - # Install wpsc plugin in case updating site to --wpsc - if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - ee_mod_plugin_settings - fi - - # Install w3tc plugin in case updating site to --w3tc | --wpfc - if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] \ - && [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" || "$EE_SITE_CACHE_OPTION" = "--wpfc" ]]; then - ee_mod_plugin_w3tc - ee_mod_plugin_settings - fi -} From 330097eb16abb9baeafd6c78b4d6ac9dd0685cf1 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 17:33:09 +0530 Subject: [PATCH 352/829] Fix varible name --- src/modules/site/ee_mod_site_option.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index 4a2b7a7e..5bb9a414 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -38,7 +38,7 @@ function ee_mod_site_option() # Kick out for invalid cache option if [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then ee_lib_error "Invalid website type $EE_SITE_CREATE_OPTION, exit status = " $? - elif [[ "$EE_SITE_CREATE_OPTION" = "--html" || "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]] && [ -n "$EE_SITE_CREATE_OPTION" ]; then + elif [[ "$EE_SITE_CREATE_OPTION" = "--html" || "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]] && [ -n "$EE_SITE_CACHE_OPTION" ]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION for $EE_SITE_CREATE_OPTION website, exit status = " $? elif [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? From 6dd37a323ee61e2c2123d8fa49d738fda2ab7086 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 18:07:26 +0530 Subject: [PATCH 353/829] Added ee site update example.com --password --- bin/easyengine | 5 ++++- src/modules/site/update/ee_mod_site_update_password.sh | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index ac5b523c..863916d7 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -648,8 +648,11 @@ elif [ "$EE_FIRST" = "site" ]; then # Let's log site current option ee_lib_echo_escape "EE_SITE_CURRENT_WP = $EE_SITE_CURRENT_WP \nEE_SITE_CURRENT_CACHE = $EE_SITE_CURRENT_CACHE \nEE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG + # Update WordPress user password + if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then + ee_mod_site_update_password # Lets update HTML|PHP website - if [[ "$EE_SITE_CURRENT_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then + elif [[ "$EE_SITE_CURRENT_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then # Lets call update function ee_mod_update_website diff --git a/src/modules/site/update/ee_mod_site_update_password.sh b/src/modules/site/update/ee_mod_site_update_password.sh index f8055b57..fc418175 100644 --- a/src/modules/site/update/ee_mod_site_update_password.sh +++ b/src/modules/site/update/ee_mod_site_update_password.sh @@ -12,7 +12,15 @@ ee_mod_site_update_password() if [ $? -eq 0 ]; then read -p "Provide WordPress user name [admin]: " ee_wp_user - if [[ $ee_wp_user = "" ]]; then + + # If user enter ? mark then show list of WordPress users + if [ "$ee_wp_user" = "?" ]; then + ee_lib_echo "List of WordPress users:" + wp --allow-root user list --fields=user_login + read -p "Provide WordPress user name [admin]: " ee_wp_user + fi + + if [ "$ee_wp_user" = "" ]; then ee_wp_user=admin fi From 1bd87e25eac3839072d6fecb5b1fb84bc7ff429e Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 18:26:31 +0530 Subject: [PATCH 354/829] Fix ee site update example.com --password --- bin/easyengine | 2 ++ src/modules/site/ee_mod_site_option.sh | 4 +++- src/modules/site/update/ee_mod_site_update_password.sh | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 863916d7..425ab1b2 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -689,6 +689,8 @@ elif [ "$EE_FIRST" = "site" ]; then # Display Success Message ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" + elif [[ "$EE_SECOND" = "update" && "$EE_SITE_CREATE_OPTION" = "--password" ]]; then + ee_lib_echo "This option is needed for updating WordPress website password" &> /dev/null else ee_lib_error "Invalid option, exit status = " $? fi diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index 5bb9a414..924858f1 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -36,7 +36,9 @@ function ee_mod_site_option() fi # Kick out for invalid cache option - if [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then + if [[ "$EE_SECOND" = "update" && "$EE_SITE_CREATE_OPTION" = "--password" ]]; then + ee_lib_echo "This option is needed for updating WordPress website password" &> /dev/null + elif [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then ee_lib_error "Invalid website type $EE_SITE_CREATE_OPTION, exit status = " $? elif [[ "$EE_SITE_CREATE_OPTION" = "--html" || "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]] && [ -n "$EE_SITE_CACHE_OPTION" ]; then ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION for $EE_SITE_CREATE_OPTION website, exit status = " $? diff --git a/src/modules/site/update/ee_mod_site_update_password.sh b/src/modules/site/update/ee_mod_site_update_password.sh index fc418175..fde5fd04 100644 --- a/src/modules/site/update/ee_mod_site_update_password.sh +++ b/src/modules/site/update/ee_mod_site_update_password.sh @@ -16,7 +16,7 @@ ee_mod_site_update_password() # If user enter ? mark then show list of WordPress users if [ "$ee_wp_user" = "?" ]; then ee_lib_echo "List of WordPress users:" - wp --allow-root user list --fields=user_login + wp --allow-root user list --fields=user_login | grep -v user_login read -p "Provide WordPress user name [admin]: " ee_wp_user fi @@ -35,7 +35,7 @@ ee_mod_site_update_password() ee_lib_error "Password Unchanged. Hint : Your password must be 8 characters long, exit status = " $? fi else - ee_lib_error "Invalid WordPress user $ee_wp_user for $EE_DOMAIN, exit status = " $? + ee_lib_error "Invalid WordPress user $ee_wp_user for $EE_DOMAIN, exit status = " $? fi fi } From 077105266dd7ce234504f659a555448b23e28270 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 22 Oct 2014 18:50:40 +0530 Subject: [PATCH 355/829] Added success message after password successfully changed --- src/modules/site/update/ee_mod_site_update_password.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/site/update/ee_mod_site_update_password.sh b/src/modules/site/update/ee_mod_site_update_password.sh index fde5fd04..5335ad9d 100644 --- a/src/modules/site/update/ee_mod_site_update_password.sh +++ b/src/modules/site/update/ee_mod_site_update_password.sh @@ -15,7 +15,7 @@ ee_mod_site_update_password() # If user enter ? mark then show list of WordPress users if [ "$ee_wp_user" = "?" ]; then - ee_lib_echo "List of WordPress users:" + ee_lib_echo "Fetching WordPress user list, please wait..." wp --allow-root user list --fields=user_login | grep -v user_login read -p "Provide WordPress user name [admin]: " ee_wp_user fi @@ -30,7 +30,8 @@ ee_mod_site_update_password() read -sp "Provide password for $ee_wp_user user: " ee_wp_pass echo if [[ ${#ee_wp_pass} -ge 8 ]]; then - wp --allow-root user update "${ee_wp_user}" --user_pass=$ee_wp_pass &>> $EE_COMMAND_LOG + wp --allow-root user update "${ee_wp_user}" --user_pass=$ee_wp_pass &>> $EE_COMMAND_LOG && \ + ee_lib_echo "Password updated successfully" else ee_lib_error "Password Unchanged. Hint : Your password must be 8 characters long, exit status = " $? fi From 148487898fe9075d675541688816ea8992ec5dd3 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 22 Oct 2014 19:02:57 +0530 Subject: [PATCH 356/829] autocompletion for ee site update --password --- config/bash_completion.d/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 7015fc94..d9244a3a 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -115,7 +115,7 @@ function EE_AUTO() if [ "$PREVIOUS2" = "create" ]; then COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "update" ]; then - COMPREPLY=( $( compgen -W "--php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) + COMPREPLY=( $( compgen -W "--password --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "delete" ]; then COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) ) fi From 4c85204f171171b8affc3b4daecf3ed3e349816d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 27 Oct 2014 19:25:54 +0530 Subject: [PATCH 357/829] Fixes http://community.rtcamp.com/t/unable-to-download-vimbadmin/3302/4 --- src/vendor/ee_ven_install_vimbadmin.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vendor/ee_ven_install_vimbadmin.sh b/src/vendor/ee_ven_install_vimbadmin.sh index 4f1d23a9..e76ac0a5 100644 --- a/src/vendor/ee_ven_install_vimbadmin.sh +++ b/src/vendor/ee_ven_install_vimbadmin.sh @@ -11,6 +11,9 @@ function ee_ven_install_vimbadmin() # Install ViMbAdmin ee_lib_echo "Installing ViMbAdmin, please wait..." ee_lib_echo "It will take nearly 10-20 minutes, please wait..." + mkdir -p /var/www/22222/htdocs/ \ + || ee_lib_error "Unable to create ViMbAdmin Directory, exit status = " $? + wget -cqO /var/www/22222/htdocs/vimbadmin.tar.gz https://github.com/opensolutions/ViMbAdmin/archive/${EE_VIMBADMIN_VERSION}.tar.gz \ || ee_lib_error "Unable to download ViMbAdmin, exit status = " $? @@ -25,7 +28,7 @@ function ee_ven_install_vimbadmin() || ee_lib_error "Unable to install ViMbAdmin, exit status = " $? # Fix permissions - chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/22222/htdocs/vimbadmin \ + chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/22222/ \ || ee_lib_error "Unable to change ownership for ViMbAdmin, exit status = " $? # Remove unwanted files From ec5652bf61aef43bca4cb5e60e78f623b6d58572 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 28 Oct 2014 15:34:26 +0530 Subject: [PATCH 358/829] Fixes http://community.rtcamp.com/t/aliases-in-vimbadmin-seem-to-be-ignored/3163/6 --- src/modules/stack/install/mail/ee_mod_setup_postfix.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index 6ffbf518..bc5b81c6 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -44,6 +44,7 @@ function ee_mod_setup_postfix() postconf -e "virtual_gid_maps = static:5000" postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domains_maps.cf" postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf" + postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf" #postconf "message_size_limit = 20971520" From 25e8e2d35d8149460e9cf0a2ebfdf3b5b8d1ac88 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 28 Oct 2014 17:23:59 +0530 Subject: [PATCH 359/829] Fixes CVE-2014-3566 (Poodle Bug) #327 --- src/modules/stack/install/ee_mod_setup_nginx.sh | 2 +- src/modules/stack/install/mail/ee_mod_setup_dovecot.sh | 3 +++ src/modules/stack/install/mail/ee_mod_setup_postfix.sh | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh index b280d4dc..4257c6b7 100644 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ b/src/modules/stack/install/ee_mod_setup_nginx.sh @@ -21,7 +21,7 @@ function ee_mod_setup_nginx() # Disable nginx version # Set custom header # SSL Settings - sed -i "s/http {/http {\n\t##\n\t# EasyEngine Settings\n\t##\n\n\tserver_tokens off;\n\treset_timedout_connection on;\n\tadd_header X-Powered-By \"EasyEngine $EE_VERSION\";\n\tadd_header rt-Fastcgi-Cache \$upstream_cache_status;\n\n\t# Limit Request\n\tlimit_req_status 403;\n\tlimit_req_zone \$binary_remote_addr zone=one:10m rate=1r\/s;\n\n\t# Proxy Settings\n\t# set_real_ip_from\tproxy-server-ip;\n\t# real_ip_header\tX-Forwarded-For;\n\n\tfastcgi_read_timeout 300;\n\tclient_max_body_size 100m;\n\n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\n/" /etc/nginx/nginx.conf + sed -i "s/http {/http {\n\t##\n\t# EasyEngine Settings\n\t##\n\n\tserver_tokens off;\n\treset_timedout_connection on;\n\tadd_header X-Powered-By \"EasyEngine $EE_VERSION\";\n\tadd_header rt-Fastcgi-Cache \$upstream_cache_status;\n\n\t# Limit Request\n\tlimit_req_status 403;\n\tlimit_req_zone \$binary_remote_addr zone=one:10m rate=1r\/s;\n\n\t# Proxy Settings\n\t# set_real_ip_from\tproxy-server-ip;\n\t# real_ip_header\tX-Forwarded-For;\n\n\tfastcgi_read_timeout 300;\n\tclient_max_body_size 100m;\n\n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\t# Fix POODLE attack\n\tssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n\n/" /etc/nginx/nginx.conf # Adjust nginx keepalive_timeout sed -i "s/keepalive_timeout.*/keepalive_timeout 30;/" /etc/nginx/nginx.conf diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index 2b1e62ad..b395a664 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -30,6 +30,9 @@ function ee_mod_setup_dovecot() sed -i "s/#\!include auth-sql.conf.ext/\!include auth-sql.conf.ext/" /etc/dovecot/conf.d/10-auth.conf \ || ee_lib_error "Unable to setup 10-auth.conf file, exit status = " $? + # Configuring 10-ssl.conf, Disable SSLv2 and SSLv3, Fixes POODLE Bug + sed -i "s/#ssl_protocols =.*/ssl_protocols = \!SSLv2 \!SSLv3/" /etc/dovecot/conf.d/10-ssl.conf + # Configuring dovecot-sql.conf.ext cp -v /usr/share/easyengine/mail/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to copy dovecot-sql.conf.ext, exit status = " $? diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index bc5b81c6..8beab678 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -33,6 +33,12 @@ function ee_mod_setup_postfix() postconf -e "smtpd_relay_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination" + # Disable SSL for POODLE + postconf -e "smtpd_tls_mandatory_protocols=!SSLv2,!SSLv3" + postconf -e "smtp_tls_mandatory_protocols=!SSLv2,!SSLv3" + postconf -e "smtpd_tls_protocols=!SSLv2,!SSLv3" + postconf -e "smtp_tls_protocols=!SSLv2,!SSLv3" + # other destination domains should be handled using virtual domains postconf -e "mydestination = localhost" From 88e5ee44165cd3c4d2ca36fca7dba4920d82a827 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 30 Oct 2014 15:25:12 +0530 Subject: [PATCH 360/829] Fix log --- src/lib/ee_lib_stack_packages.sh | 6 ++++++ src/lib/ee_lib_variables.sh | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index 332fd1f9..f5d97054 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -11,6 +11,12 @@ function ee_lib_stack_packages() if [ "$EE_PACKAGE_NAME" != "" ]; then # Export EE_DISPLAY variable to Display ee http auth after site creation. export EE_DISPLAY=false + + # Log only single time + # ee site create example.com called ee stack install nginx + # So in log file all logs written twice + export EE_LOG=false + # The following command creates its own sub-shell # and our ee_lib_error function only exit from that sub-shell # so we need to exit from parent shell also diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 1d6eaf83..d74c65d1 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -18,7 +18,15 @@ readonly EE_VIMBADMIN_VERSION='3.0.10' # EasyEngine Date variable for backup readonly EE_DATE=$(date +%d%b%Y%H%M%S) -EE_COMMAND_LOG=/var/log/easyengine/ee.log +# Log only single time +# ee site create example.com called ee stack install nginx +# So in log file all logs written twice +if [ -n "$EE_LOG" ]; then + EE_COMMAND_LOG=/dev/null +else + EE_COMMAND_LOG=/var/log/easyengine/ee.log +fi + readonly EE_LOG_DIR=/var/log/easyengine readonly EE_ERROR_LOG=/var/log/easyengine/error.log readonly EE_LINUX_DISTRO=$(lsb_release -i |awk '{print $3}') From 7027f7cd6c5f2ea09108b9551ba55139e2931c2b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 30 Oct 2014 15:29:56 +0530 Subject: [PATCH 361/829] ee stack purge will remove mysql before so in that case we dont need to through any error for removing slow_query_log databse --- src/vendor/ee_ven_remove_utils.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vendor/ee_ven_remove_utils.sh b/src/vendor/ee_ven_remove_utils.sh index 5772c4da..ec6f4067 100644 --- a/src/vendor/ee_ven_remove_utils.sh +++ b/src/vendor/ee_ven_remove_utils.sh @@ -8,6 +8,5 @@ function ee_ven_remove_utils() || ee_lib_error "Unable to remove EasyEngine (ee) admin utilities" # Drop Anemometer database - mysql -e "drop database if exists slow_query_log" \ - || ee_lib_error "Unable to drop slow_query_log database, exit status = " $? + mysql -e "drop database if exists slow_query_log" &>> $EE_COMMAND_LOG } From 87cb764c7724bbd0ec863b357194cc396a1e7fbb Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 30 Oct 2014 15:33:32 +0530 Subject: [PATCH 362/829] Update comment --- src/lib/ee_lib_stack_packages.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index f5d97054..48f14f98 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -14,7 +14,8 @@ function ee_lib_stack_packages() # Log only single time # ee site create example.com called ee stack install nginx - # So in log file all logs written twice + # So when ee stack install nginx run in sub-shell the value of EE_COMMAND_LOG=/dev/null + # So in log file all logs written single time only export EE_LOG=false # The following command creates its own sub-shell From d4ea6ebec6b215ffcfd1dd72982c4f85e6e39f40 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 30 Oct 2014 16:04:42 +0530 Subject: [PATCH 363/829] Fix double autoremove message --- src/lib/ee_lib_autoremove.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_autoremove.sh b/src/lib/ee_lib_autoremove.sh index ab10a207..bdc9ae6a 100644 --- a/src/lib/ee_lib_autoremove.sh +++ b/src/lib/ee_lib_autoremove.sh @@ -3,5 +3,5 @@ function ee_lib_autoremove() { ee_lib_echo "Removing unwanted packages, please wait..." - $EE_APT_GET autoremove | tee -ai $EE_COMMAND_LOG + $EE_APT_GET autoremove } \ No newline at end of file From ad19eb8853fb0853157e8e92e1c31d7e272ea63b Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 30 Oct 2014 16:19:19 +0530 Subject: [PATCH 364/829] Fix log messages --- src/lib/ee_lib_stack_packages.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index 48f14f98..2a726bfd 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -3,6 +3,11 @@ function ee_lib_stack_packages() { local ee_stack_package + # Log only single time + # ee site create example.com called ee stack install nginx + # So when ee stack install nginx run in sub-shell the value of EE_COMMAND_LOG=/dev/null + # So in log file all logs written single time only + export EE_LOG=false for ee_stack_package in $@;do # Check NGINX installed & install if not @@ -12,12 +17,6 @@ function ee_lib_stack_packages() # Export EE_DISPLAY variable to Display ee http auth after site creation. export EE_DISPLAY=false - # Log only single time - # ee site create example.com called ee stack install nginx - # So when ee stack install nginx run in sub-shell the value of EE_COMMAND_LOG=/dev/null - # So in log file all logs written single time only - export EE_LOG=false - # The following command creates its own sub-shell # and our ee_lib_error function only exit from that sub-shell # so we need to exit from parent shell also From feac2d0d1f5b8539012326c4c277bf3573754199 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 30 Oct 2014 17:13:00 +0530 Subject: [PATCH 365/829] Adding Dovecot installtion to log file --- src/modules/stack/install/mail/ee_mod_install_dovecot.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index 09225e4b..fafb37d8 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -11,12 +11,13 @@ function ee_mod_install_dovecot() debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" + # 2>&1 is needed as config file is written in STDEER # Debian 6 doesn't provide Dovecot 2.x if [ "$EE_DEBIAN_VERSION" == "squeeze" ]; then - $EE_APT_GET -t squeeze-backports install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ + $EE_APT_GET -t squeeze-backports install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved 2>&1 \ || ee_lib_error "Unable to install Dovecot, exit status = " $? else - $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ + $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved 2>&1 \ || ee_lib_error "Unable to install Dovecot, exit status = " $? fi From e4da10f0ce4df1e91870b5ba3db45dbcace29233 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 30 Oct 2014 17:14:09 +0530 Subject: [PATCH 366/829] Fix Yoast plugin for wordpress multisite subdir setup --- config/nginx/common/wpcommon.conf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/nginx/common/wpcommon.conf b/config/nginx/common/wpcommon.conf index eb6c4918..91450a79 100644 --- a/config/nginx/common/wpcommon.conf +++ b/config/nginx/common/wpcommon.conf @@ -27,8 +27,10 @@ location /wp-content/uploads/ { location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ { rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent; rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last; - rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last; - rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; + + # Rules for yoast sitemap with wp|wpsubdir|wpsubdomain + rewrite ^.*/sitemap_index\.xml$ /index.php?sitemap=1 last; + rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; # Following lines are options. Needed for WordPress seo addons rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last; From 4a27c3faa43676f7ac1d0c8398c34529d937ed6d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 30 Oct 2014 17:29:21 +0530 Subject: [PATCH 367/829] Disable MySQL performance_schema by default #326 --- src/modules/stack/install/ee_mod_setup_mysql.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/ee_mod_setup_mysql.sh b/src/modules/stack/install/ee_mod_setup_mysql.sh index b83ffd8a..a8ba0263 100644 --- a/src/modules/stack/install/ee_mod_setup_mysql.sh +++ b/src/modules/stack/install/ee_mod_setup_mysql.sh @@ -6,11 +6,11 @@ function ee_mod_setup_mysql() # Setting wait_timeout = 30 & interactive_timeout = 60 if [ ! -f /etc/mysql/my.cnf ]; then - echo -e "[mysqld] \nwait_timeout = 30 \ninteractive_timeout = 60" > /etc/mysql/my.cnf + echo -e "[mysqld] \nwait_timeout = 30 \ninteractive_timeout = 60 \nperformance_schema = 0" > /etc/mysql/my.cnf else grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG if [ $? -ne 0 ]; then - sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf + sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60 \nperformance_schema = 0" /etc/mysql/my.cnf fi fi } From bf5345e04539f6325727c4a35d806eadb0cb6d99 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 30 Oct 2014 17:35:24 +0530 Subject: [PATCH 368/829] Install postfix before wp-cli for wordpress sites --- src/modules/site/ee_mod_site_packages.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/site/ee_mod_site_packages.sh b/src/modules/site/ee_mod_site_packages.sh index 9cf69368..66a19a42 100644 --- a/src/modules/site/ee_mod_site_packages.sh +++ b/src/modules/site/ee_mod_site_packages.sh @@ -17,10 +17,11 @@ function ee_mod_site_packages() ee_lib_stack_packages mysql fi + # Check & Install Postfix Packages + ee_lib_stack_packages postfix + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then # Install WP-CLI ee_ven_install_wpcli fi - # Check & Install Postfix Packages - ee_lib_stack_packages postfix } From b9ae5f58a14b76310ba779d148ba8a78a43fbe52 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 30 Oct 2014 17:38:56 +0530 Subject: [PATCH 369/829] Minor fix --- bin/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install b/bin/install index 5238f341..b26838ac 100644 --- a/bin/install +++ b/bin/install @@ -124,7 +124,7 @@ if [ -z "$BRANCH" ]; then BRANCH=stable else # Cross check EasyEngine (ee) branch name - git ls-remote --heads https://github.com/rtCamp/easyengine | grep $BRANCH &>> $EE_INSTALL_LOG + git ls-remote --heads https://github.com/rtCamp/easyengine | grep ${BRANCH}$ &>> $EE_INSTALL_LOG if [ $? -ne 0 ]; then ee_lib_error "The $BRANCH branch does not exist, please provide the correct branch name, exit status = " $? fi From 19cbd76eca854b76d041fdeed65bcd7b0c051690 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 30 Oct 2014 18:20:00 +0530 Subject: [PATCH 370/829] Minor update --- src/lib/ee_lib_variables.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index d74c65d1..1b5c2153 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -20,7 +20,8 @@ readonly EE_DATE=$(date +%d%b%Y%H%M%S) # Log only single time # ee site create example.com called ee stack install nginx -# So in log file all logs written twice +# So when ee stack install nginx run in sub-shell the value of EE_COMMAND_LOG=/dev/null +# So in log file all logs written single time only if [ -n "$EE_LOG" ]; then EE_COMMAND_LOG=/dev/null else From e61ced04e61cf29b85fcf02a338d26d8ed2261ec Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 31 Oct 2014 16:28:20 +0530 Subject: [PATCH 371/829] Fix log files --- bin/easyengine | 2 +- src/lib/ee_lib_stack_packages.sh | 2 +- src/lib/ee_lib_variables.sh | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 425ab1b2..9d723302 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -868,7 +868,7 @@ fi } -EasyEngine $@ | tee -ai $EE_COMMAND_LOG +EasyEngine $@ | tee -ai $EE_TEE_LOG # If any command fails its return non-zero exit code [EasyEngine $@] diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index 2a726bfd..f17df84d 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -5,7 +5,7 @@ function ee_lib_stack_packages() local ee_stack_package # Log only single time # ee site create example.com called ee stack install nginx - # So when ee stack install nginx run in sub-shell the value of EE_COMMAND_LOG=/dev/null + # So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null # So in log file all logs written single time only export EE_LOG=false diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 1b5c2153..45a7cb1e 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -20,14 +20,15 @@ readonly EE_DATE=$(date +%d%b%Y%H%M%S) # Log only single time # ee site create example.com called ee stack install nginx -# So when ee stack install nginx run in sub-shell the value of EE_COMMAND_LOG=/dev/null +# So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null # So in log file all logs written single time only if [ -n "$EE_LOG" ]; then - EE_COMMAND_LOG=/dev/null + EE_TEE_LOG=/dev/null else - EE_COMMAND_LOG=/var/log/easyengine/ee.log + EE_TEE_LOG=/var/log/easyengine/ee.log fi +EE_COMMAND_LOG=/var/log/easyengine/ee.log readonly EE_LOG_DIR=/var/log/easyengine readonly EE_ERROR_LOG=/var/log/easyengine/error.log readonly EE_LINUX_DISTRO=$(lsb_release -i |awk '{print $3}') From 6447a85f15a9f77ce0f300f80474ccfeef4bb340 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 3 Nov 2014 11:46:46 +0530 Subject: [PATCH 372/829] Change Fast CGI name to FastCGI --- bin/easyengine | 6 +++--- templates/nginx/wp/wpfc.conf | 2 +- templates/nginx/wpsubdir/wpfc.conf | 2 +- templates/nginx/wpsubdomain/wpfc.conf | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 9d723302..f8513416 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -569,7 +569,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_CURRENT_WP="--wp" EE_SITE_CURRENT_CACHE="--w3tc" EE_SITE_CURRENT_TYPE="--wp --w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ]; then + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FASTCGI" ]; then EE_SITE_CURRENT_WP="--wp" EE_SITE_CURRENT_CACHE="--wpfc" EE_SITE_CURRENT_TYPE="--wp --wpfc" @@ -586,7 +586,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_CURRENT_WP="--wpsubdir" EE_SITE_CURRENT_CACHE="--w3tc" EE_SITE_CURRENT_TYPE="--wpsubdir --w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ]; then + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FASTCGI" ]; then EE_SITE_CURRENT_WP="--wpsubdir" EE_SITE_CURRENT_CACHE="--wpfc" EE_SITE_CURRENT_TYPE="--wpsubdir --wpfc" @@ -603,7 +603,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_CURRENT_WP="--wpsubdomain" EE_SITE_CURRENT_CACHE="--w3tc" EE_SITE_CURRENT_TYPE="--wpsubdomain --w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ]; then + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FASTCGI" ]; then EE_SITE_CURRENT_WP="--wpsubdomain" EE_SITE_CURRENT_CACHE="--wpfc" EE_SITE_CURRENT_TYPE="--wpsubdomain --wpfc" diff --git a/templates/nginx/wp/wpfc.conf b/templates/nginx/wp/wpfc.conf index ba35bfae..68c33a51 100644 --- a/templates/nginx/wp/wpfc.conf +++ b/templates/nginx/wp/wpfc.conf @@ -1,4 +1,4 @@ -# WPSINGLE FAST CGI NGINX CONFIGURATION +# WPSINGLE FASTCGI NGINX CONFIGURATION server { diff --git a/templates/nginx/wpsubdir/wpfc.conf b/templates/nginx/wpsubdir/wpfc.conf index 6e59806c..556cefda 100644 --- a/templates/nginx/wpsubdir/wpfc.conf +++ b/templates/nginx/wpsubdir/wpfc.conf @@ -1,4 +1,4 @@ -# WPSUBDIR FAST CGI NGINX CONFIGURATION +# WPSUBDIR FASTCGI NGINX CONFIGURATION server { diff --git a/templates/nginx/wpsubdomain/wpfc.conf b/templates/nginx/wpsubdomain/wpfc.conf index 56e93a95..a2e02c85 100644 --- a/templates/nginx/wpsubdomain/wpfc.conf +++ b/templates/nginx/wpsubdomain/wpfc.conf @@ -1,4 +1,4 @@ -# WPSUBDOMAIN FAST CGI NGINX CONFIGURATION +# WPSUBDOMAIN FASTCGI NGINX CONFIGURATION server { From 6a6c78cbfb0911cc20c99a44b223c9a200f8a4a7 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 3 Nov 2014 15:06:32 +0530 Subject: [PATCH 373/829] Fix variable names --- bin/easyengine | 2 +- src/modules/site/ee_mod_site_backup.sh | 3 ++- .../site/update/ee_mod_update_nginx.sh | 25 ++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index f8513416..7391a5c2 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -646,7 +646,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi # Let's log site current option - ee_lib_echo_escape "EE_SITE_CURRENT_WP = $EE_SITE_CURRENT_WP \nEE_SITE_CURRENT_CACHE = $EE_SITE_CURRENT_CACHE \nEE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG + ee_lib_echo_escape "EE_SITE_CURRENT_WP = $EE_SITE_CURRENT_WP \nEE_SITE_CURRENT_CACHE = $EE_SITE_CURRENT_CACHE \nEE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \n\nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG # Update WordPress user password if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index 347a00a7..13001912 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -16,7 +16,7 @@ function ee_mod_site_backup() || ee_lib_error "Failed: Backup NGINX configuration, exit status =" $? # Move htdocs - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then + if [ "$EE_SITE_CURRENT_TYPE" = "--html" ] || [ "$EE_SITE_CURRENT_TYPE" = "--php" ] || [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ]; then ee_lib_echo "Backup webroot, please wait..." mv $ee_webroot/htdocs $ee_webroot/backup/$EE_DATE/ \ || ee_lib_error "Failed: Backup webroot, exit status =" $? @@ -25,6 +25,7 @@ function ee_mod_site_backup() fi # Database backup + # Check ee-config.php or wp-config.php present if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) ee_lib_echo "Backup Database, please wait..." diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index 1a6c5fc4..30c0f4c4 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -2,11 +2,8 @@ function ee_mod_update_nginx() { - # Find out information about current NGINX configuration - EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) - # Git commit - ee_lib_git /etc/nginx/ "Before ee site update: $EE_DOMAIN running on $EE_SITE_CURRENT_OPTION" + ee_lib_git /etc/nginx/ "Before ee site update: $EE_DOMAIN running on $EE_SITE_CURRENT_TYPE" # Update NGINX configuration ee_lib_echo "Updating $EE_DOMAIN, please wait..." @@ -30,7 +27,7 @@ function ee_mod_update_nginx() sed -i "s'$ee_nginx_current_header'$ee_nginx_update_header'" /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? # Update NGINX conf for HTML site - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then + if [ "$EE_SITE_CURRENT_TYPE" = "--html" ]; then sed -i 's/access\.log/access.log rt_cache/' /etc/nginx/sites-available/$EE_DOMAIN && \ sed -i '/index index.html index.htm;$/c \\tindex index.php index.htm index.html;' /etc/nginx/sites-available/$EE_DOMAIN && \ sed -i '/location \/ {/,/}/d ' /etc/nginx/sites-available/$EE_DOMAIN \ @@ -55,7 +52,7 @@ function ee_mod_update_nginx() fi # Update PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) to --wpsc --w3tc --wpfc options - elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then + elif [ "$EE_SITE_CURRENT_TYPE" = "--php" ] || [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then sed -i 's/include common\/php.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? @@ -68,7 +65,7 @@ function ee_mod_update_nginx() fi # Update --wpsc (--wp/--wpsubdir/--wpsubdomain) to --basic --w3tc --wpfc options - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then sed -i 's/include common\/wpsc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? @@ -81,7 +78,7 @@ function ee_mod_update_nginx() fi # Update --w3tc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --wpfc options - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then + elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then sed -i 's/include common\/w3tc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? @@ -94,7 +91,7 @@ function ee_mod_update_nginx() fi # Update --wpfc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --w3tc options - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then + elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then sed -i 's/include common\/wpfc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? @@ -108,7 +105,7 @@ function ee_mod_update_nginx() fi # Add WordPress common file wpcommon.conf for HTML PHP & MYSQL sites - if [[ "$EE_SITE_CURRENT_OPTION" = "HTML" || "$EE_SITE_CURRENT_OPTION" = "PHP" || "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]] && \ + if [[ "$EE_SITE_CURRENT_TYPE" = "--html" || "$EE_SITE_CURRENT_TYPE" = "--php" || "$EE_SITE_CURRENT_TYPE" = "--mysql" ]] && \ [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]]; then sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? fi @@ -116,10 +113,10 @@ function ee_mod_update_nginx() # Update server_name for HTML PHP MYSQL WP (single site) only # Don't execute for WordPress Multisite if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]; then + && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" ] \ + && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" ] \ + && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" ] \ + && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]; then sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" /etc/nginx/sites-available/$EE_DOMAIN && \ sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' /etc/nginx/sites-available/$EE_DOMAIN && \ From 4d2c1cd411b38127542c39448c389abb57c84d46 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 3 Nov 2014 16:00:29 +0530 Subject: [PATCH 374/829] Fix wpsc.conf typo mistake --- src/modules/site/update/ee_mod_update_nginx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh index 30c0f4c4..aa5156fe 100644 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -70,7 +70,7 @@ function ee_mod_update_nginx() sed -i 's/include common\/wpsc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + sed -i 's/include common\/wpsc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ From 988d1af19d852f6dde8f793edbbe2888b17e8cec Mon Sep 17 00:00:00 2001 From: pjv Date: Mon, 3 Nov 2014 14:57:50 -0600 Subject: [PATCH 375/829] fix for robots.txt location Allow wordpress to generate robots.txt file if static file does not exist --- config/nginx/common/locations.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/nginx/common/locations.conf b/config/nginx/common/locations.conf index d6495a85..0c5623e1 100644 --- a/config/nginx/common/locations.conf +++ b/config/nginx/common/locations.conf @@ -9,8 +9,9 @@ location = /favicon.ico { } location = /robots.txt { - access_log off; - log_not_found off; + try_files $uri $uri/ /index.php?$args; + access_log off; + log_not_found off; } # Cache static files From 00dfe443b540c7e267f5a7dfaba29a004800b39e Mon Sep 17 00:00:00 2001 From: pjv Date: Mon, 3 Nov 2014 15:03:21 -0600 Subject: [PATCH 376/829] whitespace --- config/nginx/common/locations.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/nginx/common/locations.conf b/config/nginx/common/locations.conf index 0c5623e1..3265ae25 100644 --- a/config/nginx/common/locations.conf +++ b/config/nginx/common/locations.conf @@ -9,9 +9,9 @@ location = /favicon.ico { } location = /robots.txt { - try_files $uri $uri/ /index.php?$args; - access_log off; - log_not_found off; + try_files $uri $uri/ /index.php?$args; + access_log off; + log_not_found off; } # Cache static files From 3c06170e5c932459bb58e2c951225d455fe7b330 Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Tue, 4 Nov 2014 10:22:21 -0800 Subject: [PATCH 377/829] Added php tags on ee-config.php for --mysql install so you can use include() and requre() --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 481b4678..9c6219bb 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -425,7 +425,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_setup_database # Add Database Information On ee-config.php - echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ + echo -e "" \ &>> /var/www/$EE_DOMAIN/ee-config.php fi From 86c392cd17bc1e417ec49d6a5a1f8f4e1f1c5257 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 5 Nov 2014 12:58:15 +0530 Subject: [PATCH 378/829] Added Ubuntu 14.10 support --- bin/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/install b/bin/install index b26838ac..38ff5d48 100644 --- a/bin/install +++ b/bin/install @@ -52,9 +52,9 @@ if [ "$EE_LINUX_DISTRO" != "Ubuntu" ] && [ "$EE_LINUX_DISTRO" != "Debian" ]; the fi # EasyEngine (ee) only support all Ubuntu/Debian distro except the distro reached EOL -lsb_release -d | egrep -e "12.04|14.04|squeeze|wheezy" &>> /dev/null +lsb_release -d | egrep -e "12.04|14.04|14.10|squeeze|wheezy" &>> /dev/null if [ "$?" -ne "0" ]; then - ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04 and Debian 6.x/7.x" + ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04/14.10 and Debian 6.x/7.x" exit 100 fi From 5ad0e745722c97632a6286dcded82cc725e8c4a2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 14:14:01 +0530 Subject: [PATCH 379/829] Fixed Swap file permission --- src/lib/ee_lib_swap.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/ee_lib_swap.sh b/src/lib/ee_lib_swap.sh index 5f9edba0..f375afac 100644 --- a/src/lib/ee_lib_swap.sh +++ b/src/lib/ee_lib_swap.sh @@ -24,6 +24,11 @@ function ee_lib_swap() # Add entry into /etc/fstab echo "/ee-swapfile none swap sw 0 0" >> /etc/fstab \ || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $? + + # Change Permission for swapfile + chown root:root /ee-swapfile && + chmod 0600 /ee-swapfile \ + || ee_lib_error "Unable to change Swapfile permission, exit status = " $? fi fi } From 6bc84606273ef15f2555ce8142b30b401ca31539 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 14:16:14 +0530 Subject: [PATCH 380/829] Fixed Swap file permission --- src/lib/ee_lib_swap.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/ee_lib_swap.sh b/src/lib/ee_lib_swap.sh index f375afac..1cb20de7 100644 --- a/src/lib/ee_lib_swap.sh +++ b/src/lib/ee_lib_swap.sh @@ -17,6 +17,11 @@ function ee_lib_swap() mkswap /ee-swapfile &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to create swapfile, exit status = " $? + # Change Permission for swapfile + chown root:root /ee-swapfile && + chmod 0600 /ee-swapfile \ + || ee_lib_error "Unable to change Swapfile permission, exit status = " $? + # On the Swap swapon /ee-swapfile &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to on Swap, exit status = " $? @@ -24,11 +29,6 @@ function ee_lib_swap() # Add entry into /etc/fstab echo "/ee-swapfile none swap sw 0 0" >> /etc/fstab \ || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $? - - # Change Permission for swapfile - chown root:root /ee-swapfile && - chmod 0600 /ee-swapfile \ - || ee_lib_error "Unable to change Swapfile permission, exit status = " $? fi fi } From 5c1714dbcdd35234c0d45959e9ec2ce030d78d41 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 14:34:10 +0530 Subject: [PATCH 381/829] Fixed Poodle bug issue for Ubuntu 12.04 --- .../stack/install/mail/ee_mod_setup_dovecot.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index b395a664..76126c8e 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -22,7 +22,7 @@ function ee_mod_setup_dovecot() # Configuring 10-mail.conf sed -i "s/mail_location = mbox:~\/mail:INBOX=\/var\/mail\/%u/mail_location = maildir:\/var\/vmail\/%d\/%n/" /etc/dovecot/conf.d/10-mail.conf \ || ee_lib_error "Unable to configure Dovecot mail_location, exit status = " $? - + # Configuring 10-auth.conf sed -i "s/#disable_plaintext_auth = yes/disable_plaintext_auth = no/" /etc/dovecot/conf.d/10-auth.conf && \ sed -i "s/auth_mechanisms = plain/auth_mechanisms = plain login/" /etc/dovecot/conf.d/10-auth.conf && \ @@ -31,7 +31,14 @@ function ee_mod_setup_dovecot() || ee_lib_error "Unable to setup 10-auth.conf file, exit status = " $? # Configuring 10-ssl.conf, Disable SSLv2 and SSLv3, Fixes POODLE Bug - sed -i "s/#ssl_protocols =.*/ssl_protocols = \!SSLv2 \!SSLv3/" /etc/dovecot/conf.d/10-ssl.conf + grep ssl_protocols /etc/dovecot/conf.d/10-ssl.conf &>> $EE_COMMAND_LOG + if [ $? -eq 0 ]; then + # For Ubuntu 14.04, Debian 6 and Debian 7 10-ssl.conf file contains commented #ssl_protocol variable + sed -i "s/#ssl_protocols =.*/ssl_protocols = \!SSLv2 \!SSLv3/" /etc/dovecot/conf.d/10-ssl.conf + else + # For Ubuntu 12.04 10-ssl.conf file does not contain commented #ssl-protocols variable + echo 'ssl_protocols = !SSLv2 !SSLv3' >> /etc/dovecot/conf.d/10-ssl.conf + fi # Configuring dovecot-sql.conf.ext cp -v /usr/share/easyengine/mail/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext &>> $EE_COMMAND_LOG \ From da1dc46091aa58324ab7b6ddc5ed4f4c4867303b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 15:01:12 +0530 Subject: [PATCH 382/829] Fixed Travis Ref:https://github.com/travis-ci/travis-ci/issues/2934 --- .travis.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index e96328bc..68678607 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ language: bash before_install: - +- chmod 066 ~/.gnupg/gpg.conf before_script: - sudo apt-get -qq purge mysql* graphviz* @@ -40,7 +40,7 @@ script: - sudo bash ee site create site2.com --wpsc - sudo bash ee site create site2.net --wp --wpsc -- sudo bash ee site create site2.org --wpsc --wp +- sudo bash ee site create site2.org --wpsc --wp - sudo bash ee site create site3.com --w3tc - sudo bash ee site create site3.net --wp --w3tc @@ -48,7 +48,7 @@ script: - sudo bash ee site create site4.com --wpfc - sudo bash ee site create site4.net --wp --wpfc -- sudo bash ee site create site4.org --wpfc --wp +- sudo bash ee site create site4.org --wpfc --wp - sudo bash ee site create site5.com --wpsubdir - sudo bash ee site create site5.net --wpsubdir --basic @@ -100,9 +100,9 @@ script: - sudo bash ee debug --nginx site1.com - sudo bash ee debug --nginx site1.com --stop -- sudo bash ee debug -rewrite +- sudo bash ee debug -rewrite - sudo bash ee debug -rewrite --stop -- sudo bash ee debug -rewrite site1.com +- sudo bash ee debug -rewrite site1.com - sudo bash ee debug -rewrite site1.com --stop - sudo bash ee debug --php @@ -148,4 +148,3 @@ script: - sudo wp --allow-root --info - From c98b4a51211c63ae76a0c96fe1c0c1ceca1eb619 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 15:38:23 +0530 Subject: [PATCH 383/829] Fixed Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 68678607..bda58e9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ language: bash before_install: -- chmod 066 ~/.gnupg/gpg.conf +- chmod 600 ~/.gnupg/gpg.conf before_script: - sudo apt-get -qq purge mysql* graphviz* From f75fa1c05373ae3e06a2933d1d0637669fd1d257 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 16:49:56 +0530 Subject: [PATCH 384/829] Fixed Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bda58e9d..b1a89d48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ language: bash before_install: -- chmod 600 ~/.gnupg/gpg.conf +- sudo bash -c 'chmod 600 /root/.gnupg/gpg.conf' before_script: - sudo apt-get -qq purge mysql* graphviz* From c1e3f1a24bfb720037715b4007b4738d80fe3ba8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 16:52:48 +0530 Subject: [PATCH 385/829] Fixed Travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b1a89d48..2c65bbbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,8 @@ language: bash before_install: -- sudo bash -c 'chmod 600 /root/.gnupg/gpg.conf' +- chmod 600 ~/.gnupg/gpg.conf +- ls -al ~/.gnupg/gpg.conf before_script: - sudo apt-get -qq purge mysql* graphviz* From cbc8119982a18bf64979abc10f7e6660febf2a85 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 16:57:28 +0530 Subject: [PATCH 386/829] Fixed Travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2c65bbbb..2d469844 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ language: bash before_install: +- ls -al ~/.gnupg/gpg.conf - chmod 600 ~/.gnupg/gpg.conf - ls -al ~/.gnupg/gpg.conf From 6d0bb0453d06efcec822d27629fad9a4a40a98a4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 17:04:17 +0530 Subject: [PATCH 387/829] Fixed Travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2d469844..8b7be13b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,8 @@ before_install: - ls -al ~/.gnupg/gpg.conf - chmod 600 ~/.gnupg/gpg.conf - ls -al ~/.gnupg/gpg.conf +- sudo chown travis:travis ~/.gnupg/gpg.conf +- ls -al ~/.gnupg/gpg.conf before_script: - sudo apt-get -qq purge mysql* graphviz* From 0a78add09d54c66c4c605c859e1b65c4dbdb3039 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 17:37:30 +0530 Subject: [PATCH 388/829] Fixed Travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8b7be13b..b27b35e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ before_install: - ls -al ~/.gnupg/gpg.conf - sudo chown travis:travis ~/.gnupg/gpg.conf - ls -al ~/.gnupg/gpg.conf +- sudo chgrp -R travis ~/.gnupg +- ls -al ~/.gnupg/gpg.conf before_script: - sudo apt-get -qq purge mysql* graphviz* From 0e48ae658d302a5879ae2d3164d4c210e0a78869 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 17:50:03 +0530 Subject: [PATCH 389/829] Fixed Travis --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b27b35e2..0df1e3e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,10 @@ language: bash before_install: -- ls -al ~/.gnupg/gpg.conf +- sudo chown -R travis ~travis/.gnupg - chmod 600 ~/.gnupg/gpg.conf - ls -al ~/.gnupg/gpg.conf -- sudo chown travis:travis ~/.gnupg/gpg.conf -- ls -al ~/.gnupg/gpg.conf -- sudo chgrp -R travis ~/.gnupg +- chmod 700 ~/.gnupg - ls -al ~/.gnupg/gpg.conf before_script: From 1ab35b9491d101478862db3789f3b5cecd5ef4b8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 5 Nov 2014 19:01:46 +0530 Subject: [PATCH 390/829] Fixed Travis.. finnaly.. --- .travis.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0df1e3e0..ad15332d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,20 +8,13 @@ notifications: language: bash - - before_install: -- sudo chown -R travis ~travis/.gnupg -- chmod 600 ~/.gnupg/gpg.conf -- ls -al ~/.gnupg/gpg.conf -- chmod 700 ~/.gnupg -- ls -al ~/.gnupg/gpg.conf +- rm -rf ~/.gnupg before_script: - sudo apt-get -qq purge mysql* graphviz* - sudo apt-get -qq autoremove - script: - sudo echo -e "[user]\n\tname = Mitesh Shah\n\temail = root@localhost.com" > ~/.gitconfig - sudo echo "Travis Banch = $TRAVIS_BRANCH" From bfaa68b13cd2d9b1a6efc44b24a39e05c518fa3d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 6 Nov 2014 12:49:59 +0530 Subject: [PATCH 391/829] Fixed \n issue on pull request #347 --- bin/easyengine | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 9c6219bb..dbe38938 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -56,11 +56,11 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Fix GnuPG key ee_lib_gpg_key_fix - fi + fi if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then # Execute: apt-get update - ee_lib_apt_get_update + ee_lib_apt_get_update # Install NGINX/PHP/MySQL/Postfix package ee_mod_install_$EE_THIRD @@ -81,7 +81,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then else # Restart NGINX/MySQL/Postfix ee_lib_service $EE_THIRD restart - + # Initialize Git ee_lib_git /etc/$EE_THIRD/ "Initialize Git" fi @@ -103,7 +103,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_lib_gpg_key_fix # Execute: apt-get update - ee_lib_apt_get_update + ee_lib_apt_get_update # Install NGINX/PHP/MySQL/Postfix package ee_mod_install_nginx @@ -118,7 +118,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Restart NGINX/MySQL/Postfix ee_lib_service nginx php5-fpm mysql restart - + # Initialize Git ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git" @@ -184,7 +184,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then ee_mod_setup_mailscaner else ee_lib_echo_fail "RAM is less then 512MB, EasyEngine skip installing Mail Scanner Packages" - + fi ee_lib_service nginx postfix dovecot amavis restart @@ -200,7 +200,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then if [ $? -ne 0 ];then ee_lib_error "Failed to find Dovecot Packages, exit status = " 1 fi - + # Install Mail Scanner ee_mod_install_mailscaner @@ -266,7 +266,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Remove Dovecot ee_mod_remove_dovecot - # Remove Mail Scanner + # Remove Mail Scanner ee_mod_remove_mailscaner # Remove ViMbAdmin @@ -396,7 +396,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_git /etc/nginx/ "Edit website: $EE_DOMAIN" # Execute: service nginx reload - ee_lib_service nginx reload + ee_lib_service nginx reload fi elif [ "$EE_SECOND" = "create" ]; then # Configure variables @@ -409,7 +409,7 @@ elif [ "$EE_FIRST" = "site" ]; then # Install required packages ee_mod_site_packages - + # Lets create HTML|PHP|MySQL website if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then # Configure variable @@ -425,7 +425,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_setup_database # Add Database Information On ee-config.php - echo -e "" \ + echo -e "" \ &>> /var/www/$EE_DOMAIN/ee-config.php fi @@ -563,10 +563,10 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_DELETE_ARGS" = "--all" ]; then # Delete MySQL database ee_mod_delete_database $EE_FIFTH - + # Delete webroot ee_mod_delete_webroot $EE_FIFTH - + # Delete NGINX configuration file ee_mod_delete_nginxconf $EE_FIFTH @@ -581,7 +581,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_DOMAIN_CHECK=$EE_THIRD EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION=$EE_FIFTH - + # Check the website name is empty or not ee_lib_check_domain @@ -610,13 +610,13 @@ elif [ "$EE_FIRST" = "site" ]; then # Lets update HTML|PHP|MySQL website if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - + # Update NGINX configuration for $EE_DOMAIN if [[ "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then ee_mod_update_domain - else + else ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? fi @@ -666,7 +666,7 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ && [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then - + if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE BASIC" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]] \ || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ @@ -674,7 +674,7 @@ elif [ "$EE_FIRST" = "site" ]; then || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain - else + else ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? fi # Setup WordPress Network @@ -694,7 +694,7 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ]]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain - else + else ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? fi # Update cache plugins @@ -710,7 +710,7 @@ elif [ "$EE_FIRST" = "site" ]; then || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ]]; then # Update NGINX configuration for $EE_DOMAIN ee_mod_update_domain - else + else ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? fi # Update cache plugins @@ -721,7 +721,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi # Adjust permission ee_lib_permissions - + # Execute: service nginx reload ee_lib_service nginx reload @@ -749,7 +749,7 @@ elif [ "$EE_FIRST" = "site" ]; then if [ $? -eq 0 ]; then ee_site_cd fi - + else ee_lib_echo "ee site commands:" ee_lib_echo_escape "\tcd\tSwitch to website root directory" @@ -888,7 +888,7 @@ elif [ "$EE_FIRST" = "import-slow-log" ];then elif [ "$EE_FIRST" = "update" ]; then ee_lib_echo "Checking EasyEngine(ee) update, please wait..." wget --no-check-certificate -qO eeup http://rt.cx/eeup && sudo bash eeup - + else ee_lib_echo "EasyEngine (ee) commands:" ee_lib_echo_escape "\tversion\tDisplay EasyEngine (ee) version" From 033cac5d1caa096cc4b54e66c07eb633fee0c36d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 6 Nov 2014 12:57:10 +0530 Subject: [PATCH 392/829] Added comment --- config/nginx/common/locations.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/nginx/common/locations.conf b/config/nginx/common/locations.conf index 3265ae25..01f3013f 100644 --- a/config/nginx/common/locations.conf +++ b/config/nginx/common/locations.conf @@ -9,6 +9,8 @@ location = /favicon.ico { } location = /robots.txt { + # Some WordPress plugin gererate robots.txt file + # Refer #340 issue try_files $uri $uri/ /index.php?$args; access_log off; log_not_found off; From 184afcc87a463454960b3c5e0de6bbce4618e845 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 6 Nov 2014 13:16:31 +0530 Subject: [PATCH 393/829] Fixed PHP log issue --- src/modules/stack/install/ee_mod_install_php.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/stack/install/ee_mod_install_php.sh b/src/modules/stack/install/ee_mod_install_php.sh index db30fadd..a3738ef7 100644 --- a/src/modules/stack/install/ee_mod_install_php.sh +++ b/src/modules/stack/install/ee_mod_install_php.sh @@ -5,5 +5,5 @@ function ee_mod_install_php() ee_lib_echo "Installing PHP, please wait..." $EE_APT_GET install php5-common php5-mysqlnd php5-xmlrpc \ php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached php5-geoip || ee_lib_error "Unable to install PHP5, exit status = " $? + php5-memcache memcached php5-geoip 2>&1 || ee_lib_error "Unable to install PHP5, exit status = " $? } From 39b0f26dd6070236cc80d31a6f35179f9f02985a Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Thu, 6 Nov 2014 15:53:03 +0530 Subject: [PATCH 394/829] Revert "Typo in wpsc.conf" --- config/nginx/common/wpsc.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/nginx/common/wpsc.conf b/config/nginx/common/wpsc.conf index 3605189d..ccbb4216 100644 --- a/config/nginx/common/wpsc.conf +++ b/config/nginx/common/wpsc.conf @@ -24,7 +24,7 @@ if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_lo # Use cached or actual file if they exists, Otherwise pass request to WordPress location / { - try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php?$args; + try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php$args; } location ~ \.php$ { From 6e3992b2afd3edf78f259e519d57e9dfb4629de0 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 6 Nov 2014 16:36:37 +0530 Subject: [PATCH 395/829] Removed from wpsc.conf #330 --- config/nginx/common/wpsc.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/nginx/common/wpsc.conf b/config/nginx/common/wpsc.conf index ccbb4216..26982e3d 100644 --- a/config/nginx/common/wpsc.conf +++ b/config/nginx/common/wpsc.conf @@ -24,7 +24,9 @@ if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_lo # Use cached or actual file if they exists, Otherwise pass request to WordPress location / { - try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php$args; + # If we add index.php?$args its break WooCommerce like plugins + # Ref: #330 + try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php; } location ~ \.php$ { From a2625a2b624a95e20a3f1f46a94aa665a66e889b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 6 Nov 2014 16:48:48 +0530 Subject: [PATCH 396/829] Display DB_HOST in ee site info --- src/modules/site/ee_mod_site_info.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/site/ee_mod_site_info.sh b/src/modules/site/ee_mod_site_info.sh index fdbff096..805c8d51 100644 --- a/src/modules/site/ee_mod_site_info.sh +++ b/src/modules/site/ee_mod_site_info.sh @@ -7,7 +7,7 @@ function ee_mod_site_info() local ee_access_log=$(grep access_log /etc/nginx/sites-available/$EE_DOMAIN | grep "/var/log/nginx/" | awk '{print($2)}' | cut -d ';' -f1) local ee_error_log=$(grep error_log /etc/nginx/sites-available/$EE_DOMAIN | grep "/var/log/nginx/" | awk '{print($2)}' | cut -d ';' -f1) local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | grep htdocs | awk '{print($2)}' | cut -d ';' -f1) - + ee_lib_echo "Information about $EE_DOMAIN:" ee_lib_echo_escape "\nNginx configuration\t \033[37m$ee_site_info ($ee_site_status)" ee_lib_echo_escape "access_log\t\t \033[37m$ee_access_log" @@ -16,17 +16,19 @@ function ee_mod_site_info() if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + local ee_db_host=$(grep DB_HOST $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) local ee_db_user=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) local ee_db_pass=$(grep DB_PASS $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + ee_lib_echo_escape "DB_HOST\t\t\t \033[37m$ee_db_host" ee_lib_echo_escape "DB_NAME\t\t\t \033[37m$ee_db_name" ee_lib_echo_escape "DB_USER\t\t\t \033[37m$ee_db_user" ee_lib_echo_escape "DB_PASS\t\t\t \033[37m$ee_db_pass" - + if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/wp-config.php/') ]; then local ee_table_prefix=$(grep table_prefix $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/wp-config.php/') | cut -d"'" -f2) ee_lib_echo_escape "table_prefix\t\t \033[37m$ee_table_prefix" - fi + fi fi } From 0b81f3577b5ea4ee5ef5133b65d45b35c347af25 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 7 Nov 2014 11:27:39 +0530 Subject: [PATCH 397/829] Minor changes --- .travis.yml | 13 +++++++++++++ src/lib/ee_lib_autoremove.sh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ad15332d..f20bb3fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -131,6 +131,19 @@ script: - sudo bash ee site update 1.com --wp - sudo bash ee site update 2.com --wpsubdir +- sudo bash ee site update 3.com --wpsubdomain +- sudo bash ee site update site1.com --wp --wpfc +- sudo bash ee site update site1.com --wp --w3tc +- sudo bash ee site update site1.com --wp --wpsc + +- sudo bash ee site update site5.com --wpsubdir --wpfc +- sudo bash ee site update site5.com --wpsubdir --w3tc +- sudo bash ee site update site5.com --wpsubdir --wpsc + +- sudo bash ee site update site9.com --wpsubdom --wpfc +- sudo bash ee site update site9.com --wpsubdom --w3tc +- sudo bash ee site update site9.com --wpsubdom --wpsc + - sudo ee site delete site12.com --no-prompt - sudo ee site delete site12.net --no-prompt - sudo ee site delete site12.org --no-prompt diff --git a/src/lib/ee_lib_autoremove.sh b/src/lib/ee_lib_autoremove.sh index bdc9ae6a..7545507b 100644 --- a/src/lib/ee_lib_autoremove.sh +++ b/src/lib/ee_lib_autoremove.sh @@ -4,4 +4,4 @@ function ee_lib_autoremove() { ee_lib_echo "Removing unwanted packages, please wait..." $EE_APT_GET autoremove -} \ No newline at end of file +} From 19228ab4e2f6212eec7937f606a4c8489940c47b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 7 Nov 2014 20:02:46 +0530 Subject: [PATCH 398/829] Migrate command started --- bin/easyengine | 32 ++++++++++++++++++++++ src/modules/site/migrate/ee_mod_migrate.sh | 6 ++++ 2 files changed, 38 insertions(+) create mode 100644 src/modules/site/migrate/ee_mod_migrate.sh diff --git a/bin/easyengine b/bin/easyengine index 97d157c9..0c26d1b1 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -15,6 +15,12 @@ EE_SECOND=$2 EE_THIRD=$3 EE_FOURTH=$4 EE_FIFTH=$5 +EE_SIXTH=$6 +EE_SEVENTH=$7 +EE_EIGTH=$8 +EE_NINTH=$9 +EE_TENTH=${10} +EE_ELEVENTH=${11} # Let's capture the EasyEngine arguments ee_lib_echo "EasyEngine (ee) $EE_VERSION execution started [$(date)]" &>> $EE_COMMAND_LOG @@ -714,6 +720,32 @@ elif [ "$EE_FIRST" = "site" ]; then ee_site_cd fi + elif [ "$EE_SECOND" = "migrate" ]; then + # Configure variables + EE_DOMAIN_CHECK=$EE_THIRD + EE_SITE_CREATE_OPTION=$EE_FOURTH + + if [ "$EE_FIFTH%=*" = "--remote-server" ]; then + EE_SITE_CACHE_OPTION="" + EE_REMOTE_SERVER=$EE_FIFTH + EE_REMOTE_USER=$EE_SIXTH + EE_REMOTE_PASSWORD=$EE_SEVENTH + EE_REMOTE_METHOD=$EE_EIGTH + EE_REMOTE_PATH=$EE_NINTH + EE_MYSQL_PATH=$EE_TENTH + else + EE_SITE_CACHE_OPTION=$EE_FIFTH + EE_REMOTE_SERVER=$EE_SIXTH + EE_REMOTE_USER=$EE_SEVENTH + EE_REMOTE_PASSWORD=$EE_EIGTH + EE_REMOTE_METHOD=$EE_NINTH + EE_REMOTE_PATH=$EE_TENTH + EE_MYSQL_PATH=$EE_ELEVENTH + fi + + # Auto switch site options + ee_mod_site_option + else ee_lib_echo "ee site commands:" ee_lib_echo_escape "\tcd\tSwitch to website root directory" diff --git a/src/modules/site/migrate/ee_mod_migrate.sh b/src/modules/site/migrate/ee_mod_migrate.sh new file mode 100644 index 00000000..dbc60d1a --- /dev/null +++ b/src/modules/site/migrate/ee_mod_migrate.sh @@ -0,0 +1,6 @@ +# Function for site migration module + +function ee_mod_migrate() +{ + +} From d5f17d78a7bcf55a2df3211d7b82cdfaf3f9b734 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 12:12:18 +0530 Subject: [PATCH 399/829] Improved ee site migrate --- bin/easyengine | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 0c26d1b1..5886a405 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -725,7 +725,15 @@ elif [ "$EE_FIRST" = "site" ]; then EE_DOMAIN_CHECK=$EE_THIRD EE_SITE_CREATE_OPTION=$EE_FOURTH - if [ "$EE_FIFTH%=*" = "--remote-server" ]; then + if [ "$EE_FOURTH%=*" = "--remote-server" ]; then + EE_SITE_CACHE_OPTION="" + EE_REMOTE_SERVER=$EE_FOURTH + EE_REMOTE_USER=$EE_FIFTH + EE_REMOTE_PASSWORD=$EE_SIXTH + EE_REMOTE_METHOD=$EE_SEVENTH + EE_REMOTE_PATH=$EE_EIGHT + EE_MYSQL_PATH=$EE_NINTH + elif [ "$EE_FIFTH%=*" = "--remote-server" ]; then EE_SITE_CACHE_OPTION="" EE_REMOTE_SERVER=$EE_FIFTH EE_REMOTE_USER=$EE_SIXTH From 7f6677ef5754e52b7f5edba4ba7e7aa61f7d2b6d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 13:03:09 +0530 Subject: [PATCH 400/829] Improved ee site migrate --- bin/easyengine | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/easyengine b/bin/easyengine index 5886a405..27e55f19 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -726,6 +726,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_SITE_CREATE_OPTION=$EE_FOURTH if [ "$EE_FOURTH%=*" = "--remote-server" ]; then + EE_SITE_CREATE_OPTION="" EE_SITE_CACHE_OPTION="" EE_REMOTE_SERVER=$EE_FOURTH EE_REMOTE_USER=$EE_FIFTH @@ -742,6 +743,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_REMOTE_PATH=$EE_NINTH EE_MYSQL_PATH=$EE_TENTH else + EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION=$EE_FIFTH EE_REMOTE_SERVER=$EE_SIXTH EE_REMOTE_USER=$EE_SEVENTH From 1182c2fb082a70b4946fa3afc2e2fb5ad1adcefa Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 13:16:34 +0530 Subject: [PATCH 401/829] Improved regrex --- bin/easyengine | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 27e55f19..07827e85 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -723,9 +723,8 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_SECOND" = "migrate" ]; then # Configure variables EE_DOMAIN_CHECK=$EE_THIRD - EE_SITE_CREATE_OPTION=$EE_FOURTH - if [ "$EE_FOURTH%=*" = "--remote-server" ]; then + if [ "${EE_FOURTH%=*}" = "--remote-server" ]; then EE_SITE_CREATE_OPTION="" EE_SITE_CACHE_OPTION="" EE_REMOTE_SERVER=$EE_FOURTH @@ -734,7 +733,8 @@ elif [ "$EE_FIRST" = "site" ]; then EE_REMOTE_METHOD=$EE_SEVENTH EE_REMOTE_PATH=$EE_EIGHT EE_MYSQL_PATH=$EE_NINTH - elif [ "$EE_FIFTH%=*" = "--remote-server" ]; then + elif [ "${EE_FIFTH%=*}" = "--remote-server" ]; then + EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION="" EE_REMOTE_SERVER=$EE_FIFTH EE_REMOTE_USER=$EE_SIXTH From 7ec269b7777b7a57cbee9427b18ff1b9b3047093 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 13:53:59 +0530 Subject: [PATCH 402/829] Some improvement in code --- bin/easyengine | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 07827e85..8835968a 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -727,30 +727,30 @@ elif [ "$EE_FIRST" = "site" ]; then if [ "${EE_FOURTH%=*}" = "--remote-server" ]; then EE_SITE_CREATE_OPTION="" EE_SITE_CACHE_OPTION="" - EE_REMOTE_SERVER=$EE_FOURTH - EE_REMOTE_USER=$EE_FIFTH - EE_REMOTE_PASSWORD=$EE_SIXTH - EE_REMOTE_METHOD=$EE_SEVENTH - EE_REMOTE_PATH=$EE_EIGHT - EE_MYSQL_PATH=$EE_NINTH + EE_REMOTE_SERVER=${EE_FOURTH##*=} + EE_REMOTE_USER=${EE_FIFTH##*=} + EE_REMOTE_PASSWORD=${EE_SIXTH##*=} + EE_REMOTE_METHOD=${EE_SEVENTH##*=} + EE_REMOTE_PATH=${EE_EIGHT##*=} + EE_MYSQL_PATH=${EE_NINTH##*=} elif [ "${EE_FIFTH%=*}" = "--remote-server" ]; then EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION="" - EE_REMOTE_SERVER=$EE_FIFTH - EE_REMOTE_USER=$EE_SIXTH - EE_REMOTE_PASSWORD=$EE_SEVENTH - EE_REMOTE_METHOD=$EE_EIGTH - EE_REMOTE_PATH=$EE_NINTH - EE_MYSQL_PATH=$EE_TENTH + EE_REMOTE_SERVER=${EE_FIFTH##*=} + EE_REMOTE_USER=${EE_SIXTH##*=} + EE_REMOTE_METHOD=${EE_EIGTH##*=} + EE_REMOTE_PASSWORD=${EE_SEVENTH##*=} + EE_REMOTE_PATH=${EE_NINTH##*=} + EE_MYSQL_PATH=${EE_TENTH##*=} else EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION=$EE_FIFTH - EE_REMOTE_SERVER=$EE_SIXTH - EE_REMOTE_USER=$EE_SEVENTH - EE_REMOTE_PASSWORD=$EE_EIGTH - EE_REMOTE_METHOD=$EE_NINTH - EE_REMOTE_PATH=$EE_TENTH - EE_MYSQL_PATH=$EE_ELEVENTH + EE_REMOTE_SERVER=${EE_SIXTH##*=} + EE_REMOTE_USER=${EE_SEVENTH##*=} + EE_REMOTE_PASSWORD=${EE_EIGTH##*=} + EE_REMOTE_METHOD=${EE_NINTH##*=} + EE_REMOTE_PATH=${EE_TENTH##*=} + EE_MYSQL_PATH=${EE_ELEVENTH##*=} fi # Auto switch site options From 3dbd57547cbdd0b5adcb3b60c8f1227b7151dffb Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 14:05:28 +0530 Subject: [PATCH 403/829] Fixed Typo --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 8835968a..f9e46229 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -731,7 +731,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_REMOTE_USER=${EE_FIFTH##*=} EE_REMOTE_PASSWORD=${EE_SIXTH##*=} EE_REMOTE_METHOD=${EE_SEVENTH##*=} - EE_REMOTE_PATH=${EE_EIGHT##*=} + EE_REMOTE_PATH=${EE_EIGTH##*=} EE_MYSQL_PATH=${EE_NINTH##*=} elif [ "${EE_FIFTH%=*}" = "--remote-server" ]; then EE_SITE_CREATE_OPTION=$EE_FOURTH From 3bb9dc688c5573a5eef11b13fbe379dd4357f219 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 14:38:44 +0530 Subject: [PATCH 404/829] Added data migration throught rsync/sftp/ftp --- bin/easyengine | 3 +++ src/modules/site/migrate/ee_mod_migrate.sh | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 src/modules/site/migrate/ee_mod_migrate.sh diff --git a/bin/easyengine b/bin/easyengine index f9e46229..9bef6474 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -756,6 +756,9 @@ elif [ "$EE_FIRST" = "site" ]; then # Auto switch site options ee_mod_site_option + # Migrate Data + ee_mod_migrate_data + else ee_lib_echo "ee site commands:" ee_lib_echo_escape "\tcd\tSwitch to website root directory" diff --git a/src/modules/site/migrate/ee_mod_migrate.sh b/src/modules/site/migrate/ee_mod_migrate.sh deleted file mode 100644 index dbc60d1a..00000000 --- a/src/modules/site/migrate/ee_mod_migrate.sh +++ /dev/null @@ -1,6 +0,0 @@ -# Function for site migration module - -function ee_mod_migrate() -{ - -} From 272a99c93c668831634470d0b72d31a3a7f1d8e8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 14:40:41 +0530 Subject: [PATCH 405/829] Added data migration throught rsync/sftp/ftp --- .../site/migrate/ee_mod_migrate_data.sh | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/modules/site/migrate/ee_mod_migrate_data.sh diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh new file mode 100644 index 00000000..71cff656 --- /dev/null +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -0,0 +1,25 @@ +# Function for site migration module + +function ee_mod_migrate_data() +{ + rm -rf /ee-backup/$EE_DOMAIN && mkdir -p /ee-backup/$EE_DOMAIN/ && cd /ee-backup/$EE_DOMAIN/ + if [ "$EE_REMOTE_METHOD" == "ssh" ]; then + # Lets FTP or rsync files + rsync -avz --progress $USER@$HOST:$DIR/ /ee-backup/$EE_DOMAIN/ + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then + rsync -avz --progress $USER@$HOST:$DIR/../wp-config.php /ee-backup/$EE_DOMAIN/ + fi + + elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then + lftp -e "mirror -c $DIR" ftp://$USER@$HOST + if [ ! -f /var/www/$SITE/htdocs/wp-config.php ]; then + lftp -e "get $DIR/../wp-config.php" ftp://$USER@$HOST + fi + + elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then + lftp -e "mirror -c $DIR" sftp://$USER@$HOST + if [ ! -f /var/www/$SITE/htdocs/wp-config.php ]; then + lftp -e "get $DIR/../wp-config.php" ftp://$USER@$HOST + fi + fi +} From ba41837197ed5c57236e0eaf293a3d0b52d01a54 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 15:06:58 +0530 Subject: [PATCH 406/829] Fixed Varibaled in Migration --- src/modules/site/migrate/ee_mod_migrate_data.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 71cff656..130ae85c 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -5,21 +5,21 @@ function ee_mod_migrate_data() rm -rf /ee-backup/$EE_DOMAIN && mkdir -p /ee-backup/$EE_DOMAIN/ && cd /ee-backup/$EE_DOMAIN/ if [ "$EE_REMOTE_METHOD" == "ssh" ]; then # Lets FTP or rsync files - rsync -avz --progress $USER@$HOST:$DIR/ /ee-backup/$EE_DOMAIN/ + rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then - rsync -avz --progress $USER@$HOST:$DIR/../wp-config.php /ee-backup/$EE_DOMAIN/ + rsync -avz --progress $EE_REMOTE_SERVER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then - lftp -e "mirror -c $DIR" ftp://$USER@$HOST - if [ ! -f /var/www/$SITE/htdocs/wp-config.php ]; then - lftp -e "get $DIR/../wp-config.php" ftp://$USER@$HOST + lftp -e "mirror -c $EE_REMOTE_PATH" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then + lftp -e "get $EE_REMOTE_PATH/../wp-config.php" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then - lftp -e "mirror -c $DIR" sftp://$USER@$HOST - if [ ! -f /var/www/$SITE/htdocs/wp-config.php ]; then - lftp -e "get $DIR/../wp-config.php" ftp://$USER@$HOST + lftp -e "mirror -c $EE_REMOTE_PATH" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then + lftp -e "get $EE_REMOTE_PATH/../wp-config.php" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi fi } From 11cb8e0bac09dbf745ad282d1154ef326af37263 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 15:10:49 +0530 Subject: [PATCH 407/829] Added missing function name --- bin/easyengine | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/easyengine b/bin/easyengine index 9bef6474..19739fb4 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -723,6 +723,7 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_SECOND" = "migrate" ]; then # Configure variables EE_DOMAIN_CHECK=$EE_THIRD + ee_lib_check_domain if [ "${EE_FOURTH%=*}" = "--remote-server" ]; then EE_SITE_CREATE_OPTION="" From d697060c7dc20f73bb3ac72f2e2761359f631161 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 15:14:32 +0530 Subject: [PATCH 408/829] Fixed Wrong variables --- src/modules/site/migrate/ee_mod_migrate_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 130ae85c..baa5bb3b 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -7,7 +7,7 @@ function ee_mod_migrate_data() # Lets FTP or rsync files rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then - rsync -avz --progress $EE_REMOTE_SERVER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ + rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then From de6ed828235cb54ba773a317396ca87f7b42c45f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 16:01:43 +0530 Subject: [PATCH 409/829] Improved SFTP/FTP data transfer --- src/modules/site/migrate/ee_mod_migrate_data.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index baa5bb3b..32a4ed6a 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -11,15 +11,15 @@ function ee_mod_migrate_data() fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then - lftp -e "mirror -c $EE_REMOTE_PATH" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then - lftp -e "get $EE_REMOTE_PATH/../wp-config.php" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then - lftp -e "mirror -c $EE_REMOTE_PATH" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then - lftp -e "get $EE_REMOTE_PATH/../wp-config.php" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi fi } From ed415535b1e8bed8e1155e08759f004f25ceb474 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 16:09:59 +0530 Subject: [PATCH 410/829] Fixed LFTP not quitting after data transfer --- src/modules/site/migrate/ee_mod_migrate_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 32a4ed6a..7e3c7308 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -17,7 +17,7 @@ function ee_mod_migrate_data() fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then - lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit"; sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi From b08f8a108e92e0c75de0d7ad0f643a2759a3668f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 16:57:18 +0530 Subject: [PATCH 411/829] Site creation with EE Migrate --- bin/easyengine | 36 ++++++++++++------- .../site/migrate/ee_mod_migrate_data.sh | 6 ++-- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 19739fb4..0ea26e0b 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -447,7 +447,9 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" fi # Display Success Message - ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" + if [ "$EE_MIGRATE" != "True" ]; then + ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" + fi elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then @@ -459,8 +461,11 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_check_domain ee_mod_setup_domain - # Setup WordPress - ee_mod_setup_wordpress + # If we are migrating site then Wordpress installation is not required + if [ "$EE_MIGRATE" != "True" ]; then + # Setup WordPress + ee_mod_setup_wordpress + fi # Adjust permission ee_lib_permissions @@ -477,17 +482,19 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" fi - # Display WordPress credential - echo - ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" - ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" - echo + if [ "$EE_MIGRATE" != "True" ]; then + # Display WordPress credential + echo + ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" + ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" + echo - # Display WordPress cache plugin settings - ee_mod_plugin_settings + # Display WordPress cache plugin settings + ee_mod_plugin_settings - # Display Success Message - ee_lib_echo_info "Successfully created new website: http://$EE_WWW_DOMAIN" + # Display Success Message + ee_lib_echo_info "Successfully created new website: http://$EE_WWW_DOMAIN" + fi fi fi elif [ "$EE_SECOND" = "delete" ]; then @@ -721,6 +728,8 @@ elif [ "$EE_FIRST" = "site" ]; then fi elif [ "$EE_SECOND" = "migrate" ]; then + export $EE_MIGRATE="True" + # Configure variables EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain @@ -760,6 +769,9 @@ elif [ "$EE_FIRST" = "site" ]; then # Migrate Data ee_mod_migrate_data + # Create site + ee site create $EE_DOMAIN $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION + else ee_lib_echo "ee site commands:" ee_lib_echo_escape "\tcd\tSwitch to website root directory" diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 7e3c7308..a2850f9c 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -6,19 +6,19 @@ function ee_mod_migrate_data() if [ "$EE_REMOTE_METHOD" == "ssh" ]; then # Lets FTP or rsync files rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit"; sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ]; then + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi fi From 8db478dd4a8593672022e642c2026523a9047ca3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 16:59:19 +0530 Subject: [PATCH 412/829] Fixed not a valid identifier error --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 0ea26e0b..d3d3fcd0 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -728,7 +728,7 @@ elif [ "$EE_FIRST" = "site" ]; then fi elif [ "$EE_SECOND" = "migrate" ]; then - export $EE_MIGRATE="True" + export EE_MIGRATE="True" # Configure variables EE_DOMAIN_CHECK=$EE_THIRD From 5fc4e174001c79ff3c44214136a80200540f344f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 17:09:52 +0530 Subject: [PATCH 413/829] Fixed Missin ] --- src/modules/site/migrate/ee_mod_migrate_data.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index a2850f9c..3133e932 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -6,19 +6,19 @@ function ee_mod_migrate_data() if [ "$EE_REMOTE_METHOD" == "ssh" ]; then # Lets FTP or rsync files rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit"; sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ ]"$EE_SITE_CREATE_OPTION" != "--mysql" ]; then lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER fi fi From 14e40b4cd9d0117fbbb64118625db52a5550df8e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 18:41:16 +0530 Subject: [PATCH 414/829] Database creation and import for ee site migrate --- bin/easyengine | 6 ++++ .../site/migrate/ee_mod_migrate_setup.sh | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/modules/site/migrate/ee_mod_migrate_setup.sh diff --git a/bin/easyengine b/bin/easyengine index d3d3fcd0..b6070991 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -772,6 +772,12 @@ elif [ "$EE_FIRST" = "site" ]; then # Create site ee site create $EE_DOMAIN $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION + # Setup migration + ee_mod_migrate_Setup + + # Setup site + ee_lib_echo_info "Successfully migrated site $EE_DOMAIN" + else ee_lib_echo "ee site commands:" ee_lib_echo_escape "\tcd\tSwitch to website root directory" diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh new file mode 100644 index 00000000..3ad54ae6 --- /dev/null +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -0,0 +1,28 @@ +# Function to Copy data from backup to webroot + +function ee_mod_migrate_setup() +{ + # Copy data + ee_lib_echo "Copying data from /ee-backup to webroot, please wait..." + cp -av /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ + + # Setup Database + if[ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + + mv /var/www/$EE_DOMAIN/htdocs/wp-config.php /var/www/$EE_DOMAIN/ + + ee_lib_echo "Setting up Database, please wait..." + ee_mod_setup_database + + # Replace old database values with new values + sed -i "s/DB_NAME.*/DB_NAME', '$EE_DB_NAME');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_user.*/DB_USER', '$EE_DB_USER');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_HOST.*/DB_HOST', '$EE_DB_HOST');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_PASSWORD.*/DB_PASSWORD', '$EE_DB_PASSWORD');/g" /var/www/$EE_DOMAIN/wp-config.php + + # Import database + ee_lib_echo "Importing database, please wait..." + pv $EE_MYSQL_PATH | mysql $EE_DB_NAME + fi + +} From 9a4569b0eb78aee5e8a6fc3f1d08c46c0b1a7bbd Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 18:57:17 +0530 Subject: [PATCH 415/829] Fixed Typo --- bin/easyengine | 4 ++-- src/modules/site/migrate/ee_mod_migrate_setup.sh | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index b6070991..39d0201e 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -773,8 +773,8 @@ elif [ "$EE_FIRST" = "site" ]; then ee site create $EE_DOMAIN $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION # Setup migration - ee_mod_migrate_Setup - + ee_mod_migrate_setup + # Setup site ee_lib_echo_info "Successfully migrated site $EE_DOMAIN" diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index 3ad54ae6..90a4eed1 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -7,8 +7,7 @@ function ee_mod_migrate_setup() cp -av /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ # Setup Database - if[ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then mv /var/www/$EE_DOMAIN/htdocs/wp-config.php /var/www/$EE_DOMAIN/ ee_lib_echo "Setting up Database, please wait..." From c075236d23edabb06889cc05744408fd2fa6fdc7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 19:02:35 +0530 Subject: [PATCH 416/829] Fixed Typo --- src/modules/site/migrate/ee_mod_migrate_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index 90a4eed1..e3b60450 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -17,7 +17,7 @@ function ee_mod_migrate_setup() sed -i "s/DB_NAME.*/DB_NAME', '$EE_DB_NAME');/g" /var/www/$EE_DOMAIN/wp-config.php sed -i "s/DB_user.*/DB_USER', '$EE_DB_USER');/g" /var/www/$EE_DOMAIN/wp-config.php sed -i "s/DB_HOST.*/DB_HOST', '$EE_DB_HOST');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_PASSWORD.*/DB_PASSWORD', '$EE_DB_PASSWORD');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_PASSWORD.*/DB_PASSWORD', '$EE_DB_PASS');/g" /var/www/$EE_DOMAIN/wp-config.php # Import database ee_lib_echo "Importing database, please wait..." From 5e23b4ce3bc27e3999af835a294a1696e8a82623 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 19:12:10 +0530 Subject: [PATCH 417/829] Fixed MySQL host during db creation --- src/modules/site/migrate/ee_mod_migrate_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index e3b60450..ba7f9a70 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -16,7 +16,7 @@ function ee_mod_migrate_setup() # Replace old database values with new values sed -i "s/DB_NAME.*/DB_NAME', '$EE_DB_NAME');/g" /var/www/$EE_DOMAIN/wp-config.php sed -i "s/DB_user.*/DB_USER', '$EE_DB_USER');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_HOST.*/DB_HOST', '$EE_DB_HOST');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_HOST.*/DB_HOST', '$EE_MYSQL_HOST');/g" /var/www/$EE_DOMAIN/wp-config.php sed -i "s/DB_PASSWORD.*/DB_PASSWORD', '$EE_DB_PASS');/g" /var/www/$EE_DOMAIN/wp-config.php # Import database From 5188e65c1ed0faaf4324ce2e0c6e1b3235fa2a9a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 19:28:50 +0530 Subject: [PATCH 418/829] Improved error handling and commented code --- bin/easyengine | 3 ++- .../site/migrate/ee_mod_migrate_data.sh | 26 ++++++++++++++----- .../site/migrate/ee_mod_migrate_setup.sh | 6 +++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 39d0201e..cd551168 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -770,7 +770,8 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_migrate_data # Create site - ee site create $EE_DOMAIN $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION + ee site create $EE_DOMAIN $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION \ + || ee_lib_error "Unable to create site, exit status = " $? # Setup migration ee_mod_migrate_setup diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 3133e932..dec8ee83 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -2,24 +2,36 @@ function ee_mod_migrate_data() { + # Remove if any previous directory and create /ee-backup rm -rf /ee-backup/$EE_DOMAIN && mkdir -p /ee-backup/$EE_DOMAIN/ && cd /ee-backup/$EE_DOMAIN/ + + ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." + # Copy webroot using ssh with the help of rsync if [ "$EE_REMOTE_METHOD" == "ssh" ]; then # Lets FTP or rsync files - rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ + rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ \ + || ee_lib_error "Unable to migrate data using rsync, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ + rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ \ + || ee_lib_error "Unable to migrate data using rsync, exit status = " $? fi - + + # Copy webroot using ftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then - lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER \ + || ee_lib_error "Unable to migrate data using ftp, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER \ + || ee_lib_error "Unable to migrate data using ftp, exit status = " $? fi + # Copy webroot using sftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then - lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit"; sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit"; sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER \ + || ee_lib_error "Unable to migrate data using sftp, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ ]"$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER + lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER \ + || ee_lib_error "Unable to migrate data using lftp, exit status = " $? fi fi } diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index ba7f9a70..8de60e1c 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -4,7 +4,8 @@ function ee_mod_migrate_setup() { # Copy data ee_lib_echo "Copying data from /ee-backup to webroot, please wait..." - cp -av /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ + cp -a /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ \ + || ee_lib_error "Unable to copy backup data to site webroot, exit status = " $? # Setup Database if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -21,7 +22,8 @@ function ee_mod_migrate_setup() # Import database ee_lib_echo "Importing database, please wait..." - pv $EE_MYSQL_PATH | mysql $EE_DB_NAME + pv $EE_MYSQL_PATH | mysql $EE_DB_NAME \ + || ee_lib_error "Unable to import database, exit status = " $? fi } From e456f9bb52d2e88104bf47854fc35966233c7e41 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 10 Nov 2014 19:43:19 +0530 Subject: [PATCH 419/829] Fix webroot permission --- src/modules/site/migrate/ee_mod_migrate_setup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index 8de60e1c..bcbfe437 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -26,4 +26,8 @@ function ee_mod_migrate_setup() || ee_lib_error "Unable to import database, exit status = " $? fi + # Fix webroot permission + chown -R www-data:www-data /var/www/$EE_DOMAIN/ \ + || ee_lib_error "Unable to change webroot permission, exit status = " $? + } From 72ea6de5d0b109bcab0b01ef3b096fcc6134291a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 12:53:37 +0530 Subject: [PATCH 420/829] Added Skiping MySQL import during update --- .../site/migrate/ee_mod_migrate_setup.sh | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index bcbfe437..4727d205 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -11,19 +11,21 @@ function ee_mod_migrate_setup() if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then mv /var/www/$EE_DOMAIN/htdocs/wp-config.php /var/www/$EE_DOMAIN/ - ee_lib_echo "Setting up Database, please wait..." - ee_mod_setup_database + if [ "$EE_MYSQL_PATH" != "" ]; then + ee_lib_echo "Setting up Database, please wait..." + ee_mod_setup_database - # Replace old database values with new values - sed -i "s/DB_NAME.*/DB_NAME', '$EE_DB_NAME');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_user.*/DB_USER', '$EE_DB_USER');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_HOST.*/DB_HOST', '$EE_MYSQL_HOST');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_PASSWORD.*/DB_PASSWORD', '$EE_DB_PASS');/g" /var/www/$EE_DOMAIN/wp-config.php + # Replace old database values with new values + sed -i "s/DB_NAME.*/DB_NAME', '$EE_DB_NAME');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_user.*/DB_USER', '$EE_DB_USER');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_HOST.*/DB_HOST', '$EE_MYSQL_HOST');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_PASSWORD.*/DB_PASSWORD', '$EE_DB_PASS');/g" /var/www/$EE_DOMAIN/wp-config.php - # Import database - ee_lib_echo "Importing database, please wait..." - pv $EE_MYSQL_PATH | mysql $EE_DB_NAME \ - || ee_lib_error "Unable to import database, exit status = " $? + # Import database + ee_lib_echo "Importing database, please wait..." + pv $EE_MYSQL_PATH | mysql $EE_DB_NAME \ + || ee_lib_error "Unable to import database, exit status = " $? + fi fi # Fix webroot permission From febcc6470f821ffb36453adb70eb7a2209c95950 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 13:08:30 +0530 Subject: [PATCH 421/829] Fixed Multiple log writting --- bin/easyengine | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index cd551168..b50b9e67 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -729,7 +729,8 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_SECOND" = "migrate" ]; then export EE_MIGRATE="True" - + export EE_TEE_LOG="false" + # Configure variables EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain From 8509b45144ffa2c1b22a4fcac4d633e927ea6f91 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 13:18:13 +0530 Subject: [PATCH 422/829] Improved log writting during ee site migrate --- bin/easyengine | 9 +++++++-- src/lib/ee_lib_stack_packages.sh | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index b50b9e67..96ac4f02 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -729,8 +729,13 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_SECOND" = "migrate" ]; then export EE_MIGRATE="True" - export EE_TEE_LOG="false" - + + # Log only single time + # ee site create example.com called ee stack install nginx + # So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null + # So in log file all logs written single time only, to do so set EE_LOG=false + export EE_LOG=false + # Configure variables EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index f17df84d..67f8d1a2 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -6,7 +6,7 @@ function ee_lib_stack_packages() # Log only single time # ee site create example.com called ee stack install nginx # So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null - # So in log file all logs written single time only + # So in log file all logs written single time only, to do so set EE_LOG=false export EE_LOG=false for ee_stack_package in $@;do @@ -48,7 +48,7 @@ function ee_lib_stack_packages() # and our ee_lib_error function only exit from that sub-shell # so we need to exit from parent shell also ee stack install postfix || exit $? - fi + fi fi done } From cfe422fd96aeaa984bd40578b6cf5496f04d0f07 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 13:23:21 +0530 Subject: [PATCH 423/829] Added PV and LFTP in installation dependencies --- bin/install | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/install b/bin/install index 38ff5d48..0574bb86 100644 --- a/bin/install +++ b/bin/install @@ -70,7 +70,7 @@ function ee_lib_error() function ee_lib_package_check() { local ee_package - + for ee_package in $@;do dpkg --get-selections | grep -v deinstall | grep $ee_package &>> $EE_INSTALL_LOG @@ -87,7 +87,7 @@ function ee_lib_package_check() if [ ! -d $EE_LOG_DIR ]; then ee_lib_echo "Creating EasyEngine (ee) log directory, please wait..." mkdir -p $EE_LOG_DIR || ee_lib_error "Unable to create log directory $EE_LOG_DIR, exit status = " $? - + # Create EasyEngine log files touch /var/log/easyengine/{ee.log,install.log,update.log,error.log} \ || ee_lib_error "Unable to create EasyEngine log files in $EE_LOG_DIR, exit status = " $? @@ -105,9 +105,9 @@ elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then ee_lib_package_check graphviz python-software-properties fi -if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ -n "$EE_PACKAGE_NAME" ]; then +if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/pv ] || [ ! -x /usr/bin/lftp ] || [ -n "$EE_PACKAGE_NAME" ]; then ee_lib_echo "Installing required packages, please wait..." | tee -ai $EE_INSTALL_LOG - apt-get -y install coreutils ed bc wget curl tar git-core $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\ + apt-get -y install coreutils ed bc wget curl tar git-core lftp pv $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\ || ee_lib_error "Unable to install required packages, exit status = " $? fi @@ -130,7 +130,7 @@ else fi fi -# Remove old version of EasyEngine (ee) +# Remove old version of EasyEngine (ee) rm -rf /tmp/easyengine &>> /dev/null # Let's clone EasyEngine (ee) From e4d53a0eca679cf4a04482a23eb292f508272cc3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 14:42:05 +0530 Subject: [PATCH 424/829] Read password from command line --- src/modules/site/migrate/ee_mod_migrate_data.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index dec8ee83..295421ec 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -15,22 +15,22 @@ function ee_mod_migrate_data() rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? fi - + # Copy webroot using ftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then - lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER \ + lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" ftp://$EE_REMOTE_SERVER \ || ee_lib_error "Unable to migrate data using ftp, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" ftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER \ + lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" ftp://$EE_REMOTE_SERVER \ || ee_lib_error "Unable to migrate data using ftp, exit status = " $? fi # Copy webroot using sftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then - lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit"; sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER \ + lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit"; -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER \ || ee_lib_error "Unable to migrate data using sftp, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ ]"$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" sftp://$EE_REMOTE_USER@$EE_REMOTE_SERVER \ + lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER \ || ee_lib_error "Unable to migrate data using lftp, exit status = " $? fi fi From adf312266beb764abc3f953a4bc93dae3ce8061e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 15:24:04 +0530 Subject: [PATCH 425/829] Removed extra semi colon --- src/modules/site/migrate/ee_mod_migrate_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 295421ec..604d5f62 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -27,7 +27,7 @@ function ee_mod_migrate_data() # Copy webroot using sftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then - lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit"; -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER \ + lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER \ || ee_lib_error "Unable to migrate data using sftp, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ ]"$EE_SITE_CREATE_OPTION" != "--mysql" ]; then lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER \ From 1a05e88659daeeeb24e0e2c673673dd64a8f5f33 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 16:03:11 +0530 Subject: [PATCH 426/829] Added SSHPASS for password less ssh --- bin/install | 4 ++-- src/modules/site/migrate/ee_mod_migrate_data.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/install b/bin/install index 0574bb86..08875504 100644 --- a/bin/install +++ b/bin/install @@ -105,9 +105,9 @@ elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then ee_lib_package_check graphviz python-software-properties fi -if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/pv ] || [ ! -x /usr/bin/lftp ] || [ -n "$EE_PACKAGE_NAME" ]; then +if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/pv ] || [ ! -x /usr/bin/lftp ] || [ ! -x /usr/bin/sshpass ] || [ -n "$EE_PACKAGE_NAME" ]; then ee_lib_echo "Installing required packages, please wait..." | tee -ai $EE_INSTALL_LOG - apt-get -y install coreutils ed bc wget curl tar git-core lftp pv $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\ + apt-get -y install coreutils ed bc wget curl tar git-core lftp pv sshpass $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\ || ee_lib_error "Unable to install required packages, exit status = " $? fi diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 604d5f62..9ad6bf9e 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -9,10 +9,10 @@ function ee_mod_migrate_data() # Copy webroot using ssh with the help of rsync if [ "$EE_REMOTE_METHOD" == "ssh" ]; then # Lets FTP or rsync files - rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ \ + rsync -avz --progress --rsh='sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER' $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ \ + rsync -avz --progress --rsh='sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER' $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? fi From 5c2a857a257a210786edff5d39fad34e84e54fed Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 17:38:57 +0530 Subject: [PATCH 427/829] Improved code --- .../site/migrate/ee_mod_migrate_data.sh | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 9ad6bf9e..962bf9cc 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -6,32 +6,39 @@ function ee_mod_migrate_data() rm -rf /ee-backup/$EE_DOMAIN && mkdir -p /ee-backup/$EE_DOMAIN/ && cd /ee-backup/$EE_DOMAIN/ ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." + # Copy webroot using ssh with the help of rsync if [ "$EE_REMOTE_METHOD" == "ssh" ]; then - # Lets FTP or rsync files - rsync -avz --progress --rsh='sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER' $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/ \ - || ee_lib_error "Unable to migrate data using rsync, exit status = " $? - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - rsync -avz --progress --rsh='sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER' $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/ \ - || ee_lib_error "Unable to migrate data using rsync, exit status = " $? + if [ "$EE_REMOTE_PASSWORD" != "" ]; then + EE_MIGRATE_CMD1='rsync -avz --progress --rsh="sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/' + EE_MIGRATE_CMD2='rsync -avz --progress --rsh="sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/' + else + EE_MIGRATE_CMD1='rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/' + EE_MIGRATE_CMD2='rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/' + fi + elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then + if [ "$EE_REMOTE_PASSWORD" != "" ]; then + $EE_MIGRATE_CMD1='lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER' + $EE_MIGRATE_CMD2='lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER' + else + $EE_MIGRATE_CMD1='lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER" sftp://$EE_REMOTE_SERVER' + $EE_MIGRATE_CMD2='lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER" ftp://$EE_REMOTE_SERVER' fi - - # Copy webroot using ftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then - lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" ftp://$EE_REMOTE_SERVER \ - || ee_lib_error "Unable to migrate data using ftp, exit status = " $? - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" ftp://$EE_REMOTE_SERVER \ - || ee_lib_error "Unable to migrate data using ftp, exit status = " $? + if [ "$EE_REMOTE_PASSWORD" != "" ]; then + $EE_MIGRATE_CMD1='lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" ftp://$EE_REMOTE_SERVER' + $EE_MIGRATE_CMD2='lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" ftp://$EE_REMOTE_SERVER' + else + $EE_MIGRATE_CMD1='lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER" ftp://$EE_REMOTE_SERVER' + $EE_MIGRATE_CMD2='lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER" ftp://$EE_REMOTE_SERVER' fi + fi - # Copy webroot using sftp with the help of lftp - elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then - lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN ; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER \ - || ee_lib_error "Unable to migrate data using sftp, exit status = " $? - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ ]"$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER \ - || ee_lib_error "Unable to migrate data using lftp, exit status = " $? - fi + $EE_MIGRATE_CMD1 \ + || ee_lib_error "Unable to migrate data using rsync, exit status = " $? + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then + $EE_MIGRATE_CMD2 \ + || ee_lib_error "Unable to migrate data using rsync, exit status = " $? fi + } From ad3afe6c278c9b1bca4bdfdc0d41e28f3f0ddb54 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 11 Nov 2014 18:01:27 +0530 Subject: [PATCH 428/829] Improved Variables --- .../site/migrate/ee_mod_migrate_data.sh | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 962bf9cc..5a603d17 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -6,31 +6,31 @@ function ee_mod_migrate_data() rm -rf /ee-backup/$EE_DOMAIN && mkdir -p /ee-backup/$EE_DOMAIN/ && cd /ee-backup/$EE_DOMAIN/ ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." - + # Copy webroot using ssh with the help of rsync if [ "$EE_REMOTE_METHOD" == "ssh" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - EE_MIGRATE_CMD1='rsync -avz --progress --rsh="sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/' - EE_MIGRATE_CMD2='rsync -avz --progress --rsh="sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/' + EE_MIGRATE_CMD1="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/" else - EE_MIGRATE_CMD1='rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/' - EE_MIGRATE_CMD2='rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/' + EE_MIGRATE_CMD1="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/" fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - $EE_MIGRATE_CMD1='lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER' - $EE_MIGRATE_CMD2='lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" sftp://$EE_REMOTE_SERVER' + $EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" + $EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" else - $EE_MIGRATE_CMD1='lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER" sftp://$EE_REMOTE_SERVER' - $EE_MIGRATE_CMD2='lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER" ftp://$EE_REMOTE_SERVER' + $EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" + $EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - $EE_MIGRATE_CMD1='lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" ftp://$EE_REMOTE_SERVER' - $EE_MIGRATE_CMD2='lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER,$EE_REMOTE_PASSWORD" ftp://$EE_REMOTE_SERVER' + $EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" + $EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" else - $EE_MIGRATE_CMD1='lftp -e "mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit" -u "$EE_REMOTE_USER" ftp://$EE_REMOTE_SERVER' - $EE_MIGRATE_CMD2='lftp -e "get -c $EE_REMOTE_PATH/../wp-config.php; quit" -u "$EE_REMOTE_USER" ftp://$EE_REMOTE_SERVER' + $EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + $EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi fi From ffb3451e658353086dd45f7623391dbde1447a14 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 12 Nov 2014 12:03:24 +0530 Subject: [PATCH 429/829] Improved sudo dependencies --- bin/install | 4 ++-- src/modules/stack/install/ee_mod_repo_mysql.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/install b/bin/install index 08875504..7b2ca1d5 100644 --- a/bin/install +++ b/bin/install @@ -105,9 +105,9 @@ elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then ee_lib_package_check graphviz python-software-properties fi -if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/pv ] || [ ! -x /usr/bin/lftp ] || [ ! -x /usr/bin/sshpass ] || [ -n "$EE_PACKAGE_NAME" ]; then +if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/pv ] || [ ! -x /usr/bin/lftp ] || [ ! -x /usr/bin/sshpass ] || [ ! -x /usr/bin/sudo ] || [ -n "$EE_PACKAGE_NAME" ]; then ee_lib_echo "Installing required packages, please wait..." | tee -ai $EE_INSTALL_LOG - apt-get -y install coreutils ed bc wget curl tar git-core lftp pv sshpass $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\ + apt-get -y install coreutils ed bc wget curl tar git-core lftp pv sshpass sudo $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\ || ee_lib_error "Unable to install required packages, exit status = " $? fi diff --git a/src/modules/stack/install/ee_mod_repo_mysql.sh b/src/modules/stack/install/ee_mod_repo_mysql.sh index 19542291..116f5d99 100644 --- a/src/modules/stack/install/ee_mod_repo_mysql.sh +++ b/src/modules/stack/install/ee_mod_repo_mysql.sh @@ -9,6 +9,6 @@ function ee_mod_repo_mysql() # Fetch and install Percona GnuPG key gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A &>> $EE_COMMAND_LOG && \ - gpg -a --export CD2EFD2A | sudo apt-key add - &>> $EE_COMMAND_LOG \ + gpg -a --export CD2EFD2A | apt-key add - &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to add Percona GnuPG key, exit status = " $? } From d968a0101f1aa61cab08c86ebcd70962da1639bd Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 12 Nov 2014 13:14:11 +0530 Subject: [PATCH 430/829] Atlast migration with/without password done --- .../site/migrate/ee_mod_migrate_data.sh | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 5a603d17..fd0f0b66 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -18,26 +18,26 @@ function ee_mod_migrate_data() fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - $EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" - $EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" else - $EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" - $EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - $EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" - $EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" else - $EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" - $EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi fi - $EE_MIGRATE_CMD1 \ + eval $EE_MIGRATE_CMD1 \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - $EE_MIGRATE_CMD2 \ + eval $EE_MIGRATE_CMD2 \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? fi From 72d850194f5ca3fb88424549ededdb1e64199b27 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 12 Nov 2014 13:21:33 +0530 Subject: [PATCH 431/829] Improved code --- src/modules/site/migrate/ee_mod_migrate_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index fd0f0b66..0d00767c 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -3,7 +3,7 @@ function ee_mod_migrate_data() { # Remove if any previous directory and create /ee-backup - rm -rf /ee-backup/$EE_DOMAIN && mkdir -p /ee-backup/$EE_DOMAIN/ && cd /ee-backup/$EE_DOMAIN/ + mkdir -p /ee-backup/$EE_DOMAIN/ && cd /ee-backup/$EE_DOMAIN/ ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." From 6a9b920b19baf76f2bc69d85b8a812c337a2307e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 12 Nov 2014 14:29:43 +0530 Subject: [PATCH 432/829] Added support for --mysql site --- .../site/migrate/ee_mod_migrate_data.sh | 23 +++++++++++-------- .../site/migrate/ee_mod_migrate_setup.sh | 17 +++++++++++++- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 0d00767c..f9bd1c9d 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -7,38 +7,43 @@ function ee_mod_migrate_data() ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + EE_SITE_CONFIG=wp-config.php + elif [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + EE_SITE_CONFIG=ee-config.php + fi + # Copy webroot using ssh with the help of rsync if [ "$EE_REMOTE_METHOD" == "ssh" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" - EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" else EE_MIGRATE_CMD1="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" - EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../wp-config.php /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" fi elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" else EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" else EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../wp-config.php; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi fi eval $EE_MIGRATE_CMD1 \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - eval $EE_MIGRATE_CMD2 \ - || ee_lib_error "Unable to migrate data using rsync, exit status = " $? + if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ]; then + eval $EE_MIGRATE_CMD2 &>> $EE_COMMAND_LOG fi } diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index 4727d205..36911ec8 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -7,7 +7,7 @@ function ee_mod_migrate_setup() cp -a /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ \ || ee_lib_error "Unable to copy backup data to site webroot, exit status = " $? - # Setup Database + # Setup Database for WordPress site if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then mv /var/www/$EE_DOMAIN/htdocs/wp-config.php /var/www/$EE_DOMAIN/ @@ -28,6 +28,21 @@ function ee_mod_migrate_setup() fi fi + # Setup database for MySQL site + if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + if [ -f /var/www/$EE_DOMAIN/htdocs/ee-config.php ]; then + rm /var/www/$EE_DOMAIN/htdocs/ee-config.php + fi + if [ "$EE_MYSQL_PATH" != "" ]; then + + EE_DB_NAME=$(grep DB_NAME /var/www/$EE_DOMAIN/ee-config.php | cut -d"'" -f4) + # Import database + ee_lib_echo "Importing database, please wait..." + pv $EE_MYSQL_PATH | mysql $EE_DB_NAME \ + || ee_lib_error "Unable to import database, exit status = " $? + fi + fi + # Fix webroot permission chown -R www-data:www-data /var/www/$EE_DOMAIN/ \ || ee_lib_error "Unable to change webroot permission, exit status = " $? From 0fd8e6e64816e3e963464e6472d29591f6b47e7f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 12 Nov 2014 15:37:17 +0530 Subject: [PATCH 433/829] Improved commenting --- src/modules/site/migrate/ee_mod_migrate_data.sh | 12 +++++++++++- src/modules/site/migrate/ee_mod_migrate_setup.sh | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index f9bd1c9d..a9fa32d4 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -7,6 +7,8 @@ function ee_mod_migrate_data() ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." + # For Wordpress site we will migrate wp-config.php from parent folder of webroot + # For MySQL site we will migrate ee-config.php from parent folder of webroot if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then EE_SITE_CONFIG=wp-config.php elif [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then @@ -22,6 +24,7 @@ function ee_mod_migrate_data() EE_MIGRATE_CMD1="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" fi + # Copy webroot using sftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" @@ -30,6 +33,7 @@ function ee_mod_migrate_data() EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi + # Copy webroot using ftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" @@ -40,10 +44,16 @@ function ee_mod_migrate_data() fi fi + # eval: Execute arguments as a shell command. + # Why eval?: direct executing Varibale as command adding some extra characters to command + # Like quote is command is not working, that is why used eval + # For more info: help eval + eval $EE_MIGRATE_CMD1 \ || ee_lib_error "Unable to migrate data using rsync, exit status = " $? if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ]; then + # In case of Wordpress site, If site don't have wp-config.php then try to copy wp-config.php from parent folder of webroot + # In case of MySQL site, try to copy ee-config.php from parent folder of webroot, (Hope remote server is using EE :P) eval $EE_MIGRATE_CMD2 &>> $EE_COMMAND_LOG fi - } diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index 36911ec8..a3a06821 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -2,7 +2,7 @@ function ee_mod_migrate_setup() { - # Copy data + # Copy data from backup to webroot ee_lib_echo "Copying data from /ee-backup to webroot, please wait..." cp -a /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ \ || ee_lib_error "Unable to copy backup data to site webroot, exit status = " $? @@ -34,7 +34,6 @@ function ee_mod_migrate_setup() rm /var/www/$EE_DOMAIN/htdocs/ee-config.php fi if [ "$EE_MYSQL_PATH" != "" ]; then - EE_DB_NAME=$(grep DB_NAME /var/www/$EE_DOMAIN/ee-config.php | cut -d"'" -f4) # Import database ee_lib_echo "Importing database, please wait..." From 6a321eb1631ba32924a6d8f1d6a20c5e40bd1aac Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 12 Nov 2014 16:12:42 +0530 Subject: [PATCH 434/829] Fixed Know-host error --- src/modules/site/migrate/ee_mod_migrate_data.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index a9fa32d4..aaaccd10 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -18,8 +18,8 @@ function ee_mod_migrate_data() # Copy webroot using ssh with the help of rsync if [ "$EE_REMOTE_METHOD" == "ssh" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - EE_MIGRATE_CMD1="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" - EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD1="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER -o StrictHostKeyChecking=no\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER -o StrictHostKeyChecking=no\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" else EE_MIGRATE_CMD1="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" From 531f2ef10b5e23ca423dba0aee1d5f3641fa3622 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 12 Nov 2014 16:33:39 +0530 Subject: [PATCH 435/829] Fixed wrong username in wp-config.php --- src/modules/site/migrate/ee_mod_migrate_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index a3a06821..523da3f6 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -17,7 +17,7 @@ function ee_mod_migrate_setup() # Replace old database values with new values sed -i "s/DB_NAME.*/DB_NAME', '$EE_DB_NAME');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_user.*/DB_USER', '$EE_DB_USER');/g" /var/www/$EE_DOMAIN/wp-config.php + sed -i "s/DB_USER.*/DB_USER', '$EE_DB_USER');/g" /var/www/$EE_DOMAIN/wp-config.php sed -i "s/DB_HOST.*/DB_HOST', '$EE_MYSQL_HOST');/g" /var/www/$EE_DOMAIN/wp-config.php sed -i "s/DB_PASSWORD.*/DB_PASSWORD', '$EE_DB_PASS');/g" /var/www/$EE_DOMAIN/wp-config.php From a95407ceacb99d9749f179e6a1273e54408d0f07 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 13 Nov 2014 16:44:34 +0530 Subject: [PATCH 436/829] Added WordPress plugin installation during ee site migrate --- bin/easyengine | 5 ++++- src/modules/site/create/ee_mod_plugin_settings.sh | 3 ++- src/modules/site/migrate/ee_mod_migrate_setup.sh | 12 ++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 96ac4f02..b838026e 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -782,7 +782,10 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup migration ee_mod_migrate_setup - # Setup site + # Display WordPress cache plugin settings + ee_mod_plugin_settings + + # Successfully message ee_lib_echo_info "Successfully migrated site $EE_DOMAIN" else diff --git a/src/modules/site/create/ee_mod_plugin_settings.sh b/src/modules/site/create/ee_mod_plugin_settings.sh index e59347be..2d6612f0 100644 --- a/src/modules/site/create/ee_mod_plugin_settings.sh +++ b/src/modules/site/create/ee_mod_plugin_settings.sh @@ -1,6 +1,7 @@ # Display WordPress cache plugin settings -function ee_mod_plugin_settings() { +function ee_mod_plugin_settings() +{ if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=wpsupercache" diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh index 523da3f6..d35fed30 100644 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ b/src/modules/site/migrate/ee_mod_migrate_setup.sh @@ -26,6 +26,18 @@ function ee_mod_migrate_setup() pv $EE_MYSQL_PATH | mysql $EE_DB_NAME \ || ee_lib_error "Unable to import database, exit status = " $? fi + + # Install WordPress plugins + ee_mod_plugin_nginx_helper + + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_mod_plugin_w3tc + fi + fi # Setup database for MySQL site From 57f0d0daa1ff03fe6e516d82e4148bf917acd6b6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 14:35:47 +0530 Subject: [PATCH 437/829] Added option for exclude files --- bin/easyengine | 4 ++++ .../site/migrate/ee_mod_migrate_data.sh | 20 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index b838026e..ed8bf8de 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -21,6 +21,7 @@ EE_EIGTH=$8 EE_NINTH=$9 EE_TENTH=${10} EE_ELEVENTH=${11} +EE_TWELTH=${12} # Let's capture the EasyEngine arguments ee_lib_echo "EasyEngine (ee) $EE_VERSION execution started [$(date)]" &>> $EE_COMMAND_LOG @@ -749,6 +750,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_REMOTE_METHOD=${EE_SEVENTH##*=} EE_REMOTE_PATH=${EE_EIGTH##*=} EE_MYSQL_PATH=${EE_NINTH##*=} + EE_REMOTE_EXCLUDE=${EE_TENTH##*=} elif [ "${EE_FIFTH%=*}" = "--remote-server" ]; then EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION="" @@ -758,6 +760,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_REMOTE_PASSWORD=${EE_SEVENTH##*=} EE_REMOTE_PATH=${EE_NINTH##*=} EE_MYSQL_PATH=${EE_TENTH##*=} + EE_REMOTE_EXCLUDE=${EE_ELEVENTH##*=} else EE_SITE_CREATE_OPTION=$EE_FOURTH EE_SITE_CACHE_OPTION=$EE_FIFTH @@ -767,6 +770,7 @@ elif [ "$EE_FIRST" = "site" ]; then EE_REMOTE_METHOD=${EE_NINTH##*=} EE_REMOTE_PATH=${EE_TENTH##*=} EE_MYSQL_PATH=${EE_ELEVENTH##*=} + EE_REMOTE_EXCLUDE=${EE_TWELTH##*=} fi # Auto switch site options diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index aaaccd10..137610eb 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -7,6 +7,14 @@ function ee_mod_migrate_data() ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." + # Paramater for directory exclude + if [ "$EE_REMOTE_EXCLUDE" != "" ]; + EE_REMOTE_EXCLUDE_CMD="" + for ee_exclude_opt in $(echo $EE_REMOTE_EXCLUDE | tr ',' ''); do + EE_REMOTE_EXCLUDE_CMD=${EE_REMOTE_EXCLUDE_CMD}"--exclude $ee_exclude_opt " + done + fi + # For Wordpress site we will migrate wp-config.php from parent folder of webroot # For MySQL site we will migrate ee-config.php from parent folder of webroot if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then @@ -18,28 +26,28 @@ function ee_mod_migrate_data() # Copy webroot using ssh with the help of rsync if [ "$EE_REMOTE_METHOD" == "ssh" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - EE_MIGRATE_CMD1="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER -o StrictHostKeyChecking=no\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD1="rsync -avz --progress ${EE_REMOTE_EXCLUDE_CMD} --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER -o StrictHostKeyChecking=no\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER -o StrictHostKeyChecking=no\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" else - EE_MIGRATE_CMD1="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" + EE_MIGRATE_CMD1="rsync -avz --progress ${EE_REMOTE_EXCLUDE_CMD} $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" fi # Copy webroot using sftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD1="lftp -e \"mirror --verbose ${EE_REMOTE_EXCLUDE_CMD} -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" else - EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD1="lftp -e \"mirror --verbose ${EE_REMOTE_EXCLUDE_CMD} -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi # Copy webroot using ftp with the help of lftp elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then if [ "$EE_REMOTE_PASSWORD" != "" ]; then - EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD1="lftp -e \"mirror --verbose ${EE_REMOTE_EXCLUDE_CMD} -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" else - EE_MIGRATE_CMD1="lftp -e \"mirror --verbose -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" + EE_MIGRATE_CMD1="lftp -e \"mirror --verbose ${EE_REMOTE_EXCLUDE_CMD} -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" fi fi From c0d21a336affc41b7ffb5c14bf3675722808b8f4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 14:46:36 +0530 Subject: [PATCH 438/829] Fixed missing then --- src/modules/site/migrate/ee_mod_migrate_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 137610eb..897e97b3 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -8,7 +8,7 @@ function ee_mod_migrate_data() ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." # Paramater for directory exclude - if [ "$EE_REMOTE_EXCLUDE" != "" ]; + if [ "$EE_REMOTE_EXCLUDE" != "" ]; then EE_REMOTE_EXCLUDE_CMD="" for ee_exclude_opt in $(echo $EE_REMOTE_EXCLUDE | tr ',' ''); do EE_REMOTE_EXCLUDE_CMD=${EE_REMOTE_EXCLUDE_CMD}"--exclude $ee_exclude_opt " From a3d22c8e26fdaa743c10fc0382cb76082c06226f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 15:05:29 +0530 Subject: [PATCH 439/829] Fixed missing space in tr command --- src/modules/site/migrate/ee_mod_migrate_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh index 897e97b3..690abb62 100644 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ b/src/modules/site/migrate/ee_mod_migrate_data.sh @@ -10,7 +10,7 @@ function ee_mod_migrate_data() # Paramater for directory exclude if [ "$EE_REMOTE_EXCLUDE" != "" ]; then EE_REMOTE_EXCLUDE_CMD="" - for ee_exclude_opt in $(echo $EE_REMOTE_EXCLUDE | tr ',' ''); do + for ee_exclude_opt in $(echo $EE_REMOTE_EXCLUDE | tr ',' ' '); do EE_REMOTE_EXCLUDE_CMD=${EE_REMOTE_EXCLUDE_CMD}"--exclude $ee_exclude_opt " done fi From 6347556ee45e874b5c8be058e8572ec25ea5f7c8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 16:30:16 +0530 Subject: [PATCH 440/829] ee site migrate arguments parsing --- bin/easyengine | 52 +++++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index ed8bf8de..bca92bea 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -741,36 +741,28 @@ elif [ "$EE_FIRST" = "site" ]; then EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain - if [ "${EE_FOURTH%=*}" = "--remote-server" ]; then - EE_SITE_CREATE_OPTION="" - EE_SITE_CACHE_OPTION="" - EE_REMOTE_SERVER=${EE_FOURTH##*=} - EE_REMOTE_USER=${EE_FIFTH##*=} - EE_REMOTE_PASSWORD=${EE_SIXTH##*=} - EE_REMOTE_METHOD=${EE_SEVENTH##*=} - EE_REMOTE_PATH=${EE_EIGTH##*=} - EE_MYSQL_PATH=${EE_NINTH##*=} - EE_REMOTE_EXCLUDE=${EE_TENTH##*=} - elif [ "${EE_FIFTH%=*}" = "--remote-server" ]; then - EE_SITE_CREATE_OPTION=$EE_FOURTH - EE_SITE_CACHE_OPTION="" - EE_REMOTE_SERVER=${EE_FIFTH##*=} - EE_REMOTE_USER=${EE_SIXTH##*=} - EE_REMOTE_METHOD=${EE_EIGTH##*=} - EE_REMOTE_PASSWORD=${EE_SEVENTH##*=} - EE_REMOTE_PATH=${EE_NINTH##*=} - EE_MYSQL_PATH=${EE_TENTH##*=} - EE_REMOTE_EXCLUDE=${EE_ELEVENTH##*=} - else - EE_SITE_CREATE_OPTION=$EE_FOURTH - EE_SITE_CACHE_OPTION=$EE_FIFTH - EE_REMOTE_SERVER=${EE_SIXTH##*=} - EE_REMOTE_USER=${EE_SEVENTH##*=} - EE_REMOTE_PASSWORD=${EE_EIGTH##*=} - EE_REMOTE_METHOD=${EE_NINTH##*=} - EE_REMOTE_PATH=${EE_TENTH##*=} - EE_MYSQL_PATH=${EE_ELEVENTH##*=} - EE_REMOTE_EXCLUDE=${EE_TWELTH##*=} + # Auto arrange migrate arguments + for ee_migrate_args in $@; do + [ "$ee_migrate_args" = "--html" ] || [ "$ee_migrate_args" = "--php" ] || [ "$ee_migrate_args" = "--mysql" ] || [ "$ee_migrate_args" = "--wp" ] || [ "$ee_migrate_args" = "--wpsubdir" ] || [ "$ee_migrate_args" = "--wpsubdomain" ] && EE_SITE_CREATE_OPTION=$ee_migrate_args && echo EE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION &>> $EE_COMMAND_LOG + [ "$ee_migrate_args" = "--basic" ] || [ "$ee_migrate_args" = "--w3tc" ] || [ "$ee_migrate_args" = "--wpsc" ] || [ "$ee_migrate_args" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$ee_migrate_args && echo EE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION &>> $EE_COMMAND_LOG + [ "${ee_migrate_args%=*}" = "--remote-host" ] && EE_REMOTE_SERVER=${ee_migrate_args##*=} && echo EE_REMOTE_SERVER = $EE_REMOTE_SERVER &>> $EE_COMMAND_LOG + [ "${ee_migrate_args%=*}" = "--remote-user" ] && EE_REMOTE_USER=${ee_migrate_args##*=} && echo EE_REMOTE_USER = $EE_REMOTE_USER &>> $EE_COMMAND_LOG + [ "${ee_migrate_args%=*}" = "--remote-password" ] && EE_REMOTE_PASSWORD=${ee_migrate_args##*=} && echo EE_REMOTE_PASSWORD = $EE_REMOTE_PASSWORD &>> $EE_COMMAND_LOG + [ "${ee_migrate_args%=*}" = "--remote-method" ] && EE_REMOTE_METHOD=${ee_migrate_args##*=} && echo EE_REMOTE_METHOD = $EE_REMOTE_METHOD &>> $EE_COMMAND_LOG + [ "${ee_migrate_args%=*}" = "--remote-path" ] && EE_REMOTE_PATH=${ee_migrate_args##*=} && echo EE_REMOTE_PATH = $EE_REMOTE_PATH &>> $EE_COMMAND_LOG + [ "${ee_migrate_args%=*}" = "--mysql-path" ] && EE_MYSQL_PATH=${ee_migrate_args##*=} && echo EE_MYSQL_PATH = $EE_MYSQL_PATH &>> $EE_COMMAND_LOG + [ "${ee_migrate_args%=*}" = "--remote-exclude" ] && EE_REMOTE_EXCLUDE=${ee_migrate_args##*=} && echo EE_REMOTE_EXCLUDE = $EE_REMOTE_EXCLUDE &>> $EE_COMMAND_LOG + done + + # Compulsary arguments for migration + if [ "$EE_REMOTE_SERVER" = "" ]; then + ee_lib_error "Missing arguments --remote-host, exit status = " 1 + elif [ "$EE_REMOTE_USER" = "" ]; then + ee_lib_error "Missing arguments --remote-user, exit status = " 1 + elif [ "$EE_REMOTE_METHOD" != "ssh" ] || [ "$EE_REMOTE_METHOD" != "sftp" ] || [ "$EE_REMOTE_METHOD" != "sftp" ]; then + ee_lib_error "EasyEngine migration supports only ssh, sftp and ftp methods, exit status = " 1 + elif [ "$EE_REMOTE_PATH" == "" ]; then + EE_REMOTE_PATH="/var/www/$EE_DOMAIN/htdocs" fi # Auto switch site options From 3be024c2cb84b5e23e27d000b628ba228a431075 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 16:45:09 +0530 Subject: [PATCH 441/829] Fixed missing ftp options --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index bca92bea..11bee08b 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -759,7 +759,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_error "Missing arguments --remote-host, exit status = " 1 elif [ "$EE_REMOTE_USER" = "" ]; then ee_lib_error "Missing arguments --remote-user, exit status = " 1 - elif [ "$EE_REMOTE_METHOD" != "ssh" ] || [ "$EE_REMOTE_METHOD" != "sftp" ] || [ "$EE_REMOTE_METHOD" != "sftp" ]; then + elif [ "$EE_REMOTE_METHOD" != "ssh" ] || [ "$EE_REMOTE_METHOD" != "sftp" ] || [ "$EE_REMOTE_METHOD" != "ftp" ]; then ee_lib_error "EasyEngine migration supports only ssh, sftp and ftp methods, exit status = " 1 elif [ "$EE_REMOTE_PATH" == "" ]; then EE_REMOTE_PATH="/var/www/$EE_DOMAIN/htdocs" From ad926943531535c020e3e959e805f6edb388a9b6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 16:51:12 +0530 Subject: [PATCH 442/829] Fixed Remote method logic --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 11bee08b..14becc00 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -759,7 +759,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_error "Missing arguments --remote-host, exit status = " 1 elif [ "$EE_REMOTE_USER" = "" ]; then ee_lib_error "Missing arguments --remote-user, exit status = " 1 - elif [ "$EE_REMOTE_METHOD" != "ssh" ] || [ "$EE_REMOTE_METHOD" != "sftp" ] || [ "$EE_REMOTE_METHOD" != "ftp" ]; then + elif [ "$EE_REMOTE_METHOD" != "ssh" ] && [ "$EE_REMOTE_METHOD" != "sftp" ] && [ "$EE_REMOTE_METHOD" != "ftp" ]; then ee_lib_error "EasyEngine migration supports only ssh, sftp and ftp methods, exit status = " 1 elif [ "$EE_REMOTE_PATH" == "" ]; then EE_REMOTE_PATH="/var/www/$EE_DOMAIN/htdocs" From 1c49a7841e111c4ebd7546989c07dc4887c3f88f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 17:18:46 +0530 Subject: [PATCH 443/829] Improved argument parsing logic --- bin/easyengine | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 14becc00..21c61841 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -15,13 +15,6 @@ EE_SECOND=$2 EE_THIRD=$3 EE_FOURTH=$4 EE_FIFTH=$5 -EE_SIXTH=$6 -EE_SEVENTH=$7 -EE_EIGTH=$8 -EE_NINTH=$9 -EE_TENTH=${10} -EE_ELEVENTH=${11} -EE_TWELTH=${12} # Let's capture the EasyEngine arguments ee_lib_echo "EasyEngine (ee) $EE_VERSION execution started [$(date)]" &>> $EE_COMMAND_LOG @@ -741,10 +734,12 @@ elif [ "$EE_FIRST" = "site" ]; then EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain + [ "$EE_SECOND" = "--html" ] || [ "$EE_SECOND" = "--php" ] || [ "$EE_SECOND" = "--mysql" ] || [ "$EE_SECOND" = "--wp" ] || [ "$EE_SECOND" = "--wpsubdir" ] || [ "$EE_SECOND" = "--wpsubdomain" ] \ + || [ "$EE_SECOND" = "--basic" ] || [ "$EE_SECOND" = "--w3tc" ] || [ "$EE_SECOND" = "--wpsc" ] || [ "$EE_SECOND" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$EE_SECOND && EE_SITE_CREATE_OPTION=$EE_SECOND && echo EE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION &>> $EE_COMMAND_LOG + [ "$EE_THIRD" = "--basic" ] || [ "$EE_THIRD" = "--w3tc" ] || [ "$EE_THIRD" = "--wpsc" ] || [ "$EE_THIRD" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$EE_THIRD && echo EE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION &>> $EE_COMMAND_LOG + # Auto arrange migrate arguments for ee_migrate_args in $@; do - [ "$ee_migrate_args" = "--html" ] || [ "$ee_migrate_args" = "--php" ] || [ "$ee_migrate_args" = "--mysql" ] || [ "$ee_migrate_args" = "--wp" ] || [ "$ee_migrate_args" = "--wpsubdir" ] || [ "$ee_migrate_args" = "--wpsubdomain" ] && EE_SITE_CREATE_OPTION=$ee_migrate_args && echo EE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION &>> $EE_COMMAND_LOG - [ "$ee_migrate_args" = "--basic" ] || [ "$ee_migrate_args" = "--w3tc" ] || [ "$ee_migrate_args" = "--wpsc" ] || [ "$ee_migrate_args" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$ee_migrate_args && echo EE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION &>> $EE_COMMAND_LOG [ "${ee_migrate_args%=*}" = "--remote-host" ] && EE_REMOTE_SERVER=${ee_migrate_args##*=} && echo EE_REMOTE_SERVER = $EE_REMOTE_SERVER &>> $EE_COMMAND_LOG [ "${ee_migrate_args%=*}" = "--remote-user" ] && EE_REMOTE_USER=${ee_migrate_args##*=} && echo EE_REMOTE_USER = $EE_REMOTE_USER &>> $EE_COMMAND_LOG [ "${ee_migrate_args%=*}" = "--remote-password" ] && EE_REMOTE_PASSWORD=${ee_migrate_args##*=} && echo EE_REMOTE_PASSWORD = $EE_REMOTE_PASSWORD &>> $EE_COMMAND_LOG From 418c70ce2c53084cded1e1a6a9feabf4baa433f2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 17:23:51 +0530 Subject: [PATCH 444/829] Improved argument parsing log --- bin/easyengine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/easyengine b/bin/easyengine index 21c61841..49a054b4 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -757,7 +757,7 @@ elif [ "$EE_FIRST" = "site" ]; then elif [ "$EE_REMOTE_METHOD" != "ssh" ] && [ "$EE_REMOTE_METHOD" != "sftp" ] && [ "$EE_REMOTE_METHOD" != "ftp" ]; then ee_lib_error "EasyEngine migration supports only ssh, sftp and ftp methods, exit status = " 1 elif [ "$EE_REMOTE_PATH" == "" ]; then - EE_REMOTE_PATH="/var/www/$EE_DOMAIN/htdocs" + EE_REMOTE_PATH="/var/www/$EE_DOMAIN/htdocs" && echo EE_REMOTE_PATH = $EE_REMOTE_PATH &>> $EE_COMMAND_LOG fi # Auto switch site options From 01a38259805ffefc1503b6c51ce23516db88fb1d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 14 Nov 2014 17:50:55 +0530 Subject: [PATCH 445/829] Fixed wrong argument number --- bin/easyengine | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/easyengine b/bin/easyengine index 49a054b4..8abbaf6c 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -734,9 +734,9 @@ elif [ "$EE_FIRST" = "site" ]; then EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain - [ "$EE_SECOND" = "--html" ] || [ "$EE_SECOND" = "--php" ] || [ "$EE_SECOND" = "--mysql" ] || [ "$EE_SECOND" = "--wp" ] || [ "$EE_SECOND" = "--wpsubdir" ] || [ "$EE_SECOND" = "--wpsubdomain" ] \ - || [ "$EE_SECOND" = "--basic" ] || [ "$EE_SECOND" = "--w3tc" ] || [ "$EE_SECOND" = "--wpsc" ] || [ "$EE_SECOND" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$EE_SECOND && EE_SITE_CREATE_OPTION=$EE_SECOND && echo EE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION &>> $EE_COMMAND_LOG - [ "$EE_THIRD" = "--basic" ] || [ "$EE_THIRD" = "--w3tc" ] || [ "$EE_THIRD" = "--wpsc" ] || [ "$EE_THIRD" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$EE_THIRD && echo EE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION &>> $EE_COMMAND_LOG + [ "$EE_FOURTH" = "--html" ] || [ "$EE_FOURTH" = "--php" ] || [ "$EE_FOURTH" = "--mysql" ] || [ "$EE_FOURTH" = "--wp" ] || [ "$EE_FOURTH" = "--wpsubdir" ] || [ "$EE_FOURTH" = "--wpsubdomain" ] \ + || [ "$EE_FOURTH" = "--basic" ] || [ "$EE_FOURTH" = "--w3tc" ] || [ "$EE_FOURTH" = "--wpsc" ] || [ "$EE_FOURTH" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$EE_FOURTH && EE_SITE_CREATE_OPTION=$EE_FOURTH && echo EE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION &>> $EE_COMMAND_LOG + [ "$EE_FIFTH" = "--basic" ] || [ "$EE_FIFTH" = "--w3tc" ] || [ "$EE_FIFTH" = "--wpsc" ] || [ "$EE_FIFTH" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$EE_FIFTH && echo EE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION &>> $EE_COMMAND_LOG # Auto arrange migrate arguments for ee_migrate_args in $@; do From f6b8e2406ab3620b4e059256dd6729b29a33a544 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Wed, 19 Nov 2014 10:58:37 +0530 Subject: [PATCH 446/829] Update wp-cli version to 0.17.1 --- src/lib/ee_lib_variables.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 45a7cb1e..817639a9 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -4,7 +4,7 @@ readonly EE_VERSION='2.2.1' # WP-CLI version -readonly EE_WP_CLI_VERSION='0.17.0' +readonly EE_WP_CLI_VERSION='0.17.1' # Adminer version readonly EE_ADMINER_VERSION='4.1.0' From 33afa7f1777d477d1e7de52d1f2d6c56b366facb Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Dec 2014 18:57:54 +0530 Subject: [PATCH 447/829] Python Commit --- .gitignore | 65 ++ CHANGELOG.txt | 157 --- CONTRIBUTING.md | 26 - LICENSE.txt | 348 ------- README.md | 87 +- bin/README.md | 8 - bin/easyengine | 950 ------------------ bin/install | 238 ----- bin/update | 530 ---------- config/README.md | 5 - config/bash_completion.d/README.md | 1 - config/bash_completion.d/ee | 127 --- config/easyengine/README.md | 1 - config/easyengine/ee.conf | 17 - config/nginx/README.md | 2 - config/nginx/common/README.md | 8 - config/nginx/common/acl.conf | 10 - config/nginx/common/locations.conf | 82 -- config/nginx/common/php.conf | 12 - config/nginx/common/w3tc.conf | 38 - config/nginx/common/wpcommon.conf | 42 - config/nginx/common/wpfc.conf | 47 - config/nginx/common/wpsc.conf | 39 - config/nginx/common/wpsubdir.conf | 14 - config/nginx/conf.d/README.md | 3 - config/nginx/conf.d/blockips.conf | 2 - config/nginx/conf.d/fastcgi.conf | 12 - config/nginx/conf.d/upstream.conf | 11 - docs/README.md | 12 +- docs/cs.md | 13 + docs/ds.md | 21 + docs/man/README.md | 1 - docs/man/ee.8 | 310 ------ .../delete/README.md => easyengine/LICENSE | 0 easyengine/README.md | 11 + easyengine/config/ee.conf | 41 + easyengine/config/plugins.d/example.conf | 11 + easyengine/ee/__init__.py | 1 + easyengine/ee/cli/__init__.py | 0 easyengine/ee/cli/bootstrap.py | 10 + easyengine/ee/cli/controllers/__init__.py | 0 easyengine/ee/cli/controllers/base.py | 28 + easyengine/ee/cli/controllers/site.py | 30 + easyengine/ee/cli/ext/__init__.py | 0 easyengine/ee/cli/main.py | 87 ++ easyengine/ee/cli/plugins/__init__.py | 0 easyengine/ee/cli/plugins/example.py | 50 + easyengine/ee/cli/templates/__init__.py | 0 easyengine/ee/core/__init__.py | 0 easyengine/ee/core/exc.py | 22 + easyengine/ee/utils/__init__.py | 0 easyengine/ee/utils/test.py | 16 + easyengine/requirements.txt | 1 + easyengine/setup.cfg | 9 + easyengine/setup.py | 34 + easyengine/tests/__init__.py | 0 easyengine/tests/cli/__init__.py | 0 easyengine/tests/cli/ext/__init__.py | 0 easyengine/tests/cli/plugins/__init__.py | 0 easyengine/tests/cli/plugins/test_example.py | 8 + easyengine/tests/cli/test_ee.py | 9 + easyengine/tests/core/__init__.py | 0 easyengine/tests/core/test_exc.py | 0 src/README.md | 12 - src/lib/README.md | 11 - src/lib/ee_lib_apt_get_update.sh | 7 - src/lib/ee_lib_autoremove.sh | 7 - src/lib/ee_lib_check_domain.sh | 16 - src/lib/ee_lib_check_fqdn.sh | 27 - src/lib/ee_lib_dotdeb.sh | 10 - src/lib/ee_lib_echo.sh | 25 - src/lib/ee_lib_error.sh | 7 - src/lib/ee_lib_git.sh | 26 - src/lib/ee_lib_gpg_key_fix.sh | 24 - src/lib/ee_lib_import_slow_log.sh | 26 - src/lib/ee_lib_mysql_info.sh | 27 - src/lib/ee_lib_nginx_info.sh | 29 - src/lib/ee_lib_package_check.sh | 20 - src/lib/ee_lib_permissions.sh | 8 - src/lib/ee_lib_php_info.sh | 56 -- src/lib/ee_lib_ram.sh | 48 - src/lib/ee_lib_service.sh | 44 - src/lib/ee_lib_stack_packages.sh | 54 - src/lib/ee_lib_swap.sh | 34 - src/lib/ee_lib_symbolic_link.sh | 8 - src/lib/ee_lib_variables.sh | 72 -- src/modules/README.md | 3 - src/modules/debug/README.md | 6 - src/modules/debug/ee_mod_debug_fpm.sh | 35 - src/modules/debug/ee_mod_debug_mysql.sh | 59 -- src/modules/debug/ee_mod_debug_nginx.sh | 77 -- src/modules/debug/ee_mod_debug_php.sh | 37 - src/modules/debug/ee_mod_debug_rewrite.sh | 72 -- src/modules/debug/ee_mod_debug_stop.sh | 24 - src/modules/debug/ee_mod_debug_wp.sh | 61 -- src/modules/ee_mod_clean.sh | 52 - src/modules/secure/ee_mod_secure_auth.sh | 28 - src/modules/secure/ee_mod_secure_ip.sh | 31 - src/modules/secure/ee_mod_secure_port.sh | 20 - src/modules/site/README.md | 6 - src/modules/site/create/README.md | 8 - .../site/create/ee_mod_plugin_nginx_helper.sh | 13 - .../site/create/ee_mod_plugin_settings.sh | 36 - src/modules/site/create/ee_mod_plugin_w3tc.sh | 13 - src/modules/site/create/ee_mod_plugin_wpsc.sh | 13 - .../site/create/ee_mod_setup_database.sh | 66 -- .../site/create/ee_mod_setup_domain.sh | 30 - .../site/create/ee_mod_setup_network.sh | 12 - .../site/create/ee_mod_setup_wordpress.sh | 144 --- .../site/delete/ee_mod_delete_database.sh | 44 - .../site/delete/ee_mod_delete_nginxconf.sh | 24 - .../site/delete/ee_mod_delete_webroot.sh | 24 - src/modules/site/ee_mod_site_backup.sh | 44 - src/modules/site/ee_mod_site_cd.sh | 8 - src/modules/site/ee_mod_site_edit.sh | 12 - src/modules/site/ee_mod_site_info.sh | 34 - src/modules/site/ee_mod_site_log.sh | 27 - src/modules/site/ee_mod_site_option.sh | 48 - src/modules/site/ee_mod_site_packages.sh | 27 - .../site/migrate/ee_mod_migrate_data.sh | 67 -- .../site/migrate/ee_mod_migrate_setup.sh | 61 -- .../update/ee_mod_site_update_password.sh | 42 - .../site/update/ee_mod_update_nginx.sh | 129 --- .../site/update/ee_mod_update_website.sh | 90 -- src/modules/stack/README.md | 2 - src/modules/stack/ee_mod_stack_status.sh | 58 -- src/modules/stack/install/README.md | 9 - .../stack/install/ee_mod_install_mysql.sh | 31 - .../stack/install/ee_mod_install_nginx.sh | 8 - .../stack/install/ee_mod_install_php.sh | 9 - .../stack/install/ee_mod_install_postfix.sh | 12 - .../stack/install/ee_mod_repo_mysql.sh | 14 - .../stack/install/ee_mod_repo_nginx.sh | 26 - src/modules/stack/install/ee_mod_repo_php.sh | 34 - .../stack/install/ee_mod_setup_mysql.sh | 16 - .../stack/install/ee_mod_setup_nginx.sh | 114 --- src/modules/stack/install/ee_mod_setup_php.sh | 84 -- .../install/mail/ee_mod_install_dovecot.sh | 24 - .../install/mail/ee_mod_install_mailscaner.sh | 9 - .../stack/install/mail/ee_mod_repo_dovecot.sh | 13 - .../install/mail/ee_mod_setup_dovecot.sh | 79 -- .../install/mail/ee_mod_setup_mailscaner.sh | 49 - .../install/mail/ee_mod_setup_postfix.sh | 72 -- .../stack/install/mail/ee_mod_setup_sieve.sh | 36 - src/modules/stack/remove/README.md | 4 - .../stack/remove/ee_mod_remove_mysql.sh | 17 - .../stack/remove/ee_mod_remove_nginx.sh | 8 - src/modules/stack/remove/ee_mod_remove_php.sh | 9 - .../stack/remove/ee_mod_remove_postfix.sh | 7 - .../remove/mail/ee_mod_remove_dovecot.sh | 13 - .../remove/mail/ee_mod_remove_mailscaner.sh | 18 - src/vendor/README.md | 8 - src/vendor/ee_ven_install_adminer.sh | 17 - src/vendor/ee_ven_install_phpmyadmin.sh | 33 - src/vendor/ee_ven_install_roundcube.sh | 30 - src/vendor/ee_ven_install_utils.sh | 127 --- src/vendor/ee_ven_install_vimbadmin.sh | 36 - src/vendor/ee_ven_install_wpcli.sh | 21 - src/vendor/ee_ven_remove_adminer.sh | 8 - src/vendor/ee_ven_remove_phpmyadmin.sh | 8 - src/vendor/ee_ven_remove_roundcube.sh | 17 - src/vendor/ee_ven_remove_utils.sh | 12 - src/vendor/ee_ven_remove_vimbadmin.sh | 16 - src/vendor/ee_ven_remove_wpcli.sh | 8 - src/vendor/ee_ven_setup_roundcube.sh | 35 - src/vendor/ee_ven_setup_vimbadmin.sh | 74 -- templates/README.md | 1 - templates/mail/10-master.conf | 26 - templates/mail/amavis-master.cf | 24 - templates/mail/auth-sql.conf.ext | 13 - templates/mail/autocreate | 10 - templates/mail/default.sieve | 4 - templates/mail/dovecot | 73 -- templates/mail/dovecot-sql.conf.ext | 15 - templates/mail/virtual_alias_maps.cf | 5 - templates/mail/virtual_domains_maps.cf | 5 - templates/mail/virtual_mailbox_maps.cf | 7 - templates/mail/webmail | 23 - templates/nginx/22222 | 61 -- templates/nginx/README.md | 7 - templates/nginx/html/README.md | 1 - templates/nginx/html/basic.conf | 19 - templates/nginx/mysql/README.md | 1 - templates/nginx/mysql/basic.conf | 16 - templates/nginx/php/README.md | 1 - templates/nginx/php/basic.conf | 16 - templates/nginx/wp/README.md | 4 - templates/nginx/wp/basic.conf | 17 - templates/nginx/wp/w3tc.conf | 17 - templates/nginx/wp/wpfc.conf | 17 - templates/nginx/wp/wpsc.conf | 17 - templates/nginx/wpsubdir/README.md | 4 - templates/nginx/wpsubdir/basic.conf | 24 - templates/nginx/wpsubdir/w3tc.conf | 24 - templates/nginx/wpsubdir/wpfc.conf | 24 - templates/nginx/wpsubdir/wpsc.conf | 24 - templates/nginx/wpsubdomain/README.md | 4 - templates/nginx/wpsubdomain/basic.conf | 23 - templates/nginx/wpsubdomain/w3tc.conf | 23 - templates/nginx/wpsubdomain/wpfc.conf | 23 - templates/nginx/wpsubdomain/wpsc.conf | 23 - 201 files changed, 483 insertions(+), 7070 deletions(-) create mode 100644 .gitignore delete mode 100644 CHANGELOG.txt delete mode 100644 CONTRIBUTING.md delete mode 100644 LICENSE.txt delete mode 100644 bin/README.md delete mode 100644 bin/easyengine delete mode 100644 bin/install delete mode 100644 bin/update delete mode 100644 config/README.md delete mode 100644 config/bash_completion.d/README.md delete mode 100644 config/bash_completion.d/ee delete mode 100644 config/easyengine/README.md delete mode 100644 config/easyengine/ee.conf delete mode 100644 config/nginx/README.md delete mode 100644 config/nginx/common/README.md delete mode 100644 config/nginx/common/acl.conf delete mode 100644 config/nginx/common/locations.conf delete mode 100644 config/nginx/common/php.conf delete mode 100644 config/nginx/common/w3tc.conf delete mode 100644 config/nginx/common/wpcommon.conf delete mode 100644 config/nginx/common/wpfc.conf delete mode 100644 config/nginx/common/wpsc.conf delete mode 100644 config/nginx/common/wpsubdir.conf delete mode 100644 config/nginx/conf.d/README.md delete mode 100644 config/nginx/conf.d/blockips.conf delete mode 100644 config/nginx/conf.d/fastcgi.conf delete mode 100644 config/nginx/conf.d/upstream.conf create mode 100644 docs/cs.md create mode 100644 docs/ds.md delete mode 100644 docs/man/README.md delete mode 100644 docs/man/ee.8 rename src/modules/site/delete/README.md => easyengine/LICENSE (100%) create mode 100644 easyengine/README.md create mode 100644 easyengine/config/ee.conf create mode 100644 easyengine/config/plugins.d/example.conf create mode 100644 easyengine/ee/__init__.py create mode 100644 easyengine/ee/cli/__init__.py create mode 100644 easyengine/ee/cli/bootstrap.py create mode 100644 easyengine/ee/cli/controllers/__init__.py create mode 100644 easyengine/ee/cli/controllers/base.py create mode 100644 easyengine/ee/cli/controllers/site.py create mode 100644 easyengine/ee/cli/ext/__init__.py create mode 100644 easyengine/ee/cli/main.py create mode 100644 easyengine/ee/cli/plugins/__init__.py create mode 100644 easyengine/ee/cli/plugins/example.py create mode 100644 easyengine/ee/cli/templates/__init__.py create mode 100644 easyengine/ee/core/__init__.py create mode 100644 easyengine/ee/core/exc.py create mode 100644 easyengine/ee/utils/__init__.py create mode 100644 easyengine/ee/utils/test.py create mode 100644 easyengine/requirements.txt create mode 100644 easyengine/setup.cfg create mode 100644 easyengine/setup.py create mode 100644 easyengine/tests/__init__.py create mode 100644 easyengine/tests/cli/__init__.py create mode 100644 easyengine/tests/cli/ext/__init__.py create mode 100644 easyengine/tests/cli/plugins/__init__.py create mode 100644 easyengine/tests/cli/plugins/test_example.py create mode 100644 easyengine/tests/cli/test_ee.py create mode 100644 easyengine/tests/core/__init__.py create mode 100644 easyengine/tests/core/test_exc.py delete mode 100644 src/README.md delete mode 100644 src/lib/README.md delete mode 100644 src/lib/ee_lib_apt_get_update.sh delete mode 100644 src/lib/ee_lib_autoremove.sh delete mode 100644 src/lib/ee_lib_check_domain.sh delete mode 100644 src/lib/ee_lib_check_fqdn.sh delete mode 100644 src/lib/ee_lib_dotdeb.sh delete mode 100644 src/lib/ee_lib_echo.sh delete mode 100644 src/lib/ee_lib_error.sh delete mode 100644 src/lib/ee_lib_git.sh delete mode 100644 src/lib/ee_lib_gpg_key_fix.sh delete mode 100644 src/lib/ee_lib_import_slow_log.sh delete mode 100644 src/lib/ee_lib_mysql_info.sh delete mode 100644 src/lib/ee_lib_nginx_info.sh delete mode 100644 src/lib/ee_lib_package_check.sh delete mode 100644 src/lib/ee_lib_permissions.sh delete mode 100644 src/lib/ee_lib_php_info.sh delete mode 100644 src/lib/ee_lib_ram.sh delete mode 100644 src/lib/ee_lib_service.sh delete mode 100644 src/lib/ee_lib_stack_packages.sh delete mode 100644 src/lib/ee_lib_swap.sh delete mode 100644 src/lib/ee_lib_symbolic_link.sh delete mode 100644 src/lib/ee_lib_variables.sh delete mode 100644 src/modules/README.md delete mode 100644 src/modules/debug/README.md delete mode 100644 src/modules/debug/ee_mod_debug_fpm.sh delete mode 100644 src/modules/debug/ee_mod_debug_mysql.sh delete mode 100644 src/modules/debug/ee_mod_debug_nginx.sh delete mode 100644 src/modules/debug/ee_mod_debug_php.sh delete mode 100644 src/modules/debug/ee_mod_debug_rewrite.sh delete mode 100644 src/modules/debug/ee_mod_debug_stop.sh delete mode 100644 src/modules/debug/ee_mod_debug_wp.sh delete mode 100644 src/modules/ee_mod_clean.sh delete mode 100644 src/modules/secure/ee_mod_secure_auth.sh delete mode 100644 src/modules/secure/ee_mod_secure_ip.sh delete mode 100644 src/modules/secure/ee_mod_secure_port.sh delete mode 100644 src/modules/site/README.md delete mode 100644 src/modules/site/create/README.md delete mode 100644 src/modules/site/create/ee_mod_plugin_nginx_helper.sh delete mode 100644 src/modules/site/create/ee_mod_plugin_settings.sh delete mode 100644 src/modules/site/create/ee_mod_plugin_w3tc.sh delete mode 100644 src/modules/site/create/ee_mod_plugin_wpsc.sh delete mode 100644 src/modules/site/create/ee_mod_setup_database.sh delete mode 100644 src/modules/site/create/ee_mod_setup_domain.sh delete mode 100644 src/modules/site/create/ee_mod_setup_network.sh delete mode 100644 src/modules/site/create/ee_mod_setup_wordpress.sh delete mode 100644 src/modules/site/delete/ee_mod_delete_database.sh delete mode 100644 src/modules/site/delete/ee_mod_delete_nginxconf.sh delete mode 100644 src/modules/site/delete/ee_mod_delete_webroot.sh delete mode 100644 src/modules/site/ee_mod_site_backup.sh delete mode 100644 src/modules/site/ee_mod_site_cd.sh delete mode 100644 src/modules/site/ee_mod_site_edit.sh delete mode 100644 src/modules/site/ee_mod_site_info.sh delete mode 100644 src/modules/site/ee_mod_site_log.sh delete mode 100644 src/modules/site/ee_mod_site_option.sh delete mode 100644 src/modules/site/ee_mod_site_packages.sh delete mode 100644 src/modules/site/migrate/ee_mod_migrate_data.sh delete mode 100644 src/modules/site/migrate/ee_mod_migrate_setup.sh delete mode 100644 src/modules/site/update/ee_mod_site_update_password.sh delete mode 100644 src/modules/site/update/ee_mod_update_nginx.sh delete mode 100644 src/modules/site/update/ee_mod_update_website.sh delete mode 100644 src/modules/stack/README.md delete mode 100644 src/modules/stack/ee_mod_stack_status.sh delete mode 100644 src/modules/stack/install/README.md delete mode 100644 src/modules/stack/install/ee_mod_install_mysql.sh delete mode 100644 src/modules/stack/install/ee_mod_install_nginx.sh delete mode 100644 src/modules/stack/install/ee_mod_install_php.sh delete mode 100644 src/modules/stack/install/ee_mod_install_postfix.sh delete mode 100644 src/modules/stack/install/ee_mod_repo_mysql.sh delete mode 100644 src/modules/stack/install/ee_mod_repo_nginx.sh delete mode 100644 src/modules/stack/install/ee_mod_repo_php.sh delete mode 100644 src/modules/stack/install/ee_mod_setup_mysql.sh delete mode 100644 src/modules/stack/install/ee_mod_setup_nginx.sh delete mode 100644 src/modules/stack/install/ee_mod_setup_php.sh delete mode 100644 src/modules/stack/install/mail/ee_mod_install_dovecot.sh delete mode 100644 src/modules/stack/install/mail/ee_mod_install_mailscaner.sh delete mode 100644 src/modules/stack/install/mail/ee_mod_repo_dovecot.sh delete mode 100644 src/modules/stack/install/mail/ee_mod_setup_dovecot.sh delete mode 100644 src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh delete mode 100644 src/modules/stack/install/mail/ee_mod_setup_postfix.sh delete mode 100644 src/modules/stack/install/mail/ee_mod_setup_sieve.sh delete mode 100644 src/modules/stack/remove/README.md delete mode 100644 src/modules/stack/remove/ee_mod_remove_mysql.sh delete mode 100644 src/modules/stack/remove/ee_mod_remove_nginx.sh delete mode 100644 src/modules/stack/remove/ee_mod_remove_php.sh delete mode 100644 src/modules/stack/remove/ee_mod_remove_postfix.sh delete mode 100644 src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh delete mode 100644 src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh delete mode 100644 src/vendor/README.md delete mode 100644 src/vendor/ee_ven_install_adminer.sh delete mode 100644 src/vendor/ee_ven_install_phpmyadmin.sh delete mode 100644 src/vendor/ee_ven_install_roundcube.sh delete mode 100644 src/vendor/ee_ven_install_utils.sh delete mode 100644 src/vendor/ee_ven_install_vimbadmin.sh delete mode 100644 src/vendor/ee_ven_install_wpcli.sh delete mode 100644 src/vendor/ee_ven_remove_adminer.sh delete mode 100644 src/vendor/ee_ven_remove_phpmyadmin.sh delete mode 100644 src/vendor/ee_ven_remove_roundcube.sh delete mode 100644 src/vendor/ee_ven_remove_utils.sh delete mode 100644 src/vendor/ee_ven_remove_vimbadmin.sh delete mode 100644 src/vendor/ee_ven_remove_wpcli.sh delete mode 100644 src/vendor/ee_ven_setup_roundcube.sh delete mode 100644 src/vendor/ee_ven_setup_vimbadmin.sh delete mode 100644 templates/README.md delete mode 100644 templates/mail/10-master.conf delete mode 100644 templates/mail/amavis-master.cf delete mode 100644 templates/mail/auth-sql.conf.ext delete mode 100644 templates/mail/autocreate delete mode 100644 templates/mail/default.sieve delete mode 100644 templates/mail/dovecot delete mode 100644 templates/mail/dovecot-sql.conf.ext delete mode 100644 templates/mail/virtual_alias_maps.cf delete mode 100644 templates/mail/virtual_domains_maps.cf delete mode 100644 templates/mail/virtual_mailbox_maps.cf delete mode 100644 templates/mail/webmail delete mode 100644 templates/nginx/22222 delete mode 100644 templates/nginx/README.md delete mode 100644 templates/nginx/html/README.md delete mode 100644 templates/nginx/html/basic.conf delete mode 100644 templates/nginx/mysql/README.md delete mode 100644 templates/nginx/mysql/basic.conf delete mode 100644 templates/nginx/php/README.md delete mode 100644 templates/nginx/php/basic.conf delete mode 100644 templates/nginx/wp/README.md delete mode 100644 templates/nginx/wp/basic.conf delete mode 100644 templates/nginx/wp/w3tc.conf delete mode 100644 templates/nginx/wp/wpfc.conf delete mode 100644 templates/nginx/wp/wpsc.conf delete mode 100644 templates/nginx/wpsubdir/README.md delete mode 100644 templates/nginx/wpsubdir/basic.conf delete mode 100644 templates/nginx/wpsubdir/w3tc.conf delete mode 100644 templates/nginx/wpsubdir/wpfc.conf delete mode 100644 templates/nginx/wpsubdir/wpsc.conf delete mode 100644 templates/nginx/wpsubdomain/README.md delete mode 100644 templates/nginx/wpsubdomain/basic.conf delete mode 100644 templates/nginx/wpsubdomain/w3tc.conf delete mode 100644 templates/nginx/wpsubdomain/wpfc.conf delete mode 100644 templates/nginx/wpsubdomain/wpsc.conf diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..7ae37858 --- /dev/null +++ b/.gitignore @@ -0,0 +1,65 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + + +# Vim .swp file +*.swp + +# Folder created for Nose testing +easyengine/bin/ +easyengine/coverage_report/ +easyengine/include/ +easyengine/local/ +easyengine/man/ diff --git a/CHANGELOG.txt b/CHANGELOG.txt deleted file mode 100644 index 796c2b4a..00000000 --- a/CHANGELOG.txt +++ /dev/null @@ -1,157 +0,0 @@ -v 2.2.1 - Oct 16,2014 -- Fixed update script issue for remote MySQL #323 -- Fixed remote MySQL delete user issue by @brennentsmith #324 -- Improved auto-completion - -v 2.2.0 - Oct 13, 2014 -- Percona Mysql 5.6 support on Fresh installation. #107 -- RAM Based Optimization for PHP5-FPM,OpCache and Memcache -- Introduced following new commands for - - ee site cd example.com # Change Directory to example.com Webroot - - ee site log example.com # Real time log monitoring for example.com access and error logs - - ee site update example.com # update example.com cache and convert site - - ee clean # Clean cache NGINX FastCGI, Memcache, OPcache. -- Change WordPress user password easily ( ee site update example.com --password) #315 -- Added PHP5-GeoIP Support -- Auto Swap creation for low RAM servers. -- Fixed Better autocompletion feature. Fixed #311. -- Fixed phpMyAdmin (blowfish_secret) error #301 -- Simplified way to update EasyEngine. #307 - -v 2.1.0 - Sept 3, 2014 - - Added Mail Server Package installation #65 - - Fixed incorrect log file path during debug #299 - - Added support for pt-query-advisor #189 - - Fixed Firefox cross-domain fonts - - Fixed ee site edit command on Nano editor - -v 2.0.2 - Aug 13, 2014 - - Remote MySQL Support - -v 2.0.1 - July 21, 2014 - - Fixed wp-cli installation #289 - -v 2.0.0 - July 14, 2014 - - Completly rewritten code - - Updated wp-cli to 0.16.0 - - Introduced ee secure command - - Changed the way to update EasyEngine #179 - - Fixed security on 22222 port by @RenzoF #263 - - Fixed MySQL stopped in ee stack status #233 - - Added WordPress SEO Yoast plugin support in wpcommon.conf #165 - - Depricated ee system command with ee stack command - - -v 1.3.8 - May 26, 2014 - - Fixed phpMyAdmin download issue #251 - - Fixed swap issue #223 by @Swingline0 - - Delete website without prompt by @edwinvandeven #239 - - -v 1.3.7 - Apr 29, 2014 - - Fixed EasyEngine Update Problem - - Fixed Issue #206 - - Update nginx version 1.6.0 - - Update wp-cli version 0.14.1 - - -v 1.3.6 - Apr 24, 2014 - - Fixed Nginx Update Problem #201 - - Automate Testing Using Travis-ci - - -v 1.3.5 - Apr 22, 2014 - - Update nginx to the latest stable version (1.4.7) - - -v 1.3.4 - Apr 22, 2014 - - Supports Ubuntu 12.04, 12.10, 13.10 & 14.04 ( Fixed Issue #94 #195 ) - - Change FPM process management from dynamic to ondemand #184 - - Fixed Issue #188 - - Fixed Debian 6 wget command issue - - -v 1.3.3 - Apr 16, 2014 - - Fixed issue #186 - - Fixed issue #187 - - -v 1.3.2 - Apr 14, 2014 - - Fixed ee update - - -v 1.3.1 - Apr 14, 2014 - - Fixed Autocompletion Issue #185 - - ee info command display php5-fpm process manager details (dynamic/ondemand) - - -v 1.3.0 - Apr 11, 2014 - - Introduce `ee debug` command - - Introduce `ee system [status|stop|start|restart]` command - - - EasyEngine Admin Tools shifted on port `22222` with self signed SSL Certificate #124 - - Setup Separate PHP5-FPM Pool on Port 9001 for debugging purpose - - Polish `ee site edit` command #157 - - Fixed MySQL Username Character Limit #113 - - Nginx Settings #100 - - -v 1.2.2 - Mar 18, 2014 - - Check/Install bc command - - Fixed EasyEngine Update Issue #134 #148 - - Automatic set WordPress Permalink Structure by @UmeshSingla - - Fixed @WP-CLI version to 0.14.1 - - Correct Typo Mistake, Thanks to @sdenike on pull request #155 - - Introduce ee site edit command by @Mermouy on pull request #153 - - Auto Switch the site create options - - Better way to detect Linux Ditribution - - -v 1.2.1 - Mar 3, 2014 - - Fixed Debian Issue #136 - - -v 1.2 - Feb 20, 2014 - - Debian 6 and Debian 7 support added - - -v 1.1.5 - Feb 17, 2014 - - Fixed WordPress multisite issue (#127). - - -v 1.1.4 - Feb 14, 2014 - - Fixed wp-cli issue with --allow-root error. - - -v 1.1.3 - Jan 28, 2014 - - Added GPL License. Ref - https://rtcamp.com/easyengine-is-gpl/ - - -v 1.1.2 - Jan 28, 2014 - - Fix White-list IP Address - - Fix ee info command - - Fix site delete issue (#111) - - -v 1.1.1 - Jan 17, 2014 - - IP-detcect issue. (#108) - - -v 1.1 - Jan 16, 2014 - - Handling redirects from “non-www to www” and vice-versa. (#71) - - Automating mysql setup. Every site which needs a database gets a new mysql user and password automatically. mysql root is not used anymore for new sites. (#72) - - Automated postfix installation. (#72) - - Added “ee info” command (#69) - - Secured /ee locations (#60 and https://rtcamp.com/tutorials/nginx/ssl-pci-compliance-performance/) - - SSL Session cache for nginx (#56) - - -v 1.0.1 - Dec 17, 2013 - - Fix wp-cli issue - - -v 1.0.0 - Oct 1, 2013 - - First Release - - Support for Standard WordPress and multisite WordPress - - Support for Nginx Fastcgi-Cache, W3 Total Cache and WP Super Cache - - Support for PHP and HTML sites diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 9d94d7fc..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,26 +0,0 @@ -# Contribute to EasyEngine (ee) - -This guide details how to use issues and pull requests to improve EasyEngine (ee). - -## How to report issue: - -Github issue-tracker is used **only** for report bugs and feature request. - -Please attach the output of following command when open a new issue/bug -```bash -lsb_release -a -ee version -ee info -wp --allow-root --info -``` - -### EasyEngine chat: -Developer & contributor discussion: https://gitter.im/rtCamp/easyengine - - -### EasyEngine support request: -For support-request please use - https://rtcamp.com/easyengine/support/ - - -### Pull Requests: -When submitting your code please follow this coding standerds - https://google-styleguide.googlecode.com/svn/trunk/shell.xml diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 46a18075..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,348 +0,0 @@ -Copyright 2013-2014 by RTCAMP SOLUTIONS PRIVATE LIMITED [https://rtcamp.com/] and Contributors [https://github.com/rtCamp/easyengine/graphs/contributors] - - - Wherever third party code has been used, credit has been given in the code's - comments. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/README.md b/README.md index 23acb4a7..2595f07c 100644 --- a/README.md +++ b/README.md @@ -1,88 +1,11 @@ -[![Stories in Ready](https://badge.waffle.io/rtcamp/easyengine.png?label=ready&title=Ready)](https://waffle.io/rtcamp/easyengine) -[![Stories in Progress](https://badge.waffle.io/rtcamp/easyengine.png?label=in%20progress&title=In%20Progress)](https://waffle.io/rtcamp/easyengine) -EasyEngine Logo +EasyEngine 3.x Developement version -[![Travis Build Status](https://travis-ci.org/rtCamp/easyengine.svg "Travis Build Status")] (https://travis-ci.org/rtCamp/easyengine) -EasyEngine (ee) is a linux shell-script collection, which makes it easy to manage your wordpress sites running on nginx web-server. -**EasyEngine currently supports:** +Thinking To Contribute??? -- Ubuntu 12.04 & 14.04 -- Debian 6 & 7 +refer docs to know more on EasyEngine Developement -## Quick Start - -```bash -wget -qO ee rt.cx/ee && sudo bash ee # install easyengine -ee site create example.com --wp # Install required packages & setup WordPress on example.com -``` - -## Update EasyEngine - - -Update Procedure For EasyEngine - -```bash -wget -qO eeup http://rt.cx/eeup && sudo bash eeup -``` - -## More Site Creation Commands - -### Standard WordPress Sites - -```bash -ee site create example.com --wp # install wordpress without any page caching -ee site create example.com --w3tc # install wordpress with w3-total-cache plugin -ee site create example.com --wpsc # install wordpress with wp-super-cache plugin -ee site create example.com --wpfc # install wordpress + nginx fastcgi_cache -``` - -### WordPress Multsite with subdirectory - -```bash -ee site create example.com --wpsubdir # install wpmu-subdirectory without any page caching -ee site create example.com --wpsubdir --w3tc # install wpmu-subdirectory with w3-total-cache plugin -ee site create example.com --wpsubdir --wpsc # install wpmu-subdirectory with wp-super-cache plugin -ee site create example.com --wpsubdir --wpfc # install wpmu-subdirectory + nginx fastcgi_cache -``` - -### WordPress Multsite with subdomain - -```bash -ee site create example.com --wpsubdom # install wpmu-subdomain without any page caching -ee site create example.com --wpsubdom --w3tc # install wpmu-subdomain with w3-total-cache plugin -ee site create example.com --wpsubdom --wpsc # install wpmu-subdomain with wp-super-cache plugin -ee site create example.com --wpsubdom --wpfc # install wpmu-subdomain + nginx fastcgi_cache -``` - -### Non-WordPress Sites -```bash -ee site create example.com --html # create example.com for static/html sites -ee site create example.com --php # create example.com with php support -ee site create example.com --mysql # create example.com with php & mysql support -``` - -## Cheatsheet - Site creation - - -| | Single Site | Multisite w/ Subdir | Multisite w/ Subdom | -|--------------------|---------------|-----------------------|-----------------------| -| **NO Cache** | --wp | --wpsubdir | --wpsubdom | -| **WP Super Cache** | --wpsc | --wpsubdir --wpsc | --wpsubdom --wpsc | -| **W3 Total Cache** | --w3tc | --wpsubdir --w3tc | --wpsubdom --w3tc | -| **Nginx cache** | --wpfc | --wpsubdir --wpfc | --wpsubdom --wpfc | - - -## Useful Links -- [Documentation] (http://rtcamp.com/easyengine/docs/) -- [FAQ] (http://rtcamp.com/easyengine/faq/) -- [Conventions used] (http://rtcamp.com/wordpress-nginx/tutorials/conventions/) - -## Donations -- [Using PayPal] (https://rtcamp.com/donate/?project=easyengine) - -## License - -Same [GPL] (http://www.gnu.org/licenses/gpl-2.0.txt) that WordPress uses! +follow instruction from step 3 in Creating cement app +http://builtoncement.com/2.4/dev/boss_templates.html diff --git a/bin/README.md b/bin/README.md deleted file mode 100644 index aa13886e..00000000 --- a/bin/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Includes binaries of EasyEngine (ee). - -Actual Path : `/usr/local/sbin/` - -1. **easyengine** - Main script for all EasyEngine (ee) tasks. -1. **update** - Script to update EasyEngine (ee). -1. **install** - Script to install EasyEngine (ee). - diff --git a/bin/easyengine b/bin/easyengine deleted file mode 100644 index 8abbaf6c..00000000 --- a/bin/easyengine +++ /dev/null @@ -1,950 +0,0 @@ -#!/bin/bash - -# Include library -for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do - source $ee_include -done - -# Main EasyEngine (ee) function to log all the outputs -EasyEngine() -{ - -# Arguments -EE_FIRST=$1 -EE_SECOND=$2 -EE_THIRD=$3 -EE_FOURTH=$4 -EE_FIFTH=$5 - -# Let's capture the EasyEngine arguments -ee_lib_echo "EasyEngine (ee) $EE_VERSION execution started [$(date)]" &>> $EE_COMMAND_LOG -ee_lib_echo "EasyEngine (ee) command: $0 $@" &>> $EE_COMMAND_LOG - - -# EasyEngine version -if [ "$EE_FIRST" = "version" ] || [ "$EE_FIRST" = "--version" ] || [ "$EE_FIRST" = "-v" ];then - # Display Easy Engine Version - echo "EasyEngine (ee) version: $EE_VERSION" - -# EasyEngine help -elif [ "$EE_FIRST" = "help" ] || [ "$EE_FIRST" = "--help" ] || [ "$EE_FIRST" = "-h" ]; then - # Display man page - man ee - -# Display information about NGINX|PHP|MySQL -elif [ "$EE_FIRST" = "info" ];then - if [ "$EE_SECOND" = "nginx" ] || [ "$EE_SECOND" = "php" ] || [ "$EE_SECOND" = "mysql" ]; then - ee_lib_${EE_SECOND}_info - else - ee_lib_nginx_info - ee_lib_php_info - ee_lib_mysql_info - fi - -# EasyEngine stack/system -elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then - # EasyEngine install - if [ "$EE_SECOND" = "install" ]; then - # EasyEngine RAM based settings - ee_lib_ram - # EasyEngine Swap creation - ee_lib_swap - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then - # Setup NGINX/PHP/Percona MySQL repository - ee_mod_repo_$EE_THIRD - - # Fix GnuPG key - ee_lib_gpg_key_fix - fi - - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then - # Execute: apt-get update - ee_lib_apt_get_update - - # Install NGINX/PHP/MySQL/Postfix package - ee_mod_install_$EE_THIRD - fi - - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then - # Setup NGINX/PHP/MySQL - ee_mod_setup_$EE_THIRD - fi - - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then - # Restart php5-fpm - if [ "$EE_THIRD" = "php" ];then - ee_lib_service php5-fpm restart - - # Initialize Git - ee_lib_git /etc/php5/ "Initialize Git" - else - # Restart NGINX/MySQL/Postfix - ee_lib_service $EE_THIRD restart - - # Initialize Git - ee_lib_git /etc/$EE_THIRD/ "Initialize Git" - fi - fi - - if [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ];then - # Install Adminer/phpMyAdmin/WP-CLI/Utils - ee_ven_install_$EE_THIRD - fi - - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "admin" ] ; then - if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then - # Setup NGINX/PHP/Percona MySQL repository - ee_mod_repo_nginx - ee_mod_repo_php - ee_mod_repo_mysql - - # Fix GnuPG key - ee_lib_gpg_key_fix - - # Execute: apt-get update - ee_lib_apt_get_update - - # Install NGINX/PHP/MySQL/Postfix package - ee_mod_install_nginx - ee_mod_install_php - ee_mod_install_mysql - ee_mod_install_postfix - - # Setup NGINX/PHP/MySQL - ee_mod_setup_nginx - ee_mod_setup_php - ee_mod_setup_mysql - - # Restart NGINX/MySQL/Postfix - ee_lib_service nginx php5-fpm mysql restart - - # Initialize Git - ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git" - - # Install WP-CLI - ee_ven_install_wpcli - fi - # Install Adminer/phpMyAdmin/Utils - ee_ven_install_adminer - ee_ven_install_phpmyadmin - ee_ven_install_utils - fi - - # EasyEngine mail server setup - if [ "$EE_THIRD" = "mail" ] || [ "$EE_THIRD" = "all" ];then - - # Check required Packages are installed or not - dpkg --get-selections | grep -v deinstall | grep nginx > /dev/null \ - && dpkg --get-selections | grep -v deinstall | grep php5-fpm > /dev/null \ - && mysqladmin ping &>> $EE_COMMAND_LOG \ - && dpkg --get-selections | grep -v deinstall | grep postfix > /dev/null - if [ $? -ne 0 ];then - ee_lib_error "Failed to find NGINX PHP MySQL Postfix, exit status=" 1 - fi - - dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null - if [ $? -eq 0 ];then - ee_lib_error "Found installed Dovecot Packages, exit status=" 1 - fi - - # Check hostname is FQDN or not, if not asks user to set hostname as FQDN - ee_lib_check_fqdn $(hostname -f) - - # Install Dovecot - ee_mod_install_dovecot - - - # Install ViMbAdmin - ee_ven_install_vimbadmin - - # Install Roundcube - ee_ven_install_roundcube - - # Configure PostFix - ee_mod_setup_postfix - - # Configure Dovecot - ee_mod_setup_dovecot - - # Setup ViMbAdmin - ee_ven_setup_vimbadmin - - # Setup Roundcube - ee_ven_setup_roundcube - - # Setup Sieve Rules - ee_mod_setup_sieve - - if [ "$EE_SETUP_MAILSCANNER" != "no" ]; then - # Install mail scanner packages - ee_mod_install_mailscaner - - # Setup Amavis - ee_mod_setup_mailscaner - else - ee_lib_echo_fail "RAM is less then 512MB, EasyEngine skip installing Mail Scanner Packages" - - fi - ee_lib_service nginx postfix dovecot amavis restart - - ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Initialize Git" - - # Display message for mail server - ee_lib_echo_escape "Configure ViMbAdmin:\thttps://$(hostname -f):22222/vimbadmin" - ee_lib_echo_escape "Security Salt:\t\t${ee_security_salt}\n" - - elif [ "$EE_THIRD" = "mailscanner" ]; then - - dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null - if [ $? -ne 0 ];then - ee_lib_error "Failed to find Dovecot Packages, exit status = " 1 - fi - - # Install Mail Scanner - ee_mod_install_mailscaner - - # Setup Mail Scanner - ee_mod_setup_mailscaner - - ee_lib_service nginx postfix dovecot amavis restart - - ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Installed Mail Scanner Packages" - fi - - # Display HTTP authentication details - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then - if [ "$EE_DISPLAY" = "true" ]; then - ee_lib_echo_info "HTTP authentication username: $EE_HTTP_AUTH_USER" - ee_lib_echo_info "HTTP authentication password: $EE_HTTP_AUTH_PASS" - fi - fi - # Display success message - if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ]; then - EE_THIRD="Web packages" - fi - ee_lib_echo "$EE_THIRD successfully installed" - - # EasyEngine remove/purge - elif [ "$EE_SECOND" = "remove" ] || [ "$EE_SECOND" = "purge" ]; then - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then - - # Remove/Purge NGINX/PHP/MySQL/Postfix package - if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then - ee_mod_remove_$EE_THIRD - - # Execute: apt-get autoremove - ee_lib_autoremove - fi - - # Remove/Purge Adminer/phpMyAdmin/WP-CLI/Utils - if [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ];then - ee_ven_remove_$EE_THIRD - fi - - - elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "admin" ] ; then - if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then - # Remove/Purge NGINX/PHP/MySQL/Postfix package - ee_mod_remove_nginx - ee_mod_remove_php - ee_mod_remove_mysql - ee_mod_remove_postfix - - # Remove/Purge WP-CLI - ee_ven_remove_wpcli - fi - # Remove/Purge Adminer/phpMyAdmin/Utils - ee_ven_remove_adminer - ee_ven_remove_phpmyadmin - ee_ven_remove_utils - - # Execute: apt-get autoremove - ee_lib_autoremove - fi - if [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "mail" ];then - # Remove Dovecot - ee_mod_remove_dovecot - - # Remove Mail Scanner - ee_mod_remove_mailscaner - - # Remove ViMbAdmin - ee_ven_remove_vimbadmin - - # Remove Roundcube - ee_ven_remove_roundcube - - # Execute: apt-get autoremove - ee_lib_autoremove - - # Restart Nginx - ee_lib_service nginx - - ee_lib_git /etc/nginx "Removed Mail Server" - - elif [ "$EE_THIRD" = "mailscanner" ]; then - # Remove Amavis - ee_mod_remove_mailscaner - - # Execute: apt-get autoremove - ee_lib_autoremove - - ee_lib_service nginx postfix dovecot restart - - ee_lib_git /etc/postfix "Removed mailscanner" - fi - - # Display success message - if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ]; then - EE_THIRD="Web packages" - fi - if [ "$EE_SECOND" = "remove" ];then - ee_lib_echo "$EE_THIRD successfully removed" - elif [ "$EE_SECOND" = "purge" ];then - ee_lib_echo "$EE_THIRD successfully purged" - fi - - elif [ "$EE_SECOND" = "status" ]; then - ee_mod_stack_status - elif [ "$EE_SECOND" = "start" ] || [ "$EE_SECOND" = "stop" ] || [ "$EE_SECOND" = "reload" ] || [ "$EE_SECOND" = "restart" ]; then - ee_lib_service nginx php5-fpm mysql postfix $EE_SECOND - else - ee_lib_echo "ee stack commands:" - ee_lib_echo_escape "\tinstall\tInstall NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI , Utils, Mailscanner and Admin tools" - ee_lib_echo_escape "\tremove\tRemove NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI, Utils, Mailscanner and Admin tools" - ee_lib_echo_escape "\tpurge\tPurge NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI, Utils, Mailscanner and Admin tools" - ee_lib_echo_escape "\tstatus\tDisplay system status information" - ee_lib_echo_escape "\tstart\tStart NGINX, PHP5, MySQL and Postfix service" - ee_lib_echo_escape "\tstop\tStop NGINX, PHP5, MySQL and Postfix service" - ee_lib_echo_escape "\treload\tReload NGINX, PHP5, MySQL and Postfix service" - ee_lib_echo_escape "\trestart\tRestart NGINX, PHP5, MySQL and Postfix service" - fi - - -# EasyEngine site -elif [ "$EE_FIRST" = "site" ]; then - if [ "$EE_SECOND" = "list" ]; then - if [ "$EE_THIRD" = "available" ];then - ee_lib_echo "List of sites-available websites:" - ls /etc/nginx/sites-available/ \ - || ee_lib_error "Unable to display list of sites-available websites, exit status = " $? - else - ee_lib_echo "List of sites-enabled websites:" - ls /etc/nginx/sites-enabled/ \ - || ee_lib_error "Unable to display list of sites-enabled websites, exit status = " $? - fi - elif [ "$EE_SECOND" = "info" ] || [ "$EE_SECOND" = "show" ]; then - # Check the website name is empty or not - EE_DOMAIN_CHECK=$EE_THIRD - ee_lib_check_domain - - if [ "$EE_SECOND" = "info" ]; then - # Display information about website - ee_mod_site_info - elif [ "$EE_SECOND" = "show" ]; then - # Check the website exist - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - - # Display NGINX configuration for $EE_DOMAIN - if [ $? -eq 0 ]; then - ee_lib_echo "Display NGINX configuration for $EE_DOMAIN" - cat /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to display NGINX configuration for $EE_DOMAIN, exit status = " $? - fi - fi - elif [ "$EE_SECOND" = "enable" ]; then - # Check the website name is empty or not - EE_DOMAIN_CHECK=$EE_THIRD - ee_lib_check_domain - - # Creating symbolic link - ee_lib_echo "Creating symbolic link for $EE_DOMAIN" - ee_lib_symbolic_link /etc/nginx/sites-available/$EE_DOMAIN /etc/nginx/sites-enabled/ - - # Execute: service nginx reload - ee_lib_service nginx reload - - # Git commit - ee_lib_git /etc/nginx/ "Enable website: $EE_DOMAIN" - elif [ "$EE_SECOND" = "disable" ]; then - # Check the website name is empty or not - EE_DOMAIN_CHECK=$EE_THIRD - ee_lib_check_domain - - # Remove symbolic link - ee_lib_echo "Removing symbolic link for $EE_DOMAIN" - rm /etc/nginx/sites-enabled/$EE_DOMAIN \ - || ee_lib_error "Unable to remove symbolic link for $EE_DOMAIN, exit status = " $? - - # Execute: service nginx reload - ee_lib_service nginx reload - - # Git commit - ee_lib_git /etc/nginx/ "Disable website: $EE_DOMAIN" - elif [ "$EE_SECOND" = "edit" ]; then - # Check the website name is empty or not - EE_DOMAIN_CHECK=$EE_THIRD - ee_lib_check_domain - - # Edit the NGINX configuration for $EE_DOMAIN - ee_mod_site_edit $EE_FOURTH - - if [ $(cd /etc/nginx; git status -s /etc/nginx/sites-available/$EE_DOMAIN | wc -l) -ne 0 ]; then - # Git commit - ee_lib_git /etc/nginx/ "Edit website: $EE_DOMAIN" - - # Execute: service nginx reload - ee_lib_service nginx reload - fi - elif [ "$EE_SECOND" = "create" ]; then - # Configure variables - EE_DOMAIN_CHECK=$EE_THIRD - EE_SITE_CREATE_OPTION=$EE_FOURTH - EE_SITE_CACHE_OPTION=$EE_FIFTH - - # Auto switch site options - ee_mod_site_option - - # Install required packages - ee_mod_site_packages - - # Lets create HTML|PHP|MySQL website - if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - # Configure variable - EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/basic.conf - echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nEE_NGINX_CONF = $EE_NGINX_CONF" &>> $EE_COMMAND_LOG - - # Setup NGINX - ee_lib_check_domain - ee_mod_setup_domain - - # Setup MySQL database - if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - ee_mod_setup_database - - # Add Database Information On ee-config.php - echo -e "" \ - &>> /var/www/$EE_DOMAIN/ee-config.php - fi - - # Adjust permission - ee_lib_permissions - - # Git commit - ee_lib_git /etc/nginx/ "$EE_DOMAIN created with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" - - # Display Http Auth credentials - if [ "$EE_DISPLAY" = "false" ]; then - ee_lib_echo_info "HTTP authentication username: easyengine" - ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" - fi - # Display Success Message - if [ "$EE_MIGRATE" != "True" ]; then - ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" - fi - elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - - # Configure variable - EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf - echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nEE_NGINX_CONF = $EE_NGINX_CONF" &>> $EE_COMMAND_LOG - - # Setup NGINX - ee_lib_check_domain - ee_mod_setup_domain - - # If we are migrating site then Wordpress installation is not required - if [ "$EE_MIGRATE" != "True" ]; then - # Setup WordPress - ee_mod_setup_wordpress - fi - - # Adjust permission - ee_lib_permissions - - # Git commit - ee_lib_git /etc/nginx/ "$EE_DOMAIN created with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" - - # Execute: service nginx reload - ee_lib_service nginx reload - - # Display Http Auth credentials - if [ "$EE_DISPLAY" = "false" ]; then - ee_lib_echo_info "HTTP authentication username: easyengine" - ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')" - fi - - if [ "$EE_MIGRATE" != "True" ]; then - # Display WordPress credential - echo - ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" - ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" - echo - - # Display WordPress cache plugin settings - ee_mod_plugin_settings - - # Display Success Message - ee_lib_echo_info "Successfully created new website: http://$EE_WWW_DOMAIN" - fi - fi - fi - elif [ "$EE_SECOND" = "delete" ]; then - # Check the website name is empty or not - EE_DELETE_ARGS=$EE_FOURTH - EE_DOMAIN_CHECK=$EE_THIRD - ee_lib_check_domain - - # Check the $EE_DOMAIN exist or not - if [ ! -f /etc/nginx/sites-available/$EE_DOMAIN ]; then - ee_lib_error "$EE_DOMAIN does not exist, exit status = " $? - fi - - # Use default whenever possible - # ee site delete example.com - # ee site delete example.com --no-prompt - if [ "$EE_DELETE_ARGS" = "" ]; then - EE_DELETE_ARGS="--all" - elif [ "$EE_DELETE_ARGS" = "--no-prompt" ]; then - EE_DELETE_ARGS="--all" - EE_FIFTH="--no-prompt" - fi - - if [ "$EE_DELETE_ARGS" = "--db" ]; then - # Delete MySQL database - ee_mod_delete_database $EE_FIFTH - elif [ "$EE_DELETE_ARGS" = "--files" ]; then - # Delete webroot - ee_mod_delete_webroot $EE_FIFTH - elif [ "$EE_DELETE_ARGS" = "--all" ]; then - # Delete MySQL database - ee_mod_delete_database $EE_FIFTH - - # Delete webroot - ee_mod_delete_webroot $EE_FIFTH - - # Delete NGINX configuration file - ee_mod_delete_nginxconf $EE_FIFTH - - # Git commit - ee_lib_git /etc/nginx/ "Delete website: $EE_DOMAIN" - - # Execute: service nginx reload - ee_lib_service nginx reload - fi - elif [ "$EE_SECOND" = "update" ]; then - # Configure variables - EE_DOMAIN_CHECK=$EE_THIRD - EE_SITE_CREATE_OPTION=$EE_FOURTH - EE_SITE_CACHE_OPTION=$EE_FIFTH - - # Check the website name is empty or not - ee_lib_check_domain - - # Auto switch site options - ee_mod_site_option - - # Let's use variable name as per action - # EE_SITE_CREATE_OPTION=$EE_SITE_CREATE_OPTION - - # Check the website exist or not - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN does not exist, exit status = " $? - - # Find out information about current NGINX configuration - EE_SITE_CURRENT_TYPE=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) - - # Detect current website type and cache - if [ "$EE_SITE_CURRENT_TYPE" = "HTML" ]; then - EE_SITE_CURRENT_TYPE="--html" - elif [ "$EE_SITE_CURRENT_TYPE" = "PHP" ]; then - EE_SITE_CURRENT_TYPE="--php" - elif [ "$EE_SITE_CURRENT_TYPE" = "MYSQL" ]; then - EE_SITE_CURRENT_TYPE="--mysql" - # Single WordPress - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE BASIC" ]; then - EE_SITE_CURRENT_WP="--wp" - EE_SITE_CURRENT_CACHE="--basic" - EE_SITE_CURRENT_TYPE="--wp --basic" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE WP SUPER CACHE" ]; then - EE_SITE_CURRENT_WP="--wp" - EE_SITE_CURRENT_CACHE="--wpsc" - EE_SITE_CURRENT_TYPE="--wp --wpsc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE W3 TOTAL CACHE" ]; then - EE_SITE_CURRENT_WP="--wp" - EE_SITE_CURRENT_CACHE="--w3tc" - EE_SITE_CURRENT_TYPE="--wp --w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FASTCGI" ]; then - EE_SITE_CURRENT_WP="--wp" - EE_SITE_CURRENT_CACHE="--wpfc" - EE_SITE_CURRENT_TYPE="--wp --wpfc" - # WordPress subdirectory - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR BASIC" ]; then - EE_SITE_CURRENT_WP="--wpsubdir" - EE_SITE_CURRENT_CACHE="--basic" - EE_SITE_CURRENT_TYPE="--wpsubdir --basic" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR WP SUPER CACHE" ]; then - EE_SITE_CURRENT_WP="--wpsubdir" - EE_SITE_CURRENT_CACHE="--wpsc" - EE_SITE_CURRENT_TYPE="--wpsubdir --wpsc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR W3 TOTAL CACHE" ]; then - EE_SITE_CURRENT_WP="--wpsubdir" - EE_SITE_CURRENT_CACHE="--w3tc" - EE_SITE_CURRENT_TYPE="--wpsubdir --w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FASTCGI" ]; then - EE_SITE_CURRENT_WP="--wpsubdir" - EE_SITE_CURRENT_CACHE="--wpfc" - EE_SITE_CURRENT_TYPE="--wpsubdir --wpfc" - # WordPress subdomain - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN BASIC" ]; then - EE_SITE_CURRENT_WP="--wpsubdomain" - EE_SITE_CURRENT_CACHE="--basic" - EE_SITE_CURRENT_TYPE="--wpsubdomain --basic" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN WP SUPER CACHE" ]; then - EE_SITE_CURRENT_WP="--wpsubdomain" - EE_SITE_CURRENT_CACHE="--wpsc" - EE_SITE_CURRENT_TYPE="--wpsubdomain --wpsc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then - EE_SITE_CURRENT_WP="--wpsubdomain" - EE_SITE_CURRENT_CACHE="--w3tc" - EE_SITE_CURRENT_TYPE="--wpsubdomain --w3tc" - elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FASTCGI" ]; then - EE_SITE_CURRENT_WP="--wpsubdomain" - EE_SITE_CURRENT_CACHE="--wpfc" - EE_SITE_CURRENT_TYPE="--wpsubdomain --wpfc" - fi - - # Detect update website type and cache - # Single WordPress - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - EE_SITE_UPDATE_TYPE="--wp --basic" - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - EE_SITE_UPDATE_TYPE="--wp --wpsc" - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - EE_SITE_UPDATE_TYPE="--wp --w3tc" - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - EE_SITE_UPDATE_TYPE="--wp --wpfc" - fi - # WordPress subdirectory - elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - EE_SITE_UPDATE_TYPE="--wpsubdir --basic" - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - EE_SITE_UPDATE_TYPE="--wpsubdir --wpsc" - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - EE_SITE_UPDATE_TYPE="--wpsubdir --w3tc" - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - EE_SITE_UPDATE_TYPE="--wpsubdir --wpfc" - fi - # WordPress subdomain - elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - EE_SITE_UPDATE_TYPE="--wpsubdomain --basic" - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - EE_SITE_UPDATE_TYPE="--wpsubdomain --wpsc" - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - EE_SITE_UPDATE_TYPE="--wpsubdomain --w3tc" - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - EE_SITE_UPDATE_TYPE="--wpsubdomain --wpfc" - fi - fi - - # Let's log site current option - ee_lib_echo_escape "EE_SITE_CURRENT_WP = $EE_SITE_CURRENT_WP \nEE_SITE_CURRENT_CACHE = $EE_SITE_CURRENT_CACHE \nEE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \n\nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG - - # Update WordPress user password - if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then - ee_mod_site_update_password - # Lets update HTML|PHP website - elif [[ "$EE_SITE_CURRENT_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then - # Lets call update function - ee_mod_update_website - - elif [[ "$EE_SITE_CURRENT_TYPE" = "--mysql" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then - # Lets call update function - ee_mod_update_website - - elif [[ "$EE_SITE_CURRENT_WP" = "--wp" ]] \ - && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then - # Lets call update function - ee_mod_update_website - - elif [[ "$EE_SITE_CURRENT_WP" = "--wpsubdir" ]] \ - && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then - # Lets call update function - ee_mod_update_website - - elif [[ "$EE_SITE_CURRENT_WP" = "--wpsubdomain" ]] \ - && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then - # Lets call update function - ee_mod_update_website - fi - - - if [ "$EE_UPDATE_WEBSITE" = "success" ]; then - # Adjust permission - ee_lib_permissions - - # Execute: service nginx reload - ee_lib_service nginx reload - - # Git commit - ee_lib_git /etc/nginx/ "After ee site update: $EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options" - - # Display Success Message - ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" - elif [[ "$EE_SECOND" = "update" && "$EE_SITE_CREATE_OPTION" = "--password" ]]; then - ee_lib_echo "This option is needed for updating WordPress website password" &> /dev/null - else - ee_lib_error "Invalid option, exit status = " $? - fi - - elif [ "$EE_SECOND" = "log" ]; then - # Display logs for websites - ee_mod_site_log ${@:3} - - # EasyEngine cd - elif [ "$EE_SECOND" = "cd" ]; then - # Check the website name is empty or not - EE_DOMAIN_CHECK=$EE_THIRD - ee_lib_check_domain - - # Check the website exist - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - - # Change Directory to $EE_DOMAIN webroot - if [ $? -eq 0 ]; then - ee_site_cd - fi - - elif [ "$EE_SECOND" = "migrate" ]; then - export EE_MIGRATE="True" - - # Log only single time - # ee site create example.com called ee stack install nginx - # So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null - # So in log file all logs written single time only, to do so set EE_LOG=false - export EE_LOG=false - - # Configure variables - EE_DOMAIN_CHECK=$EE_THIRD - ee_lib_check_domain - - [ "$EE_FOURTH" = "--html" ] || [ "$EE_FOURTH" = "--php" ] || [ "$EE_FOURTH" = "--mysql" ] || [ "$EE_FOURTH" = "--wp" ] || [ "$EE_FOURTH" = "--wpsubdir" ] || [ "$EE_FOURTH" = "--wpsubdomain" ] \ - || [ "$EE_FOURTH" = "--basic" ] || [ "$EE_FOURTH" = "--w3tc" ] || [ "$EE_FOURTH" = "--wpsc" ] || [ "$EE_FOURTH" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$EE_FOURTH && EE_SITE_CREATE_OPTION=$EE_FOURTH && echo EE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION &>> $EE_COMMAND_LOG - [ "$EE_FIFTH" = "--basic" ] || [ "$EE_FIFTH" = "--w3tc" ] || [ "$EE_FIFTH" = "--wpsc" ] || [ "$EE_FIFTH" = "--wpfc" ] && EE_SITE_CACHE_OPTION=$EE_FIFTH && echo EE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION &>> $EE_COMMAND_LOG - - # Auto arrange migrate arguments - for ee_migrate_args in $@; do - [ "${ee_migrate_args%=*}" = "--remote-host" ] && EE_REMOTE_SERVER=${ee_migrate_args##*=} && echo EE_REMOTE_SERVER = $EE_REMOTE_SERVER &>> $EE_COMMAND_LOG - [ "${ee_migrate_args%=*}" = "--remote-user" ] && EE_REMOTE_USER=${ee_migrate_args##*=} && echo EE_REMOTE_USER = $EE_REMOTE_USER &>> $EE_COMMAND_LOG - [ "${ee_migrate_args%=*}" = "--remote-password" ] && EE_REMOTE_PASSWORD=${ee_migrate_args##*=} && echo EE_REMOTE_PASSWORD = $EE_REMOTE_PASSWORD &>> $EE_COMMAND_LOG - [ "${ee_migrate_args%=*}" = "--remote-method" ] && EE_REMOTE_METHOD=${ee_migrate_args##*=} && echo EE_REMOTE_METHOD = $EE_REMOTE_METHOD &>> $EE_COMMAND_LOG - [ "${ee_migrate_args%=*}" = "--remote-path" ] && EE_REMOTE_PATH=${ee_migrate_args##*=} && echo EE_REMOTE_PATH = $EE_REMOTE_PATH &>> $EE_COMMAND_LOG - [ "${ee_migrate_args%=*}" = "--mysql-path" ] && EE_MYSQL_PATH=${ee_migrate_args##*=} && echo EE_MYSQL_PATH = $EE_MYSQL_PATH &>> $EE_COMMAND_LOG - [ "${ee_migrate_args%=*}" = "--remote-exclude" ] && EE_REMOTE_EXCLUDE=${ee_migrate_args##*=} && echo EE_REMOTE_EXCLUDE = $EE_REMOTE_EXCLUDE &>> $EE_COMMAND_LOG - done - - # Compulsary arguments for migration - if [ "$EE_REMOTE_SERVER" = "" ]; then - ee_lib_error "Missing arguments --remote-host, exit status = " 1 - elif [ "$EE_REMOTE_USER" = "" ]; then - ee_lib_error "Missing arguments --remote-user, exit status = " 1 - elif [ "$EE_REMOTE_METHOD" != "ssh" ] && [ "$EE_REMOTE_METHOD" != "sftp" ] && [ "$EE_REMOTE_METHOD" != "ftp" ]; then - ee_lib_error "EasyEngine migration supports only ssh, sftp and ftp methods, exit status = " 1 - elif [ "$EE_REMOTE_PATH" == "" ]; then - EE_REMOTE_PATH="/var/www/$EE_DOMAIN/htdocs" && echo EE_REMOTE_PATH = $EE_REMOTE_PATH &>> $EE_COMMAND_LOG - fi - - # Auto switch site options - ee_mod_site_option - - # Migrate Data - ee_mod_migrate_data - - # Create site - ee site create $EE_DOMAIN $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION \ - || ee_lib_error "Unable to create site, exit status = " $? - - # Setup migration - ee_mod_migrate_setup - - # Display WordPress cache plugin settings - ee_mod_plugin_settings - - # Successfully message - ee_lib_echo_info "Successfully migrated site $EE_DOMAIN" - - else - ee_lib_echo "ee site commands:" - ee_lib_echo_escape "\tcd\tSwitch to website root directory" - ee_lib_echo_escape "\tlist\tList NGINX enabled website" - ee_lib_echo_escape "\tinfo\tDisplay information about given website" - ee_lib_echo_escape "\tshow\tDisplay NGINX configuration for given website" - ee_lib_echo_escape "\tenable\tEnable website" - ee_lib_echo_escape "\tdisable\tDisable website" - ee_lib_echo_escape "\tedit\tEdit NGINX configuration for given website" - ee_lib_echo_escape "\tcreate\tCreate new HTML, PHP, MySQL or WordPress website" - ee_lib_echo_escape "\tdelete\tDelete existing website" - ee_lib_echo_escape "\tlog\tMonitor access and error logs for single or multiple websites" - ee_lib_echo_escape "\tupdate\tupdate current website" - fi - -# EasyEngine debug -elif [ "$EE_FIRST" = "debug" ]; then - # Default action - EE_DEBUG="--start" - - # Auto arrange debug arguments - for ee_debug_args in $@; do - [ "$ee_debug_args" = "-i" ] && EE_DEBUG_INTERACTIVE=$ee_debug_args && echo EE_DEBUG_INTERACTIVE = $EE_DEBUG_INTERACTIVE &>> $EE_COMMAND_LOG - [ "$ee_debug_args" = "--stop" ] && EE_DEBUG=$ee_debug_args && echo EE_DEBUG = $EE_DEBUG &>> $EE_COMMAND_LOG - [ "$ee_debug_args" = "--nginx" ] && EE_DEBUG_NGINX=$ee_debug_args && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $EE_COMMAND_LOG - [ "$ee_debug_args" = "--rewrite" ] && EE_DEBUG_REWRITE=$ee_debug_args && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $EE_COMMAND_LOG - [ "$ee_debug_args" = "--php" ] && EE_DEBUG_PHP=$ee_debug_args && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $EE_COMMAND_LOG - [ "$ee_debug_args" = "--fpm" ] && EE_DEBUG_FPM=$ee_debug_args && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $EE_COMMAND_LOG - [ "$ee_debug_args" = "--mysql" ] && EE_DEBUG_MYSQL=$ee_debug_args && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $EE_COMMAND_LOG - [ "$ee_debug_args" = "--wp" ] && EE_DEBUG_WP=$ee_debug_args && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG - [ "${ee_debug_args%=*}" = "--import-slow-log-interval" ] && EE_DEBUG_IMPORT_SLOW_LOG=$ee_debug_args && echo EE_DEBUG_IMPORT_SLOW_LOG = $EE_DEBUG_IMPORT_SLOW_LOG &>> $EE_COMMAND_LOG - if [ "$ee_debug_args" != "debug" ] && [ "$ee_debug_args" != "-i" ] && [ "$ee_debug_args" != "--start" ] && [ "$ee_debug_args" != "--stop" ] && [ "$ee_debug_args" != "--nginx" ] && [ "$ee_debug_args" != "--rewrite" ] && [ "$ee_debug_args" != "--php" ] && [ "$ee_debug_args" != "--fpm" ] && [ "$ee_debug_args" != "--mysql" ] && [ "$ee_debug_args" != "--wp" ]; then - ls /etc/nginx/sites-available/ | grep $ee_debug_args &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - EE_DOMAIN_CHECK=$ee_debug_args && echo EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK &>> $EE_COMMAND_LOG - - # Domain name find out - ee_lib_check_domain - echo EE_DOMAIN = $EE_DOMAIN &>> $EE_COMMAND_LOG - fi - fi - done - - # The following code execute on - # ee debug - # ee debug -i - # ee debug --start - # ee debug --stop - # ee debug example.com - if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ]; then - EE_DEBUG_NGINX="--nginx" && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $EE_COMMAND_LOG - EE_DEBUG_REWRITE="--rewrite" && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $EE_COMMAND_LOG - EE_DEBUG_PHP="--php" && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $EE_COMMAND_LOG - EE_DEBUG_FPM="--fpm" && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $EE_COMMAND_LOG - EE_DEBUG_MYSQL="--mysql" && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $EE_COMMAND_LOG - - if [ -n "$EE_DOMAIN" ]; then - EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG - fi - fi - - # Actual debug function call - if [ "$EE_DEBUG_NGINX" = "--nginx" ]; then - # Debug NGINX - ee_mod_debug_nginx - fi - - if [ "$EE_DEBUG_REWRITE" = "--rewrite" ]; then - # Debug NGINX rewrite rules - ee_mod_debug_rewrite - fi - - if [ "$EE_DEBUG_PHP" = "--php" ]; then - # Debug PHP slow log and enable xdebug profiling - ee_mod_debug_php - fi - - if [ "$EE_DEBUG_FPM" = "--fpm" ]; then - # Change PHP log_level from notice to debug - ee_mod_debug_fpm - fi - - if [ "$EE_DEBUG_MYSQL" = "--mysql" ]; then - # Enable MySQL slow query - ee_mod_debug_mysql - fi - - if [ "$EE_DEBUG_WP" = "--wp" ]; then - # Enable WordPress debug.log - ee_mod_debug_wp - fi - - # Execute: service nginx reload - if [ "$EE_TRIGGER_NGINX" = "true" ]; then - ee_lib_service nginx reload - fi - - if [ "$EE_TRIGGER_PHP" = "true" ]; then - ee_lib_service php5-fpm restart - fi - - if [ "$EE_DEBUG_INTERACTIVE" = "-i" ]; then - # Debug stop on CTRL+C - trap "ee_mod_debug_stop" EXIT - - if [ ! -z "$EE_DEBUG_MSG" ]; then - tail -f $EE_DEBUG_MSG - fi - elif [ "$EE_DEBUG_INTERACTIVE" != "-i" ] && [ "$EE_DEBUG" != "--stop" ]; then - if [ ! -z "$EE_DEBUG_MSG" ]; then - ee_lib_echo_info "tail -f $EE_DEBUG_MSG" - fi - fi - -# EasyEngine secure -elif [ "$EE_FIRST" = "secure" ]; then - if [ "$EE_SECOND" = "--auth" ] || [ "$EE_SECOND" = "--port" ] || [ "$EE_SECOND" = "--ip" ]; then - ee_mod_secure_$(echo $EE_SECOND | sed 's/--//') - ee_lib_service nginx reload - else - ee_lib_echo "ee secure commands:" - ee_lib_echo_escape "\t--auth\tUpdate credential of HTTP authentication" - ee_lib_echo_escape "\t--port\tChange EasyEngine admin port 22222" - ee_lib_echo_escape "\t--ip\tUpdate whitelist IP address" - fi - -# Clean NGINX FastCGI, Memcache, OPcache cache -elif [ "$EE_FIRST" = "clean" ]; then - ee_mod_clean ${@:2} - -# Import MySQL slow log to Anememoter -elif [ "$EE_FIRST" = "import-slow-log" ];then - ee_lib_import_slow_log - -# EasyEngine update -elif [ "$EE_FIRST" = "update" ]; then - ee_lib_echo "Run following command to update EasyEngine" - ee_lib_echo_info "wget --no-check-certificate -qO eeup http://rt.cx/eeup && sudo bash eeup" - -else - ee_lib_echo "EasyEngine (ee) commands:" - ee_lib_echo_escape "\tversion\tDisplay EasyEngine (ee) version" - ee_lib_echo_escape "\thelp\tDisplay EasyEngine (ee) man page" - ee_lib_echo_escape "\tinfo\tDisplay Information about NGINX, PHP5, MySQL" - ee_lib_echo_escape "\tclean\tClean Nginx FastCGI cache/OPcache/Memcache/all cache" - ee_lib_echo_escape "\tstack\tInstall/Remove/Purge NGINX, PHP, MySQL, Postfix" - ee_lib_echo_escape "\tsite\tPerform various site specific operation" - ee_lib_echo_escape "\tdebug\tPerform various debugging operation" - ee_lib_echo_escape "\tsecure\tUpdate HTTP authentication and EasyEngine admin port" - ee_lib_echo_escape "\tupdate\tUpdate EasyEngine (ee) to latest version" -fi - -} - -EasyEngine $@ | tee -ai $EE_TEE_LOG - - -# If any command fails its return non-zero exit code [EasyEngine $@] -# But when failed command piped then its [EasyEngine $@] exit status -# is suppress by next piped command [| tee -ai $EE_COMMAND_LOG] - -# Example: -# (call | tee -ai example.log); echo $? -# 0 - -# (call | tee -ai example.log; exit ${PIPESTATUS[0]}); echo $? -# 127 - -exit ${PIPESTATUS[0]} diff --git a/bin/install b/bin/install deleted file mode 100644 index 7b2ca1d5..00000000 --- a/bin/install +++ /dev/null @@ -1,238 +0,0 @@ -#!/bin/bash - -# Define echo function -# Blue color -function ee_lib_echo() -{ - echo $(tput setaf 4)$@$(tput sgr0) -} - -# White color -function ee_lib_echo_info() -{ - echo $(tput setaf 7)$@$(tput sgr0) -} - -# Red color -function ee_lib_echo_fail() -{ - echo $(tput setaf 1)$@$(tput sgr0) -} - - -# 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 - -# Execute: apt-get update -ee_lib_echo "Executing apt-get update, please wait..." -apt-get update &>> /dev/null - -# Checking lsb_release package -if [ ! -x /usr/bin/lsb_release ]; then - ee_lib_echo "Installing lsb-release, please wait..." - apt-get -y install lsb-release &>> /dev/null -fi - -# Define variables for later use -readonly EE_LOG_DIR=/var/log/easyengine -readonly EE_INSTALL_LOG=/var/log/easyengine/install.log -readonly EE_ERROR_LOG=/var/log/easyengine/error.log -readonly EE_LINUX_DISTRO=$(lsb_release -i |awk '{print $3}') -readonly EE_DEBIAN_VERSION=$(lsb_release -sc) - -# Checking linux distro -if [ "$EE_LINUX_DISTRO" != "Ubuntu" ] && [ "$EE_LINUX_DISTRO" != "Debian" ]; then - ee_lib_echo_fail "EasyEngine (ee) is made for Ubuntu and Debian only as of now" - ee_lib_echo_fail "You are free to fork EasyEngine (ee): https://github.com/rtCamp/easyengine/fork" - exit 100 -fi - -# EasyEngine (ee) only support all Ubuntu/Debian distro except the distro reached EOL -lsb_release -d | egrep -e "12.04|14.04|14.10|squeeze|wheezy" &>> /dev/null -if [ "$?" -ne "0" ]; then - ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04/14.10 and Debian 6.x/7.x" - exit 100 -fi - - -# Capture errors -function ee_lib_error() -{ - echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" | tee -ai $EE_ERROR_LOG - exit $2 -} - -# Check the specified package is installed or not -function ee_lib_package_check() -{ - local ee_package - - for ee_package in $@;do - dpkg --get-selections | grep -v deinstall | grep $ee_package &>> $EE_INSTALL_LOG - - # Generate a list of not installed package - if [ $? -ne 0 ]; then - EE_PACKAGE_NAME="$EE_PACKAGE_NAME $ee_package" - fi - - done -} - -# Pre checks to avoid later screw ups -# Checking EasyEngine (ee) log directory -if [ ! -d $EE_LOG_DIR ]; then - ee_lib_echo "Creating EasyEngine (ee) log directory, please wait..." - mkdir -p $EE_LOG_DIR || ee_lib_error "Unable to create log directory $EE_LOG_DIR, exit status = " $? - - # Create EasyEngine log files - touch /var/log/easyengine/{ee.log,install.log,update.log,error.log} \ - || ee_lib_error "Unable to create EasyEngine log files in $EE_LOG_DIR, exit status = " $? - - # Keep EasyEngine log folder accessible to root only - chmod -R 700 /var/log/easyengine \ - || ee_lib_error "Unable to change permissions for EasyEngine log folder, exit status = " $? - -fi - -# Install required packages -if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - ee_lib_package_check graphviz python-software-properties software-properties-common -elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - ee_lib_package_check graphviz python-software-properties -fi - -if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ ! -x /usr/bin/pv ] || [ ! -x /usr/bin/lftp ] || [ ! -x /usr/bin/sshpass ] || [ ! -x /usr/bin/sudo ] || [ -n "$EE_PACKAGE_NAME" ]; then - ee_lib_echo "Installing required packages, please wait..." | tee -ai $EE_INSTALL_LOG - apt-get -y install coreutils ed bc wget curl tar git-core lftp pv sshpass sudo $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\ - || ee_lib_error "Unable to install required packages, exit status = " $? -fi - -# Checking name servers -if [[ -z $(cat /etc/resolv.conf 2> /dev/null | awk '/^nameserver/ { print $2 }') ]]; then - ee_lib_echo_fail "Unable to detect name servers" && ee_lib_error "Unable to detect name servers, exit status = " $? - ee_lib_echo_fail "Please configure /etc/resolv.conf" && ee_lib_error "Please configure /etc/resolv.conf, exit status = " $? -fi -# Pre checks end - -# Decide EasyEngine (ee) branch -BRANCH=$1 -if [ -z "$BRANCH" ]; then - BRANCH=stable -else - # Cross check EasyEngine (ee) branch name - git ls-remote --heads https://github.com/rtCamp/easyengine | grep ${BRANCH}$ &>> $EE_INSTALL_LOG - if [ $? -ne 0 ]; then - ee_lib_error "The $BRANCH branch does not exist, please provide the correct branch name, exit status = " $? - fi -fi - -# Remove old version of EasyEngine (ee) -rm -rf /tmp/easyengine &>> /dev/null - -# Let's clone EasyEngine (ee) -ee_lib_echo "Cloning EasyEngine (ee) $BRANCH branch, please wait..." | tee -ai $EE_INSTALL_LOG -git clone -b $BRANCH https://github.com/rtCamp/easyengine.git /tmp/easyengine &>> $EE_INSTALL_LOG \ -|| ee_lib_error "Unable to clone EasyEngine (ee) $BRANCH branch, exit status = " $? - - -# Setup EasyEngine (ee) -if [ ! -d /etc/easyengine ]; then - mkdir -p /etc/easyengine \ - || ee_lib_error "Unable to create /etc/easyengine directory, exit status = " $? -fi - -if [ ! -d /usr/share/easyengine/ ] -then - mkdir -p /usr/share/easyengine/ \ - || ee_lib_error "Unable to create /usr/share/easyengine/ directory, exit status = " $? -fi - -if [ ! -d /usr/local/lib/easyengine ] -then - mkdir -p /usr/local/lib/easyengine \ - || ee_lib_error "Unable to create /usr/local/lib/easyengine directory, exit status = " $? -fi - - -# Install EasyEngine (ee) -ee_lib_echo "Installing EasyEngine (ee), please wait..." | tee -ai $EE_INSTALL_LOG - -# EasyEngine (ee) auto completion file -cp -a /tmp/easyengine/config/bash_completion.d/ee /etc/bash_completion.d/ &>> $EE_INSTALL_LOG \ -|| ee_lib_error "Unable to copy EasyEngine (ee) auto completion file, exit status = " $? - -# EasyEngine (ee) config file -cp -a /tmp/easyengine/config/easyengine/ee.conf /etc/easyengine/ &>> $EE_INSTALL_LOG \ -|| ee_lib_error "Unable to copy EasyEngine (ee) config file, exit status = " $? - -# Templates -cp -a /tmp/easyengine/config/nginx /tmp/easyengine/templates/* /usr/share/easyengine/ &>> $EE_INSTALL_LOG \ -|| ee_lib_error "Unable to copy NGINX sample files, exit status = " $? - -# EasyEngine (ee) library and modules -cp -a /tmp/easyengine/src/* /usr/local/lib/easyengine \ -|| ee_lib_error "Unable to copy src files, exit status = " $? - -# EasyEngine (ee) command -cp -a /tmp/easyengine/bin/easyengine /usr/local/sbin/ &>> $EE_INSTALL_LOG \ -|| ee_lib_error "Unable to copy EasyEngine (ee) command, exit status = " $? - -# Change permission of EasyEngine (ee) command -chmod 750 /usr/local/sbin/easyengine || ee_lib_error "Unable to change permission of EasyEngine (ee) command, exit status = " $? - -# Create symbolic link -if [ ! -L /usr/local/sbin/ee ]; then - ln -s /usr/local/sbin/easyengine /usr/local/sbin/ee -fi - -# EasyEngine (ee) man page -cp -a /tmp/easyengine/docs/man/ee.8 /usr/share/man/man8/ &>> $EE_INSTALL_LOG \ -|| ee_lib_error "Unable to copy EasyEngine (ee) man page, exit status = " $? - -# Git config settings -GIT_USER_NAME=$(git config user.name) -GIT_USER_EMAIL=$(git config user.email) - -if [ -z "$GIT_USER_NAME" ] || [ -z "$GIT_USER_EMAIL" ]; then - echo - ee_lib_echo "EasyEngine (ee) required your name & email address" | tee -ai $EE_INSTALL_LOG - ee_lib_echo "to track changes you made under the Git version control" | tee -ai $EE_INSTALL_LOG - ee_lib_echo "EasyEngine (ee) will be able to send you daily reports & alerts in upcoming version" | tee -ai $EE_INSTALL_LOG - ee_lib_echo "EasyEngine (ee) will NEVER send your information across" | tee -ai $EE_INSTALL_LOG -fi - -if [ -z "$GIT_USER_NAME" ]; then - read -p "Enter your name [$(whoami)]: " GIT_USER_NAME - # If enter is pressed - if [[ $GIT_USER_NAME = "" ]]; then - GIT_USER_NAME=$(whoami) - fi - git config --global user.name "${GIT_USER_NAME}" - echo "git config user.name = $(git config user.name)" &>> $EE_INSTALL_LOG -fi - -if [ -z "$GIT_USER_EMAIL" ];then - read -p "Enter your email address [$(whoami)@$(hostname -f)]: " GIT_USER_EMAIL - # If enter is pressed - if [[ $GIT_USER_EMAIL = "" ]] - then - GIT_USER_EMAIL=$(whoami)@$(hostname -f) - fi - git config --global user.email $GIT_USER_EMAIL - echo "git config user.email = $(git config user.email)" &>> $EE_INSTALL_LOG -fi - -# Enable EasyEngine (ee) auto completion -echo -ee_lib_echo "For EasyEngine (ee) auto completion, run the following command" | tee -ai $EE_INSTALL_LOG -ee_lib_echo_info "source /etc/bash_completion.d/ee" | tee -ai $EE_INSTALL_LOG -echo - -# Display success message -ee_lib_echo "EasyEngine (ee) installed successfully" | tee -ai $EE_INSTALL_LOG -ee_lib_echo "EasyEngine (ee) help: https://rtcamp.com/easyengine/docs/" | tee -ai $EE_INSTALL_LOG -echo diff --git a/bin/update b/bin/update deleted file mode 100644 index 7f982adf..00000000 --- a/bin/update +++ /dev/null @@ -1,530 +0,0 @@ -#!/bin/bash - -# Define variables -readonly EE_UPDATE_LOG=/var/log/easyengine/update.log - -# Define echo function -# Blue color -function ee_lib_echo() -{ - echo $(tput setaf 4)$@$(tput sgr0) -} - -# White color -function ee_lib_echo_info() -{ - echo $(tput setaf 7)$@$(tput sgr0) -} - -# Red color -function ee_lib_echo_fail() -{ - echo $(tput setaf 1)$@$(tput sgr0) -} - -# Capture errors -function ee_lib_error() -{ - echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" | tee -ai $EE_ERROR_LOG - exit $2 -} - -# Initialize Git -function ee_lib_git() -{ - for ee_git_dir in ${@:1:$(($#-1))}; do - if [ -d $ee_git_dir ]; then - # Change directory - cd $ee_git_dir - - # Check .git - if [ ! -d .git ]; then - # ee_lib_echo "Initialize Git on ${ee_git_dir}" - git init &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to initialize Git on $ee_git_dir, exit status = " $? - fi - - # Check for untracked files - if [ $(git status -s | wc -l) -ne 0 ]; then - # Add files in Git version control - ee_lib_echo "Git commit on $ee_git_dir, please wait..." - git add --all && git commit -am "${@: -1}" &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to Git commit on $ee_git_dir, exit status = " $? - fi - fi - done -} - -# Update EasyEngine (ee) -# EasyEngine version: 1.0.0 -# EasyEngine (ee) version: 2.0.0 -EE_CURRENT_VERSION=$(ee version | sed 's/(ee) //' | awk '{print $3}') -EE_LATEST_VERSION=$(curl -sL https://api.github.com/repos/rtCamp/easyengine/releases | grep tag_name | awk '{print($2)}' | cut -d'"' -f2 | cut -c2- | head -n1) -echo EE_CURRENT_VERSION = $EE_CURRENT_VERSION EE_LATEST_VERSION = $EE_LATEST_VERSION &>> $EE_UPDATE_LOG - -if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then - read -p "Update EasyEngine to $EE_LATEST_VERSION (y/n): " EE_ANS - - if [ "$EE_ANS" = "y" ] || [ "$EE_ANS" = "Y" ]; then - ee_lib_echo "EasyEngine (ee) update started [$(date)]" | tee -ai $EE_UPDATE_LOG - - # Install required packages - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - ee_lib_package_check graphviz python-software-properties software-properties-common - elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - ee_lib_package_check graphviz python-software-properties - fi - - if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ -n "$EE_PACKAGE_NAME" ]; then - ee_lib_echo "Installing required packages, please wait..." | tee -ai $EE_INSTALL_LOG - apt-get -y install coreutils ed bc wget curl tar git-core $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\ - || ee_lib_error "Unable to install required packages, exit status = " $? - fi - - # Get Anemometer password - if [ -d /var/www/22222/htdocs/db/anemometer ]; then - if [ -f /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh ]; then - ee_anemometer_pass=$(grep "\-\-password" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh | cut -d"=" -f3 ) - else - ee_anemometer_pass=$(grep "password=" /etc/logrotate.d/mysql-server | cut -d"=" -f3 ) - fi - ee_anemometer_pass=$(echo $ee_anemometer_pass | rev | cut -c 3- | rev) - fi - - # Git backup - ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "EasyEngine version $EE_CURRENT_VERSION" - - # Remove old version of EasyEngine (ee) - rm -rf /tmp/easyengine &>> /dev/null - - # Let's clone EasyEngine (ee) - ee_lib_echo "Cloning EasyEngine (ee) stable branch, please wait..." | tee -ai $EE_UPDATE_LOG - git clone -b stable https://github.com/rtCamp/easyengine.git /tmp/easyengine &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to clone EasyEngine (ee) stable branch, exit status = " $? - - # Setup EasyEngine (ee) - if [ ! -d /etc/easyengine ]; then - mkdir -p /etc/easyengine \ - || ee_lib_error "Unable to create /etc/easyengine directory, exit status = " $? - fi - - if [ ! -d /usr/share/easyengine/ ] - then - mkdir -p /usr/share/easyengine/ \ - || ee_lib_error "Unable to create /usr/share/easyengine/ directory, exit status = " $? - fi - - if [ ! -d /usr/local/lib/easyengine ] - then - mkdir -p /usr/local/lib/easyengine \ - || ee_lib_error "Unable to create /usr/local/lib/easyengine directory, exit status = " $? - fi - - # Setup EasyEngine (ee) - # EasyEngine (ee) auto completion file - cp -av /tmp/easyengine/config/bash_completion.d/ee /etc/bash_completion.d/ &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to copy EasyEngine (ee) auto completion file, exit status = " $? - - # Templates - cp -a /tmp/easyengine/config/nginx /tmp/easyengine/templates/* /usr/share/easyengine/ &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to copy NGINX sample files, exit status = " $? - - # NGINX Setup - sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $EE_LATEST_VERSION\";/" /etc/nginx/nginx.conf - rsync -avz --exclude acl.conf /usr/share/easyengine/nginx/common/* /etc/nginx/common/ &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to rsync NGINX common files, exit status = " $? - - # EasyEngine (ee) library and modules - cp -av /tmp/easyengine/src/* /usr/local/lib/easyengine &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to copy src files, exit status = " $? - - # EasyEngine (ee) command - cp -av /tmp/easyengine/bin/easyengine /usr/local/sbin/ &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to copy EasyEngine (ee) command, exit status = " $? - - # Change permission of EasyEngine (ee) command - chmod 750 /usr/local/sbin/easyengine || ee_lib_error "Unable to change permission of EasyEngine (ee) command, exit status = " $? - - # Create symbolic link - if [ ! -L /usr/local/sbin/ee ]; then - ln -s /usr/local/sbin/easyengine /usr/local/sbin/ee - fi - - # EasyEngine (ee) man page - cp -av /tmp/easyengine/docs/man/ee.8 /usr/share/man/man8/ &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to copy EasyEngine (ee) man page, exit status = " $? - - - if [[ $EE_CURRENT_VERSION < 1.9.0 ]]; then - # EasyEngine (ee) config file - cp -av /etc/easyengine/ee.conf /etc/easyengine/ee.bak &>> $EE_UPDATE_LOG - cp -av /tmp/easyengine/config/easyengine/ee.conf /etc/easyengine/ &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to copy EasyEngine (ee) config file, exit status = " $? - - - # Lets re-used our functions - # Include library - for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do - source $ee_include - done - - # Avoid re-source and readonly errors - ee_source=1 - - # Lets modify the $EE_COMMAND_LOG value - # So all the logs write in $EE_UPDATE_LOG - EE_COMMAND_LOG=$EE_UPDATE_LOG - - # Install required packages - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - ee_lib_package_check graphviz python-software-properties software-properties-common - elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - ee_lib_package_check graphviz python-software-properties - fi - - if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ -n "$EE_PACKAGE_NAME" ]; then - ee_lib_echo "Installing required packages, please wait..." | tee -ai $EE_UPDATE_LOG - apt-get -y install coreutils ed bc wget curl tar git-core $EE_PACKAGE_NAME | tee -ai $EE_UPDATE_LOG\ - || ee_lib_error "Unable to install required packages, exit status = " $? - fi - - # Get old value from ee.bak file - ee_stack_ip=$(grep ip_address /etc/easyengine/ee.bak | cut -d'=' -f2) - ee_mysql_host=$(grep mysqlhost /etc/easyengine/ee.bak | cut -d'=' -f2) - ee_wp_user=$(grep wpadminuser /etc/easyengine/ee.bak | cut -d'=' -f2) - ee_wp_pass=$(grep wpadminpass /etc/easyengine/ee.bak | cut -d'=' -f2) - #ee_wp_email=$(grep wpadminemail /etc/easyengine/ee.bak | cut -d'=' -f2) - - # Set localhost when no host found - if [ -z $ee_mysql_host ]; then - ee_mysql_host=localhost - fi - - # Ask email address - ee_lib_echo "Update your email address, which is used to setup WordPress" - read -p "Enter email address: " ee_wp_email - - # Update value in ee.conf file - $EE_CONFIG_SET stack.ip-address "$(echo -n $ee_stack_ip)" && \ - $EE_CONFIG_SET mysql.host "$(echo -n $ee_mysql_host)" && \ - $EE_CONFIG_SET wordpress.user "$(echo -n $ee_wp_user)" && \ - $EE_CONFIG_SET wordpress.password "$(echo -n $ee_wp_pass)" && \ - $EE_CONFIG_SET wordpress.email "$(echo -n $ee_wp_email)" \ - || ee_lib_error "Unable to update ee.conf file, exit status = " $? - - # NGINX conf.d - cp -v /usr/share/easyengine/nginx/conf.d/fastcgi.conf /etc/nginx/conf.d/ &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to copy fastcgi.conf file, exit status = " $? - - cp -v /usr/share/easyengine/nginx/conf.d/upstream.conf /etc/nginx/conf.d/ &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to copy upstream.conf file, exit status = " $? - - - # NGINX common - if [[ $EE_CURRENT_VERSION = 1.0.0 ]] || [[ $EE_CURRENT_VERSION = 1.0.1 ]] || [[ $EE_CURRENT_VERSION = 1.1.0 ]]; then - # Move allowed_ip.conf to acl.conf - (sed "/allow/,+2d" /usr/share/easyengine/nginx/common/acl.conf; grep -v ^# /etc/nginx/common/allowed_ip.conf ) > /etc/nginx/common/acl.conf - sed -i '/allow ;/d' /etc/nginx/common/acl.conf - - # Update nginx.conf - # SSL settings - grep ssl_ /etc/nginx/nginx.conf &>> $EE_UPDATE_LOG - if [ $? -ne 0 ]; then - sed -i "/client_max_body_size/a \ \n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\n" /etc/nginx/nginx.conf - fi - # Log format - sed -i "s/log_format rt_cache.*/log_format rt_cache '\$remote_addr \$upstream_response_time \$upstream_cache_status [\$time_local] '/" /etc/nginx/nginx.conf - sed -i "s/.*\$body_bytes_sent'/\t\t'\$http_host \"\$request\" \$status \$body_bytes_sent '/" /etc/nginx/nginx.conf - - # Update PHP session storage to Memcache - sed -i "/extension/a \session.save_handler = memcache\nsession.save_path = \"tcp://localhost:11211\"" /etc/php5/mods-available/memcache.ini - - # Set easyengine:easyengine as default http authentication - if [ ! -f /etc/nginx/htpasswd-ee ]; then - printf "easyengine:$(openssl passwd -crypt easyengine 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null - fi - - # Update EasyEngine current version - EE_CURRENT_VERSION="1.2.2" - fi - if [[ $EE_CURRENT_VERSION = 1.2.2 ]]; then - # Update NGINX configuration - sed -i "/worker_processes/a \worker_rlimit_nofile 100000;" /etc/nginx/nginx.conf - sed -i "s/# multi_accept/multi_accept/" /etc/nginx/nginx.conf - sed -i "s/keepalive_timeout.*/keepalive_timeout 30;/" /etc/nginx/nginx.conf - - # Setup port 22222 - cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG - if [ "$EE_LINUX_DISTRO" == "Debian" ]; then - # Dotdeb nginx repository doesn't support spdy - sed -i "s/ spdy//;" /usr/share/easyengine/nginx/22222 - fi - - # Create a symbolic link for 22222 - if [ ! -L /etc/nginx/sites-enabled/22222 ]; then - ln -s /etc/nginx/sites-available/22222 /etc/nginx/sites-enabled/ - fi - - # Setup logs for 22222 - if [ ! -d /var/www/22222/logs ]; then - mkdir -p /var/www/22222/logs - ln -s /var/log/nginx/22222.access.log /var/www/22222/logs/access.log - ln -s /var/log/nginx/22222.error.log /var/www/22222/logs/error.log - fi - - # Setup SSL - # Create SSL certificate directory - if [ ! -d /var/www/22222/cert ]; then - mkdir /var/www/22222/cert - fi - - # Generate SSL key - ee_lib_echo "Generating SSL private key" - openssl genrsa -out /var/www/22222/cert/22222.key 2048 &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to generate SSL private key for port 22222, exit status = " $? - - ee_lib_echo "Generating a certificate signing request (CSR)" - openssl req -new -batch -subj /commonName=127.0.0.1/ -key /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.csr &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to generate certificate signing request (CSR) for port 22222, exit status = " $? - - ee_lib_echo "Removing pass phrase from SSL private key" - mv /var/www/22222/cert/22222.key /var/www/22222/cert/22222.key.org - openssl rsa -in /var/www/22222/cert/22222.key.org -out /var/www/22222/cert/22222.key &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to remove pass phrase from SSL for port 22222, exit status = " $? - - ee_lib_echo "Generating SSL certificate" - openssl x509 -req -days 3652 -in /var/www/22222/cert/22222.csr -signkey /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.crt &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to generate SSL certificate for port 22222, exit status = " $? - - # Update PHP configuration - dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Installing php5-xdebug package, please wait..." - apt-get -y install php5-xdebug \ - || ee_lib_error "Unable to install php5-xdebug package, exit status = " $? - - ee_lib_echo "Setting up PHP5, please wait..." - - # Custom php5 log directory - if [ ! -d /var/log/php5/ ]; then - mkdir -p /var/log/php5/ \ - || ee_lib_error "Unable to create /var/log/PHP5/, exit status = " $? - fi - - # Update timezone - local ee_time_zone=$(cat /etc/timezone | head -n1 | sed "s'/'\\\/'") - sed -i "s/;date.timezone.*/date.timezone = $ee_time_zone/" /etc/php5/fpm/php.ini - - # Change php5-fpm error log location - sed -i "s'error_log.*'error_log = /var/log/php5/fpm.log'" /etc/php5/fpm/php-fpm.conf - - # Separate php5-fpm for ee debug command - cp -v /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/debug.conf - - sed -i "s'\[www\]'[debug]'" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change debug pool name, exit status = " $? - - sed -i "s'listen = 127.0.0.1:9000'listen = 127.0.0.1:9001'" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change listen = 127.0.0.1:9001 for debug pool, exit status = " $? - - sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change slowlog settings for debug pool, exit status = " $? - - sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change request_slowlog_timeout for debug pool, exit status = " $? - - echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/ \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to add xdebug settings for debug pool, exit status = " $? - fi - - mysqladmin ping &> /dev/null &>> $EE_UPDATE_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Installing percona-toolkit package, please wait..." - apt-get -y install percona-toolkit \ - || ee_lib_error "Unable to install percona-toolkit package, exit status = " $? - fi - - # Install 22222 admin tools - ee_ven_install_utils - ee_ven_install_phpmyadmin - - # Update EasyEngine current version - EE_CURRENT_VERSION="1.3.0" - fi - if [[ $EE_CURRENT_VERSION = 1.3.0 ]] || [[ $EE_CURRENT_VERSION = 1.3.1 ]] || [[ $EE_CURRENT_VERSION = 1.3.2 ]] || [[ $EE_CURRENT_VERSION = 1.3.3 ]]; then - grep "^pm = ondemand" /etc/php5/fpm/pool.d/www.conf &>> $EE_UPDATE_LOG - if [ $? -ne 0 ]; then - sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/www.conf \ - || ee_lib_error "Unable to change process manager from dynamic to ondemand, exit status = " $? - fi - grep "^pm = ondemand" /etc/php5/fpm/pool.d/debug.conf &>> $EE_UPDATE_LOG - if [ $? -ne 0 ]; then - sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change process manager from dynamic to ondemand on debug.conf, exit status = " $? - fi - - # Update EasyEngine current version - EE_CURRENT_VERSION="1.3.4" - fi - if [[ $EE_CURRENT_VERSION = 1.3.4 ]] || [[ $EE_CURRENT_VERSION = 1.3.5 ]] || [[ $EE_CURRENT_VERSION = 1.3.6 ]] || [[ $EE_CURRENT_VERSION = 1.3.7 ]] || [[ $EE_CURRENT_VERSION = 1.3.8 ]]; then - # Update 22222 for fix #259 - cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG - if [ "$EE_LINUX_DISTRO" == "Debian" ]; then - # Dotdeb nginx repository doesn't support spdy - sed -i "s/ spdy//;" /usr/share/easyengine/nginx/22222 - fi - # Update NGINX - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - ls /etc/apt/sources.list.d/brianmercer-nginx* &>> $EE_UPDATE_LOG - if [ $? -eq 0 ]; then - rm /etc/apt/sources.list.d/brianmercer-nginx* - # Add rtCamp nginx launchpad repository - ee_lib_echo "Adding rtCamp NGINX launchpad repository, please wait..." - add-apt-repository -y ppa:rtcamp/nginx &>> $EE_UPDATE_LOG \ - || ee_lib_error "Unable to add rtCamp NGINX launchpad repository, exit status = " $? - - # Execute: apt-get update - ee_lib_apt_get_update - - # Install NGINX - apt-get -o Dpkg::Options::="--force-confold" -y install nginx-custom \ - || ee_lib_error "Unable to install nginx-custom package, exit status = " $? - fi - fi - - # Update EasyEngine current version - EE_CURRENT_VERSION="2.0.0" - fi - fi - - if [[ $EE_CURRENT_VERSION > 1.9.0 ]]; then - - # Lets re-used our functions - # Include library - if [ -z $ee_source ]; then - for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do - source $ee_include - done - fi - - if [[ $EE_CURRENT_VERSION = 2.0.0 ]] || [[ $EE_CURRENT_VERSION = 2.0.1 ]]; then - sed -i 's/host =.*/grant-host = localhost/' /etc/easyengine/ee.conf - - # Add Vimbadmin rules - if [ -f /etc/nginx/sites-available/22222 ];then - ee_port=$(grep listen /etc/nginx/sites-available/22222 | awk '{ print $2 }') - cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - sed -i "s/listen.*/listen $ee_port default_server ssl spdy;/" /etc/nginx/sites-available/22222 \ - || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? - elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - # Dotdeb nginx repository doesn't support spdy - sed -i "s/listen.*/listen $ee_port default_server ssl;/" /etc/nginx/sites-available/22222 \ - || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? - fi - fi - - if [ -d /var/www/22222/htdocs/db/anemometer ];then - # Download pt-query-advisor Fixed #189 - wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ - || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? - chmod 0755 /usr/bin/pt-query-advisor - - # Enable pt-query-advisor plugin in Anemometer - sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ - || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $? - fi - - # Update EasyEngine current version - EE_CURRENT_VERSION="2.1.0" - fi - - if [[ $EE_CURRENT_VERSION = 2.1.0 ]]; then - - # Change permission of EasyEngine log folder - chmod -R 700 /var/log/easyengine \ - || ee_lib_error "Unable to change permissions for EasyEngine log folder, exit status = " $? - - # RAM based optimization settings - ee_lib_ram - - if [ -f /etc/php5/fpm/pool.d/www.conf ]; then - sed -i "s/pm.max_children = .*/pm.max_children = ${EE_PHP_MAX_CHILDREN}/" /etc/php5/fpm/pool.d/www.conf - fi - - # Setup Zend OpCache as per RAM - if [ -f /etc/php5/fpm/conf.d/05-opcache.ini ]; then - grep memory_consumption /etc/php5/fpm/conf.d/05-opcache.ini &> /dev/null - if [ $? -ne 0 ]; then - sed -i "s/zend_extension=opcache.so/zend_extension=opcache.so\nopcache.memory_consumption=${EE_OPCACHE_SIZE}\nopcache.max_accelerated_files=50000/" /etc/php5/fpm/conf.d/05-opcache.ini \ - || ee_lib_error "Unable to change opcache.memory_consumption, exit status = " $? - fi - fi - - # Setup PHP Memcache as per RAM - if [ -f /etc/memcached.conf ]; then - sed -i "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \ - || ee_lib_error "Unable to change Memcache memory value, exit status = " $? - fi - - # Add PHP GeoIP module - dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG - if [ $? -eq 0 ]; then - $EE_APT_GET install php5-geoip - ee_lib_echo "Downloading GeoIP Database, please wait..." - mkdir -p /usr/share/GeoIP - wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz - gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz - mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat - fi - - # Fix PhpMyAdmin config issue - if [ -d /var/www/22222/htdocs/db/pma ]; then - ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1) - - if [ ! -f /var/www/22222/htdocs/db/pma/config.inc.php ]; then - cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? - fi - - sed -i "s/a8b7c6d/$ee_random/" /var/www/22222/htdocs/db/pma/config.inc.php \ - || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? - fi - - # Update EasyEngine current version - EE_CURRENT_VERSION="2.2.0" - fi - # if [[ $EE_CURRENT_VERSION = 2.2.0 ]]; then - # fi - fi - - # Update WP-CLI - ee_ven_install_wpcli - - # Set Anemometer password - if [ -d /var/www/22222/htdocs/db/anemometer ]; then - # Change Anemometer Hostname in ee_lib_import_slow_log - sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ - || ee_lib_error "Unable to change Anemometer hostnameme, exit status = " $? - - # Change Anemometer password in ee_lib_import_slow_log - sed -i "s/--password.*/--password=${ee_anemometer_pass} \\\/" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ - || ee_lib_error "Unable to change Anemometer password, exit status = " $? - fi - - # Restart service - ee_lib_service nginx php5-fpm restart - - # Git backup - ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix /etc/easyengine "EasyEngine version $EE_LATEST_VERSION" - - # Enable EasyEngine (ee) auto completion - echo - ee_lib_echo "For EasyEngine (ee) auto completion, run the following command" | tee -ai $EE_UPDATE_LOG - ee_lib_echo_info "source /etc/bash_completion.d/ee" | tee -ai $EE_UPDATE_LOG - echo - ee_lib_echo "EasyEngine (ee) updated successfully" - fi -else - ee_lib_echo "Latest version ($EE_CURRENT_VERSION) already installed" -fi diff --git a/config/README.md b/config/README.md deleted file mode 100644 index 2e377a8e..00000000 --- a/config/README.md +++ /dev/null @@ -1,5 +0,0 @@ -1. **bash_completion.d** - EasyEngine auto completion script. Actual Linux Path : `/etc/bash_completion.d/` - -1. **easyengine** - EasyEngine (ee) configuration file. Actual Linux Path : `/etc/easyengine/` - -1. **nginx** - NGINX configuration files. Actual Linux Path : `/etc/nginx` diff --git a/config/bash_completion.d/README.md b/config/bash_completion.d/README.md deleted file mode 100644 index b4ca7639..00000000 --- a/config/bash_completion.d/README.md +++ /dev/null @@ -1 +0,0 @@ -1. **ee** - EasyEngine auto completion script. \ No newline at end of file diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee deleted file mode 100644 index d9244a3a..00000000 --- a/config/bash_completion.d/ee +++ /dev/null @@ -1,127 +0,0 @@ -# EasyEngine auto complete - -function ee_single() -{ - for (( j=0; j<${#COMP_WORDS[@]}; j++ )); do - for (( i=0; i<${#COMPREPLY[@]}; i++ )); do - if [[ ${COMP_WORDS[COMP_CWORD-j]} == ${COMPREPLY[i]} ]]; then - rem=( ${COMP_WORDS[COMP_CWORD-j]} ); - COMPREPLY=( "${COMPREPLY[@]/$rem}" ) - fi - done - done -} - -function EE_AUTO() -{ - # Get current word - local CURRENT=${COMP_WORDS[COMP_CWORD]} - - # Get previous word - local PREVIOUS=${COMP_WORDS[COMP_CWORD-1]} - local PREVIOUS2=${COMP_WORDS[COMP_CWORD-2]} - local PREVIOUS3=${COMP_WORDS[COMP_CWORD-3]} - - # List of suggested words - case "$PREVIOUS" in - - # List of suggested words - easyengine|ee) - COMPREPLY=( $(compgen -W '$(echo clean version help info update import-slow-log; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) - return 0 - ;; - - stack) - COMPREPLY=( $( compgen -W '$(echo purge status stop start reload restart; command find /usr/local/lib/easyengine/modules/stack -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT ) ) - return 0 - ;; - - install|remove|purge) - COMPREPLY=( $( compgen -W '$(echo mail all web mailscanner admin; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) - return 0 - ;; - - clean) - COMPREPLY=( $( compgen -W '$(echo cd fastcgi memcache opcache all;)' -- $CURRENT ) ) - return 0 - ;; - - site) - COMPREPLY=( $( compgen -W '$(echo cd create delete disable edit enable info list log show update;)' -- $CURRENT ) ) - return 0 - ;; - - list) - COMPREPLY=( $( compgen -W "enable available" -- $CURRENT ) ) - return 0 - ;; - - info|enable|edit|show|delete|cd|log|update) - if [ "$PREVIOUS2" = "site" ]; then - COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)' -- $CURRENT ) ) - fi - return 0 - ;; - - disable) - COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)' -- $CURRENT ) ) - return 0 - ;; - - --wpsubdir|--wpsubdomain) - COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) ) - return 0 - ;; - - debug) - COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) - return 0 - ;; - - --nginx|--rewrite|--php|--fpm|--mysql) - if [ "$PREVIOUS" = "--mysql" ]; then - COMPREPLY=( $(compgen -W '$(echo --import-slow-log-interval; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) - else - COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) - fi - ee_single - return 0 - ;; - - - --wp) - if [ "$PREVIOUS3" = "create" ] || [ "$PREVIOUS3" = "update" ]; then - COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) ) - else - COMPREPLY=( $(compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | grep -v wp | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) - ee_single - fi - return 0 - ;; - - --stop) - - COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)' -- $CURRENT ) ) - ee_single - return 0 - ;; - - secure) - COMPREPLY=( $( compgen -W '$( cd /usr/local/lib/easyengine/modules/secure; find -type f | grep secure | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT ) ) - return 0 - ;; - - *) - if [ "$PREVIOUS2" = "create" ]; then - COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) - elif [ "$PREVIOUS2" = "update" ]; then - COMPREPLY=( $( compgen -W "--password --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) - elif [ "$PREVIOUS2" = "delete" ]; then - COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) ) - fi - return 0 - ;; - esac -} - -complete -F EE_AUTO ee easyengine diff --git a/config/easyengine/README.md b/config/easyengine/README.md deleted file mode 100644 index 94585607..00000000 --- a/config/easyengine/README.md +++ /dev/null @@ -1 +0,0 @@ -1. **ee** - EasyEngine (ee) configuration file. \ No newline at end of file diff --git a/config/easyengine/ee.conf b/config/easyengine/ee.conf deleted file mode 100644 index 74d68b20..00000000 --- a/config/easyengine/ee.conf +++ /dev/null @@ -1,17 +0,0 @@ -# EasyEngine (ee) configuration file - -[stack] - apt-get-assume-yes = true - gpg-key-fix = false - ip-address = - -[mysql] - grant-host = localhost - db-name = false - db-user = false - -[wordpress] - prefix = false - user = - password = - email = diff --git a/config/nginx/README.md b/config/nginx/README.md deleted file mode 100644 index 8db13186..00000000 --- a/config/nginx/README.md +++ /dev/null @@ -1,2 +0,0 @@ -1. **common** - NGINX common configuration settings -1. **conf.d** - NGINX default settings for access control, PHP upstream & FastCGI cache settings. \ No newline at end of file diff --git a/config/nginx/common/README.md b/config/nginx/common/README.md deleted file mode 100644 index 44041308..00000000 --- a/config/nginx/common/README.md +++ /dev/null @@ -1,8 +0,0 @@ -1. **acl.conf** - Protect locations using HTTP AUTH OR IP-Based authentication -1. **locations.conf** - Defines common locations -1. **php** - common PHP NGINX configuration. -1. **wpcommon.conf** - WordPress common settings -1. **w3tc.conf** - W3 Total Cache configuration settings. -1. **wpsc.conf** - WP Super Cache configuration settings. -1. **wpfc.conf** - NGINX FastCGI configuration settings. -1. **wpsubdir.conf** - NGINX configuration for WordPress Multisite (subdirectory). \ No newline at end of file diff --git a/config/nginx/common/acl.conf b/config/nginx/common/acl.conf deleted file mode 100644 index 7549293b..00000000 --- a/config/nginx/common/acl.conf +++ /dev/null @@ -1,10 +0,0 @@ -# EasyEngine (ee) protect locations using -# HTTP authentication || IP address - -satisfy any; -auth_basic "Restricted Area"; -auth_basic_user_file htpasswd-ee; - -# Allowed IP Address List -allow 127.0.0.1; -deny all; diff --git a/config/nginx/common/locations.conf b/config/nginx/common/locations.conf deleted file mode 100644 index 01f3013f..00000000 --- a/config/nginx/common/locations.conf +++ /dev/null @@ -1,82 +0,0 @@ -# NGINX CONFIGURATION FOR COMMON LOCATION -# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) - -# Basic locations files -location = /favicon.ico { - access_log off; - log_not_found off; - expires max; -} - -location = /robots.txt { - # Some WordPress plugin gererate robots.txt file - # Refer #340 issue - try_files $uri $uri/ /index.php?$args; - access_log off; - log_not_found off; -} - -# Cache static files -location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ { - add_header "Access-Control-Allow-Origin" "*"; - access_log off; - log_not_found off; - expires max; -} - - -# Security settings for better privacy - -# Deny hidden files -location ~ /\. { - deny all; - access_log off; - log_not_found off; -} - -# Deny backup extensions & log files -location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp|sql)$ { - deny all; - access_log off; - log_not_found off; -} - -# Return 403 forbidden for readme.(txt|html) or license.(txt|html) -if ($request_uri ~* "^.+(readme|license)\.(txt|html)$") { - return 403; -} - - -# Status pages -location /nginx_status { - stub_status on; - access_log off; - include common/acl.conf; -} - -location ~ ^/(status|ping) { - include fastcgi_params; - fastcgi_pass php; - include common/acl.conf; -} - - -# EasyEngine (ee) utilities - -# phpMyAdmin settings -location /pma { - return 301 https://$host:22222/db/pma; -} - -location /phpMyAdmin { - return 301 https://$host:22222/db/pma; -} - -location /phpmyadmin { - return 301 https://$host:22222/db/pma; -} - -# Adminer settings -location /adminer { - return 301 https://$host:22222/db/adminer; -} diff --git a/config/nginx/common/php.conf b/config/nginx/common/php.conf deleted file mode 100644 index b35d197d..00000000 --- a/config/nginx/common/php.conf +++ /dev/null @@ -1,12 +0,0 @@ -# PHP NGINX CONFIGURATION -# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) - -location / { - try_files $uri $uri/ /index.php?$args; -} - -location ~ \.php$ { - try_files $uri =404; - include fastcgi_params; - fastcgi_pass php; -} diff --git a/config/nginx/common/w3tc.conf b/config/nginx/common/w3tc.conf deleted file mode 100644 index 34210c11..00000000 --- a/config/nginx/common/w3tc.conf +++ /dev/null @@ -1,38 +0,0 @@ -# W3TC NGINX CONFIGURATION -# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) - -set $cache_uri $request_uri; - -# POST requests and URL with a query string should always go to php -if ($request_method = POST) { - set $cache_uri 'null cache'; -} - -if ($query_string != "") { - set $cache_uri 'null cache'; -} - -# Don't cache URL containing the following segments -if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { - set $cache_uri 'null cache'; -} - -# Don't use the cache for logged in users or recent commenter -if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { - set $cache_uri 'null cache'; -} - -# Use cached or actual file if they exists, Otherwise pass request to WordPress -location / { - try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args; -} - -location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ { - try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1; -} - -location ~ \.php$ { - try_files $uri =404; - include fastcgi_params; - fastcgi_pass php; -} diff --git a/config/nginx/common/wpcommon.conf b/config/nginx/common/wpcommon.conf deleted file mode 100644 index 91450a79..00000000 --- a/config/nginx/common/wpcommon.conf +++ /dev/null @@ -1,42 +0,0 @@ -# WordPress COMMON SETTINGS -# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) - -# Limit access to avoid brute force attack -location = /wp-login.php { - limit_req zone=one burst=1 nodelay; - include fastcgi_params; - fastcgi_pass php; -} - -# Disable wp-config.txt -location = /wp-config.txt { - deny all; - access_log off; - log_not_found off; -} - -# Disallow php in upload folder -location /wp-content/uploads/ { - location ~ \.php$ { - #Prevent Direct Access Of PHP Files From Web Browsers - deny all; - } -} - -# Yoast sitemap -location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ { - rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent; - rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last; - - # Rules for yoast sitemap with wp|wpsubdir|wpsubdomain - rewrite ^.*/sitemap_index\.xml$ /index.php?sitemap=1 last; - rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; - - # Following lines are options. Needed for WordPress seo addons - rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last; - rewrite ^/locations\.kml$ /index.php?sitemap=wpseo_local_kml last; - rewrite ^/geo_sitemap\.xml$ /index.php?sitemap=wpseo_local last; - rewrite ^/video-sitemap\.xsl$ /index.php?xsl=video last; - - access_log off; -} diff --git a/config/nginx/common/wpfc.conf b/config/nginx/common/wpfc.conf deleted file mode 100644 index c8285765..00000000 --- a/config/nginx/common/wpfc.conf +++ /dev/null @@ -1,47 +0,0 @@ -# WPFC NGINX CONFIGURATION -# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) - -set $skip_cache 0; - -# POST requests and URL with a query string should always go to php -if ($request_method = POST) { - set $skip_cache 1; -} - -if ($query_string != "") { - set $skip_cache 1; -} - -# Don't cache URL containing the following segments -if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { - set $skip_cache 1; -} - -# Don't use the cache for logged in users or recent commenter -if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { - set $skip_cache 1; -} - -# Use cached or actual file if they exists, Otherwise pass request to WordPress -location / { - try_files $uri $uri/ /index.php?$args; -} - -location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ { - try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1; -} - -location ~ \.php$ { - try_files $uri =404; - include fastcgi_params; - fastcgi_pass php; - - fastcgi_cache_bypass $skip_cache; - fastcgi_no_cache $skip_cache; - - fastcgi_cache WORDPRESS; -} - -location ~ /purge(/.*) { - fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; -} diff --git a/config/nginx/common/wpsc.conf b/config/nginx/common/wpsc.conf deleted file mode 100644 index 26982e3d..00000000 --- a/config/nginx/common/wpsc.conf +++ /dev/null @@ -1,39 +0,0 @@ -# WPSC NGINX CONFIGURATION -# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) - -set $cache_uri $request_uri; - -# POST requests and URL with a query string should always go to php -if ($request_method = POST) { - set $cache_uri 'null cache'; -} - -if ($query_string != "") { - set $cache_uri 'null cache'; -} - -# Don't cache URL containing the following segments -if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { - set $cache_uri 'null cache'; -} - -# Don't use the cache for logged in users or recent commenter -if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { - set $cache_uri 'null cache'; -} - -# Use cached or actual file if they exists, Otherwise pass request to WordPress -location / { - # If we add index.php?$args its break WooCommerce like plugins - # Ref: #330 - try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php; -} - -location ~ \.php$ { - try_files $uri =404; - include fastcgi_params; - fastcgi_pass php; - - # Following line is needed by WP Super Cache plugin - fastcgi_param SERVER_NAME $http_host; -} diff --git a/config/nginx/common/wpsubdir.conf b/config/nginx/common/wpsubdir.conf deleted file mode 100644 index e8ea8bb4..00000000 --- a/config/nginx/common/wpsubdir.conf +++ /dev/null @@ -1,14 +0,0 @@ -# WPSUBDIRECTORY NGINX CONFIGURATION -# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) - -if (!-e $request_filename) { - - # Redirect wp-admin to wp-admin/ - rewrite /wp-admin$ $scheme://$host$uri/ permanent; - - # Redirect wp-* files/folders - rewrite ^(/[^/]+)?(/wp-.*) $2 last; - - # Redirect other php files - rewrite ^(/[^/]+)?(/.*\.php) $2 last; -} diff --git a/config/nginx/conf.d/README.md b/config/nginx/conf.d/README.md deleted file mode 100644 index 13c0c7ea..00000000 --- a/config/nginx/conf.d/README.md +++ /dev/null @@ -1,3 +0,0 @@ -1. **blockips.conf** - Block IP address -1. **fastcgi.conf** - FastCGI cache Settings -1. **upstream.conf** - Common upstream settings \ No newline at end of file diff --git a/config/nginx/conf.d/blockips.conf b/config/nginx/conf.d/blockips.conf deleted file mode 100644 index 8228bedb..00000000 --- a/config/nginx/conf.d/blockips.conf +++ /dev/null @@ -1,2 +0,0 @@ -# Block IP Address -# deny 1.1.1.1; diff --git a/config/nginx/conf.d/fastcgi.conf b/config/nginx/conf.d/fastcgi.conf deleted file mode 100644 index bae48edf..00000000 --- a/config/nginx/conf.d/fastcgi.conf +++ /dev/null @@ -1,12 +0,0 @@ -# FastCGI cache settings - -fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:50m inactive=60m; -fastcgi_cache_key "$scheme$request_method$host$request_uri"; -fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503; -fastcgi_cache_valid any 1h; - -fastcgi_buffers 16 16k; -fastcgi_buffer_size 32k; - -fastcgi_param SERVER_NAME $http_host; -fastcgi_ignore_headers Cache-Control Expires Set-Cookie; diff --git a/config/nginx/conf.d/upstream.conf b/config/nginx/conf.d/upstream.conf deleted file mode 100644 index 989f58d9..00000000 --- a/config/nginx/conf.d/upstream.conf +++ /dev/null @@ -1,11 +0,0 @@ -# Common upstream settings - -upstream php { - # server unix:/run/php5-fpm.sock; - server 127.0.0.1:9000; -} - -upstream debug { - # Debug Pool - server 127.0.0.1:9001; -} diff --git a/docs/README.md b/docs/README.md index f746d8f1..a18a5a87 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1,11 @@ -1. **man** - manual pages for EasyEngine (ee). Actual Linux Path : `/usr/share/man/man8/` +**Framework** + +EasyEngine 3.x is based on cement cli application developement framework + +Cement version 2.4.0 + +Know more about Cement From [here](http://builtoncement.com/2.4/) + +**Language** + +EasyEngine intend to use latest version of Python i.e 3.4 to avoid future refactoring. diff --git a/docs/cs.md b/docs/cs.md new file mode 100644 index 00000000..42122c8c --- /dev/null +++ b/docs/cs.md @@ -0,0 +1,13 @@ + +## EasyEngine coding standard + + For contributing EasyEngine you must follow [PEP8](https://www.python.org/dev/peps/pep-0008) style guide. + +- Indentation - + + 4 spaces shoule be used as Indentation as mentioned in above style guide. + +- Class Name - + + +- Function Name - diff --git a/docs/ds.md b/docs/ds.md new file mode 100644 index 00000000..60ec69c4 --- /dev/null +++ b/docs/ds.md @@ -0,0 +1,21 @@ + +**EasyEngine 3.x Ditectory Structure** + +``` +easyengine +|-- config +| `-- plugins.d +|-- ee +| |-- cli +| | |-- controllers +| | |-- ext +| | |-- plugins +| | `-- templates +| |-- core +| `-- utils +`-- tests + |-- cli + | |-- ext + | `-- plugins + `-- core +``` diff --git a/docs/man/README.md b/docs/man/README.md deleted file mode 100644 index 204094dc..00000000 --- a/docs/man/README.md +++ /dev/null @@ -1 +0,0 @@ -1. **ee.8** - manual page for EasyEngine (ee). diff --git a/docs/man/ee.8 b/docs/man/ee.8 deleted file mode 100644 index cf0821f0..00000000 --- a/docs/man/ee.8 +++ /dev/null @@ -1,310 +0,0 @@ -.TH ee 8 "EasyEngine (ee) version: 2.0.0" "July 11, 2014" "EasyEngine" -.SH NAME -.B EasyEngine (ee) -\- Manage Nginx Based Websites. -.SH SYNOPSIS -ee [ version | help | info | stack | site | debug | update ] -.TP -ee stack [ install | remove | purge ] [ --web | --mail | --all | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] -.TP -ee stack [ status | start | stop | reload | restart ] -.TP -ee site [ list | info | show | enable | disable | edit ] [ example.com ] -.TP -ee site create example.com [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] -.TP -ee site update example.com [ --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] -.TP -ee site delete example.com [--db | --files | --all | --no-prompt ] -.TP -ee debug [ -i | --nginx | --rewrite | --php | --fpm | --mysql ] [ --stop ] -.TP -ee debug example.com [ -i | --nginx | --rewrite | --wp ] [--stop ] -.TP -ee secure [ --auth | --port | --ip ] -.SH DESCRIPTION -EasyEngine aka ee is the opensource project developed with the purpose to automate web-server configuration. -.br -EasyEngine is the collection of shell scripts that provides automation for the web-server -.br -installation, site creation, services debugging & monitoring. -.SH OPTIONS -.TP -.B version -.br -Display easyengine (ee) version information. -.TP -.B info -.br -ee info - Display Nginx, PHP, MySQL and ee common location information -.br -ee site info - Diplay given website details like enable, disable. weboot and log files. -.TP -.B help -.br -Display easyengine (ee) help. -.TP -.B stack -.TP -.B install [ all | web | mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] -.br - Install Nginx PHP5 MySQL Postfix stack Packages if not used with -.br - any options.Installs specific package if used with option. -.TP -.B remove [ all | web | mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] -.br - Remove Nginx PHP5 MySQL Postfix stack Packages if not used with -.br - any options. Remove specific package if used with option. -.TP -.B purge [ all | web | mail | nginx | php | mysql | postfix | adminer | phpmyadmin | wpcli | utils ] -.br - Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any -.br - options.Purge specific package if used with option. -.TP -.B status -.br - Display status of NGINX, PHP5-FPM, MySQL, Postfix services. -.TP -.B start -.br - Start services NGINX, PHP5-FPM, MySQL, Postfix. -.TP -.B stop -.br - Stop services NGINX, PHP5-FPM, MySQL, Postfix. -.TP -.B reload -.br - Reload services NGINX, PHP5-FPM, MySQL, Postfix. -.TP -.B restart -.br - Restart services NGINX, PHP5-FPM, MySQL, Postfix. -.TP -.B site -.br -.TP -.B cd [ example.com ] -.br - Change directory to webroot of specified site in subshell. -.TP -.B log [ example.com ] -.br - monitor access and error logs for site specified. -.TP -.B list [ enable | available ] -.br - Lists all available sites from /etc/nginx/sites-enabled/ -.br - by default & enable argument. Display sites list from -.br - /etc/nginx/sites-available/ if used with available option. - -.TP -.B info [ example.com ] -.br - prints information about site such as access log, error log -.br - location and type of site. -.TP -.B show [ example.com ] -.br - Display NGINX configuration of site. -.TP -.B enable [ example.com ] -.br - Enable site by creating softlink with site file in -.br - /etc/nginx/sites-available to /etc/nginx/sites-enabled/. -.TP -.B disable [ example.com ] -.br - Disable site by Destroying softlink with site file in -.br - /etc/nginx/sites-available to /etc/nginx/sites-enabled/. -.TP -.B edit [ example.com ] -.br - Edit NGINX configuration of site. -.TP -.B create [ example.com ] [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] -.br - Create new site according to given options. If no options provided -.br - create static site with html only. -.TP -.B update [ example.com ] [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] -.br - Update site configuration according to specified options. -.TP -.B delete [ example.com ] [--no-prompt ] [ --db | --files ] -.br - Delete site i.e webroot, database, ad configuration permenantly. -.TP -.B debug [ -i | --nginx | --php | --mysql | --rewrite | --fpm ] [ --start | --stop ] -.br - Starts server level debugging. If used without arguments starts debugging -.br - all services, else debug only service provided with argument. Stop -.br - Debugging if used with --stop argument. -.TP -.B debug example.com [ -i | --nginx | --rewrite | --wp ] [ --start | --stop ] -.br - Starts site level debugging. If used without arguments starts debugging all -.br - services, else debug only service provided with argument. Stop Debugging -.br - if used with --stop argument. -.TP -.B secure [ --auth | --port ] -.br - Update security settings. -.TP -.B clean [ fastcgi | opcache | memcache | all ] -.br - Clean NGINX fastCGI cache, Opcache, Memcache. -.br - Clean NGINX fastCGI cache if no option specified. -.SH ARGUMENTS -.TP -.B -i -.br - setup intractive mode while used with debug. -.TP -.B --nginx -.br - used with ee debug command. used to start or stop nginx debugging. -.TP -.B --php -.br - used with ee debug command. used to start or stop php debugging. -.TP -.B --mysql -.br - used with ee debug command. used to start or stop mysql debugging. -.TP -.B --rewrite -.br - used with ee debug command. used to start or stop nginx rewrite rules debugging. -.TP -.B --fpm -.br - used with ee debug command. used to start or stop fpm debugging. -.TP -.B --wp -.br - used with ee debug command. used to start or stop wordpress site debugging. -.TP -.B --start -.br - used with ee debug command. used to stop debugging. -.TP -.B --stop -.br - used with ee debug command. used to stop debugging. -.TP -.B --html -.br - Create a HTML website. -.TP -.B --php -.br - Create a PHP website. -.TP -.B --mysql -.br - Create a PHP+MySQL website. -.TP -.B --wp -.br - Create a WordPress Website. -.TP -.B --wpsubdir -.br - Create a Wordpress Multisite with Sub Directories Setup. -.TP -.B --wpsubdomain -.br - Create a Wordpress Multisite with Sub Domains Setup. -.br -.TP -.B --db -.br - Delete website database. -.br -.TP -.B --files -.br - Delete website webroot. -.br -.TP -.B --no-prompt -.br - Does not prompt for confirmation when delete command used. -.TP -.B --auth -.br - used with ee secure command. Update credential of HTTP authentication -.TP -.B --port -.br - used with ee secure command. Change EasyEngine admin port 22222. -.TP -.B --ip -.br - used with ee secure command. Update whitelist IP address -.SH WORDPRESS CACHING OPTIONS -.TP -.B --basic -.br - Create WordPress website without cache. -.TP -.B --w3tc -.br - Install and activate Nginx-helper and W3 Total Cache plugin. -.TP -.B --wpsc -.br - Install and activate Nginx-helper and WP Super Cache plugin. -.TP -.B --wpfc -.br - Install and activate Nginx-helper and W3 Total Cache plugin with -.br - Nginx FastCGI cache. -.SH FILES -.br -/etc/easyengine/ee.conf -.SH BUGS -Report bugs at -.SH AUTHOR -.br -.B rtCamp Team -.I \ -.br -.B Mitesh Shah -.I \ -.br -.B Manish -.I \ -.br -.B Gaurav -.I \ -.br -.B Harshad -.I \ -.SH "SEE ALSO" -.br -EE: -.I https://rtcamp.com/easyengine/ -.br -FAQ: -.I https://rtcamp.com/easyengine/faq/ -.br -DOCS: -.I https://rtcamp.com/easyengine/docs/ - diff --git a/src/modules/site/delete/README.md b/easyengine/LICENSE similarity index 100% rename from src/modules/site/delete/README.md rename to easyengine/LICENSE diff --git a/easyengine/README.md b/easyengine/README.md new file mode 100644 index 00000000..5e127fd4 --- /dev/null +++ b/easyengine/README.md @@ -0,0 +1,11 @@ +EasyEngine +============================================================================== + +Installation +------------ + +``` +$ pip install -r requirements.txt + +$ python setup.py install +``` diff --git a/easyengine/config/ee.conf b/easyengine/config/ee.conf new file mode 100644 index 00000000..6e2c379a --- /dev/null +++ b/easyengine/config/ee.conf @@ -0,0 +1,41 @@ +# EasyEngine Configuration +# +# All commented values are the application default +# + +[ee] + +### Toggle application level debug (does not toggle framework debugging) +# debug = false + +### Where external (third-party) plugins are loaded from +# plugin_dir = /var/lib/ee/plugins/ + +### Where all plugin configurations are loaded from +# plugin_config_dir = /etc/ee/plugins.d/ + +### Where external templates are loaded from +# template_dir = /var/lib/ee/templates/ + + +[log] + +### Where the log file lives (no log file by default) +# file = none + +### The level for which to log. One of: info, warn, error, fatal, debug +# level = info + +### Whether or not to log to console +# to_console = true + +### Whether or not to rotate the log file when it reaches `max_bytes` +# rotate = false + +### Max size in bytes that a log file can grow until it is rotated. +# max_bytes = 512000 + +### The maximun number of log files to maintain when rotating +# max_files = 4 + + diff --git a/easyengine/config/plugins.d/example.conf b/easyengine/config/plugins.d/example.conf new file mode 100644 index 00000000..415e8499 --- /dev/null +++ b/easyengine/config/plugins.d/example.conf @@ -0,0 +1,11 @@ +### Example Plugin Configuration for EasyEngine + +[example] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true + +### Additional plugin configuration settings +foo = bar diff --git a/easyengine/ee/__init__.py b/easyengine/ee/__init__.py new file mode 100644 index 00000000..de40ea7c --- /dev/null +++ b/easyengine/ee/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/easyengine/ee/cli/__init__.py b/easyengine/ee/cli/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/ee/cli/bootstrap.py b/easyengine/ee/cli/bootstrap.py new file mode 100644 index 00000000..86fd4047 --- /dev/null +++ b/easyengine/ee/cli/bootstrap.py @@ -0,0 +1,10 @@ +"""EasyEngine bootstrapping.""" + +# All built-in application controllers should be imported, and registered +# in this file in the same way as EEBaseController. + +from cement.core import handler +from ee.cli.controllers.base import EEBaseController + +def load(app): + handler.register(EEBaseController) diff --git a/easyengine/ee/cli/controllers/__init__.py b/easyengine/ee/cli/controllers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/ee/cli/controllers/base.py b/easyengine/ee/cli/controllers/base.py new file mode 100644 index 00000000..357c30ed --- /dev/null +++ b/easyengine/ee/cli/controllers/base.py @@ -0,0 +1,28 @@ +"""EasyEngine base controller.""" + +from cement.core.controller import CementBaseController, expose + +class EEBaseController(CementBaseController): + class Meta: + label = 'base' + description = 'easyengine is the commandline tool to manage your websites based on wordpress and nginx with easy to use commands.' + arguments = [ + (['-f', '--foo'], + dict(help='the notorious foo option', dest='foo', action='store', + metavar='TEXT') ), + ] + + @expose(hide=True) + def default(self): + print "Inside EEBaseController.default()." + + # If using an output handler such as 'mustache', you could also + # render a data dictionary using a template. For example: + # + # data = dict(foo='bar') + # self.app.render(data, 'default.mustache') + # + # + # The 'default.mustache' file would be loaded from + # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + # diff --git a/easyengine/ee/cli/controllers/site.py b/easyengine/ee/cli/controllers/site.py new file mode 100644 index 00000000..4c691110 --- /dev/null +++ b/easyengine/ee/cli/controllers/site.py @@ -0,0 +1,30 @@ +"""EasyEngine site controller.""" + +from cement.core.controller import CementBaseController, expose + +class EESiteController(CementBaseController): + class Meta: + label = 'site' + interface = controller.IController + stacked_on = 'base' + stacked_type = 'nested' + description = 'site command manges website configuration with the help of the following subcommands' + (['-f', '--foo'], + dict(help='the notorious foo option', dest='foo', action='store', + metavar='TEXT') ), + ] + + @expose(hide=True) + def default(self): + print "Inside EESiteController.default()." + + # If using an output handler such as 'mustache', you could also + # render a data dictionary using a template. For example: + # + # data = dict(foo='bar') + # self.app.render(data, 'default.mustache') + # + # + # The 'default.mustache' file would be loaded from + # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + # diff --git a/easyengine/ee/cli/ext/__init__.py b/easyengine/ee/cli/ext/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/ee/cli/main.py b/easyengine/ee/cli/main.py new file mode 100644 index 00000000..15e59dd9 --- /dev/null +++ b/easyengine/ee/cli/main.py @@ -0,0 +1,87 @@ +"""EasyEngine main application entry point.""" + +from cement.core import foundation +from cement.utils.misc import init_defaults +from cement.core.exc import FrameworkError, CaughtSignal +from ee.core import exc + +# Application default. Should update config/ee.conf to reflect any +# changes, or additions here. +defaults = init_defaults('ee') + +# All internal/external plugin configurations are loaded from here +defaults['ee']['plugin_config_dir'] = '/etc/ee/plugins.d' + +# External plugins (generally, do not ship with application code) +defaults['ee']['plugin_dir'] = '/var/lib/ee/plugins' + +# External templates (generally, do not ship with application code) +defaults['ee']['template_dir'] = '/var/lib/ee/templates' + + +class EEApp(foundation.CementApp): + class Meta: + label = 'ee' + config_defaults = defaults + + # All built-in application bootstrapping (always run) + bootstrap = 'ee.cli.bootstrap' + + # Optional plugin bootstrapping (only run if plugin is enabled) + plugin_bootstrap = 'ee.cli.plugins' + + # Internal templates (ship with application code) + template_module = 'ee.cli.templates' + + # Internal plugins (ship with application code) + plugin_bootstrap = 'ee.cli.plugins' + + +class EETestApp(EEApp): + """A test app that is better suited for testing.""" + class Meta: + argv = [] + config_files = [] + + +# Define the applicaiton object outside of main, as some libraries might wish +# to import it as a global (rather than passing it into another class/func) +app = EEApp() + +def main(): + try: + # Default our exit status to 0 (non-error) + code = 0 + + # Setup the application + app.setup() + + # Run the application + app.run() + except exc.EEError as e: + # Catch our application errors and exit 1 (error) + code = 1 + print(e) + except FrameworkError as e: + # Catch framework errors and exit 1 (error) + code = 1 + print(e) + except CaughtSignal as e: + # Default Cement signals are SIGINT and SIGTERM, exit 0 (non-error) + code = 0 + print(e) + finally: + # Print an exception (if it occurred) and --debug was passed + if app.debug: + import sys + import traceback + + exc_type, exc_value, exc_traceback = sys.exc_info() + if exc_traceback is not None: + traceback.print_exc() + + # Close the application + app.close(code) + +if __name__ == '__main__': + main() diff --git a/easyengine/ee/cli/plugins/__init__.py b/easyengine/ee/cli/plugins/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/ee/cli/plugins/example.py b/easyengine/ee/cli/plugins/example.py new file mode 100644 index 00000000..0c3184b3 --- /dev/null +++ b/easyengine/ee/cli/plugins/example.py @@ -0,0 +1,50 @@ +"""Example Plugin for EasyEngine.""" + +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook + +def example_plugin_hook(app): + # do something with the ``app`` object here. + pass + +class ExamplePluginController(CementBaseController): + class Meta: + # name that the controller is displayed at command line + label = 'example' + + # text displayed next to the label in ``--help`` output + description = 'this is an example plugin controller' + + # stack this controller on-top of ``base`` (or any other controller) + stacked_on = 'base' + + # determines whether the controller is nested, or embedded + stacked_type = 'nested' + + # these arguments are only going to display under + # ``$ ee example --help`` + arguments = [ + ( + ['-f', '--foo'], + dict( + help='Notorious foo option', + action='store', + ) + ) + ] + + @expose(hide=True) + def default(self): + print("Inside ExamplePluginController.default()") + + @expose(help="this is an example sub-command.") + def example_plugin_command(self): + print("Inside ExamplePluginController.example_plugin_command()") + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(ExamplePluginController) + + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', example_plugin_hook) diff --git a/easyengine/ee/cli/templates/__init__.py b/easyengine/ee/cli/templates/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/ee/core/__init__.py b/easyengine/ee/core/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/ee/core/exc.py b/easyengine/ee/core/exc.py new file mode 100644 index 00000000..c8a2feb4 --- /dev/null +++ b/easyengine/ee/core/exc.py @@ -0,0 +1,22 @@ +"""EasyEngine exception classes.""" + +class EEError(Exception): + """Generic errors.""" + def __init__(self, msg): + Exception.__init__(self) + self.msg = msg + + def __str__(self): + return self.msg + +class EEConfigError(EEError): + """Config related errors.""" + pass + +class EERuntimeError(EEError): + """Generic runtime errors.""" + pass + +class EEArgumentError(EEError): + """Argument related errors.""" + pass diff --git a/easyengine/ee/utils/__init__.py b/easyengine/ee/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/ee/utils/test.py b/easyengine/ee/utils/test.py new file mode 100644 index 00000000..d49f4b88 --- /dev/null +++ b/easyengine/ee/utils/test.py @@ -0,0 +1,16 @@ +"""Testing utilities for EasyEngine.""" + +from ee.cli.main import EETestApp +from cement.utils.test import * + +class EETestCase(CementTestCase): + app_class = EETestApp + + def setUp(self): + """Override setup actions (for every test).""" + super(EETestCase, self).setUp() + + def tearDown(self): + """Override teardown actions (for every test).""" + super(EETestCase, self).tearDown() + diff --git a/easyengine/requirements.txt b/easyengine/requirements.txt new file mode 100644 index 00000000..24fb2218 --- /dev/null +++ b/easyengine/requirements.txt @@ -0,0 +1 @@ +cement>=2.4.0 diff --git a/easyengine/setup.cfg b/easyengine/setup.cfg new file mode 100644 index 00000000..a273d468 --- /dev/null +++ b/easyengine/setup.cfg @@ -0,0 +1,9 @@ +[nosetests] +verbosity=3 +debug=0 +detailed-errors=1 +with-coverage=1 +cover-package=ee +cover-erase=1 +cover-html=1 +cover-html-dir=coverage_report/ diff --git a/easyengine/setup.py b/easyengine/setup.py new file mode 100644 index 00000000..99863cdd --- /dev/null +++ b/easyengine/setup.py @@ -0,0 +1,34 @@ + +from setuptools import setup, find_packages +import sys, os + +setup(name='ee', + version='3.0', + description="EasyEngine is the commandline tool to manage your Websites based on WordPress and NGINX with easy to use commands.", + long_description="EasyEngine is the commandline tool to manage your Websites based on WordPress and NGINX with easy to use commands.", + classifiers=[], + keywords='', + author='rtCamp Soultions Pvt. LTD', + author_email='sys@rtcamp.com', + url='http://rtcamp.com/easyengine', + license='GPL', + packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), + include_package_data=True, + zip_safe=False, + test_suite='nose.collector', + install_requires=[ + ### Required to build documentation + # "Sphinx >= 1.0", + ### Required for testing + # "nose", + # "coverage", + ### Required to function + 'cement', + ], + setup_requires=[], + entry_points=""" + [console_scripts] + ee = ee.cli.main:main + """, + namespace_packages=[], + ) diff --git a/easyengine/tests/__init__.py b/easyengine/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/tests/cli/__init__.py b/easyengine/tests/cli/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/tests/cli/ext/__init__.py b/easyengine/tests/cli/ext/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/tests/cli/plugins/__init__.py b/easyengine/tests/cli/plugins/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/tests/cli/plugins/test_example.py b/easyengine/tests/cli/plugins/test_example.py new file mode 100644 index 00000000..860a5485 --- /dev/null +++ b/easyengine/tests/cli/plugins/test_example.py @@ -0,0 +1,8 @@ +"""Tests for Example Plugin.""" + +from ee.utils import test + +class ExamplePluginTestCase(test.EETestCase): + def test_load_example_plugin(self): + self.app.setup() + self.app.plugin.load_plugin('example') diff --git a/easyengine/tests/cli/test_ee.py b/easyengine/tests/cli/test_ee.py new file mode 100644 index 00000000..0ea3fef3 --- /dev/null +++ b/easyengine/tests/cli/test_ee.py @@ -0,0 +1,9 @@ +"""CLI tests for ee.""" + +from ee.utils import test + +class CliTestCase(test.EETestCase): + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() diff --git a/easyengine/tests/core/__init__.py b/easyengine/tests/core/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/easyengine/tests/core/test_exc.py b/easyengine/tests/core/test_exc.py new file mode 100644 index 00000000..e69de29b diff --git a/src/README.md b/src/README.md deleted file mode 100644 index 616083d2..00000000 --- a/src/README.md +++ /dev/null @@ -1,12 +0,0 @@ - -1. **lib** - EasyEngine (ee) libraries - - Actual Linux path: `/usr/local/lib/easyengine/lib/` - -1. **modules** - EasyEngine (ee) modules - - Actual Linux path: `/usr/local/lib/easyengine/modules/` - -1. **vendor** - EasyEngine (ee) 3rd party packages - - Actual Linux path: `/usr/local/lib/easyengine/vendor/` diff --git a/src/lib/README.md b/src/lib/README.md deleted file mode 100644 index 4ad8b073..00000000 --- a/src/lib/README.md +++ /dev/null @@ -1,11 +0,0 @@ -1. **ee_lib_apt_get_update.sh** - Execute apt-get update -1. **ee_lib_dotdeb.sh** - Fetch and install Dotdeb.org GnuPG key -1. **ee_lib_echo.sh**- Define echo function -1. **ee_lib_error.sh** - Capture errors -1. **ee_lib_git_commit.sh** - Record changes to the repository -1. **ee_lib_git_init.sh** - Initialize Git -1. **ee_lib_gpg_key_fix.sh** - Fix GnuPG key -1. **ee_lib_http_auth.sh** - Setup HTTP authentication -1. **ee_lib_package_check.sh** - Check the specified package is installed or not -1. **ee_lib_service.sh** - Services Start/Stop/Restart/Reload -1. **ee_lib_variables.sh** - Define global variables \ No newline at end of file diff --git a/src/lib/ee_lib_apt_get_update.sh b/src/lib/ee_lib_apt_get_update.sh deleted file mode 100644 index e9fe39f9..00000000 --- a/src/lib/ee_lib_apt_get_update.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Execute: apt-get update - -function ee_lib_apt_get_update() -{ - ee_lib_echo "Executing apt-get update, please wait..." - apt-get update &>> $EE_COMMAND_LOG || ee_lib_error "Unable to execute apt-get update, exit status = " $? -} diff --git a/src/lib/ee_lib_autoremove.sh b/src/lib/ee_lib_autoremove.sh deleted file mode 100644 index 7545507b..00000000 --- a/src/lib/ee_lib_autoremove.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Execute: apt-get autoremove - -function ee_lib_autoremove() -{ - ee_lib_echo "Removing unwanted packages, please wait..." - $EE_APT_GET autoremove -} diff --git a/src/lib/ee_lib_check_domain.sh b/src/lib/ee_lib_check_domain.sh deleted file mode 100644 index b23e4226..00000000 --- a/src/lib/ee_lib_check_domain.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Check domain name - -function ee_lib_check_domain() -{ - # Check if domain name is empty or not - while [ -z $EE_DOMAIN_CHECK ]; do - # Ask user to enter domain name - read -p "Enter domain name: " EE_DOMAIN_CHECK - done - - # Remove http:// https:// & www. - EE_DOMAIN=$(echo $EE_DOMAIN_CHECK | tr 'A-Z' 'a-z' | sed "s'http://''" | sed "s'https://''" | sed "s'/''" | sed "s'www.''" ) - - # Remove http:// https:// For WordPress Setup (www.example.com) - EE_WWW_DOMAIN=$(echo $EE_DOMAIN_CHECK | tr 'A-Z' 'a-z' | sed "s'http://''" | sed "s'https://''" | sed "s'/''") -} diff --git a/src/lib/ee_lib_check_fqdn.sh b/src/lib/ee_lib_check_fqdn.sh deleted file mode 100644 index 712b393d..00000000 --- a/src/lib/ee_lib_check_fqdn.sh +++ /dev/null @@ -1,27 +0,0 @@ -# Check Server hostname is FQDN or not - -function ee_lib_check_fqdn() -{ - case $1 in - *.*) - if [ "$EE_FQDN" != "" ];then - echo $EE_FQDN > /etc/hostname - if [ "$EE_LINUX_DISTRO" == "Debian" ];then - grep $EE_FQDN /etc/hosts &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - sed -i "1i\127.0.0.1 $EE_FQDN" /etc/hosts \ - || ee_lib_error "Unable setup hostname = " $? - fi - /etc/init.d/hostname.sh start &>> $EE_COMMAND_LOG - else - service hostname restart &>> $EE_COMMAND_LOG - fi - echo "hostname = $(hostname -f)" &>> $EE_COMMAND_LOG - fi - ;; - *) - read -p "Enter hostname [FQDN]: " EE_FQDN - ee_lib_check_fqdn $EE_FQDN - ;; - esac -} diff --git a/src/lib/ee_lib_dotdeb.sh b/src/lib/ee_lib_dotdeb.sh deleted file mode 100644 index 9acf3ec3..00000000 --- a/src/lib/ee_lib_dotdeb.sh +++ /dev/null @@ -1,10 +0,0 @@ -# Fetch and install Dotdeb.org GnuPG key - -function ee_lib_dotdeb() -{ - wget --no-check-certificate -cO /tmp/dotdeb.gpg http://www.dotdeb.org/dotdeb.gpg \ - &>> $EE_COMMAND_LOG || ee_lib_error "Unable to download Dotdeb.org GnuPG key, exit status = " $? - - apt-key add /tmp/dotdeb.gpg &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to add Dotdeb.org GnuPG key, exit status = " $? -} diff --git a/src/lib/ee_lib_echo.sh b/src/lib/ee_lib_echo.sh deleted file mode 100644 index d2166e33..00000000 --- a/src/lib/ee_lib_echo.sh +++ /dev/null @@ -1,25 +0,0 @@ -# Define echo function - -# Blue color -function ee_lib_echo() -{ - echo $(tput setaf 4)$@$(tput sgr0) -} - -# White color -function ee_lib_echo_info() -{ - echo $(tput setaf 7)$@$(tput sgr0) -} - -# Red color -function ee_lib_echo_fail() -{ - echo $(tput setaf 1)$@$(tput sgr0) -} - -# Execute: echo -e -function ee_lib_echo_escape() -{ - echo -e $(tput sgr0)$@$(tput sgr0) -} diff --git a/src/lib/ee_lib_error.sh b/src/lib/ee_lib_error.sh deleted file mode 100644 index 206a9023..00000000 --- a/src/lib/ee_lib_error.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Capture errors - -function ee_lib_error() -{ - echo -e "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" | tee -ai $EE_ERROR_LOG - exit $2 -} diff --git a/src/lib/ee_lib_git.sh b/src/lib/ee_lib_git.sh deleted file mode 100644 index 3467c90e..00000000 --- a/src/lib/ee_lib_git.sh +++ /dev/null @@ -1,26 +0,0 @@ -# Initialize Git - -function ee_lib_git() -{ - for ee_git_dir in ${@:1:$(($#-1))}; do - if [ -d $ee_git_dir ]; then - # Change directory - cd $ee_git_dir - - # Check .git - if [ ! -d .git ]; then - # ee_lib_echo "Initialize Git on ${ee_git_dir}" - git init &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to initialize Git on $ee_git_dir, exit status = " $? - fi - - # Check for untracked files - if [ $(git status -s | wc -l) -ne 0 ]; then - # Add files in Git version control - ee_lib_echo "Git commit on $ee_git_dir, please wait..." - git add --all && git commit -am "${@: -1}" &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to Git commit on $ee_git_dir, exit status = " $? - fi - fi - done -} diff --git a/src/lib/ee_lib_gpg_key_fix.sh b/src/lib/ee_lib_gpg_key_fix.sh deleted file mode 100644 index 1f28fc3d..00000000 --- a/src/lib/ee_lib_gpg_key_fix.sh +++ /dev/null @@ -1,24 +0,0 @@ -# Fix GnuPG key - -function ee_lib_gpg_key_fix() -{ - local ee_gpg_key_check - - # GnuPG key check - $EE_CONFIG_GET stack.gpg-key-fix | grep -i true &>> $EE_COMMAND_LOG - - if [ $? -eq 0 ];then - - # Fix GnuPG key problems - apt-get update > /dev/null 2> /tmp/gpg_key - - for ee_gpg_key_check in $(grep "NO_PUBKEY" /tmp/gpg_key |sed "s/.*NO_PUBKEY //") - do - ee_lib_echo "Processing GnuPG key: $ee_gpg_key_check" - gpg --keyserver subkeys.pgp.net --recv $ee_gpg_key_check &>> $EE_COMMAND_LOG \ - && gpg --export --armor $ee_gpg_key_check \ - | apt-key add - &>> $EE_COMMAND_LOG - done - - fi -} diff --git a/src/lib/ee_lib_import_slow_log.sh b/src/lib/ee_lib_import_slow_log.sh deleted file mode 100644 index cfa41c72..00000000 --- a/src/lib/ee_lib_import_slow_log.sh +++ /dev/null @@ -1,26 +0,0 @@ -# Import MySQL slow log to Anememoter - -function ee_lib_import_slow_log() -{ - - if [ -d /var/www/22222/htdocs/db/anemometer ]; then - if [ -f /var/log/mysql/mysql-slow.log ]; then - ee_lib_echo "Importing MySQL slow log, please wait..." - dpkg --compare-versions $(pt-query-digest --version | awk '{print $2 }') ge 2.2 - if [ $? -eq 0 ]; then - ee_anemometer_history=history - else - ee_anemometer_history=review-history - fi - - pt-query-digest --user=anemometer --password=anemometer_password \ - --review D=slow_query_log,t=global_query_review \ - --${ee_anemometer_history} D=slow_query_log,t=global_query_review_history \ - --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\"anemometer-mysql\"" /var/log/mysql/mysql-slow.log - else - ee_lib_echo_fail "Failed to find MySQL slow log file, enable MySQL slow log" - fi - else - ee_lib_echo_fail "Anemometer is not installed" - fi -} diff --git a/src/lib/ee_lib_mysql_info.sh b/src/lib/ee_lib_mysql_info.sh deleted file mode 100644 index d35a1fa6..00000000 --- a/src/lib/ee_lib_mysql_info.sh +++ /dev/null @@ -1,27 +0,0 @@ -# MySQL information - -function ee_lib_mysql_info() -{ - mysqladmin ping &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - local ee_mysql_version=$(mysql -V | awk '{print($5)}' | cut -d ',' -f1) - local ee_mysql_port=$(mysql -e "show variables" | grep ^port | awk '{print($2)}') - local ee_mysql_socket=$(mysql -e "show variables" | grep "^socket" | awk '{print($2)}') - local ee_mysql_data_dir=$(mysql -e "show variables" | grep datadir | awk '{print($2)}') - local ee_mysql_wait_timeout=$(mysql -e "show variables" | grep ^wait_timeout | awk '{print($2)}') - local ee_mysql_interactive_timeout=$(mysql -e "show variables" | grep ^interactive_timeout | awk '{print($2)}') - local ee_mysql_max_connections=$(mysql -e "show variables" | grep "^max_connections" | awk '{print($2)}') - local ee_mysql_max_used_connections=$(mysql -e "show global status" | grep Max_used_connections | awk '{print($2)}') - - ee_lib_echo - ee_lib_echo "MySQL ($ee_mysql_version) on $EE_MYSQL_HOST:" - ee_lib_echo_escape "port\t\t\t\t \033[37m$ee_mysql_port" - ee_lib_echo_escape "wait_timeout\t\t\t \033[37m$ee_mysql_wait_timeout" - ee_lib_echo_escape "interactive_timeout\t\t \033[37m$ee_mysql_interactive_timeout" - ee_lib_echo_escape "max_used_connections\t\t \033[37m$ee_mysql_max_used_connections/$ee_mysql_max_connections" - ee_lib_echo_escape "datadir\t\t\t\t \033[37m$ee_mysql_data_dir" - ee_lib_echo_escape "socket\t\t\t\t \033[37m$ee_mysql_socket" - else - ee_lib_echo "MYSQL not installed" - fi -} diff --git a/src/lib/ee_lib_nginx_info.sh b/src/lib/ee_lib_nginx_info.sh deleted file mode 100644 index 0214fc80..00000000 --- a/src/lib/ee_lib_nginx_info.sh +++ /dev/null @@ -1,29 +0,0 @@ -# NGINX information - -function ee_lib_nginx_info() -{ - ee_lib_package_check $EE_NGINX_PACKAGE - if [ "$EE_PACKAGE_NAME" = "" ]; then - local ee_nginx_version=$(nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2 | cut -d'/' -f2) - local ee_nginx_user=$(grep ^user /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_nginx_processes=$(grep worker_processes /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_nginx_connections=$(grep worker_connections /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_nginx_keep_alive=$(grep keepalive_timeout /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_fastcgi_timeout=$(grep fastcgi_read_timeout /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_clinet_max_body_size=$(grep client_max_body_size /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1) - local ee_nginx_allowed_ip_add=$(grep ^allow /etc/nginx/common/acl.conf | cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' ') - - ee_lib_echo - ee_lib_echo - ee_lib_echo "NGINX ($ee_nginx_version):" - ee_lib_echo_escape "user\t\t\t\t \033[37m$ee_nginx_user" - ee_lib_echo_escape "worker_processes\t\t \033[37m$ee_nginx_processes" - ee_lib_echo_escape "worker_connections\t\t \033[37m$ee_nginx_connections" - ee_lib_echo_escape "keepalive_timeout\t\t \033[37m$ee_nginx_keep_alive" - ee_lib_echo_escape "fastcgi_read_timeout\t\t \033[37m$ee_fastcgi_timeout" - ee_lib_echo_escape "client_max_body_size\t\t \033[37m$ee_clinet_max_body_size" - ee_lib_echo_escape "allow\t\t\t\t \033[37m$ee_nginx_allowed_ip_add" - else - ee_lib_echo "NGINX not installed" - fi -} diff --git a/src/lib/ee_lib_package_check.sh b/src/lib/ee_lib_package_check.sh deleted file mode 100644 index 2ada9565..00000000 --- a/src/lib/ee_lib_package_check.sh +++ /dev/null @@ -1,20 +0,0 @@ -# Check the specified package is installed or not - -function ee_lib_package_check() -{ - # If nginx is not installed and php is installed - # ee site create example.com --wp is tries to installl php as $EE_PACKAGE_NAME=nginx-custom - EE_PACKAGE_NAME="" - - local ee_package - - for ee_package in $@;do - dpkg --get-selections | grep -v deinstall | grep $ee_package &>> $EE_COMMAND_LOG - - # Generate a list of not installed package - if [ $? -ne 0 ]; then - EE_PACKAGE_NAME="$EE_PACKAGE_NAME $ee_package" - fi - - done -} diff --git a/src/lib/ee_lib_permissions.sh b/src/lib/ee_lib_permissions.sh deleted file mode 100644 index 0a6346c1..00000000 --- a/src/lib/ee_lib_permissions.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Adjust permission - -function ee_lib_permissions() -{ - ee_lib_echo "Changing ownership of /var/www/$EE_DOMAIN, please wait..." - chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/$EE_DOMAIN/ \ - || ee_lib_error "Unable to change ownership for $EE_DOMAIN, exit status = " $? -} diff --git a/src/lib/ee_lib_php_info.sh b/src/lib/ee_lib_php_info.sh deleted file mode 100644 index 48500c60..00000000 --- a/src/lib/ee_lib_php_info.sh +++ /dev/null @@ -1,56 +0,0 @@ -# PHP information -function ee_lib_php_info() -{ - ee_lib_package_check php5-fpm - if [ "$EE_PACKAGE_NAME" = "" ]; then - #Collect information from php.ini - local ee_php_version=$(php -v | head -n1 | cut -d' ' -f2 | cut -d'+' -f1) - local ee_php_memory=$(grep ^memory_limit /etc/php5/fpm/php.ini | awk '{print $3}') - local ee_php_expose=$(grep ^expose_php /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) - local ee_php_post_max_size=$(grep post_max_size /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) - local ee_php_upload_max_filesize=$(grep upload_max_filesize /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) - local ee_php_max_execution_time=$(grep max_execution_time /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2) - - - ee_lib_echo - ee_lib_echo "PHP ($ee_php_version):" - ee_lib_echo_escape "user\t\t\t\t \033[37m$EE_PHP_USER" - ee_lib_echo_escape "expose_php\t\t\t \033[37m$ee_php_expose" - ee_lib_echo_escape "memory_limit\t\t\t \033[37m$ee_php_memory" - ee_lib_echo_escape "post_max_size\t\t\t \033[37m$ee_php_post_max_size" - ee_lib_echo_escape "upload_max_filesize\t\t \033[37m$ee_php_upload_max_filesize" - ee_lib_echo_escape "max_execution_time\t\t \033[37m$ee_php_max_execution_time" - - - #Collect information from $ee_php_pool and debug.conf - for ee_php_pool in www.conf debug.conf;do - local ee_php_ping_path=$(grep ^ping.path /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_status_path=$(grep ^pm.status_path /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_process_manager=$(grep "^pm =" /etc/php5/fpm/pool.d/$ee_php_pool | awk '{print $3}') - local ee_php_max_requests=$(grep ^pm.max_requests /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_max_children=$(grep ^pm.max_children /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_start_servers=$(grep ^pm.start_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_min_spare_servers=$(grep ^pm.min_spare_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_max_spare_servers=$(grep ^pm.max_spare_servers /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_php_request_terminate_timeout=$(grep ^request_terminate_timeout /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - local ee_xdebug_check=$( grep "php_admin_flag\[xdebug.profiler_enable_trigger\]" /etc/php5/fpm/pool.d/$ee_php_pool | grep on &> /dev/null && echo on || echo off) - local ee_php_listen=$(grep '^listen =' /etc/php5/fpm/pool.d/$ee_php_pool | cut -d'=' -f2| cut -d' ' -f2) - - ee_lib_echo - ee_lib_echo "Information about $ee_php_pool" - ee_lib_echo_escape "ping.path\t\t\t \033[37m$ee_php_ping_path" - ee_lib_echo_escape "pm.status_path\t\t\t \033[37m$ee_php_status_path" - ee_lib_echo_escape "process_manager\t\t\t \033[37m$ee_php_process_manager" - ee_lib_echo_escape "pm.max_requests\t\t\t \033[37m$ee_php_max_requests" - ee_lib_echo_escape "pm.max_children\t\t\t \033[37m$ee_php_max_children" - ee_lib_echo_escape "pm.start_servers\t\t \033[37m$ee_php_start_servers" - ee_lib_echo_escape "pm.min_spare_servers\t\t \033[37m$ee_php_min_spare_servers" - ee_lib_echo_escape "pm.max_spare_servers\t\t \033[37m$ee_php_max_spare_servers" - ee_lib_echo_escape "request_terminate_timeout\t \033[37m$ee_php_request_terminate_timeout" - ee_lib_echo_escape "xdebug.profiler_enable_trigger\t \033[37m$ee_xdebug_check" - ee_lib_echo_escape "listen\t\t\t\t \033[37m$ee_php_listen" - done - else - ee_lib_echo "PHP not installed" - fi -} diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh deleted file mode 100644 index cc9c9120..00000000 --- a/src/lib/ee_lib_ram.sh +++ /dev/null @@ -1,48 +0,0 @@ -# EasyEngine RAM based settings - -function ee_lib_ram() -{ - # Detect RAM and SWAP of System - readonly EE_TOTAL_RAM=$(free -m | grep -i Mem | awk '{ print $2 }') - readonly EE_TOTAL_SWAP=$(free -m | grep -i Swap | awk '{ print $2 }') - - # RAM < 512MB - if [ $EE_TOTAL_RAM -le 512 ]; then - EE_OPCACHE_SIZE="64" - EE_MEMCACHE_SIZE="64" - EE_PHP_MAX_CHILDREN="10" - EE_SETUP_MAILSCANNER="no" - EE_SWAP="1024" - # RAM > 512MB and RAM < 1024MB - elif [ $EE_TOTAL_RAM -gt 512 ] && [ $EE_TOTAL_RAM -le 1024 ]; then - EE_OPCACHE_SIZE="128" - EE_MEMCACHE_SIZE="128" - EE_PHP_MAX_CHILDREN="10" - EE_SWAP="1024" - # RAM > 1024MB and RAM < 2048MB - elif [ $EE_TOTAL_RAM -gt 1024 ] && [ $EE_TOTAL_RAM -le 2048 ]; then - EE_OPCACHE_SIZE="256" - EE_MEMCACHE_SIZE="256" - EE_PHP_MAX_CHILDREN="20" - # RAM > 2048MB and RAM < 4096MB - elif [ $EE_TOTAL_RAM -gt 2048 ] && [ $EE_TOTAL_RAM -le 4096 ]; then - EE_OPCACHE_SIZE="512" - EE_MEMCACHE_SIZE="512" - EE_PHP_MAX_CHILDREN="40" - # RAM > 4096MB and RAM < 8192MB - elif [ $EE_TOTAL_RAM -gt 4096 ] && [ $EE_TOTAL_RAM -le 8192 ]; then - EE_OPCACHE_SIZE="512" - EE_MEMCACHE_SIZE="1024" - EE_PHP_MAX_CHILDREN="80" - # RAM > 8192MB and RAM < 16384MB - elif [ $EE_TOTAL_RAM -gt 8192 ] && [ $EE_TOTAL_RAM -le 16384 ]; then - EE_OPCACHE_SIZE="512" - EE_MEMCACHE_SIZE="2048" - EE_PHP_MAX_CHILDREN="100" - # RAM > 16384MB - elif [ $EE_TOTAL_RAM -gt 16384 ]; then - EE_OPCACHE_SIZE="512" - EE_MEMCACHE_SIZE="2048" - EE_PHP_MAX_CHILDREN="100" - fi -} diff --git a/src/lib/ee_lib_service.sh b/src/lib/ee_lib_service.sh deleted file mode 100644 index 6ec5dcc2..00000000 --- a/src/lib/ee_lib_service.sh +++ /dev/null @@ -1,44 +0,0 @@ -# Services Start/Stop/Restart/Reload -# ee_lib_service nginx start -# ee_lib_service nginx stop -# ee_lib_service nginx restart -# ee_lib_service nginx php5-fpm mysql postfix restart - -function ee_lib_service() -{ - for ee_service_name in ${@:1:$(($#-1))}; do - if [ -f /etc/init.d/$ee_service_name ];then - # Display message - ee_lib_echo "Executing service $ee_service_name ${@: -1}, please wait..." - - # Check nginx and php5-fpm test before start/stop/restart/reload - if [ $ee_service_name = "nginx" ]; then - # Adjust nginx server_names_hash_bucket_size - $ee_service_name -t 2>&1 | grep server_names_hash_bucket_size &>> $EE_COMMAND_LOG - if [ $? -eq 0 ];then - EE_NGINX_CALCULATION=$(echo "l($(ls /etc/nginx/sites-enabled/ | wc -c))/l(2)+2" | bc -l) - EE_NGINX_SET_BUCKET=$(echo "2^$EE_NGINX_CALCULATION" | bc -l 2> /dev/null) - sed -i "s/.*server_names_hash_bucket_size.*/\tserver_names_hash_bucket_size $EE_NGINX_SET_BUCKET;/" /etc/nginx/nginx.conf - fi - # Test and start/stop/restart/reload nginx service - $ee_service_name -t &>> $EE_COMMAND_LOG \ - && service $ee_service_name ${@: -1} &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to execute service $ee_service_name ${@: -1}, exit status = " $? - elif [ $ee_service_name = "php5-fpm" ]; then - # Test and start/stop/restart/reload php5-fpm service - $ee_service_name -t &>> $EE_COMMAND_LOG \ - && service $ee_service_name ${@: -1} &>> $EE_COMMAND_LOG\ - || ee_lib_error "Unable to execute service $ee_service_name ${@: -1}, exit status = " $? - elif [ $ee_service_name = "dovecot" ]; then - # Test and start/stop/restart/reload Dovecot service - $ee_service_name -n &>> $EE_COMMAND_LOG \ - && service $ee_service_name ${@: -1} &>> $EE_COMMAND_LOG\ - || ee_lib_error "Unable to execute service $ee_service_name ${@: -1}, exit status = " $? - else - # start/stop/restart/reload services - service $ee_service_name ${@: -1} &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to execute service $ee_service_name ${@: -1}, exit status = " $? - fi - fi - done -} diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh deleted file mode 100644 index 67f8d1a2..00000000 --- a/src/lib/ee_lib_stack_packages.sh +++ /dev/null @@ -1,54 +0,0 @@ -# Check & Install Packages - -function ee_lib_stack_packages() -{ - local ee_stack_package - # Log only single time - # ee site create example.com called ee stack install nginx - # So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null - # So in log file all logs written single time only, to do so set EE_LOG=false - export EE_LOG=false - - for ee_stack_package in $@;do - # Check NGINX installed & install if not - if [ "$ee_stack_package" = "nginx" ]; then - ee_lib_package_check $EE_NGINX_PACKAGE - if [ "$EE_PACKAGE_NAME" != "" ]; then - # Export EE_DISPLAY variable to Display ee http auth after site creation. - export EE_DISPLAY=false - - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install nginx || exit $? - fi - # Check PHP installed & install if not - elif [ "$ee_stack_package" = "php" ]; then - ee_lib_package_check php5-fpm - if [ "$EE_PACKAGE_NAME" != "" ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install php || exit $? - fi - # Check MySQL installed & install if not - elif [ "$ee_stack_package" = "mysql" ]; then - mysqladmin ping &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install mysql || exit $? - fi - # Check Postfix installed & install if not - elif [ "$ee_stack_package" = "postfix" ]; then - ee_lib_package_check postfix - if [ "$EE_PACKAGE_NAME" != "" ]; then - # The following command creates its own sub-shell - # and our ee_lib_error function only exit from that sub-shell - # so we need to exit from parent shell also - ee stack install postfix || exit $? - fi - fi - done -} diff --git a/src/lib/ee_lib_swap.sh b/src/lib/ee_lib_swap.sh deleted file mode 100644 index 1cb20de7..00000000 --- a/src/lib/ee_lib_swap.sh +++ /dev/null @@ -1,34 +0,0 @@ -# EasyEngine Swap creation - -function ee_lib_swap() -{ - if [ $EE_TOTAL_RAM -le 512 ]; then - if [ $EE_TOTAL_SWAP -le $EE_SWAP ];then - - # Use dd command to create SWAP - # Swap Parameters: - # Location: /ee-swapfile - # Block Size: 1024 - ee_lib_echo "Adding 1GB swapfile, please wait..." - dd if=/dev/zero of=/ee-swapfile bs=1024 count=1048k &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to generate /ee-swapfile, exit status = " $? - - # Create it as a Swap - mkswap /ee-swapfile &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to create swapfile, exit status = " $? - - # Change Permission for swapfile - chown root:root /ee-swapfile && - chmod 0600 /ee-swapfile \ - || ee_lib_error "Unable to change Swapfile permission, exit status = " $? - - # On the Swap - swapon /ee-swapfile &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to on Swap, exit status = " $? - - # Add entry into /etc/fstab - echo "/ee-swapfile none swap sw 0 0" >> /etc/fstab \ - || ee_lib_error "Unable to add entry into /etc/fstab, exit status = " $? - fi - fi -} diff --git a/src/lib/ee_lib_symbolic_link.sh b/src/lib/ee_lib_symbolic_link.sh deleted file mode 100644 index e73378ed..00000000 --- a/src/lib/ee_lib_symbolic_link.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Create symbolic link - -function ee_lib_symbolic_link() -{ - # Creating symbolic link - ln -sf $1 $2 \ - || ee_lib_error "Unable to create symbolic link for $1 -> $2, exit status = " $? -} diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh deleted file mode 100644 index 817639a9..00000000 --- a/src/lib/ee_lib_variables.sh +++ /dev/null @@ -1,72 +0,0 @@ -# Define global variables - -# EasyEngine version -readonly EE_VERSION='2.2.1' - -# WP-CLI version -readonly EE_WP_CLI_VERSION='0.17.1' - -# Adminer version -readonly EE_ADMINER_VERSION='4.1.0' - -# Roundcube Version -readonly EE_ROUNDCUBE_VERSION='1.0.3' - -# ViMbAdmin Version -readonly EE_VIMBADMIN_VERSION='3.0.10' - -# EasyEngine Date variable for backup -readonly EE_DATE=$(date +%d%b%Y%H%M%S) - -# Log only single time -# ee site create example.com called ee stack install nginx -# So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null -# So in log file all logs written single time only -if [ -n "$EE_LOG" ]; then - EE_TEE_LOG=/dev/null -else - EE_TEE_LOG=/var/log/easyengine/ee.log -fi - -EE_COMMAND_LOG=/var/log/easyengine/ee.log -readonly EE_LOG_DIR=/var/log/easyengine -readonly EE_ERROR_LOG=/var/log/easyengine/error.log -readonly EE_LINUX_DISTRO=$(lsb_release -i |awk '{print $3}') -readonly EE_CONFIG_GET=$(echo "git config --file /etc/easyengine/ee.conf") -readonly EE_CONFIG_SET=$(echo "git config --file /etc/easyengine/ee.conf" --replace-all) -readonly EE_APT_GET=$($EE_CONFIG_GET stack.apt-get-assume-yes | grep -i true &> /dev/null && echo apt-get -y || echo apt-get) -EE_IP_ADDRESS=$($EE_CONFIG_GET stack.ip-address | cut -d'=' -f2 | sed 's/ //g' | tr ',' '\n') - -# Distribution specific variable -if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - #Specify nginx package - readonly EE_NGINX_PACKAGE=nginx-custom -elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - # Specify nginx package - readonly EE_NGINX_PACKAGE=nginx-full - # Detect Debian version - readonly EE_DEBIAN_VERSION=$(lsb_release -sc) -fi - -# Find php user-name -if [ -f /etc/php5/fpm/pool.d/www.conf ]; then - readonly EE_PHP_USER=$(grep ^user /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2 | cut -d' ' -f2) -else - # At installation time: ee stack install - # File /etc/php5/fpm/pool.d/www.conf not present - readonly EE_PHP_USER=www-data -fi - -# Find out MySQL hostname -if [ -z $(git config --file $HOME/.my.cnf client.host) ]; then - readonly EE_MYSQL_HOST=localhost -else - readonly EE_MYSQL_HOST=$(git config --file $HOME/.my.cnf client.host) -fi - -# Find out MySQL client-host to setup grants -if [ -z $($EE_CONFIG_GET mysql.grant-host) ]; then - readonly EE_MYSQL_GRANT_HOST=localhost -else - readonly EE_MYSQL_GRANT_HOST=$($EE_CONFIG_GET mysql.grant-host) -fi diff --git a/src/modules/README.md b/src/modules/README.md deleted file mode 100644 index 61aa3112..00000000 --- a/src/modules/README.md +++ /dev/null @@ -1,3 +0,0 @@ -1. **stack** - includes install and remove scripts for EasyEngine [ee] modules. (ee stack install/remove). -1. **site** - includes scripts for site create commands. -1. **debug** - includes scripts for debug commands. \ No newline at end of file diff --git a/src/modules/debug/README.md b/src/modules/debug/README.md deleted file mode 100644 index ab696fd8..00000000 --- a/src/modules/debug/README.md +++ /dev/null @@ -1,6 +0,0 @@ -- ee_mod_debug_fpm.sh - debug PHP5-FPM -- ee_mod_debug_mysql.sh - debug mysql -- ee_mod_debug_nginx.sh - debug NGINX -- ee_mod_debug_php.sh - debug PHP -- ee_mod_debug_rewrite.sh - debug NGINX rewrite -- ee_mod_debug_wp.sh - debug WordPress diff --git a/src/modules/debug/ee_mod_debug_fpm.sh b/src/modules/debug/ee_mod_debug_fpm.sh deleted file mode 100644 index 357b10f4..00000000 --- a/src/modules/debug/ee_mod_debug_fpm.sh +++ /dev/null @@ -1,35 +0,0 @@ -# PHP5-FPM debug - -function ee_mod_debug_fpm() -{ - if [ "$EE_DEBUG" = "--start" ]; then - grep "log_level = debug" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - ee_lib_echo "Setup PHP5-FPM log_level = debug, please wait..." - sed -i "s';log_level.*'log_level = debug'" /etc/php5/fpm/php-fpm.conf \ - || ee_lib_error "Unable to setup PHP5-FPM log_level = debug, exit status = " $? - - # PHP5-FPM reload trigger - EE_TRIGGER_PHP="true" - else - # Display message - ee_lib_echo "PHP5-FPM log_level = debug already setup" - fi - - # Debug message - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/php5/fpm.log" - elif [ "$EE_DEBUG" = "--stop" ]; then - grep "log_level = debug" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Disable PHP5-FPM log_level = debug, please wait..." - sed -i "s'log_level.*'log_level = notice'" /etc/php5/fpm/php-fpm.conf \ - || ee_lib_error "Unable to setup PHP5-FPM log_level = debug, exit status = " $? - - # PHP5-FPM reload trigger - EE_TRIGGER_PHP="true" - else - # Display message - ee_lib_echo "PHP5-FPM log_level = debug already disabled" - fi - fi -} diff --git a/src/modules/debug/ee_mod_debug_mysql.sh b/src/modules/debug/ee_mod_debug_mysql.sh deleted file mode 100644 index ef0c6011..00000000 --- a/src/modules/debug/ee_mod_debug_mysql.sh +++ /dev/null @@ -1,59 +0,0 @@ -# MySQL debug - -function ee_mod_debug_mysql() -{ - if [ "$EE_DEBUG" = "--start" ]; then - mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - ee_lib_echo "Setup MySQL slow log, please wait..." - - mysql -e "set global slow_query_log = 'ON';" \ - || ee_lib_error "Unable to setup slow_query_log, exit status = " $? - - mysql -e "set global slow_query_log_file = '/var/log/mysql/mysql-slow.log';" \ - || ee_lib_error "Unable to setup slow_query_log_file, exit status = " $? - - mysql -e "set global long_query_time = 2;" \ - || ee_lib_error "Unable to setup long_query_time, exit status = " $? - - mysql -e "set global log_queries_not_using_indexes = 'ON';" \ - || ee_lib_error "Unable to setup log_queries_not_using_indexes, exit status = " $? - - # Set a cron for slow query log - if [ ! -z $EE_DEBUG_IMPORT_SLOW_LOG ]; then - ee_cron_time=${EE_DEBUG_IMPORT_SLOW_LOG##*=} - [[ $ee_cron_time =~ ^-?[0-9]+$ ]] || ee_cron_time=5 - crontab -l 2> /dev/null | { cat; echo -e "#EasyEngine start MySQL slow log\n*/$ee_cron_time * * * * /usr/local/sbin/ee import-slow-log\n#EasyEngine end MySQL slow log"; } | crontab - - fi - - else - # Display message - ee_lib_echo "MySQL slow log already enabled" - fi - - # Debug message - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/mysql/mysql-slow.log" - elif [ "$EE_DEBUG" = "--stop" ]; then - mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Disable MySQL slow log, please wait..." - - mysql -e "set global slow_query_log = 'OFF';" \ - || ee_lib_error "Unable to setup slow_query_log, exit status = " $? - - mysql -e "set global slow_query_log_file = '/var/log/mysql/mysql-slow.log';" \ - || ee_lib_error "Unable to setup slow_query_log_file, exit status = " $? - - mysql -e "set global long_query_time = 10;" \ - || ee_lib_error "Unable to setup long_query_time, exit status = " $? - - mysql -e "set global log_queries_not_using_indexes = 'OFF';" - - # Delete EasyEngine crons - crontab -l | sed '/#EasyEngine start/,/#EasyEngine end/d' | crontab - - else - # Display message - ee_lib_echo "MySQL slow log already disable" - fi - fi -} diff --git a/src/modules/debug/ee_mod_debug_nginx.sh b/src/modules/debug/ee_mod_debug_nginx.sh deleted file mode 100644 index 1c330945..00000000 --- a/src/modules/debug/ee_mod_debug_nginx.sh +++ /dev/null @@ -1,77 +0,0 @@ -# NGINX debug - -function ee_mod_debug_nginx() -{ - if [ "$EE_DEBUG" = "--start" ]; then - if [ -z $EE_DOMAIN ]; then - if [ -z "$EE_IP_ADDRESS" ]; then - # Enable NGINX debug for all IP - EE_DEBUG_ADDRESS="0.0.0.0/0" - else - EE_DEBUG_ADDRESS=$EE_IP_ADDRESS - fi - - for ee_ip in $EE_DEBUG_ADDRESS; do - grep "debug_connection $ee_ip" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - ee_lib_echo "Setup NGINX debug connection for $ee_ip, please wait..." - sed -i "/events {/a \\\t$(echo debug_connection $ee_ip\;)" /etc/nginx/nginx.conf \ - || ee_lib_error "Unable to setup NGINX debug connection for $ee_ip, exit status = " $? - - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - fi - done - - if [ "$EE_TRIGGER_NGINX" != "true" ]; then - # Display message - ee_lib_echo "NGINX debug connection already enabled" - fi - - # Debug message - EE_DEBUG_MSG="/var/log/nginx/*.error.log" - else - grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - ee_lib_echo "Setup NGINX debug connection for $EE_DOMAIN, please wait..." - sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to setup NGINX debug connection for for $EE_DOMAIN, exit status = " $? - - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "Already enable NGINX debug connection for $EE_DOMAIN" - fi - - # Debug message - EE_DEBUG_MSG="/var/www/$EE_DOMAIN/logs/error.log" - fi - elif [ "$EE_DEBUG" = "--stop" ]; then - if [ -z $EE_DOMAIN ]; then - grep "debug_connection" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Disable NGINX debug connection, please wait..." - sed -i "/debug_connection.*/d" /etc/nginx/nginx.conf \ - || ee_lib_error "Unable to disable NGINX debug connection, exit status = " $? - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "NGINX debug connection already disable" - fi - else - grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Disable NGINX debug connection for $EE_DOMAIN, please wait..." - sed -i "s/error.log debug;/error.log;/" /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to disable NGINX debug connection for $EE_DOMAIN, exit status = " $? - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "Already disable NGINX debug connection for $EE_DOMAIN" - fi - fi - fi -} diff --git a/src/modules/debug/ee_mod_debug_php.sh b/src/modules/debug/ee_mod_debug_php.sh deleted file mode 100644 index 12ad1ed5..00000000 --- a/src/modules/debug/ee_mod_debug_php.sh +++ /dev/null @@ -1,37 +0,0 @@ -# PHP debug - -function ee_mod_debug_php() -{ - if [ "$EE_DEBUG" = "--start" ]; then - # Perform search inside upstream php block - sed -n "/upstream php {/,/}/p" /etc/nginx/conf.d/upstream.conf | grep 9001 &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - ee_lib_echo "Setup PHP5-FPM slow log, please wait..." - sed -i "/upstream php {/,/}/s/9000/9001/" /etc/nginx/conf.d/upstream.conf \ - || ee_lib_error "Unable to setup PHP5-FPM slow log, exit status = " $? - - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "PHP5-FPM slow log already enabled" - fi - - # Debug message - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/php5/slow.log" - elif [ "$EE_DEBUG" = "--stop" ]; then - # Perform search inside upstream php block - sed -n "/upstream php {/,/}/p" /etc/nginx/conf.d/upstream.conf | grep 9001 &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Disable PHP5-FPM slow log, please wait..." - sed -i "/upstream php {/,/}/s/9001/9000/" /etc/nginx/conf.d/upstream.conf \ - || ee_lib_error "Unable to disable PHP5-FPM slow log, exit status = " $? - - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "PHP5-FPM slow log already disabled" - fi - fi -} diff --git a/src/modules/debug/ee_mod_debug_rewrite.sh b/src/modules/debug/ee_mod_debug_rewrite.sh deleted file mode 100644 index e7560a67..00000000 --- a/src/modules/debug/ee_mod_debug_rewrite.sh +++ /dev/null @@ -1,72 +0,0 @@ -# NGINX rewrite debug - -function ee_mod_debug_rewrite() -{ - if [ "$EE_DEBUG" = "--start" ]; then - if [ -z $EE_DOMAIN ]; then - grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - ee_lib_echo "Setup NGINX rewrite logs, please wait..." - sed -i '/http {/a \\trewrite_log on;' /etc/nginx/nginx.conf \ - || ee_lib_error "Unable to setup NGINX rewrite logs, exit status = " $? - - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "NGINX rewrite logs already enabled" - fi - - # Debug message - if [ "$EE_DEBUG_MSG" != "/var/log/nginx/*.error.log" ];then - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/log/nginx/*.error.log" - fi - else - grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - ee_lib_echo "Setup NGINX rewrite logs for $EE_DOMAIN, please wait..." - sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to setup NGINX rewrite logs for $EE_DOMAIN, exit status = " $? - - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "NGINX rewrite logs for $EE_DOMAIN already enabled" - fi - - # Debug message - if [ "$EE_DEBUG_MSG" != "/var/www/$EE_DOMAIN/logs/error.log" ];then - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/www/$EE_DOMAIN/logs/error.log" - fi - fi - elif [ "$EE_DEBUG" = "--stop" ]; then - if [ -z $EE_DOMAIN ]; then - grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Disable NGINX rewrite logs, please wait..." - sed -i "/rewrite_log.*/d" /etc/nginx/nginx.conf \ - || ee_lib_error "Unable to disable NGINX rewrite logs, exit status = " $? - - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "NGINX rewrite logs already disable" - fi - else - grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Disable NGINX rewrite logs for $EE_DOMAIN, please wait..." - sed -i "/rewrite_log.*/d" /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to disable NGINX rewrite logs for $EE_DOMAIN, exit status = " $? - - # NGINX reload trigger - EE_TRIGGER_NGINX="true" - else - # Display message - ee_lib_echo "NGINX rewrite logs for $EE_DOMAIN already disable" - fi - fi - fi -} diff --git a/src/modules/debug/ee_mod_debug_stop.sh b/src/modules/debug/ee_mod_debug_stop.sh deleted file mode 100644 index 37d68ac3..00000000 --- a/src/modules/debug/ee_mod_debug_stop.sh +++ /dev/null @@ -1,24 +0,0 @@ -# Execute: ee debug --stop -# When ee debug module run with -i flag -# This function is called when user press CTRL+C - -function ee_mod_debug_stop() -{ - if [ "$EE_DEBUG" = "--start" ]; then - if [ -z "$EE_DOMAIN" ]; then - ee debug --stop - else - ee debug --stop $EE_DOMAIN - fi - fi - - # Unset trap so we don't get infinite loop - trap - EXIT - - # Flush file system buffers - # More details: info coreutils 'sync invocation' - sync - - # Successful exit - exit 0; -} diff --git a/src/modules/debug/ee_mod_debug_wp.sh b/src/modules/debug/ee_mod_debug_wp.sh deleted file mode 100644 index 1850b459..00000000 --- a/src/modules/debug/ee_mod_debug_wp.sh +++ /dev/null @@ -1,61 +0,0 @@ -# WordPress debug - -function ee_mod_debug_wp() -{ - if [ "$EE_DEBUG" = "--start" ]; then - if [ -e /var/www/$EE_DOMAIN/wp-config.php ]; then - grep "'WP_DEBUG'" /var/www/$EE_DOMAIN/wp-config.php | grep true &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - ee_lib_echo "Enable WordPress debug logs for $EE_DOMAIN, please wait..." - - # Create debug.log and fix permission - touch /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log - chown $EE_PHP_USER:$EE_PHP_USER /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log - - # Turn on - sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$EE_DOMAIN/wp-config.php \ - || ee_lib_error "Unable to activate WordPress debug logs, exit status = " $? - - # Install developer plugin - ee_lib_echo "Installing developer plugin, please wait..." - cd /var/www/$EE_DOMAIN/htdocs/ && \ - wp plugin --allow-root install developer &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to install developer plugin, exit status = " $? - - # Fix Developer plugin permissions - chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/$EE_DOMAIN/htdocs/wp-content/plugins/developer \ - || ee_lib_error "Unable to change ownership for developer plugin, exit status = " $? - - else - # Display message - ee_lib_echo "WordPress debug log already enabled for $EE_DOMAIN" - fi - - # Debug message - EE_DEBUG_MSG="$EE_DEBUG_MSG /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log" - else - # Display message - ee_lib_echo_fail "Unable to find /var/www/$EE_DOMAIN/wp-config.php" - fi - elif [ "$EE_DEBUG" = "--stop" ]; then - if [ -e /var/www/$EE_DOMAIN/wp-config.php ]; then - grep "'WP_DEBUG'" /var/www/$EE_DOMAIN/wp-config.php | grep true &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_lib_echo "Disable WordPress debug logs for $EE_DOMAIN, please wait..." - - # Turn off - sed -i "s/define('WP_DEBUG', true);/define('WP_DEBUG', false);/" /var/www/$EE_DOMAIN/wp-config.php \ - && sed -i "/define('WP_DEBUG_DISPLAY', false);/d" /var/www/$EE_DOMAIN/wp-config.php \ - && sed -i "/define('WP_DEBUG_LOG', true);/d" /var/www/$EE_DOMAIN/wp-config.php \ - && sed -i "/define('SAVEQUERIES', true);/d" /var/www/$EE_DOMAIN/wp-config.php \ - || ee_lib_error "Unable to disable WordPress debug logs, exit status = " $? - else - # Display message - ee_lib_echo "WordPress debug log already disabled for $EE_DOMAIN" - fi - else - # Display message - ee_lib_echo_fail "Unable to find /var/www/$EE_DOMAIN/wp-config.php" - fi - fi -} diff --git a/src/modules/ee_mod_clean.sh b/src/modules/ee_mod_clean.sh deleted file mode 100644 index d3c0d09e..00000000 --- a/src/modules/ee_mod_clean.sh +++ /dev/null @@ -1,52 +0,0 @@ -# Clean NGINX FastCGI, Memcache, OPcache cache - -function ee_mod_clean() -{ - - if [ $# -eq 0 ]; then - ee_clean_fastcgi="fastcgi" - fi - for ee_clean in $@; do - if [ "$ee_clean" = "" ] || [ "$ee_clean" = "fastcgi" ]; then - ee_clean_fastcgi="fastcgi" - elif [ "$ee_clean" = "memcache" ]; then - ee_clean_memcache="memcache" - elif [ "$ee_clean" = "opcache" ]; then - ee_clean_opcache="opcache" - elif [ "$ee_clean" = "all" ]; then - ee_clean_fastcgi="fastcgi" - ee_clean_memcache="memcache" - ee_clean_opcache="opcache" - else - ee_lib_error "$ee_clean invalid option, exit status = " $? - fi - done - - # Clean NGINX FastCGI cache - if [ "$ee_clean_fastcgi" = "fastcgi" ]; then - if [ -d /var/run/nginx-cache/ ]; then - ee_lib_echo "Cleaning NGINX FastCGI cache, please wait..." - rm -rf /var/run/nginx-cache/* &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to clean FastCGI cache, exit status = " $? - fi - fi - - # Clean Memcache - if [ "$ee_clean_memcache" = "memcache" ]; then - dpkg --get-selections | grep -v deinstall | grep memcached &>> $EE_COMMAND_LOG \ - || ee_lib_error "Memcache not installed, exit status = " $? - - if [ $? -eq 0 ]; then - ee_lib_echo "Cleaning Memcached, please wait..." - service memcached restart &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to restart memcached, exit status = " $? - fi - fi - - # Clean OPcache - if [ "$ee_clean_opcache" = "opcache" ]; then - ee_lib_echo "Cleaning OPcache, please wait..." - wget --no-check-certificate --spider -q https://127.0.0.1:22222/cache/opcache/opgui.php?page=reset \ - || ee_lib_error "Unable to clean OPcache, exit status = " $? - fi -} diff --git a/src/modules/secure/ee_mod_secure_auth.sh b/src/modules/secure/ee_mod_secure_auth.sh deleted file mode 100644 index d7ffa005..00000000 --- a/src/modules/secure/ee_mod_secure_auth.sh +++ /dev/null @@ -1,28 +0,0 @@ -# Setup HTTP authentication - -function ee_mod_secure_auth() -{ - # Random characters - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - - read -p "Provide HTTP authentication user name [$(git config user.name)]: " EE_HTTP_AUTH_USER - read -sp "Provide HTTP authentication password [$ee_random]: " EE_HTTP_AUTH_PASS - echo - - # If enter is pressed, set git config user.name - if [[ $EE_HTTP_AUTH_USER = "" ]]; then - EE_HTTP_AUTH_USER=$(git config user.name) - fi - - if [[ $EE_HTTP_AUTH_PASS = "" ]]; then - EE_HTTP_AUTH_PASS=$ee_random - fi - - # Add HTTP authentication details - echo - ee_lib_echo "HTTP authentication username: $EE_HTTP_AUTH_USER" &>> $EE_COMMAND_LOG - ee_lib_echo "HTTP authentication password: $EE_HTTP_AUTH_PASS" &>> $EE_COMMAND_LOG - - # Generate htpasswd-ee file - printf "$EE_HTTP_AUTH_USER:$(openssl passwd -crypt $EE_HTTP_AUTH_PASS 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null -} diff --git a/src/modules/secure/ee_mod_secure_ip.sh b/src/modules/secure/ee_mod_secure_ip.sh deleted file mode 100644 index e5d835b9..00000000 --- a/src/modules/secure/ee_mod_secure_ip.sh +++ /dev/null @@ -1,31 +0,0 @@ -# White list IP address - -function ee_mod_secure_ip() -{ - read -p "Enter the comma separated IP addresses to white list [127.0.0.1]: " ee_ip - - # If enter is pressed, set 127.0.0.1 - if [[ $ee_ip = "" ]]; then - ee_ip=127.0.0.1 - fi - - # Check weather IP address already present or not - for ee_check_ip in $(echo $ee_ip | cut -d'=' -f2 | sed 's/ //g' | tr ',' '\n'); do - grep $ee_check_ip /etc/easyengine/ee.conf &>> /dev/null - if [ $? -ne 0 ]; then - ee_update_ip="$ee_update_ip $ee_check_ip" - fi - done - - # Update ee.conf - $EE_CONFIG_SET stack.ip-address "$($EE_CONFIG_GET stack.ip-address),$(echo $ee_update_ip | tr ' ' ',')" - - # White list IP address - EE_IP_ADDRESS=$($EE_CONFIG_GET stack.ip-address | cut -d'=' -f2 | sed 's/ //g' | tr ',' '\n') - if [ -n "$EE_IP_ADDRESS" ]; then - sed -i "/allow.*/d" /etc/nginx/common/acl.conf - for ee_whitelist_ip_address in $(echo $EE_IP_ADDRESS);do - sed -i "/deny/i $(echo allow $ee_whitelist_ip_address\;)" /etc/nginx/common/acl.conf - done - fi -} diff --git a/src/modules/secure/ee_mod_secure_port.sh b/src/modules/secure/ee_mod_secure_port.sh deleted file mode 100644 index eaaa069d..00000000 --- a/src/modules/secure/ee_mod_secure_port.sh +++ /dev/null @@ -1,20 +0,0 @@ -# Setup EasyEngine admin port - -function ee_mod_secure_port() -{ - read -p "EasyEngine admin port [22222]: " ee_port - - # If enter is pressed, set 22222 - if [[ $ee_port = "" ]]; then - ee_port=22222 - fi - - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - sed -i "s/listen.*/listen $ee_port default_server ssl spdy;/" /etc/nginx/sites-available/22222 \ - || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? - elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - # Dotdeb nginx repository doesn't support spdy - sed -i "s/listen.*/listen $ee_port default_server ssl;/" /etc/nginx/sites-available/22222 \ - || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? - fi -} diff --git a/src/modules/site/README.md b/src/modules/site/README.md deleted file mode 100644 index 91f0954b..00000000 --- a/src/modules/site/README.md +++ /dev/null @@ -1,6 +0,0 @@ - -1. **create** - scripts to create website. -1. **delete** - scripts to delete website. -1. **edit** - script to edit site nginx configuration for website. -1. **info** - script to display website information. - diff --git a/src/modules/site/create/README.md b/src/modules/site/create/README.md deleted file mode 100644 index 9a838750..00000000 --- a/src/modules/site/create/README.md +++ /dev/null @@ -1,8 +0,0 @@ - -- ee_mod_plugin_nginx_helper.sh - setup nginx-helper plugin. -- ee_mod_plugin_w3tc.sh - Setup W3 Total Cache. -- ee_mod_plugin_wpsc.sh - Setup WP Super Cache -- ee_mod_setup_database.sh - Database setup -- ee_mod_setup_domain.sh - Domain setup -- ee_mod_setup_network.sh - Setup WordPress Network -- ee_mod_setup_wordpress.sh - Setup WordPress given domain name. \ No newline at end of file diff --git a/src/modules/site/create/ee_mod_plugin_nginx_helper.sh b/src/modules/site/create/ee_mod_plugin_nginx_helper.sh deleted file mode 100644 index f0839e17..00000000 --- a/src/modules/site/create/ee_mod_plugin_nginx_helper.sh +++ /dev/null @@ -1,13 +0,0 @@ -# Setup NGINX Helper - -function ee_mod_plugin_nginx_helper() -{ - cd /var/www/$EE_DOMAIN/htdocs/ - ee_lib_echo "Installing Nginx Helper plugin, please wait..." - wp plugin --allow-root install nginx-helper &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to install Nginx Helper plugin, exit status = " $? - - # Activate Nginx Helper - wp plugin --allow-root activate nginx-helper $EE_NETWORK_ACTIVATE &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to activate Nginx Helper plugin, exit status = " $? -} diff --git a/src/modules/site/create/ee_mod_plugin_settings.sh b/src/modules/site/create/ee_mod_plugin_settings.sh deleted file mode 100644 index 2d6612f0..00000000 --- a/src/modules/site/create/ee_mod_plugin_settings.sh +++ /dev/null @@ -1,36 +0,0 @@ -# Display WordPress cache plugin settings - -function ee_mod_plugin_settings() -{ - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=wpsupercache" - else - ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=wpsupercache" - fi - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=nginx" - else - ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=nginx" - fi - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" - else - ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/admin.php?page=w3tc_general" - fi - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_lib_echo_escape "Page Cache:\t\tDisable" - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - ee_lib_echo_escape "Page Cache:\t\tDisk Enhanced" - fi - ee_lib_echo_escape "Database Cache:\t\tMemcached" - ee_lib_echo_escape "Object Cache:\t\tMemcached" - ee_lib_echo_escape "Browser Cache:\t\tDisable" - fi -} diff --git a/src/modules/site/create/ee_mod_plugin_w3tc.sh b/src/modules/site/create/ee_mod_plugin_w3tc.sh deleted file mode 100644 index af10ead9..00000000 --- a/src/modules/site/create/ee_mod_plugin_w3tc.sh +++ /dev/null @@ -1,13 +0,0 @@ -# Setup W3 Total Cache - -function ee_mod_plugin_w3tc() -{ - cd /var/www/$EE_DOMAIN/htdocs/ - ee_lib_echo "Installing W3 Total Cache plugin, please wait..." - wp plugin --allow-root install w3-total-cache &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to install W3 Total Cache plugin, exit status = " $? - - # Activate W3 Total Cache - wp plugin --allow-root activate w3-total-cache $EE_NETWORK_ACTIVATE &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to activate W3 Total Cache plugin, exit status = " $? -} diff --git a/src/modules/site/create/ee_mod_plugin_wpsc.sh b/src/modules/site/create/ee_mod_plugin_wpsc.sh deleted file mode 100644 index d1e38618..00000000 --- a/src/modules/site/create/ee_mod_plugin_wpsc.sh +++ /dev/null @@ -1,13 +0,0 @@ -# Setup WP Super Cache - -function ee_mod_plugin_wpsc() -{ - cd /var/www/$EE_DOMAIN/htdocs/ - ee_lib_echo "Installing WP Super Cache plugin, please wait..." - wp plugin --allow-root install wp-super-cache &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to install WP Super Cache plugin, exit status = " $? - - # Activate WP Super Cache - wp plugin --allow-root activate wp-super-cache $EE_NETWORK_ACTIVATE &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to activate WP Super Cache plugin, exit status = " $? -} diff --git a/src/modules/site/create/ee_mod_setup_database.sh b/src/modules/site/create/ee_mod_setup_database.sh deleted file mode 100644 index a8c53d2b..00000000 --- a/src/modules/site/create/ee_mod_setup_database.sh +++ /dev/null @@ -1,66 +0,0 @@ -# Database setup - -function ee_mod_setup_database() -{ - # Random characters - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - - # Replace dot(.) with underscore(_) in EE_DOMAIN Name - local ee_replace_dot=$(echo $EE_DOMAIN | tr '.' '_') - - # Default database or custom database - if [ $($EE_CONFIG_GET mysql.db-name) == "true" ];then - read -p "Enter the MySQL database name [$ee_replace_dot]: " EE_DB_NAME - fi - - # If mysql.db-name = false - # Then it never ask for MySQL database name in this case $EE_DB_NAME is empty - # If mysql.db-name = true - # User enter custom database name then $EE_DB_NAME is not empty & we used provided database name - # If user pressed enter then $EE_DB_NAME is empty - - if [[ $EE_DB_NAME = "" ]]; then - EE_DB_NAME=$ee_replace_dot - fi - - # Default database user or custom user - if [ $($EE_CONFIG_GET mysql.db-user) == "true" ]; then - read -p "Enter the MySQL database username [$ee_replace_dot]: " EE_DB_USER - read -sp "Enter the MySQL database password [$ee_random]: " EE_DB_PASS - fi - - # If mysql.db-user = false - # Then it never ask for MySQL database user in this case $EE_DB_USER is empty - # If mysql.db-name = true - # User enter custom database user then $EE_DB_USER is not empty & we used provided database user - # If user pressed enter then $EE_DB_USER is empty - - if [[ $EE_DB_USER = "" ]]; then - EE_DB_USER=$ee_replace_dot - fi - - if [[ $EE_DB_PASS = "" ]]; then - EE_DB_PASS=$ee_random - fi - - # Fix MySQL username ERROR 1470 (HY000) - if [[ $(echo -n $EE_DB_USER | wc -c) -gt 16 ]]; then - ee_lib_echo "Autofix MySQL username (ERROR 1470 (HY000)), please wait..." - local ee_random10=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n1) - EE_DB_USER=$(echo $EE_DB_USER | cut -c1-16 | sed "s/.\{10\}$/$ee_random10/") - fi - - # Create MySQL database - echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS \nEE_MYSQL_HOST = $EE_MYSQL_HOST \nEE_MYSQL_GRANT_HOST = $EE_MYSQL_GRANT_HOST" &>> $EE_COMMAND_LOG - mysql -e "create database \`$EE_DB_NAME\`" \ - || ee_lib_error "Unable to create $EE_DB_NAME database, exit status = " $? - - # Create MySQL User - mysql -e "create user '$EE_DB_USER'@'$EE_MYSQL_GRANT_HOST' identified by '$EE_DB_PASS'" \ - || ee_lib_error "Unable to create $EE_DB_USER database user, exit status = " $? - - # Grant permission - mysql -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_GRANT_HOST'" \ - || ee_lib_error "Unable to grant privileges for $EE_DB_USER database user, exit status = " $? - mysql -e "flush privileges" -} diff --git a/src/modules/site/create/ee_mod_setup_domain.sh b/src/modules/site/create/ee_mod_setup_domain.sh deleted file mode 100644 index 9344c437..00000000 --- a/src/modules/site/create/ee_mod_setup_domain.sh +++ /dev/null @@ -1,30 +0,0 @@ -# Domain setup - -function ee_mod_setup_domain() -{ - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null - if [ $? -ne 0 ]; then - - # Creating $EE_DOMAIN - ee_lib_echo "Creating $EE_DOMAIN, please wait..." - sed "s/example.com/$EE_DOMAIN/g" \ - /usr/share/easyengine/nginx/$EE_NGINX_CONF \ - > /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to create NGINX configuration file for $EE_DOMAIN, exit status = " $? - - # Creating symbolic link - ee_lib_echo "Creating symbolic link for $EE_DOMAIN" - ee_lib_symbolic_link /etc/nginx/sites-available/$EE_DOMAIN /etc/nginx/sites-enabled/ - - # Creating htdocs & logs directory - ee_lib_echo "Creating htdocs & logs directory" - mkdir -p /var/www/$EE_DOMAIN/htdocs && mkdir -p /var/www/$EE_DOMAIN/logs \ - || ee_lib_error "Unable to create htdocs & logs directory, exit status = " $? - - # Creating symbolic links for logs - ee_lib_symbolic_link /var/log/nginx/$EE_DOMAIN.access.log /var/www/$EE_DOMAIN/logs/access.log - ee_lib_symbolic_link /var/log/nginx/$EE_DOMAIN.error.log /var/www/$EE_DOMAIN/logs/error.log - else - ee_lib_error "$EE_DOMAIN already exist, exit status = " $? - fi -} diff --git a/src/modules/site/create/ee_mod_setup_network.sh b/src/modules/site/create/ee_mod_setup_network.sh deleted file mode 100644 index 3afee52b..00000000 --- a/src/modules/site/create/ee_mod_setup_network.sh +++ /dev/null @@ -1,12 +0,0 @@ -# Setup WordPress Network - -function ee_mod_setup_network() -{ - cd /var/www/$EE_DOMAIN/htdocs || ee_lib_error "Unable to change directory, exit status = " $? - wp core install-network --allow-root --title="$EE_WWW_DOMAIN" $EE_WP_SUBDOMAIN &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to setup WordPress network, exit status = " $? - - sed -i "/WP_DEBUG/a \define('WP_ALLOW_MULTISITE', true);" /var/www/$EE_DOMAIN/wp-config.php - sed -i "/WP_ALLOW_MULTISITE/a \define('WPMU_ACCEL_REDIRECT', true);" /var/www/$EE_DOMAIN/wp-config.php - -} diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh deleted file mode 100644 index e91d7a1d..00000000 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ /dev/null @@ -1,144 +0,0 @@ -# Setup WordPress for $EE_DOMAIN - -function ee_mod_setup_wordpress() -{ - # Random characters - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - - # Download latest WordPress - ee_lib_echo "Downloading WordPress, please wait..." - cd /var/www/$EE_DOMAIN/htdocs && wp --allow-root core download &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to download WordPress, exit status = " $? - - # Database setup - # if EE_DB_NAME, EE_DB_USER, EE_DB_PASS are empty then setup database for new site - # else current mysql site is to be updated - if [ "$EE_DB_NAME" = "" ] && [ "$EE_DB_USER" = "" ] && [ "$EE_DB_PASS" = "" ]; then - ee_mod_setup_database - else - # Display when run ee site update mysql.com --wp - echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS \nEE_MYSQL_HOST = $EE_MYSQL_HOST \nEE_MYSQL_GRANT_HOST = $EE_MYSQL_GRANT_HOST" &>> $EE_COMMAND_LOG - fi - - # Default WordPress prefix or custom prefix - if [ $($EE_CONFIG_GET wordpress.prefix) == "true" ];then - read -p "Enter the WordPress table prefix [wp_]: " EE_WP_PREFIX - # Display EE_WP_PREFIX valid characters warning & try again - while [[ ! ($EE_WP_PREFIX =~ ^[A-Za-z0-9_]*$) ]]; do - echo "Warning: table prefix can only contain numbers, letters, and underscores" - read -p "Enter the WordPress table prefix [wp_]: " EE_WP_PREFIX - done - fi - - # If wordpress.prefix = false - # Then it never ask for WordPress prefix in this case $EE_WP_PREFIX is empty - # If wordpress.prefix = true - # User enter custom WordPress prefix then $EE_WP_PREFIX is not empty & we used provided WordPress prefix - # If user pressed enter then $EE_WP_PREFIX is empty - - # WordPress database table prefix default: wp_ - if [[ $EE_WP_PREFIX = "" ]];then - EE_WP_PREFIX=wp_ - fi - - # Let's log WordPress table prefix - echo EE_WP_PREFIX = $EE_WP_PREFIX &>> $EE_COMMAND_LOG - - # Modify wp-config.php & move outside the webroot - cp /var/www/$EE_DOMAIN/htdocs/wp-config-sample.php \ - /var/www/$EE_DOMAIN/wp-config.php - - sed -i "s/database_name_here/$EE_DB_NAME/" \ - /var/www/$EE_DOMAIN/wp-config.php - - sed -i "s/username_here/$EE_DB_USER/" \ - /var/www/$EE_DOMAIN/wp-config.php - - sed -i "s/password_here/$EE_DB_PASS/" \ - /var/www/$EE_DOMAIN/wp-config.php - - sed -i "s/localhost/$EE_MYSQL_HOST/" \ - /var/www/$EE_DOMAIN/wp-config.php - - sed -i "s/wp_/$EE_WP_PREFIX/" \ - /var/www/$EE_DOMAIN/wp-config.php - - printf '%s\n' "g/put your unique phrase here/d" \ - a "$(curl -sL https://api.wordpress.org/secret-key/1.1/salt/)" . w \ - | ed -s /var/www/$EE_DOMAIN/wp-config.php - - # Set WordPress username - # First get WordPress username from /etc/easyengine/ee.conf file - EE_WP_USER=$($EE_CONFIG_GET wordpress.user) - - if [[ $EE_WP_USER = "" ]]; then - git config user.name &>> /dev/null - if [ $? -eq 0 ]; then - # Set WordPress username from git config user.name - EE_WP_USER=$(git config user.name) - else - while [ -z $EE_WP_USER ]; do - # Ask user to provide WordPress username - ee_lib_echo "Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods and the @ symbol." - read -p "Enter WordPress username: " EE_WP_USER - done - fi - fi - - # Set WordPress password - EE_WP_PASS=$($EE_CONFIG_GET wordpress.password) - if [[ $EE_WP_PASS = "" ]]; then - EE_WP_PASS=$ee_random - fi - - # Set WordPress email - # First get WordPress email from /etc/easyengine/ee.conf file - EE_WP_EMAIL=$($EE_CONFIG_GET wordpress.email) - - if [[ $EE_WP_EMAIL = "" ]]; then - git config user.email &>> /dev/null - if [ $? -eq 0 ]; then - # Set WordPress email from git config user.email - EE_WP_EMAIL=$(git config user.email) - else - while [ -z $EE_WP_EMAIL ]; do - # Ask user to provide WordPress email - read -p "Enter WordPress email: " EE_WP_EMAIL - done - fi - fi - - # Let's log WordPress username/password/email - echo -e "EE_WP_USER = $EE_WP_USER \nEE_WP_PASS = $EE_WP_PASS \nEE_WP_EMAIL = $EE_WP_EMAIL" &>> $EE_COMMAND_LOG - - # Create WordPress tables - ee_lib_echo "Setting up WordPress, please wait..." - cd /var/www/$EE_DOMAIN/htdocs \ - || ee_lib_error "Unable to change directory to install WordPress, exit status = " $? - - wp core install --allow-root --url=$EE_WWW_DOMAIN --title="$EE_WWW_DOMAIN" \ - --admin_name="$EE_WP_USER" --admin_password=$EE_WP_PASS --admin_email=$EE_WP_EMAIL &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to create WordPress tables for $EE_DOMAIN, exit status = " $? - - # Update WordPress permalink structure day and postname - ee_lib_echo "Updating WordPress permalink, please wait..." - wp rewrite structure --allow-root /%year%/%monthnum%/%day%/%postname%/ &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to update WordPress permalink for $EE_DOMAIN, exit status = " $? - - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi - - # Install WordPress plugins - ee_mod_plugin_nginx_helper - - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_mod_plugin_w3tc - fi - -} diff --git a/src/modules/site/delete/ee_mod_delete_database.sh b/src/modules/site/delete/ee_mod_delete_database.sh deleted file mode 100644 index 290c2331..00000000 --- a/src/modules/site/delete/ee_mod_delete_database.sh +++ /dev/null @@ -1,44 +0,0 @@ -# Delete MySQL database - -function ee_mod_delete_database() -{ - # HTML & PHP website doesn't have database - head -n1 /etc/nginx/sites-available/$EE_DOMAIN | egrep -e 'HTML|PHP' &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - # Database details - local ee_db_name=$(grep DB_NAME /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) - local ee_db_user=$(grep DB_USER /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) - local ee_db_pass=$(grep DB_PASS /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) - local ee_db_host=$(grep DB_HOST /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) - ee_lib_echo_escape " DB_NAME = $ee_db_name \n DB_USER = $ee_db_user \n DB_HOST = $ee_db_host \n GRANT_HOST = $EE_MYSQL_GRANT_HOST" - - if [ "$1" = "--no-prompt" ];then - # Delete database without any prompt - local ee_prompt="y" - else - # Fix read prompt - stty echo - # Ask user to confirm - read -p "Are you sure to drop $ee_db_name database (y/n): " ee_prompt - fi - - if [ "$ee_prompt" = "y" ]; then - # Drop database - mysql -e "drop database \`$ee_db_name\`" \ - || ee_lib_error "Unable to drop $ee_db_name database, exit status = " $? - - # Never drop root user - if [ "$ee_db_user" != "root" ]; then - # Drop database user - mysql -e "drop user '$ee_db_user'@'$EE_MYSQL_GRANT_HOST'" \ - || ee_lib_error "Unable to drop database user $ee_db_user, exit status = " $? - # Flush privileges - mysql -e "flush privileges" \ - || ee_lib_error "Unable to flush MySQL privileges, exit status = " $? - fi - else - # Deny message - ee_lib_echo_fail "User denied to drop $ee_db_name database" - fi - fi -} diff --git a/src/modules/site/delete/ee_mod_delete_nginxconf.sh b/src/modules/site/delete/ee_mod_delete_nginxconf.sh deleted file mode 100644 index c09478df..00000000 --- a/src/modules/site/delete/ee_mod_delete_nginxconf.sh +++ /dev/null @@ -1,24 +0,0 @@ -# Delete NGINX configuration file - -function ee_mod_delete_nginxconf() -{ - - if [ "$1" = "--no-prompt" ];then - # Delete NGINX configuration without any prompt - local ee_prompt="y" - else - # Fix read prompt - stty echo - # Ask user to confirm - read -p "Are you sure to remove $EE_DOMAIN NGINX configuration (y/n): " ee_prompt - fi - - if [ "$ee_prompt" = "y" ]; then - # Delete $EE_DOMAIN NGINX configuration - rm -rf /etc/nginx/sites-available/$EE_DOMAIN /etc/nginx/sites-enabled/$EE_DOMAIN \ - || ee_lib_error "Unable to remove $EE_DOMAIN NGINX configuration, exit status = " $? - else - # Deny message - ee_lib_echo_fail "User denied to remove $EE_DOMAIN NGINX configuration" - fi -} diff --git a/src/modules/site/delete/ee_mod_delete_webroot.sh b/src/modules/site/delete/ee_mod_delete_webroot.sh deleted file mode 100644 index 40ffce09..00000000 --- a/src/modules/site/delete/ee_mod_delete_webroot.sh +++ /dev/null @@ -1,24 +0,0 @@ -# Delete webroot - -function ee_mod_delete_webroot() -{ - - if [ "$1" = "--no-prompt" ];then - # Delete webroot without any prompt - local ee_prompt="y" - else - # Fix read prompt - stty echo - # Ask user to confirm - read -p "Are you sure to remove $EE_DOMAIN webroot (y/n): " ee_prompt - fi - - if [ "$ee_prompt" = "y" ]; then - # Delete $EE_DOMAIN webroot - rm -rf /var/www/$EE_DOMAIN \ - || ee_lib_error "Unable to remove $EE_DOMAIN webroot, exit status = " $? - else - # Deny message - ee_lib_echo_fail "User denied to remove $EE_DOMAIN webroot" - fi -} diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh deleted file mode 100644 index 13001912..00000000 --- a/src/modules/site/ee_mod_site_backup.sh +++ /dev/null @@ -1,44 +0,0 @@ -# Backup NGINX configuration & Database & Webroot - -function ee_mod_site_backup() -{ - - # Backup directory setup - local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') - if [ ! -d $ee_webroot/backup/$EE_DATE ]; then - mkdir -p $ee_webroot/backup/$EE_DATE || ee_lib_error "Fail to create backup directory, exit status =" $? - fi - - ee_lib_echo "Backup location: $ee_webroot/backup/$EE_DATE" - ee_lib_echo "Backup NGINX configuration, please wait..." - # Backup $EE_DOMAIN NGINX configuration - cp /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/$EE_DATE/ \ - || ee_lib_error "Failed: Backup NGINX configuration, exit status =" $? - - # Move htdocs - if [ "$EE_SITE_CURRENT_TYPE" = "--html" ] || [ "$EE_SITE_CURRENT_TYPE" = "--php" ] || [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ]; then - ee_lib_echo "Backup webroot, please wait..." - mv $ee_webroot/htdocs $ee_webroot/backup/$EE_DATE/ \ - || ee_lib_error "Failed: Backup webroot, exit status =" $? - ee_lib_echo "Setting up webroot, please wait..." - mkdir -p $ee_webroot/htdocs || ee_lib_error "Failed: Setting up webroot, exit status =" $? - fi - - # Database backup - # Check ee-config.php or wp-config.php present - if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then - local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - ee_lib_echo "Backup Database, please wait..." - mysqldump $ee_db_name > $ee_webroot/backup/$EE_DATE/${ee_db_name}.sql \ - || ee_lib_error "Failed: Backup Database, exit status =" $? - - # Move ee-config.php and copy wp-config.php to backup - if [ -f $ee_webroot/ee-config.php ]; then - mv $ee_webroot/ee-config.php $ee_webroot/backup/$EE_DATE/ \ - || ee_lib_error "Failed: Backup ee-config.php, exit status =" $? - else - cp $ee_webroot/wp-config.php $ee_webroot/backup/$EE_DATE/ \ - || ee_lib_error "Failed: Backup wp-config.php, exit status =" $? - fi - fi -} diff --git a/src/modules/site/ee_mod_site_cd.sh b/src/modules/site/ee_mod_site_cd.sh deleted file mode 100644 index 40ced381..00000000 --- a/src/modules/site/ee_mod_site_cd.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Change directory to website root - -function ee_site_cd() -{ - cd $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g') \ - || ee_lib_error "Unable to change directory for $EE_DOMAIN, exit status = " $? - exec bash -} diff --git a/src/modules/site/ee_mod_site_edit.sh b/src/modules/site/ee_mod_site_edit.sh deleted file mode 100644 index a3d9ebe7..00000000 --- a/src/modules/site/ee_mod_site_edit.sh +++ /dev/null @@ -1,12 +0,0 @@ -# Open website in default editor - -function ee_mod_site_edit() -{ - # Redirect VIM warning to /dev/null - sensible-editor --help | head -n1 | grep VIM &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 2> /dev/null - else - sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 - fi -} diff --git a/src/modules/site/ee_mod_site_info.sh b/src/modules/site/ee_mod_site_info.sh deleted file mode 100644 index 805c8d51..00000000 --- a/src/modules/site/ee_mod_site_info.sh +++ /dev/null @@ -1,34 +0,0 @@ -# Display information about website - -function ee_mod_site_info() -{ - local ee_site_status=$(ls /etc/nginx/sites-enabled/$EE_DOMAIN &> /dev/null && echo Enable || echo Disable) - local ee_site_info=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) - local ee_access_log=$(grep access_log /etc/nginx/sites-available/$EE_DOMAIN | grep "/var/log/nginx/" | awk '{print($2)}' | cut -d ';' -f1) - local ee_error_log=$(grep error_log /etc/nginx/sites-available/$EE_DOMAIN | grep "/var/log/nginx/" | awk '{print($2)}' | cut -d ';' -f1) - local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | grep htdocs | awk '{print($2)}' | cut -d ';' -f1) - - ee_lib_echo "Information about $EE_DOMAIN:" - ee_lib_echo_escape "\nNginx configuration\t \033[37m$ee_site_info ($ee_site_status)" - ee_lib_echo_escape "access_log\t\t \033[37m$ee_access_log" - ee_lib_echo_escape "error_log\t\t \033[37m$ee_error_log" - ee_lib_echo_escape "Webroot\t\t\t \033[37m$ee_webroot" - - if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then - local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - local ee_db_host=$(grep DB_HOST $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - local ee_db_user=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - local ee_db_pass=$(grep DB_PASS $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - - ee_lib_echo_escape "DB_HOST\t\t\t \033[37m$ee_db_host" - ee_lib_echo_escape "DB_NAME\t\t\t \033[37m$ee_db_name" - ee_lib_echo_escape "DB_USER\t\t\t \033[37m$ee_db_user" - ee_lib_echo_escape "DB_PASS\t\t\t \033[37m$ee_db_pass" - - if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/wp-config.php/') ]; then - local ee_table_prefix=$(grep table_prefix $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/wp-config.php/') | cut -d"'" -f2) - ee_lib_echo_escape "table_prefix\t\t \033[37m$ee_table_prefix" - fi - fi - -} diff --git a/src/modules/site/ee_mod_site_log.sh b/src/modules/site/ee_mod_site_log.sh deleted file mode 100644 index 95cf7a62..00000000 --- a/src/modules/site/ee_mod_site_log.sh +++ /dev/null @@ -1,27 +0,0 @@ -# Checks log - -function ee_mod_site_log() -{ - # Sets ee_log_path to empty, so that it should not use its previous values - local ee_log_path="" - # Check if domain name passed - if [ $# -eq 0 ]; then - for ee_domain_name in $(ls /etc/nginx/sites-available/*); do - ee_log_path="$ee_log_path /var/log/nginx/$(basename $ee_domain_name).*.log" - done - else - for ee_domain_name in $@; do - EE_DOMAIN_CHECK=$ee_domain_name - ee_lib_check_domain - - # Check the website exist - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - - if [ $? -eq 0 ]; then - ee_log_path="$ee_log_path /var/log/nginx/$EE_DOMAIN.*.log" - fi - done - fi - tail -f ${ee_log_path} -} diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh deleted file mode 100644 index 924858f1..00000000 --- a/src/modules/site/ee_mod_site_option.sh +++ /dev/null @@ -1,48 +0,0 @@ -# Auto switch site options - -function ee_mod_site_option() -{ - if [ "$EE_SITE_CREATE_OPTION" = "--basic" ] || [ "$EE_SITE_CREATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_CREATE_OPTION=$EE_FIFTH - EE_SITE_CACHE_OPTION=$EE_FOURTH - else - EE_SITE_CREATE_OPTION=--wp - EE_SITE_CACHE_OPTION=$EE_FOURTH - fi - fi - - # WordPresss subdirectory variables - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then - EE_SITE_CREATE_OPTION="--wpsubdir" - EE_NETWORK_ACTIVATE="--network" - fi - - # WordPress sub-domain variables - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_CREATE_OPTION="--wpsubdomain" - EE_NETWORK_ACTIVATE="--network" - EE_WP_SUBDOMAIN="--subdomains" - fi - - # Use default whenever possible - if [ "$EE_SITE_CREATE_OPTION" = "" ]; then - EE_SITE_CREATE_OPTION=--html - fi - - # For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION - if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then - EE_SITE_CACHE_OPTION=--basic - fi - - # Kick out for invalid cache option - if [[ "$EE_SECOND" = "update" && "$EE_SITE_CREATE_OPTION" = "--password" ]]; then - ee_lib_echo "This option is needed for updating WordPress website password" &> /dev/null - elif [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then - ee_lib_error "Invalid website type $EE_SITE_CREATE_OPTION, exit status = " $? - elif [[ "$EE_SITE_CREATE_OPTION" = "--html" || "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]] && [ -n "$EE_SITE_CACHE_OPTION" ]; then - ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION for $EE_SITE_CREATE_OPTION website, exit status = " $? - elif [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then - ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? - fi -} diff --git a/src/modules/site/ee_mod_site_packages.sh b/src/modules/site/ee_mod_site_packages.sh deleted file mode 100644 index 66a19a42..00000000 --- a/src/modules/site/ee_mod_site_packages.sh +++ /dev/null @@ -1,27 +0,0 @@ -# Install Required Packages while site create - -function ee_mod_site_packages() -{ - # Install required packages - - if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install NGINX Packages - ee_lib_stack_packages nginx - fi - if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install PHP Packages - ee_lib_stack_packages php - fi - if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Check & Install Percona MySQL Packages - ee_lib_stack_packages mysql - fi - - # Check & Install Postfix Packages - ee_lib_stack_packages postfix - - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - # Install WP-CLI - ee_ven_install_wpcli - fi -} diff --git a/src/modules/site/migrate/ee_mod_migrate_data.sh b/src/modules/site/migrate/ee_mod_migrate_data.sh deleted file mode 100644 index 690abb62..00000000 --- a/src/modules/site/migrate/ee_mod_migrate_data.sh +++ /dev/null @@ -1,67 +0,0 @@ -# Function for site migration module - -function ee_mod_migrate_data() -{ - # Remove if any previous directory and create /ee-backup - mkdir -p /ee-backup/$EE_DOMAIN/ && cd /ee-backup/$EE_DOMAIN/ - - ee_lib_echo "Copying webroot from $EE_REMOTE_SERVER, please wait..." - - # Paramater for directory exclude - if [ "$EE_REMOTE_EXCLUDE" != "" ]; then - EE_REMOTE_EXCLUDE_CMD="" - for ee_exclude_opt in $(echo $EE_REMOTE_EXCLUDE | tr ',' ' '); do - EE_REMOTE_EXCLUDE_CMD=${EE_REMOTE_EXCLUDE_CMD}"--exclude $ee_exclude_opt " - done - fi - - # For Wordpress site we will migrate wp-config.php from parent folder of webroot - # For MySQL site we will migrate ee-config.php from parent folder of webroot - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - EE_SITE_CONFIG=wp-config.php - elif [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - EE_SITE_CONFIG=ee-config.php - fi - - # Copy webroot using ssh with the help of rsync - if [ "$EE_REMOTE_METHOD" == "ssh" ]; then - if [ "$EE_REMOTE_PASSWORD" != "" ]; then - EE_MIGRATE_CMD1="rsync -avz --progress ${EE_REMOTE_EXCLUDE_CMD} --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER -o StrictHostKeyChecking=no\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" - EE_MIGRATE_CMD2="rsync -avz --progress --rsh=\"sshpass -p$EE_REMOTE_PASSWORD ssh -l $EE_REMOTE_USER -o StrictHostKeyChecking=no\" $EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" - else - EE_MIGRATE_CMD1="rsync -avz --progress ${EE_REMOTE_EXCLUDE_CMD} $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/ /ee-backup/$EE_DOMAIN/" - EE_MIGRATE_CMD2="rsync -avz --progress $EE_REMOTE_USER@$EE_REMOTE_SERVER:$EE_REMOTE_PATH/../$EE_SITE_CONFIG /ee-backup/$EE_DOMAIN/" - fi - # Copy webroot using sftp with the help of lftp - elif [ "$EE_REMOTE_METHOD" == "sftp" ]; then - if [ "$EE_REMOTE_PASSWORD" != "" ]; then - EE_MIGRATE_CMD1="lftp -e \"mirror --verbose ${EE_REMOTE_EXCLUDE_CMD} -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" sftp://$EE_REMOTE_SERVER" - else - EE_MIGRATE_CMD1="lftp -e \"mirror --verbose ${EE_REMOTE_EXCLUDE_CMD} -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" sftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" - fi - # Copy webroot using ftp with the help of lftp - elif [ "$EE_REMOTE_METHOD" == "ftp" ]; then - if [ "$EE_REMOTE_PASSWORD" != "" ]; then - EE_MIGRATE_CMD1="lftp -e \"mirror --verbose ${EE_REMOTE_EXCLUDE_CMD} -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER,$EE_REMOTE_PASSWORD\" ftp://$EE_REMOTE_SERVER" - else - EE_MIGRATE_CMD1="lftp -e \"mirror --verbose ${EE_REMOTE_EXCLUDE_CMD} -c $EE_REMOTE_PATH /ee-backup/$EE_DOMAIN; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" - EE_MIGRATE_CMD2="lftp -e \"get -c $EE_REMOTE_PATH/../$EE_SITE_CONFIG; quit\" -u \"$EE_REMOTE_USER\" ftp://$EE_REMOTE_SERVER" - fi - fi - - # eval: Execute arguments as a shell command. - # Why eval?: direct executing Varibale as command adding some extra characters to command - # Like quote is command is not working, that is why used eval - # For more info: help eval - - eval $EE_MIGRATE_CMD1 \ - || ee_lib_error "Unable to migrate data using rsync, exit status = " $? - if [ ! -f /ee-backup/$EE_DOMAIN/wp-config.php ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ]; then - # In case of Wordpress site, If site don't have wp-config.php then try to copy wp-config.php from parent folder of webroot - # In case of MySQL site, try to copy ee-config.php from parent folder of webroot, (Hope remote server is using EE :P) - eval $EE_MIGRATE_CMD2 &>> $EE_COMMAND_LOG - fi -} diff --git a/src/modules/site/migrate/ee_mod_migrate_setup.sh b/src/modules/site/migrate/ee_mod_migrate_setup.sh deleted file mode 100644 index d35fed30..00000000 --- a/src/modules/site/migrate/ee_mod_migrate_setup.sh +++ /dev/null @@ -1,61 +0,0 @@ -# Function to Copy data from backup to webroot - -function ee_mod_migrate_setup() -{ - # Copy data from backup to webroot - ee_lib_echo "Copying data from /ee-backup to webroot, please wait..." - cp -a /ee-backup/$EE_DOMAIN/* /var/www/$EE_DOMAIN/htdocs/ \ - || ee_lib_error "Unable to copy backup data to site webroot, exit status = " $? - - # Setup Database for WordPress site - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - mv /var/www/$EE_DOMAIN/htdocs/wp-config.php /var/www/$EE_DOMAIN/ - - if [ "$EE_MYSQL_PATH" != "" ]; then - ee_lib_echo "Setting up Database, please wait..." - ee_mod_setup_database - - # Replace old database values with new values - sed -i "s/DB_NAME.*/DB_NAME', '$EE_DB_NAME');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_USER.*/DB_USER', '$EE_DB_USER');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_HOST.*/DB_HOST', '$EE_MYSQL_HOST');/g" /var/www/$EE_DOMAIN/wp-config.php - sed -i "s/DB_PASSWORD.*/DB_PASSWORD', '$EE_DB_PASS');/g" /var/www/$EE_DOMAIN/wp-config.php - - # Import database - ee_lib_echo "Importing database, please wait..." - pv $EE_MYSQL_PATH | mysql $EE_DB_NAME \ - || ee_lib_error "Unable to import database, exit status = " $? - fi - - # Install WordPress plugins - ee_mod_plugin_nginx_helper - - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_mod_plugin_w3tc - fi - - fi - - # Setup database for MySQL site - if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - if [ -f /var/www/$EE_DOMAIN/htdocs/ee-config.php ]; then - rm /var/www/$EE_DOMAIN/htdocs/ee-config.php - fi - if [ "$EE_MYSQL_PATH" != "" ]; then - EE_DB_NAME=$(grep DB_NAME /var/www/$EE_DOMAIN/ee-config.php | cut -d"'" -f4) - # Import database - ee_lib_echo "Importing database, please wait..." - pv $EE_MYSQL_PATH | mysql $EE_DB_NAME \ - || ee_lib_error "Unable to import database, exit status = " $? - fi - fi - - # Fix webroot permission - chown -R www-data:www-data /var/www/$EE_DOMAIN/ \ - || ee_lib_error "Unable to change webroot permission, exit status = " $? - -} diff --git a/src/modules/site/update/ee_mod_site_update_password.sh b/src/modules/site/update/ee_mod_site_update_password.sh deleted file mode 100644 index 5335ad9d..00000000 --- a/src/modules/site/update/ee_mod_site_update_password.sh +++ /dev/null @@ -1,42 +0,0 @@ -# Update WordPress user password - -ee_mod_site_update_password() -{ - local ee_wp_user ee_wp_pass - - cd $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g') \ - || ee_lib_error "Unable to change directory for $EE_DOMAIN, exit status = " $? - - wp --allow-root core version &>> /dev/null \ - || ee_lib_error "Error: $EE_DOMAIN does not seem to be a WordPress install, exit status = " $? - - if [ $? -eq 0 ]; then - read -p "Provide WordPress user name [admin]: " ee_wp_user - - # If user enter ? mark then show list of WordPress users - if [ "$ee_wp_user" = "?" ]; then - ee_lib_echo "Fetching WordPress user list, please wait..." - wp --allow-root user list --fields=user_login | grep -v user_login - read -p "Provide WordPress user name [admin]: " ee_wp_user - fi - - if [ "$ee_wp_user" = "" ]; then - ee_wp_user=admin - fi - - # Check WordPress user exist or not - wp --allow-root user list --fields=user_login | grep ${ee_wp_user}$ &>> /dev/null - if [ $? -eq 0 ]; then - read -sp "Provide password for $ee_wp_user user: " ee_wp_pass - echo - if [[ ${#ee_wp_pass} -ge 8 ]]; then - wp --allow-root user update "${ee_wp_user}" --user_pass=$ee_wp_pass &>> $EE_COMMAND_LOG && \ - ee_lib_echo "Password updated successfully" - else - ee_lib_error "Password Unchanged. Hint : Your password must be 8 characters long, exit status = " $? - fi - else - ee_lib_error "Invalid WordPress user $ee_wp_user for $EE_DOMAIN, exit status = " $? - fi - fi -} diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh deleted file mode 100644 index aa5156fe..00000000 --- a/src/modules/site/update/ee_mod_update_nginx.sh +++ /dev/null @@ -1,129 +0,0 @@ -# Update NGINX configuration for $EE_DOMAIN - -function ee_mod_update_nginx() -{ - # Git commit - ee_lib_git /etc/nginx/ "Before ee site update: $EE_DOMAIN running on $EE_SITE_CURRENT_TYPE" - - # Update NGINX configuration - ee_lib_echo "Updating $EE_DOMAIN, please wait..." - - if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then - # Find out current NGINX configuration header - ee_nginx_current_header=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") - - # Update NGINX configuration header - if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - ee_nginx_conf=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/basic.conf - elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_nginx_conf=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf - fi - ee_nginx_update_header=$(head -n1 /usr/share/easyengine/nginx/$ee_nginx_conf | grep "NGINX CONFIGURATION") - - # Echo values - echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nee_nginx_update_header = $ee_nginx_update_header" &>> $EE_COMMAND_LOG - - # Update Head Line of NGINX conf - sed -i "s'$ee_nginx_current_header'$ee_nginx_update_header'" /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - - # Update NGINX conf for HTML site - if [ "$EE_SITE_CURRENT_TYPE" = "--html" ]; then - sed -i 's/access\.log/access.log rt_cache/' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/index index.html index.htm;$/c \\tindex index.php index.htm index.html;' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/location \/ {/,/}/d ' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - - # Update HTML to PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) options - if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - # Update HTML to --wpsc (--wp/--wpsubdir/--wpsubdomain) options - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - # Update HTML to --w3tc (--wp/--wpsubdir/--wpsubdomain) options - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - # Update HTML to --wpfc (--wp/--wpsubdir/--wpsubdomain) options - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - fi - - # Update PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) to --wpsc --w3tc --wpfc options - elif [ "$EE_SITE_CURRENT_TYPE" = "--php" ] || [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/php.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/php.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/php.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - fi - - # Update --wpsc (--wp/--wpsubdir/--wpsubdomain) to --basic --w3tc --wpfc options - elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpsc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpsc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - fi - - # Update --w3tc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --wpfc options - elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/w3tc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - fi - - # Update --wpfc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --w3tc options - elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpfc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ - || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? - fi - fi - - # Add WordPress common file wpcommon.conf for HTML PHP & MYSQL sites - if [[ "$EE_SITE_CURRENT_TYPE" = "--html" || "$EE_SITE_CURRENT_TYPE" = "--php" || "$EE_SITE_CURRENT_TYPE" = "--mysql" ]] && \ - [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - - # Update server_name for HTML PHP MYSQL WP (single site) only - # Don't execute for WordPress Multisite - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ - && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" ] \ - && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" ] \ - && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" ] \ - && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]; then - - sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' /etc/nginx/sites-available/$EE_DOMAIN && \ - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - else - ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? - fi -} diff --git a/src/modules/site/update/ee_mod_update_website.sh b/src/modules/site/update/ee_mod_update_website.sh deleted file mode 100644 index 17224714..00000000 --- a/src/modules/site/update/ee_mod_update_website.sh +++ /dev/null @@ -1,90 +0,0 @@ -# Update Websites - -function ee_mod_update_website() { - # Let's take backup first - ee_mod_site_backup - - # Install required packages - ee_mod_site_packages - - # Let's start update - ee_mod_update_nginx - - # Setup MySQL database for HTML|PHP websites - if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - ee_mod_setup_database - - # Add Database Information On ee-config.php - echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ - &>> /var/www/$EE_DOMAIN/ee-config.php - fi - - # Use same database when update MySQL website updated to WordPress - if [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ]; then - # Use same database for WordPress - EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - fi - - # Setup/Install WordPress for HTML|PHP|MySQL websites - if [[ "$EE_SITE_CURRENT_TYPE" = "--html" || "$EE_SITE_CURRENT_TYPE" = "--php" || "$EE_SITE_CURRENT_TYPE" = "--mysql" ]] && - [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then - # Setup WordPress - ee_mod_setup_wordpress - - # Display WordPress credential - echo - ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" - ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" - echo - - # Display WordPress cache plugin settings - ee_mod_plugin_settings - - # Update WordPress Websites - elif [[ "$EE_SITE_CURRENT_WP" = "--wp" || "$EE_SITE_CURRENT_WP" = "--wpsubdir" || "$EE_SITE_CURRENT_WP" = "--wpsubdomain" ]]; then - # Setup WordPress Network for --wp websites - if [[ "$EE_SITE_CURRENT_WP" = "--wp" ]]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi - fi - - # Uninstall unwanted plugins - # Current site type: --wp --wpsc - # Update site type: --wpsubdomain --wpsc - # Only delete plugin when current cache is --wpsc and update cache is not --wpsc - if [[ "$EE_SITE_CURRENT_CACHE" = "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--wpsc" ]]; then - cd /var/www/$EE_DOMAIN/htdocs/ - ee_lib_echo "Unistalling WP Super Cache plugin, please wait..." - wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG - fi - - # Delete plugin when current cache is --w3tc|--wpfc and update cache is not --w3tc|--wpfc - if [[ "$EE_SITE_CURRENT_CACHE" = "--w3tc" || "$EE_SITE_CURRENT_CACHE" = "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then - cd /var/www/$EE_DOMAIN/htdocs/ - ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." - wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG - fi - - # Install WordPress plugins - # As nginx-helper is installed all type of WordPress - # We don't need to install it again - #ee_mod_plugin_nginx_helper - - if [[ "$EE_SITE_CURRENT_CACHE" != "--wpsc" && "$EE_SITE_CACHE_OPTION" = "--wpsc" ]]; then - ee_mod_plugin_wpsc - fi - - if [[ "$EE_SITE_CURRENT_CACHE" != "--w3tc" && "$EE_SITE_CURRENT_CACHE" != "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" || "$EE_SITE_CACHE_OPTION" = "--wpfc" ]]; then - ee_mod_plugin_w3tc - fi - - # Display WordPress cache plugin settings - ee_mod_plugin_settings - fi - - # Use this variable to detect and change ownership, reload nginx, - EE_UPDATE_WEBSITE="success" -} \ No newline at end of file diff --git a/src/modules/stack/README.md b/src/modules/stack/README.md deleted file mode 100644 index 696342ab..00000000 --- a/src/modules/stack/README.md +++ /dev/null @@ -1,2 +0,0 @@ -1. **install** - contains installation scripts for EasyEngine [ee] modules. ( ee stack install ) -1. **remove** - contains remove scripts for EasyEngine [ee] modules. ( ee stack remove ) diff --git a/src/modules/stack/ee_mod_stack_status.sh b/src/modules/stack/ee_mod_stack_status.sh deleted file mode 100644 index 6083a89e..00000000 --- a/src/modules/stack/ee_mod_stack_status.sh +++ /dev/null @@ -1,58 +0,0 @@ -# Execute: ee stack status - -function ee_mod_stack_status() -{ - # Detect operating system - local ee_operating_system=$(lsb_release -d | awk '{print $2,$3,$4}') - - # Detect system load and processes - local ee_system_load=$(cat /proc/loadavg | awk '{print $1}') - local ee_system_processes=$(ps ax | wc -l) - - # Uses of / partition and users logged in - local ee_logged_in_users=$(w -h | wc -l) - local ee_root_usage=$(df -h | grep /$ | head -1 | awk '{print $5}') - - # Memory uses - local ee_memory_total=$(free | grep Mem: | awk '{print $2}') - local ee_memory_used=$(free | grep Mem: | awk '{print $3}') - local ee_memory_buffers=$(free | grep Mem: | awk '{print $6}') - local ee_memory_cache=$(free | grep Mem: | awk '{print $7}') - local ee_memory_usage=$(echo "($ee_memory_used-$ee_memory_buffers-$ee_memory_cache)*100/$ee_memory_total" | bc -l | cut -d'.' -f1) - - # Swap uses - local ee_swap_total=$(free | grep Swap: | awk '{print $2}') - if [[ $ee_swap_total > 0 ]]; then - local ee_swap_used=$(free | grep Swap: | awk '{print $3}') - local ee_swap_usage=$(echo "scale=2; $ee_swap_used*100/$ee_swap_total" | bc -l)% - else - local ee_swap_usage=$(echo "N/A") - fi - - # Service status - local ee_nginx_status=$(service nginx status 2> /dev/null 2>> $EE_COMMAND_LOG| grep 'nginx is running' \ - &>> $EE_COMMAND_LOG && ee_lib_echo "Running" || ee_lib_echo_fail "Stopped") - local ee_php_status=$(service php5-fpm status 2> /dev/null | grep running \ - &>> $EE_COMMAND_LOG && ee_lib_echo "Running" || ee_lib_echo_fail "Stopped") - local ee_mysql_status=$(mysqladmin ping \ - &>> $EE_COMMAND_LOG && ee_lib_echo "Running" || ee_lib_echo_fail "Stopped") - local ee_postfix_status=$(service postfix status 2> /dev/null | grep 'postfix is running' \ - &>> $EE_COMMAND_LOG && ee_lib_echo "Running" || ee_lib_echo_fail "Stopped") - - ee_lib_echo - ee_lib_echo - ee_lib_echo_info " System information as of $(/bin/date)" - ee_lib_echo - ee_lib_echo_escape " System load:\t$ee_system_load\t\t Processes:\t\t$ee_system_processes" - ee_lib_echo_escape " Usage of /:\t$ee_root_usage\t\t Users logged in:\t$ee_logged_in_users" - ee_lib_echo_escape " Memory usage:\t$ee_memory_usage%\t\t Swap usage:\t\t$ee_swap_usage" - ee_lib_echo - ee_lib_echo_info " Service status information" - ee_lib_echo - ee_lib_echo_escape " Nginx:\t\t$ee_nginx_status" - ee_lib_echo_escape " PHP5-FPM:\t$ee_php_status" - ee_lib_echo_escape " MySQL:\t\t$ee_mysql_status" - ee_lib_echo_escape " Postfix:\t$ee_postfix_status" - ee_lib_echo - ee_lib_echo -} diff --git a/src/modules/stack/install/README.md b/src/modules/stack/install/README.md deleted file mode 100644 index 185cb1b5..00000000 --- a/src/modules/stack/install/README.md +++ /dev/null @@ -1,9 +0,0 @@ -1. **ee_mod_install_mysql.sh** - Install MySQL package -1. **ee_mod_install_nginx.sh** - Install nginx package -1. **ee_mod_install_php.sh** - Install php5-fpm package -1. **ee_mod_install_postfix.sh** - Install Postfix package -1. **ee_mod_repo_nginx.sh** - Setup nginx repository -1. **ee_mod_repo_php.sh** - Setup php5-fpm repository -1. **ee_mod_setup_mysql.sh** - Setup MySQL -1. **ee_mod_setup_nginx.sh** - Setup nginx -1. **ee_mod_setup_php.sh** - Setup php5-fpm \ No newline at end of file diff --git a/src/modules/stack/install/ee_mod_install_mysql.sh b/src/modules/stack/install/ee_mod_install_mysql.sh deleted file mode 100644 index c3f9242f..00000000 --- a/src/modules/stack/install/ee_mod_install_mysql.sh +++ /dev/null @@ -1,31 +0,0 @@ -# Install MySQL package - -ee_mod_install_mysql() -{ - # Random characters - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - - # Check Percona MySQL is installed or not - ee_lib_package_check percona-server-server-5.6 - - # If Percona MySQL is not installed - # Then set random MySQL password for root user - if [ -n "$EE_PACKAGE_NAME" ]; then - - # Setting up MySQL password - debconf-set-selections <<< "percona-server-server-5.6 percona-server-server/root_password password $ee_random" - debconf-set-selections <<< "percona-server-server-5.6 percona-server-server/root_password_again password $ee_random" - - # Generate ~/.my.cnf - echo -e "[client]\nuser=root\npassword=$ee_random" > ~/.my.cnf - - fi - - ee_lib_echo "Installing Percona MySQL, please Wait..." - $EE_APT_GET install percona-server-server-5.6 mysqltuner percona-toolkit \ - || ee_lib_error "Unable to install Percona MySQL, exit status = " $? - - # Download tuning-primer.sh - wget --no-check-certificate -cqO /usr/local/bin/tuning-primer.sh https://launchpadlibrarian.net/78745738/tuning-primer.sh - chmod a+x /usr/local/bin/tuning-primer.sh -} diff --git a/src/modules/stack/install/ee_mod_install_nginx.sh b/src/modules/stack/install/ee_mod_install_nginx.sh deleted file mode 100644 index b7c7c5c8..00000000 --- a/src/modules/stack/install/ee_mod_install_nginx.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Install nginx package - -function ee_mod_install_nginx() -{ - ee_lib_echo "Installing $EE_NGINX_PACKAGE, please wait..." - $EE_APT_GET install $EE_NGINX_PACKAGE \ - || ee_lib_error "Unable to install $EE_NGINX_PACKAGE, exit status = " $? -} diff --git a/src/modules/stack/install/ee_mod_install_php.sh b/src/modules/stack/install/ee_mod_install_php.sh deleted file mode 100644 index a3738ef7..00000000 --- a/src/modules/stack/install/ee_mod_install_php.sh +++ /dev/null @@ -1,9 +0,0 @@ -# Install php5-fpm package - -function ee_mod_install_php() -{ - ee_lib_echo "Installing PHP, please wait..." - $EE_APT_GET install php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached php5-geoip 2>&1 || ee_lib_error "Unable to install PHP5, exit status = " $? -} diff --git a/src/modules/stack/install/ee_mod_install_postfix.sh b/src/modules/stack/install/ee_mod_install_postfix.sh deleted file mode 100644 index 4a1571c1..00000000 --- a/src/modules/stack/install/ee_mod_install_postfix.sh +++ /dev/null @@ -1,12 +0,0 @@ -# Install Postfix package - -function ee_mod_install_postfix() -{ - # Setup Postfix - debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'" - debconf-set-selections <<< "postfix postfix/mailname string $(hostname -f)" - - # Install Postfix - ee_lib_echo "Installing Postfix, please wait..." - $EE_APT_GET install postfix || ee_lib_error "Unable to install Postfix, exit status = " $? -} diff --git a/src/modules/stack/install/ee_mod_repo_mysql.sh b/src/modules/stack/install/ee_mod_repo_mysql.sh deleted file mode 100644 index 116f5d99..00000000 --- a/src/modules/stack/install/ee_mod_repo_mysql.sh +++ /dev/null @@ -1,14 +0,0 @@ -# Setup Percona repository - -function ee_mod_repo_mysql() -{ - # Add Percona repository - ee_lib_echo "Adding Percona repository, please wait..." - echo "deb http://repo.percona.com/apt $(lsb_release -sc) main" > /etc/apt/sources.list.d/percona-$(lsb_release -sc).list \ - || ee_lib_error "Unable to add Percona repository, exit status = " $? - - # Fetch and install Percona GnuPG key - gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A &>> $EE_COMMAND_LOG && \ - gpg -a --export CD2EFD2A | apt-key add - &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to add Percona GnuPG key, exit status = " $? -} diff --git a/src/modules/stack/install/ee_mod_repo_nginx.sh b/src/modules/stack/install/ee_mod_repo_nginx.sh deleted file mode 100644 index 773b8d54..00000000 --- a/src/modules/stack/install/ee_mod_repo_nginx.sh +++ /dev/null @@ -1,26 +0,0 @@ -# Setup nginx repository - -function ee_mod_repo_nginx() -{ - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - - # Add rtCamp nginx launchpad repository - ee_lib_echo "Adding rtCamp NGINX launchpad repository, please wait..." - add-apt-repository -y ppa:rtcamp/nginx &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to add rtCamp NGINX launchpad repository, exit status = " $? - - elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then - - # Add Dotdeb nginx repository - ee_lib_echo "Adding Dotdeb NGINX repository, please wait..." - echo "deb http://packages.dotdeb.org $(lsb_release -sc) all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc).list \ - || ee_lib_error "Unable to add Dotdeb NGINX repository, exit status = " $? - - # Fetch and install dotdeb GnuPG key - ee_lib_dotdeb - - # Dotdeb nginx repository doesn't support spdy - sed -i "s/ spdy//;" /usr/share/easyengine/nginx/22222 - - fi -} diff --git a/src/modules/stack/install/ee_mod_repo_php.sh b/src/modules/stack/install/ee_mod_repo_php.sh deleted file mode 100644 index 2e1015a5..00000000 --- a/src/modules/stack/install/ee_mod_repo_php.sh +++ /dev/null @@ -1,34 +0,0 @@ -# Setup php5-fpm repository - -function ee_mod_repo_php() -{ - # Ubuntu - if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then - - # Add ondrej php5 launchpad repository - ee_lib_echo "Adding Ondrej PHP5 launchpad repository, please wait..." - add-apt-repository -y ppa:ondrej/php5 &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to add ondrej php5 launchpad repository, exit status = " $? - - # Debian 6 - elif [ "$EE_DEBIAN_VERSION" == "squeeze" ]; then - - ee_lib_echo "Adding Dotdeb PHP5.4 repository, please wait..." - echo "deb http://packages.dotdeb.org $(lsb_release -sc)-php54 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc)-php54.list \ - || ee_lib_error "Unable to add Dotdeb PHP5.4 repository, exit status = " $? - - # Fetch and install Dotdeb GnuPG key - ee_lib_dotdeb - - # Debian 7 - elif [ "$EE_DEBIAN_VERSION" == "wheezy" ]; then - - ee_lib_echo "Adding Dotdeb PHP5.5 repository, please wait..." - echo "deb http://packages.dotdeb.org $(lsb_release -sc)-php55 all" > /etc/apt/sources.list.d/dotdeb-$(lsb_release -sc)-php55.list \ - || ee_lib_error "Unable to add Dotdeb PHP5.5 repository, exit status = " $? - - # Fetch and install dotdeb GnuPG key - ee_lib_dotdeb - - fi -} diff --git a/src/modules/stack/install/ee_mod_setup_mysql.sh b/src/modules/stack/install/ee_mod_setup_mysql.sh deleted file mode 100644 index a8ba0263..00000000 --- a/src/modules/stack/install/ee_mod_setup_mysql.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Setup MySQL - -function ee_mod_setup_mysql() -{ - ee_lib_echo "Setting up Percona MySQL, please wait..." - - # Setting wait_timeout = 30 & interactive_timeout = 60 - if [ ! -f /etc/mysql/my.cnf ]; then - echo -e "[mysqld] \nwait_timeout = 30 \ninteractive_timeout = 60 \nperformance_schema = 0" > /etc/mysql/my.cnf - else - grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG - if [ $? -ne 0 ]; then - sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60 \nperformance_schema = 0" /etc/mysql/my.cnf - fi - fi -} diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh deleted file mode 100644 index 4257c6b7..00000000 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ /dev/null @@ -1,114 +0,0 @@ -# Setup nginx - -function ee_mod_setup_nginx() -{ - local ee_whitelist_ip_address - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - - ee_lib_echo "Setting up NGINX, please wait..." - - grep "EasyEngine" /etc/nginx/nginx.conf &>> /dev/null - if [ $? -ne 0 ]; then - - # Adjust nginx worker_processes and worker_rlimit_nofile value - sed -i "s/worker_processes.*/worker_processes auto;/" /etc/nginx/nginx.conf - sed -i "/worker_processes/a \worker_rlimit_nofile 100000;" /etc/nginx/nginx.conf - - # Adjust nginx worker_connections and multi_accept - sed -i "s/worker_connections.*/worker_connections 4096;/" /etc/nginx/nginx.conf - sed -i "s/# multi_accept/multi_accept/" /etc/nginx/nginx.conf - - # Disable nginx version - # Set custom header - # SSL Settings - sed -i "s/http {/http {\n\t##\n\t# EasyEngine Settings\n\t##\n\n\tserver_tokens off;\n\treset_timedout_connection on;\n\tadd_header X-Powered-By \"EasyEngine $EE_VERSION\";\n\tadd_header rt-Fastcgi-Cache \$upstream_cache_status;\n\n\t# Limit Request\n\tlimit_req_status 403;\n\tlimit_req_zone \$binary_remote_addr zone=one:10m rate=1r\/s;\n\n\t# Proxy Settings\n\t# set_real_ip_from\tproxy-server-ip;\n\t# real_ip_header\tX-Forwarded-For;\n\n\tfastcgi_read_timeout 300;\n\tclient_max_body_size 100m;\n\n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\t# Fix POODLE attack\n\tssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n\n/" /etc/nginx/nginx.conf - - # Adjust nginx keepalive_timeout - sed -i "s/keepalive_timeout.*/keepalive_timeout 30;/" /etc/nginx/nginx.conf - - # Adjust nginx log format - sed -i "s/error_log.*/error_log \/var\/log\/nginx\/error.log;\n\n\tlog_format rt_cache '\$remote_addr \$upstream_response_time \$upstream_cache_status [\$time_local] '\n\t\t'\$http_host \"\$request\" \$status \$body_bytes_sent '\n\t\t'\"\$http_referer\" \"\$http_user_agent\"';/" /etc/nginx/nginx.conf - - # Enable Gun-zip - sed -i "s/# gzip/gzip/" /etc/nginx/nginx.conf - fi - - # Update EasyEngine version - # Launchpad PPA already have above settings - # On Ubuntu above block never executed - sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $EE_VERSION\";/" /etc/nginx/nginx.conf - - # Create directory if not exist - if [ ! -d /etc/nginx/conf.d ]; then - mkdir /etc/nginx/conf.d || ee_lib_error "Unable to create /etc/nginx/conf.d, exit status = " $? - fi - - if [ ! -d /etc/nginx/common ]; then - mkdir /etc/nginx/common || ee_lib_error "Unable to create /etc/nginx/common, exit status = " $? - fi - - # Copy files - cp -a /usr/share/easyengine/nginx/conf.d /usr/share/easyengine/nginx/common /etc/nginx - - # Setup port 22222 - cp /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ - - # Create a symbolic link for 22222 - if [ ! -L /etc/nginx/sites-enabled/22222 ]; then - ln -s /etc/nginx/sites-available/22222 /etc/nginx/sites-enabled/ - fi - - # Setup logs for 22222 - if [ ! -d /var/www/22222/logs ]; then - mkdir -p /var/www/22222/logs - ln -s /var/log/nginx/22222.access.log /var/www/22222/logs/access.log - ln -s /var/log/nginx/22222.error.log /var/www/22222/logs/error.log - fi - - # Setup SSL - # Create SSL certificate directory - if [ ! -d /var/www/22222/cert ]; then - mkdir /var/www/22222/cert - fi - - # Generate SSL key - ee_lib_echo "Generating SSL private key" - openssl genrsa -out /var/www/22222/cert/22222.key 2048 &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to generate SSL private key for port 22222, exit status = " $? - - ee_lib_echo "Generating a certificate signing request (CSR)" - openssl req -new -batch -subj /commonName=127.0.0.1/ -key /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.csr &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to generate certificate signing request (CSR) for port 22222, exit status = " $? - - ee_lib_echo "Removing pass phrase from SSL private key" - mv /var/www/22222/cert/22222.key /var/www/22222/cert/22222.key.org - openssl rsa -in /var/www/22222/cert/22222.key.org -out /var/www/22222/cert/22222.key &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to remove pass phrase from SSL for port 22222, exit status = " $? - - ee_lib_echo "Generating SSL certificate" - openssl x509 -req -days 3652 -in /var/www/22222/cert/22222.csr -signkey /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.crt &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to generate SSL certificate for port 22222, exit status = " $? - - # White list IP address - if [ -n "$EE_IP_ADDRESS" ]; then - for ee_whitelist_ip_address in $(echo $EE_IP_ADDRESS);do - sed -i "/deny/i $(echo allow $ee_whitelist_ip_address\;)" /etc/nginx/common/acl.conf - done - fi - - # Generate htpasswd-ee file - if [ ! -f /etc/nginx/htpasswd-ee ]; then - # Export EE_DISPLAY variable to Display ee http auth after site creation. - if [ -z $EE_DISPLAY ]; then - export EE_DISPLAY=true - fi - # Use same variable name as used in ee_mod_secure_auth function - EE_HTTP_AUTH_USER=easyengine - EE_HTTP_AUTH_PASS=$ee_random - echo - ee_lib_echo "HTTP authentication username: $EE_HTTP_AUTH_USER" &>> $EE_COMMAND_LOG - ee_lib_echo "HTTP authentication password: $EE_HTTP_AUTH_PASS" &>> $EE_COMMAND_LOG - - printf "$EE_HTTP_AUTH_USER:$(openssl passwd -crypt $EE_HTTP_AUTH_PASS 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null - fi -} diff --git a/src/modules/stack/install/ee_mod_setup_php.sh b/src/modules/stack/install/ee_mod_setup_php.sh deleted file mode 100644 index 46d6cc54..00000000 --- a/src/modules/stack/install/ee_mod_setup_php.sh +++ /dev/null @@ -1,84 +0,0 @@ -# Setup php5-fpm - -function ee_mod_setup_php() -{ - ee_lib_echo "Setting up PHP5, please wait..." - - # Custom php5 log directory - if [ ! -d /var/log/php5/ ]; then - mkdir -p /var/log/php5/ || ee_lib_error "Unable to create /var/log/PHP5/, exit status = " $? - fi - - grep "EasyEngine" /etc/php5/fpm/php.ini &> /dev/null - if [ $? -ne 0 ]; then - - local ee_time_zone=$(cat /etc/timezone | head -n1 | sed "s'/'\\\/'") - - # Adjust php.ini - sed -i "s/\[PHP\]/[PHP]\n; EasyEngine/" /etc/php5/fpm/php.ini - sed -i "s/expose_php.*/expose_php = Off/" /etc/php5/fpm/php.ini - sed -i "s/post_max_size.*/post_max_size = 100M/" /etc/php5/fpm/php.ini - sed -i "s/upload_max_filesize.*/upload_max_filesize = 100M/" /etc/php5/fpm/php.ini - sed -i "s/max_execution_time.*/max_execution_time = 300/" /etc/php5/fpm/php.ini - sed -i "s/;date.timezone.*/date.timezone = $ee_time_zone/" /etc/php5/fpm/php.ini - - # Change php5-fpm error log location - sed -i "s'error_log.*'error_log = /var/log/php5/fpm.log'" /etc/php5/fpm/php-fpm.conf - - # Enable php status and ping - sed -i "s/;ping.path/ping.path/" /etc/php5/fpm/pool.d/www.conf - sed -i "s/;pm.status_path/pm.status_path/" /etc/php5/fpm/pool.d/www.conf - - # Adjust php5-fpm pool - sed -i "s/;pm.max_requests/pm.max_requests/" /etc/php5/fpm/pool.d/www.conf - sed -i "s/pm.max_children = 5/pm.max_children = ${EE_PHP_MAX_CHILDREN}/" /etc/php5/fpm/pool.d/www.conf - sed -i "s/pm.start_servers = 2/pm.start_servers = 20/" /etc/php5/fpm/pool.d/www.conf - sed -i "s/pm.min_spare_servers = 1/pm.min_spare_servers = 10/" /etc/php5/fpm/pool.d/www.conf - sed -i "s/pm.max_spare_servers = 3/pm.max_spare_servers = 30/" /etc/php5/fpm/pool.d/www.conf - sed -i "s/;request_terminate_timeout.*/request_terminate_timeout = 300/" /etc/php5/fpm/pool.d/www.conf - sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/www.conf \ - || ee_lib_error "Unable to change process manager from dynamic to ondemand, exit status = " $? - - # Adjust php5-fpm listen - sed -i "s'listen = /var/run/php5-fpm.sock'listen = 127.0.0.1:9000'" /etc/php5/fpm/pool.d/www.conf \ - || ee_lib_error "Unable to change php5-fpm listen socket, exit status = " $? - - # Separate php5-fpm for ee debug command - cp /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/debug.conf - - sed -i "s'\[www\]'[debug]'" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change debug pool name, exit status = " $? - - sed -i "s'listen = 127.0.0.1:9000'listen = 127.0.0.1:9001'" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change listen = 127.0.0.1:9001 for debug pool, exit status = " $? - - sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change slowlog settings for debug pool, exit status = " $? - - sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf \ - || ee_lib_error "Unable to change request_slowlog_timeout for debug pool, exit status = " $? - - echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/ \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to add xdebug settings for debug pool, exit status = " $? - - ee_lib_echo "Downloading GeoIP Database, please wait..." - mkdir -p /usr/share/GeoIP - wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz - gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz - mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat - - # Setup Zend OpCache as per RAM - if [ -f /etc/php5/fpm/conf.d/05-opcache.ini ]; then - grep memory_consumption /etc/php5/fpm/conf.d/05-opcache.ini &> /dev/null - if [ $? -ne 0 ]; then - sed -i "s/zend_extension=opcache.so/zend_extension=opcache.so\nopcache.memory_consumption=${EE_OPCACHE_SIZE}\nopcache.max_accelerated_files=50000/" /etc/php5/fpm/conf.d/05-opcache.ini \ - || ee_lib_error "Unable to change opcache.memory_consumption, exit status = " $? - fi - fi - - # Setup PHP Memcache as per RAM - sed -i "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \ - || ee_lib_error "Unable to change Memcache memory value, exit status = " $? - - fi -} diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh deleted file mode 100644 index fafb37d8..00000000 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ /dev/null @@ -1,24 +0,0 @@ -# Install Dovecot package - -function ee_mod_install_dovecot() -{ - # Add Dovecot repo for Debian 6 - ee_mod_repo_dovecot - ee_lib_apt_get_update - - # Install Dovecot - ee_lib_echo "Installing Dovecot, please wait..." - debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" - debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" - - # 2>&1 is needed as config file is written in STDEER - # Debian 6 doesn't provide Dovecot 2.x - if [ "$EE_DEBIAN_VERSION" == "squeeze" ]; then - $EE_APT_GET -t squeeze-backports install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved 2>&1 \ - || ee_lib_error "Unable to install Dovecot, exit status = " $? - else - $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved 2>&1 \ - || ee_lib_error "Unable to install Dovecot, exit status = " $? - fi - -} diff --git a/src/modules/stack/install/mail/ee_mod_install_mailscaner.sh b/src/modules/stack/install/mail/ee_mod_install_mailscaner.sh deleted file mode 100644 index 4c3c5b7b..00000000 --- a/src/modules/stack/install/mail/ee_mod_install_mailscaner.sh +++ /dev/null @@ -1,9 +0,0 @@ -# Install Amavis package - -function ee_mod_install_mailscaner() -{ - # Install Amavis - ee_lib_echo "Installing Amavis, SpamAssassin and ClamAV, please wait..." - $EE_APT_GET install amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch cpio lzop cabextract p7zip rpm unrar-free \ - || ee_lib_error "Unable to install Amavis, SpamAssassin and ClamAV, exit status = " $? -} diff --git a/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh b/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh deleted file mode 100644 index 5f27164b..00000000 --- a/src/modules/stack/install/mail/ee_mod_repo_dovecot.sh +++ /dev/null @@ -1,13 +0,0 @@ -# Setup nginx repository - -function ee_mod_repo_dovecot() -{ - if [ "$EE_DEBIAN_VERSION" == "squeeze" ];then - - # Add Dovecot repository - ee_lib_echo "Adding Dovecot repository, please wait..." - echo "deb http://http.debian.net/debian-backports squeeze-backports main" > /etc/apt/sources.list.d/dovecot-$(lsb_release -sc).list \ - || ee_lib_error "Unable to add Dovecot repository, exit status = " $? - - fi -} diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh deleted file mode 100644 index 76126c8e..00000000 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ /dev/null @@ -1,79 +0,0 @@ -# Setup Dovecot - -function ee_mod_setup_dovecot() -{ - - EE_EMAIL=$($EE_CONFIG_GET wordpress.email) - if [[ $EE_EMAIL = "" ]]; then - EE_EMAIL=$(git config user.email) - fi - - EE_HOSTNAME=$(hostname -f) - - ee_lib_echo "Setting up Dovecot, please wait..." - # Adding mail user with GID 5000 and UID 5000 - adduser --uid 5000 --home /var/vmail --disabled-password --gecos '' vmail &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to setup vmail user/group = " $? - - # Configuring dovecot.conf - sed -i "s/*.protocol/*.protocol\\nprotocols = imap pop3 lmtp sieve/" /etc/dovecot/dovecot.conf \ - || ee_lib_error "Unable to configure Dovecot protocol, exit status = " $? - - # Configuring 10-mail.conf - sed -i "s/mail_location = mbox:~\/mail:INBOX=\/var\/mail\/%u/mail_location = maildir:\/var\/vmail\/%d\/%n/" /etc/dovecot/conf.d/10-mail.conf \ - || ee_lib_error "Unable to configure Dovecot mail_location, exit status = " $? - - # Configuring 10-auth.conf - sed -i "s/#disable_plaintext_auth = yes/disable_plaintext_auth = no/" /etc/dovecot/conf.d/10-auth.conf && \ - sed -i "s/auth_mechanisms = plain/auth_mechanisms = plain login/" /etc/dovecot/conf.d/10-auth.conf && \ - sed -i "s/\!include auth-system.conf.ext/#\!include auth-system.conf.ext/" /etc/dovecot/conf.d/10-auth.conf && \ - sed -i "s/#\!include auth-sql.conf.ext/\!include auth-sql.conf.ext/" /etc/dovecot/conf.d/10-auth.conf \ - || ee_lib_error "Unable to setup 10-auth.conf file, exit status = " $? - - # Configuring 10-ssl.conf, Disable SSLv2 and SSLv3, Fixes POODLE Bug - grep ssl_protocols /etc/dovecot/conf.d/10-ssl.conf &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - # For Ubuntu 14.04, Debian 6 and Debian 7 10-ssl.conf file contains commented #ssl_protocol variable - sed -i "s/#ssl_protocols =.*/ssl_protocols = \!SSLv2 \!SSLv3/" /etc/dovecot/conf.d/10-ssl.conf - else - # For Ubuntu 12.04 10-ssl.conf file does not contain commented #ssl-protocols variable - echo 'ssl_protocols = !SSLv2 !SSLv3' >> /etc/dovecot/conf.d/10-ssl.conf - fi - - # Configuring dovecot-sql.conf.ext - cp -v /usr/share/easyengine/mail/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to copy dovecot-sql.conf.ext, exit status = " $? - - cp -v /usr/share/easyengine/mail/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf.ext &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to setup auth-sql.conf.ext, exit status = " $? - - - # Configuring 10-master.conf - cp -v /etc/dovecot/conf.d/10-master.conf /etc/dovecot/conf.d/10-master.conf.bak &>> $EE_COMMAND_LOG - cp -v /usr/share/easyengine/mail/10-master.conf /etc/dovecot/conf.d/10-master.conf &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to setup 10-master.conf, exit status = " $? - - # Change Dovecot log location - sed -i "s/#log_path = syslog/log_path = \/var\/log\/dovecot.log/" /etc/dovecot/conf.d/10-logging.conf \ - || ee_lib_error "Unable to setup Dovecot log_path, exit status = " $? - - # Configure self signed SSL for Dovecot - ee_lib_echo "Generating self signed certificate for Dovecot, please wait..." - openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/dovecot.pem -keyout /etc/ssl/private/dovecot.pem &>> $EE_COMMAND_LOG - chmod 0600 /etc/ssl/private/dovecot.pem - - # Setting up certificate in file - sed -i "s'/etc/dovecot/dovecot.pem'/etc/ssl/certs/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ - && sed -i "s'/etc/dovecot/private/dovecot.pem'/etc/ssl/private/dovecot.pem'" /etc/dovecot/conf.d/10-ssl.conf \ - || ee_lib_error "Unable to setup Dovecot SSL certificate path, exit status = " $? - - # Setting Dovecot init.d script - if [ ! -f /etc/init.d/dovecot ];then - cp -v /usr/share/easyengine/mail/dovecot /etc/init.d/dovecot &>> $EE_COMMAND_LOG - fi - # Add autocreate plugin - sed -i "s'#mail_plugins = \$mail_plugins'mail_plugins = \$mail_plugins autocreate'" /etc/dovecot/conf.d/20-imap.conf \ - || ee_lib_error "Unable to setup Dovecot autocreate plugin, exit status = " $? - cat /usr/share/easyengine/mail/autocreate >> /etc/dovecot/conf.d/20-imap.conf - -} diff --git a/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh b/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh deleted file mode 100644 index 2c5f0013..00000000 --- a/src/modules/stack/install/mail/ee_mod_setup_mailscaner.sh +++ /dev/null @@ -1,49 +0,0 @@ -# Install mail scanner packages - -function ee_mod_setup_mailscaner() -{ - # Configure Amavis - - ee_lib_echo "Setting up Amavis, please wait..." - sed -i "s'#@'@'" /etc/amavis/conf.d/15-content_filter_mode && \ - sed -i "s'# ' '" /etc/amavis/conf.d/15-content_filter_mode \ - || ee_lib_error "Unable to setup Amavis, exit status = " $? - - # Add mail filtering rules - sed -i "s/use strict;/use strict;\n\$sa_spam_subject_tag = undef;\n\$spam_quarantine_to = undef;\n\$sa_tag_level_deflt = undef;\n\n# Prevent spams from automatically rejected by mail-server\n\$final_spam_destiny = D_PASS;\n# We need to provide list of domains for which filtering need to be done\n@lookup_sql_dsn = (\n ['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306',\n 'vimbadmin',\n 'password']);\n\n\$sql_select_policy = 'SELECT domain FROM domain WHERE CONCAT("@",domain) IN (%k)';/" /etc/amavis/conf.d/50-user \ - || ee_lib_error "Unable to setup Amavis, exit status = " $? - - sed -i "s'\@local_domains_acl = ( \".\$mydomain\" );'\@local_domains_acl = ( \".\" );'" /etc/amavis/conf.d/05-domain_id \ - || ee_lib_error "Unable to setup Amavis, exit status = " $? - - # Configure Postfix to use Amavis - # For postfix main.cf - postconf -e "content_filter = smtp-amavis:[127.0.0.1]:10024" - - # For postfix master.cf - sed -i "s/1 pickup/1 pickup\n -o content_filter=\n -o receive_override_options=no_header_body_checks/" /etc/postfix/master.cf \ - || ee_lib_error "Unable to setup Amavis, exit status = " $? - cat /usr/share/easyengine/mail/amavis-master.cf >> /etc/postfix/master.cf - - # Grep ViMbAdmin host and Password from Postfix Configuration - ee_vimbadmin_host=$(grep hosts /etc/postfix/mysql/virtual_alias_maps.cf | awk '{ print $3 }') - ee_vimbadmin_password=$(grep password /etc/postfix/mysql/virtual_alias_maps.cf | awk '{ print $3 }') - - # Changing hosts and password of ViMbAdmin database in Amavis configuration - sed -i "s/127.0.0.1/$ee_vimbadmin_host/" /etc/amavis/conf.d/50-user && - sed -i "s/password/$ee_vimbadmin_password/" /etc/amavis/conf.d/50-user \ - || ee_lib_error "Unable to setup ViMbAdmin database details in Amavis configuration, exit status = " $? - - # Configure ClamAv and Amavis to each other files - adduser clamav amavis &>> $EE_COMMAND_LOG - adduser amavis clamav &>> $EE_COMMAND_LOG - chmod -R 775 /var/lib/amavis/tmp &>> $EE_COMMAND_LOG - - # Update ClamAV database (freshclam) - ee_lib_echo "Updating ClamAV database, please wait..." - freshclam &>> $EE_COMMAND_LOG - - service clamav-daemon restart &>> $EE_COMMAND_LOG \ - || ee_lib_echo "Unable to start ClamAV deamon" - -} diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh deleted file mode 100644 index 8beab678..00000000 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ /dev/null @@ -1,72 +0,0 @@ -# Setup Postfix - -function ee_mod_setup_postfix() -{ - - EE_EMAIL=$($EE_CONFIG_GET wordpress.email) - if [[ $EE_EMAIL = "" ]]; then - EE_EMAIL=$(git config user.email) - fi - - EE_HOSTNAME=$(hostname -f) - - #We previously not used this package. So, if some one don't have Postfix-MySQL installed, - #Postfix will not work - ee_lib_echo "Installing Postfix-MySQL, please wait..." - $EE_APT_GET install postfix-mysql \ - || ee_lib_error "Unable to install Postfix-MySQL, exit status = " $? - - ee_lib_echo "Setting up Postfix, please wait..." - #Configure Master.cf - sed -i 's/#submission/submission/' /etc/postfix/master.cf && - sed -i 's/#smtps/smtps/' /etc/postfix/master.cf \ - || ee_lib_error "Unable to setup details in master.cf file, exit status = " $? - - # Handle SMTP authentication using Dovecot" - # On Debian6 following command not work ( Postfix < 2.8 ) - # postconf "smtpd_sasl_type = dovecot" - # The -e option is no longer needed with Postfix version 2.8 and later. - - postconf -e "smtpd_sasl_type = dovecot" - postconf -e "smtpd_sasl_path = private/auth" - postconf -e "smtpd_sasl_auth_enable = yes" - - postconf -e "smtpd_relay_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination" - - # Disable SSL for POODLE - postconf -e "smtpd_tls_mandatory_protocols=!SSLv2,!SSLv3" - postconf -e "smtp_tls_mandatory_protocols=!SSLv2,!SSLv3" - postconf -e "smtpd_tls_protocols=!SSLv2,!SSLv3" - postconf -e "smtp_tls_protocols=!SSLv2,!SSLv3" - - # other destination domains should be handled using virtual domains - postconf -e "mydestination = localhost" - - # using Dovecot's LMTP for mail delivery and giving it path to store mail - postconf -e "virtual_transport = lmtp:unix:private/dovecot-lmtp" - - # virtual mailbox setups - postconf -e "virtual_uid_maps = static:5000" - postconf -e "virtual_gid_maps = static:5000" - postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domains_maps.cf" - postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf" - postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf" - #postconf "message_size_limit = 20971520" - - - # Setting up Postfix MySQL configuration - mkdir -p /etc/postfix/mysql - cp -av /usr/share/easyengine/mail/virtual_alias_maps.cf /etc/postfix/mysql/virtual_alias_maps.cf &>> $EE_COMMAND_LOG && \ - cp -av /usr/share/easyengine/mail/virtual_domains_maps.cf /etc/postfix/mysql/virtual_domains_maps.cf &>> $EE_COMMAND_LOG && \ - cp -av /usr/share/easyengine/mail/virtual_mailbox_maps.cf /etc/postfix/mysql/virtual_mailbox_maps.cf &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to copy Postfix MySQL configuration files, exit status = " $? - - # Configure self signed SSL for Postfix - ee_lib_echo "Generating self signed certificate for Postfix, please wait..." - openssl req -new -x509 -days 3650 -nodes -subj /commonName=${EE_HOSTNAME}/emailAddress=${EE_EMAIL} -out /etc/ssl/certs/postfix.pem -keyout /etc/ssl/private/postfix.pem &>> $EE_COMMAND_LOG - chmod 0600 /etc/ssl/private/postfix.pem - - postconf -e smtpd_tls_cert_file=/etc/ssl/certs/postfix.pem - postconf -e smtpd_tls_key_file=/etc/ssl/private/postfix.pem - -} diff --git a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh deleted file mode 100644 index 1e0b7dfb..00000000 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ /dev/null @@ -1,36 +0,0 @@ -# Setup Sieve rules - -function ee_mod_setup_sieve() -{ - EE_EMAIL=$($EE_CONFIG_GET wordpress.email) - if [[ $EE_EMAIL = "" ]]; then - EE_EMAIL=$(git config user.email) - fi - - ee_lib_echo "Setting up Sieve rules, please wait..." - - # Enable sieve plugin support for dovecot-lmtp - sed -i "s' #mail_plugins = \$mail_plugins' postmaster_address =$EE_EMAIL \n mail_plugins = \$mail_plugins sieve'" /etc/dovecot/conf.d/20-lmtp.conf \ - || ee_lib_error "Unable to add sieve plugin support for dovecot-lmtp, exit status = " $? - - # Sieve dovecot-pluign configuration - sed -i "s'sieve = ~/.dovecot.sieve'sieve = ~/.dovecot.sieve\n sieve_global_path = /var/lib/dovecot/sieve/default.sieve'" /etc/dovecot/conf.d/90-sieve.conf && \ - sed -i "s'#sieve_global_dir ='sieve_global_dir = /var/lib/dovecot/sieve/'" /etc/dovecot/conf.d/90-sieve.conf \ - || ee_lib_error "Unable to setup Sieve dovecot-pluign, exit status = " $? - - # Create global Sieve rules file - mkdir -p /var/lib/dovecot/sieve/ - cp /usr/share/easyengine/mail/default.sieve /var/lib/dovecot/sieve/default.sieve - chown -R vmail:vmail /var/lib/dovecot - - # Compile Sieve rules - sievec /var/lib/dovecot/sieve/default.sieve \ - || ee_lib_error "Unable to compile Sieve rules, exit status = " $? - - # Configure Roundcube - sed -i "s:\$config\['plugins'\] = array(:\$config\['plugins'\] = array(\n 'sieverules',:" /var/www/roundcubemail/htdocs/config/config.inc.php \ - || ee_lib_error "Unable to configure Sieve Roundcube plugin, exit status = " $? - - echo "\$config['sieverules_port'] = 4190;" >> /var/www/roundcubemail/htdocs/config/config.inc.php - -} diff --git a/src/modules/stack/remove/README.md b/src/modules/stack/remove/README.md deleted file mode 100644 index 1f568f43..00000000 --- a/src/modules/stack/remove/README.md +++ /dev/null @@ -1,4 +0,0 @@ -1. **ee_mod_remove_mysql.sh** - Remove MySQL package -1. **ee_mod_remove_nginx.sh** - Remove nginx package -1. **ee_mod_remove_php.sh** - Remove php5 package -1. **ee_mod_remove_postfix.sh** - Remove Postfix package \ No newline at end of file diff --git a/src/modules/stack/remove/ee_mod_remove_mysql.sh b/src/modules/stack/remove/ee_mod_remove_mysql.sh deleted file mode 100644 index 9f9215c1..00000000 --- a/src/modules/stack/remove/ee_mod_remove_mysql.sh +++ /dev/null @@ -1,17 +0,0 @@ -# Remove MySQL package - -function ee_mod_remove_mysql() -{ - dpkg --get-selections | grep -v deinstall | grep mysql-server &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_mysql_server=mysql-server - else - ee_mysql_server=percona-server-server-5.6 - fi - ee_lib_echo "$EE_SECOND Percona MySQL package, please wait..." - $EE_APT_GET $EE_SECOND $ee_mysql_server mysqltuner percona-toolkit \ - || ee_lib_error "Unable to $EE_SECOND Percona MySQL, exit status = " $? - - # Remove tuning-primer.sh - rm -f /usr/local/bin/tuning-primer.sh -} diff --git a/src/modules/stack/remove/ee_mod_remove_nginx.sh b/src/modules/stack/remove/ee_mod_remove_nginx.sh deleted file mode 100644 index 01e59206..00000000 --- a/src/modules/stack/remove/ee_mod_remove_nginx.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Remove nginx package - -function ee_mod_remove_nginx() -{ - ee_lib_echo "$EE_SECOND $EE_NGINX_PACKAGE package, please wait..." - $EE_APT_GET $EE_SECOND $EE_NGINX_PACKAGE nginx-common \ - || ee_lib_error "Unable to $EE_SECOND $NGINX_PACKAGE, exit status = " $? -} diff --git a/src/modules/stack/remove/ee_mod_remove_php.sh b/src/modules/stack/remove/ee_mod_remove_php.sh deleted file mode 100644 index 2ade5bba..00000000 --- a/src/modules/stack/remove/ee_mod_remove_php.sh +++ /dev/null @@ -1,9 +0,0 @@ -# Remove php5 package - -function ee_mod_remove_php() -{ - ee_lib_echo "$EE_SECOND PHP5 package, please wait..." - $EE_APT_GET $EE_SECOND php5-common php5-mysqlnd php5-xmlrpc \ - php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached php5-geoip || ee_lib_error "Unable to $EE_SECOND PHP5, exit status = " $? -} diff --git a/src/modules/stack/remove/ee_mod_remove_postfix.sh b/src/modules/stack/remove/ee_mod_remove_postfix.sh deleted file mode 100644 index c4281aa3..00000000 --- a/src/modules/stack/remove/ee_mod_remove_postfix.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Remove Postfix package - -function ee_mod_remove_postfix() -{ - ee_lib_echo "$EE_SECOND Postfix, please wait..." - $EE_APT_GET $EE_SECOND postfix || ee_lib_error "Unable to $EE_SECOND Postfix, exit status = " $? -} diff --git a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh b/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh deleted file mode 100644 index b929b43b..00000000 --- a/src/modules/stack/remove/mail/ee_mod_remove_dovecot.sh +++ /dev/null @@ -1,13 +0,0 @@ -# Remove Dovecot package - -function ee_mod_remove_dovecot() -{ - ee_lib_echo "$EE_SECOND Dovecot package, please wait..." - $EE_APT_GET $EE_SECOND dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ - || ee_lib_error "Unable to $EE_SECOND Dovecot, exit status = " $? - - deluser --remove-home vmail &>> $EE_COMMAND_LOG || ee_lib_error "Unable to Remove user vmail, exit status = " $? - rm -f /etc/init.d/dovecot - rm -rf /var/vmail - -} diff --git a/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh b/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh deleted file mode 100644 index 17cef9ee..00000000 --- a/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh +++ /dev/null @@ -1,18 +0,0 @@ -# Remove MailScan package - -function ee_mod_remove_mailscaner() -{ - - # Remove Amavis configuration from Postfix configuration - # Better approach is: postconf -X "content_filter", But available for Postfix 2.11 (latest) - sed -i '/content_filter/d' /etc/postfix/main.cf - sed -i '/content_filter/d' /etc/postfix/master.cf - sed -i '/receive_override_options/d' /etc/postfix/master.cf - sed -i '/smtp-amavis/,$d' /etc/postfix/master.cf - - #Remove/Purge mailscan packages - ee_lib_echo "$EE_SECOND Amavis, SpamAssassin and ClamAV package, please wait..." - $EE_APT_GET $EE_SECOND amavisd-new spamassassin clamav clamav-daemon arj zoo nomarch lzop cabextract p7zip rpm unrar-free \ - || ee_lib_error "Unable to $EE_SECOND Amavis, SpamAssassin and ClamAV,, exit status = " $? - -} diff --git a/src/vendor/README.md b/src/vendor/README.md deleted file mode 100644 index 7e4fac04..00000000 --- a/src/vendor/README.md +++ /dev/null @@ -1,8 +0,0 @@ -1. **ee_ven_install_adminer.sh** - Install Adminer -1. **ee_ven_install_phpmyadmin.sh** - Install phpMyAdmin -1. **ee_ven_install_utils.sh** - Install admin utilities -1. **ee_ven_install_wp_cli.sh** - Install WP-CLI -1. **ee_ven_remove_adminer.sh** - Remove Adminer -1. **ee_ven_remove_phpmyadmin.sh** - Remove phpMyAdmin -1. **ee_ven_remove_utils.sh** - Remove admin utilities -1. **ee_ven_remove_wp_cli.sh** - Remove WP-CLI diff --git a/src/vendor/ee_ven_install_adminer.sh b/src/vendor/ee_ven_install_adminer.sh deleted file mode 100644 index f88be0e2..00000000 --- a/src/vendor/ee_ven_install_adminer.sh +++ /dev/null @@ -1,17 +0,0 @@ -# Install Adminer - -function ee_ven_install_adminer() -{ - if [ ! -d /var/www/22222/htdocs/db/adminer ]; then - - # Setup Adminer - mkdir -p /var/www/22222/htdocs/db/adminer/ \ - || ee_lib_error "Unable to create Adminer directory: /var/www/22222/htdocs/db/adminer/, exit status = " $? - - # Download Adminer - ee_lib_echo "Downloading Adminer, please wait..." - wget --no-check-certificate -cqO /var/www/22222/htdocs/db/adminer/index.php http://downloads.sourceforge.net/adminer/adminer-${EE_ADMINER_VERSION}.php \ - || ee_lib_error "Unable to download Adminer, exit status = " $? - - fi -} diff --git a/src/vendor/ee_ven_install_phpmyadmin.sh b/src/vendor/ee_ven_install_phpmyadmin.sh deleted file mode 100644 index 5e0ba0e3..00000000 --- a/src/vendor/ee_ven_install_phpmyadmin.sh +++ /dev/null @@ -1,33 +0,0 @@ -# Install phpMyAdmin - -function ee_ven_install_phpmyadmin() -{ - if [ ! -d /var/www/22222/htdocs/db/pma ]; then - - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1) - - # Setup phpMyAdmin directory - mkdir -p /var/www/22222/htdocs/db/pma/ \ - || ee_lib_error "Unable to create phpMyAdmin directory: /var/www/22222/htdocs/db/pma/, exit status = " $? - - # Download phpMyAdmin - ee_lib_echo "Downloading phpMyAdmin, please wait..." - wget --no-check-certificate -cqO /var/www/22222/htdocs/db/pma/pma.tar.gz https://github.com/phpmyadmin/phpmyadmin/archive/STABLE.tar.gz \ - || ee_lib_error "Unable to download phpMyAdmin, exit status = " $? - - # Extract phpMyAdmin - tar --strip-components=1 -zxf /var/www/22222/htdocs/db/pma/pma.tar.gz -C /var/www/22222/htdocs/db/pma/ \ - || ee_lib_error "Unable to extract phpMyAdmin, exit status = " $? - - # Remove unwanted files - rm -f /var/www/22222/htdocs/db/pma/pma.tar.gz - - # Setup phpMyAdmin - cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? - - sed -i "s/a8b7c6d/$ee_random/" /var/www/22222/htdocs/db/pma/config.inc.php \ - || ee_lib_error "Unable to setup phpMyAdmin, exit status = " $? - - fi -} diff --git a/src/vendor/ee_ven_install_roundcube.sh b/src/vendor/ee_ven_install_roundcube.sh deleted file mode 100644 index 03e65f02..00000000 --- a/src/vendor/ee_ven_install_roundcube.sh +++ /dev/null @@ -1,30 +0,0 @@ -# Install Roundcube - -function ee_ven_install_roundcube() -{ - # Install Roundcube dependencies - ee_lib_echo "Installing Roundcube, please wait..." - $EE_APT_GET install php-pear \ - || ee_lib_error "Unable to install php-pear, exit status = " $? - pear install Mail_Mime Net_SMTP Mail_mimeDecode Net_IDNA2-beta Auth_SASL Net_Sieve Crypt_GPG &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to install pear packages, exit status = " $? - - # Setup Roundcube directory - mkdir -p /var/www/roundcubemail/{htdocs,logs} - ee_lib_symbolic_link /var/log/nginx/roundcubemail.access.log /var/www/roundcubemail/logs/access.log - ee_lib_symbolic_link /var/log/nginx/roundcubemail.error.log /var/www/roundcubemail/logs/error.log - - # Install Roundcube - wget -cqO /var/www/roundcube.tar.gz https://github.com/roundcube/roundcubemail/releases/download/${EE_ROUNDCUBE_VERSION}/roundcubemail-${EE_ROUNDCUBE_VERSION}.tar.gz \ - || ee_lib_error "Unable to download Roundcube, exit status = " $? - - tar -zxf /var/www/roundcube.tar.gz -C /var/www/roundcubemail/htdocs/ --strip-components=1 \ - || ee_lib_error "Unable to extract Roundcube, exit status = " $? - - # Fix permissions - chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/roundcubemail \ - || ee_lib_error "Unable to change ownership for ViMbAdmin, exit status = " $? - - # Remove unwanted files - rm -rf /var/www/roundcube.tar.gz /var/www/roundcubemail-1.0.1 -} diff --git a/src/vendor/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh deleted file mode 100644 index 260dad69..00000000 --- a/src/vendor/ee_ven_install_utils.sh +++ /dev/null @@ -1,127 +0,0 @@ -# Install EasyEngine (ee) admin utilities - -function ee_ven_install_utils() -{ - dpkg -l | grep php5-fpm &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - # Setup phpMemcachedAdmin - if [ ! -d /var/www/22222/htdocs/cache/memcache ];then - # Create memcache directory - mkdir -p /var/www/22222/htdocs/cache/memcache \ - || ee_lib_error "Unable to create /var/www/22222/htdocs/cache/memcache directory, exit status = " $? - - # Download phpMemcachedAdmin - ee_lib_echo "Installing phpMemcachedAdmin, please wait..." - wget --no-check-certificate -cqO /var/www/22222/htdocs/cache/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz \ - || ee_lib_error "Unable to download phpMemcachedAdmin, exit status = " $? - - # Extract phpMemcachedAdmin - tar -zxf /var/www/22222/htdocs/cache/memcache/memcache.tar.gz -C /var/www/22222/htdocs/cache/memcache - - # Remove unwanted file - rm -f /var/www/22222/htdocs/cache/memcache/memcache.tar.gz - fi - - # Nginx FastCGI cleanup - if [ ! -d /var/www/22222/htdocs/cache/nginx ]; then - mkdir -p /var/www/22222/htdocs/cache/nginx \ - || ee_lib_error "Unable to create /var/www/22222/htdocs/cache/nginx Directory, exit status = " $? - - # Download nginx FastCGI cleanup - ee_lib_echo "Downloading nginx FastCGI cleanup script, please wait..." - wget --no-check-certificate -cqO /var/www/22222/htdocs/cache/nginx/clean.php https://raw.githubusercontent.com/rtCamp/eeadmin/master/cache/nginx/clean.php \ - || ee_lib_error "Unable to download nginx FastCGI cleanup script, exit status = " $? - fi - - # Setup opcache - if [ ! -d /var/www/22222/htdocs/cache/opcache ]; then - mkdir -p /var/www/22222/htdocs/cache/opcache \ - || ee_lib_error "Unable to create /var/www/22222/htdocs/cache/opcache directory, exit status = " $? - - # Download opcache tools - ee_lib_echo "Downloading OPcache, please wait..." - wget --no-check-certificate -cqO /var/www/22222/htdocs/cache/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php \ - || ee_lib_error "Unable to download opcache.php" - wget --no-check-certificate -cqO /var/www/22222/htdocs/cache/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php \ - || ee_lib_error "Unable to download opgui.php" - wget --no-check-certificate -cqO /var/www/22222/htdocs/cache/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php \ - || ee_lib_error "Unable to download ocp.php" - fi - - # PHP5-FPM status page - if [ ! -d /var/www/22222/htdocs/fpm/status/ ]; then - mkdir -p /var/www/22222/htdocs/fpm/status/ \ - || ee_lib_error "Unable to create /var/www/22222/htdocs/fpm/status/ directory, exit status = " $? - touch /var/www/22222/htdocs/fpm/status/{php,debug} - fi - - # Setup Webgrind - if [ ! -d /var/www/22222/htdocs/php/webgrind/ ]; then - mkdir -p mkdir -p /var/www/22222/htdocs/php/webgrind/ \ - || ee_lib_error "Unable to create /var/www/22222/htdocs/php/webgrind/ directory, exit status = " $? - - # Clone Webgrind - ee_lib_echo "Cloning Webgrind, please wait..." - git clone https://github.com/jokkedk/webgrind.git /var/www/22222/htdocs/php/webgrind/ &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to clone Webgrind, exit status = " $? - sed -i "s'/usr/local/bin/dot'/usr/bin/dot'" /var/www/22222/htdocs/php/webgrind/config.php - fi - - # phpinfo() - echo -e "" &>> /var/www/22222/htdocs/php/info.php - fi - mysqladmin ping &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - # Setup Anemometer - if [ ! -d /var/www/22222/htdocs/db/anemometer ]; then - mkdir -p /var/www/22222/htdocs/db/anemometer/ \ - || ee_lib_error "Unable to create /var/www/22222/htdocs/db/anemometer/ directory, exit status = " $? - - # Clone Anemometer - ee_lib_echo "Cloning Anemometer, please wait..." - git clone https://github.com/box/Anemometer.git /var/www/22222/htdocs/db/anemometer &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to clone Anemometer, exit status = " $? - - # Setup Anemometer - mysql < /var/www/22222/htdocs/db/anemometer/install.sql \ - || ee_lib_error "Unable to import Anemometer database, exit status = " $? - - ee_anemometer_pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - - # Grant select privileges for anemometer - mysql -e "grant select on *.* to 'anemometer'@'$EE_MYSQL_GRANT_HOST'" ; - - # Grant all privileges for slow_query_log database. - mysql -e "grant all on slow_query_log.* to 'anemometer'@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_anemometer_pass';" - - # Anemometer configuration - cp /var/www/22222/htdocs/db/anemometer/conf/sample.config.inc.php /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ - || ee_lib_error "Unable to copy Anemometer configuration file, exit status = " $? - - sed -i "s/root/anemometer/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php - sed -i "/password/ s/''/'$ee_anemometer_pass'/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php - sed -i "s/'host' => 'localhost',/'host' => '$EE_MYSQL_HOST',/g" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php - - # Change Anemometer Hostname in ee_lib_import_slow_log - sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ - || ee_lib_error "Unable to change Anemometer hostnameme, exit status = " $? - - # Change Anemometer password in ee_lib_import_slow_log - sed -i "s/--password.*/--password=${ee_anemometer_pass} \\\/" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \ - || ee_lib_error "Unable to change Anemometer password, exit status = " $? - - # Download pt-query-advisor Fixed #189 - wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \ - || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $? - chmod 0755 /usr/bin/pt-query-advisor - - # Enable pt-query-advisor plugin in Anemometer - sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \ - || ee_lib_error "Unable to activate pt-query-advisor plugin, exit status = " $? - - fi - fi - # Change permission - chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/22222 \ - || ee_lib_error "Unable to change ownership for /var/www/22222" -} diff --git a/src/vendor/ee_ven_install_vimbadmin.sh b/src/vendor/ee_ven_install_vimbadmin.sh deleted file mode 100644 index e76ac0a5..00000000 --- a/src/vendor/ee_ven_install_vimbadmin.sh +++ /dev/null @@ -1,36 +0,0 @@ -# Install ViMbAdmin - -function ee_ven_install_vimbadmin() -{ - - # Install needed PHP5 libraries for ViMbAdmin - # ee stack install php installed php5-mcrypt, php5-memcache, php5-mysqlnd - $EE_APT_GET install php5-cgi php5-json php-gettext \ - || ee_lib_error "Unable to install php-pear, exit status = " $? - - # Install ViMbAdmin - ee_lib_echo "Installing ViMbAdmin, please wait..." - ee_lib_echo "It will take nearly 10-20 minutes, please wait..." - mkdir -p /var/www/22222/htdocs/ \ - || ee_lib_error "Unable to create ViMbAdmin Directory, exit status = " $? - - wget -cqO /var/www/22222/htdocs/vimbadmin.tar.gz https://github.com/opensolutions/ViMbAdmin/archive/${EE_VIMBADMIN_VERSION}.tar.gz \ - || ee_lib_error "Unable to download ViMbAdmin, exit status = " $? - - mkdir -p /var/www/22222/htdocs/vimbadmin - tar --strip-components=1 -zxf /var/www/22222/htdocs/vimbadmin.tar.gz -C /var/www/22222/htdocs/vimbadmin - - # Install Composer - cd /var/www/22222/htdocs/vimbadmin - curl -sS https://getcomposer.org/installer | php &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to install Composer, exit status = " $? - php composer.phar install --prefer-dist --no-dev &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to install ViMbAdmin, exit status = " $? - - # Fix permissions - chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/22222/ \ - || ee_lib_error "Unable to change ownership for ViMbAdmin, exit status = " $? - - # Remove unwanted files - rm -rf /var/www/22222/htdocs/vimbadmin.tar.gz /var/www/22222/htdocs/vimbadmin/composer.phar -} diff --git a/src/vendor/ee_ven_install_wpcli.sh b/src/vendor/ee_ven_install_wpcli.sh deleted file mode 100644 index e7dc1abe..00000000 --- a/src/vendor/ee_ven_install_wpcli.sh +++ /dev/null @@ -1,21 +0,0 @@ -# Install WP-CLI - -function ee_ven_install_wpcli() -{ - dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_COMMAND_LOG - if [ $? -eq 0 ]; then - ee_wp_cli_current=$(wp --allow-root --info 2> /dev/null | grep 'WP-CLI' | grep version | awk '{print $3}') - if [[ $ee_wp_cli_current < $EE_WP_CLI_VERSION ]]; then - ee_lib_echo "Downloading WP-CLI, please wait..." - wget -qO /usr/bin/wp https://github.com/wp-cli/wp-cli/releases/download/v${EE_WP_CLI_VERSION}/wp-cli.phar \ - || ee_lib_error "Unable to download WP-CLI, exit status = " $? - - # Executable permission - chmod a+x /usr/bin/wp \ - || ee_lib_error "Unable to set executable permission for wp-cli, exit status = " $? - - # Download auto completion - wget -qO /etc/bash_completion.d/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/v${EE_WP_CLI_VERSION}/utils/wp-completion.bash - fi - fi -} diff --git a/src/vendor/ee_ven_remove_adminer.sh b/src/vendor/ee_ven_remove_adminer.sh deleted file mode 100644 index b091f8b3..00000000 --- a/src/vendor/ee_ven_remove_adminer.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Remove Adminer - -function ee_ven_remove_adminer() -{ - ee_lib_echo "Removing Adminer, please wait..." - rm -rf /var/www/22222/htdocs/db/adminer \ - || ee_lib_error "Unable to remove Adminer, exit status = " $? -} diff --git a/src/vendor/ee_ven_remove_phpmyadmin.sh b/src/vendor/ee_ven_remove_phpmyadmin.sh deleted file mode 100644 index 6ae0ded3..00000000 --- a/src/vendor/ee_ven_remove_phpmyadmin.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Remove phpMyAdmin - -function ee_ven_remove_phpmyadmin() -{ - ee_lib_echo "Removing phpMyAdmin, please wait..." - rm -rf /var/www/22222/htdocs/db/pma \ - || ee_lib_error "Unable to remove phpMyAdmin, exit status = " $? -} diff --git a/src/vendor/ee_ven_remove_roundcube.sh b/src/vendor/ee_ven_remove_roundcube.sh deleted file mode 100644 index 57546631..00000000 --- a/src/vendor/ee_ven_remove_roundcube.sh +++ /dev/null @@ -1,17 +0,0 @@ -# Remove Roundcube - -function ee_ven_remove_roundcube() -{ - ee_lib_echo "Removing Roundcube dependencies, please wait..." - # Remove packages installed using Pear - pear uninstall Mail_Mime Net_SMTP Mail_mimeDecode Net_IDNA2-beta Auth_SASL Net_Sieve Crypt_GPG &>> $EE_COMMAND_LOG - - # Remove Roundcube - ee_lib_echo "Removing Roundcube, please wait..." - - mysql -e "drop database \`roundcubemail\`" &>> $EE_COMMAND_LOG - mysql -e "drop user roundcube@'$EE_MYSQL_GRANT_HOST'" &>> $EE_COMMAND_LOG - - rm -rf /var/www/roundcubemail /etc/nginx/sites-available/webmail /etc/nginx/sites-enabled/webmail \ - || ee_lib_error "Unable to remove Roundcube, exit status = " $? -} diff --git a/src/vendor/ee_ven_remove_utils.sh b/src/vendor/ee_ven_remove_utils.sh deleted file mode 100644 index ec6f4067..00000000 --- a/src/vendor/ee_ven_remove_utils.sh +++ /dev/null @@ -1,12 +0,0 @@ -# Remove EasyEngine (ee) admin utilities - -function ee_ven_remove_utils() -{ - # Remove EasyEngine (ee) admin utilities - ee_lib_echo "Remove EasyEngine (ee) admin utilities, please wait..." - rm -rf /var/www/22222/htdocs/cache/ /var/www/22222/htdocs/fpm /var/www/22222/htdocs/php /var/www/22222/htdocs/db/anemometer \ - || ee_lib_error "Unable to remove EasyEngine (ee) admin utilities" - - # Drop Anemometer database - mysql -e "drop database if exists slow_query_log" &>> $EE_COMMAND_LOG -} diff --git a/src/vendor/ee_ven_remove_vimbadmin.sh b/src/vendor/ee_ven_remove_vimbadmin.sh deleted file mode 100644 index 3966ae19..00000000 --- a/src/vendor/ee_ven_remove_vimbadmin.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Remove ViMbAdmin - -function ee_ven_remove_vimbadmin() -{ - ee_lib_echo "Removing ViMbAdmin, please wait..." - - mysql -e "drop database \`vimbadmin\`" &>> $EE_COMMAND_LOG - mysql -e "drop user vimbadmin@'$EE_MYSQL_GRANT_HOST'" &>> $EE_COMMAND_LOG - - ee_lib_echo "Removing ViMbAdmin PHP dependencies, please wait..." - $EE_APT_GET $EE_SECOND php5-cgi php-gettext \ - ||ee_lib_error "Unable to $EE_SECOND ViMbAdmin PHP dependencies, exit status = " $? - - rm -rf /var/www/22222/htdocs/vimbadmin \ - || ee_lib_error "Unable to remove ViMbAdmin, exit status = " $? -} diff --git a/src/vendor/ee_ven_remove_wpcli.sh b/src/vendor/ee_ven_remove_wpcli.sh deleted file mode 100644 index 1da8fbce..00000000 --- a/src/vendor/ee_ven_remove_wpcli.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Remove wpcli - -function ee_ven_remove_wpcli() -{ - ee_lib_echo "Removing WP-CLI, please wait..." - rm -rf /usr/bin/wp /etc/bash_completion.d/wp-completion.bash \ - || ee_lib_error "Unable to remove WP-CLI, exit status = " $? -} diff --git a/src/vendor/ee_ven_setup_roundcube.sh b/src/vendor/ee_ven_setup_roundcube.sh deleted file mode 100644 index 0af6c635..00000000 --- a/src/vendor/ee_ven_setup_roundcube.sh +++ /dev/null @@ -1,35 +0,0 @@ -# Setup Roundcube - -function ee_ven_setup_roundcube() -{ - ee_lib_echo "Setting up Roundcube, please wait..." - - # Random characters - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - - # Setting up database for Roundcube - mysql -e "create database \`roundcubemail\`" \ - || ee_lib_error "Unable to create Roundcube database, exit status = " $? - - # Create MySQL user - mysql -e "grant all privileges on roundcubemail.* to roundcube@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_random'" \ - || ee_lib_error "Unable to grant privileges for Roundcube database user, exit status = " $? - mysql -e "flush privileges" - - # Import Roundcube initial database - mysql roundcubemail < /var/www/roundcubemail/htdocs/SQL/mysql.initial.sql \ - || ee_lib_error "Unable to import database for Roundcube, exit status = " $? - - # Setup configuration for Roundcube - cp -av /var/www/roundcubemail/htdocs/config/config.inc.php.sample /var/www/roundcubemail/htdocs/config/config.inc.php &>> $EE_COMMAND_LOG - sed -i "s'mysql://roundcube:pass@localhost/roundcubemail'mysql://roundcube:${ee_random}@${EE_MYSQL_HOST}/roundcubemail'" /var/www/roundcubemail/htdocs/config/config.inc.php \ - || ee_lib_error "Unable to setup Roundcube database details in config.inc.php file, exit status = " $? - - # Setup Nginx configuration to access Webmail - cp -v /usr/share/easyengine/mail/webmail /etc/nginx/sites-available/ &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to copy Nginx configuration for Roundcube, exit status = " $? - - ln -sf /etc/nginx/sites-available/webmail /etc/nginx/sites-enabled/ \ - || ee_lib_error "Unable to create softlink for Webmail, exit status = " $? - -} diff --git a/src/vendor/ee_ven_setup_vimbadmin.sh b/src/vendor/ee_ven_setup_vimbadmin.sh deleted file mode 100644 index 4ad1509d..00000000 --- a/src/vendor/ee_ven_setup_vimbadmin.sh +++ /dev/null @@ -1,74 +0,0 @@ -# Setup ViMbAdmin - -function ee_ven_setup_vimbadmin() -{ - if [ $EE_MYSQL_HOST = "localhost" ];then - ee_vimbadmin_host="127.0.0.1" - else - ee_vimbadmin_host=$EE_MYSQL_HOST - fi - - ee_lib_echo "Setting up ViMbAdmin, please wait..." - - # Random characters - local ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) - - # Setting up database for ViMbAdmin - mysql -e "create database \`vimbadmin\`" \ - || ee_lib_error "Unable to create ViMbAdmin database, exit status = " $? - - # Create MySQL User - mysql -e "grant all privileges on vimbadmin.* to vimbadmin@'$EE_MYSQL_GRANT_HOST' IDENTIFIED BY '$ee_random'" \ - || ee_lib_error "Unable to grant privileges for ViMbAdmin database user, exit status = " $? - mysql -e "flush privileges" - - # Setup configuration for ViMbAdmin - cp -av /var/www/22222/htdocs/vimbadmin/application/configs/application.ini.dist /var/www/22222/htdocs/vimbadmin/application/configs/application.ini &>> $EE_COMMAND_LOG - - sed -i "s/defaults.mailbox.uid = 2000/defaults.mailbox.uid = 5000/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && - sed -i "s/defaults.mailbox.gid = 2000/defaults.mailbox.gid = 5000/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && - sed -i "s'maildir:/srv/vmail/%d/%u/mail:LAYOUT=fs'maildir:/var/vmail/%d/%u'" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && - sed -i "s'/srv/vmail/%d/%u'/var/vmail/'" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && - sed -i "s/pdo_mysql/mysqli/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && - sed -i "s/'xxx'/'$ee_random'/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && - sed -i "s/resources.doctrine2.connection.options.host = 'localhost'/resources.doctrine2.connection.options.host = '$ee_vimbadmin_host'/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini && - sed -i "s/defaults.mailbox.password_scheme = \"md5.salted\"/defaults.mailbox.password_scheme = \"md5\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ - || ee_lib_error "Unable to setup ViMbAdmin configuration file, exit status = " $? - - # Changing hosts and password of ViMbAdmin database in postfix configuration - # Note: As Amavis is optional, Amavis ViMbAdmin settings are present is ee_mod_setup_mailscaner function - sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_alias_maps.cf && - sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_alias_maps.cf \ - || ee_lib_error "Unable to setup ViMbAdmin database details in virtual_alias_maps.cf file, exit status = " $? - - sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_domains_maps.cf && - sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_domains_maps.cf \ - || ee_lib_error "Unable to setup ViMbAdmin database details in virtual_domains_maps.cf file, exit status = " $? - - sed -i "s/password = password/password = $ee_random/" /etc/postfix/mysql/virtual_mailbox_maps.cf && - sed -i "s/hosts = 127.0.0.1/hosts = $ee_vimbadmin_host/" /etc/postfix/mysql/virtual_mailbox_maps.cf \ - || ee_lib_error "Unable to setup ViMbAdmin database details in virtual_mailbox_maps.cf file, exit status = " $? - - sed -i "s/password=password/password=$ee_random/" /etc/dovecot/dovecot-sql.conf.ext && - sed -i "s/hosts=localhost/hosts=$ee_vimbadmin_host/" /etc/dovecot/dovecot-sql.conf.ext \ - || ee_lib_error "Unable to setup ViMbAdmin database details in dovecot-sql.conf.ext file, exit status = " $? - - # Copying HTACCESS - cp -av /var/www/22222/htdocs/vimbadmin/public/.htaccess.dist /var/www/22222/htdocs/vimbadmin/public/.htaccess &>> $EE_COMMAND_LOG - - # Setting default database - /var/www/22222/htdocs/vimbadmin/bin/doctrine2-cli.php orm:schema-tool:create &>> $EE_COMMAND_LOG \ - || ee_lib_error "Unable to setup ViMbAdmin default database , exit status = " $? - - ee_security_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) - sed -i "s/securitysalt = \"\"/securitysalt = \"$ee_security_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ - || ee_lib_error "Unable to setup ViMbAdmin security salt , exit status = " $? - - ee_rememberme_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) - sed -i "s/resources.auth.oss.rememberme.salt = \"\"/resources.auth.oss.rememberme.salt = \"$ee_rememberme_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ - || ee_lib_error "Unable to setup ViMbAdmin remember me salt , exit status = " $? - - ee_password_salt=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n1) - sed -i "s/defaults.mailbox.password_salt = \"\"/defaults.mailbox.password_salt = \"$ee_password_salt\"/" /var/www/22222/htdocs/vimbadmin/application/configs/application.ini \ - || ee_lib_error "Unable to setup ViMbAdmin mailbox password salt , exit status = " $? -} diff --git a/templates/README.md b/templates/README.md deleted file mode 100644 index bcff3c4a..00000000 --- a/templates/README.md +++ /dev/null @@ -1 +0,0 @@ -1. **nginx** - includes config file templates. Actul Linux path: `/usr/share/easyengine/` diff --git a/templates/mail/10-master.conf b/templates/mail/10-master.conf deleted file mode 100644 index 1c46e384..00000000 --- a/templates/mail/10-master.conf +++ /dev/null @@ -1,26 +0,0 @@ -service lmtp { - unix_listener /var/spool/postfix/private/dovecot-lmtp { - mode = 0600 - user = postfix - group = postfix - } -} - -service auth { - unix_listener /var/spool/postfix/private/auth { - mode = 0666 - user = postfix - group = postfix - } - - unix_listener auth-userdb { - mode = 0600 - user = vmail - } - - user = dovecot -} - -service auth-worker { - user = vmail -} diff --git a/templates/mail/amavis-master.cf b/templates/mail/amavis-master.cf deleted file mode 100644 index cc4b872c..00000000 --- a/templates/mail/amavis-master.cf +++ /dev/null @@ -1,24 +0,0 @@ -smtp-amavis unix - - n - 2 smtp - -o smtp_data_done_timeout=1200 - -o smtp_send_xforward_command=yes - -o disable_dns_lookups=yes - -o max_use=20 - -127.0.0.1:10025 inet n - n - - smtpd - -o content_filter= - -o smtpd_delay_reject=no - -o smtpd_client_restrictions=permit_mynetworks,reject - -o smtpd_helo_restrictions= - -o smtpd_sender_restrictions= - -o smtpd_recipient_restrictions=permit_mynetworks,reject - -o smtpd_data_restrictions=reject_unauth_pipelining - -o smtpd_end_of_data_restrictions= - -o smtpd_restriction_classes= - -o mynetworks=127.0.0.0/8 - -o smtpd_error_sleep_time=0 - -o smtpd_soft_error_limit=1001 - -o smtpd_hard_error_limit=1000 - -o smtpd_client_connection_count_limit=0 - -o smtpd_client_connection_rate_limit=0 - -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks - -o local_header_rewrite_clients= diff --git a/templates/mail/auth-sql.conf.ext b/templates/mail/auth-sql.conf.ext deleted file mode 100644 index d3f0b7fa..00000000 --- a/templates/mail/auth-sql.conf.ext +++ /dev/null @@ -1,13 +0,0 @@ -passdb { -driver = sql -args = /etc/dovecot/dovecot-sql.conf.ext -} - -userdb { -driver = prefetch -} - -userdb { -driver = sql -args = /etc/dovecot/dovecot-sql.conf.ext -} diff --git a/templates/mail/autocreate b/templates/mail/autocreate deleted file mode 100644 index 66a68eb0..00000000 --- a/templates/mail/autocreate +++ /dev/null @@ -1,10 +0,0 @@ -plugin { -autocreate = Trash -autocreate2 = Junk -autocreate3 = Drafts -autocreate4 = Sent -autosubscribe = Trash -autosubscribe2 = Junk -autosubscribe3 = Drafts -autosubscribe4 = Sent -} diff --git a/templates/mail/default.sieve b/templates/mail/default.sieve deleted file mode 100644 index 62532322..00000000 --- a/templates/mail/default.sieve +++ /dev/null @@ -1,4 +0,0 @@ -require "fileinto"; -if header :contains "X-Spam-Flag" "YES" { - fileinto "Junk"; -} diff --git a/templates/mail/dovecot b/templates/mail/dovecot deleted file mode 100644 index 7d001128..00000000 --- a/templates/mail/dovecot +++ /dev/null @@ -1,73 +0,0 @@ -# EasyEngine Dovecot init script -### BEGIN INIT INFO -# Provides: dovecot -# Required-Start: $local_fs $remote_fs $network $syslog $time -# Required-Stop: $local_fs $remote_fs $network $syslog -# Should-Start: postgresql mysql slapd winbind -# Should-Stop: postgresql mysql slapd winbind -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Dovecot init script -# Description: Init script for dovecot services -### END INIT INFO - -# Example /etc/init.d/dovecot script. Change DAEMON if necessary. -# License is public domain. - -DAEMON=/usr/sbin/dovecot - -# Uncomment to allow Dovecot daemons to produce core dumps. -#ulimit -c unlimited - -test -x $DAEMON || exit 1 -set -e - -base_dir=`$DAEMON config -h base_dir` -pidfile=$base_dir/master.pid - -if test -f $pidfile; then - running=yes -else - running=no -fi - -case "$1" in - start) - echo -n "Starting Dovecot" - $DAEMON - echo "." - ;; - stop) - if test $running = yes; then - echo "Stopping Dovecot" - kill `cat $pidfile` - echo "." - else - echo "Dovecot is already stopped." - fi - ;; - reload) - if test $running = yes; then - echo -n "Reloading Dovecot configuration" - kill -HUP `cat $pidfile` - echo "." - else - echo "Dovecot isn't running." - fi - ;; - restart|force-reload) - echo -n "Restarting Dovecot" - if test $running = yes; then - kill `cat $pidfile` - sleep 1 - fi - $DAEMON - echo "." - ;; - *) - echo "Usage: /etc/init.d/dovecot {start|stop|reload|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/templates/mail/dovecot-sql.conf.ext b/templates/mail/dovecot-sql.conf.ext deleted file mode 100644 index 03d413fb..00000000 --- a/templates/mail/dovecot-sql.conf.ext +++ /dev/null @@ -1,15 +0,0 @@ -driver = mysql - -connect = host=localhost user=vimbadmin password=password dbname=vimbadmin -default_pass_scheme = MD5 - -password_query = SELECT username as user, password as password, \ -homedir AS home, maildir AS mail, \ -concat('*:bytes=', quota) as quota_rule, uid, gid \ -FROM mailbox \ -WHERE username = '%Lu' AND active = '1' \ -AND ( access_restriction = 'ALL' OR LOCATE( access_restriction, '%Us' ) > 0 ) - -user_query = SELECT homedir AS home, maildir AS mail, \ -concat('*:bytes=', quota) as quota_rule, uid, gid \ -FROM mailbox WHERE username = '%u' diff --git a/templates/mail/virtual_alias_maps.cf b/templates/mail/virtual_alias_maps.cf deleted file mode 100644 index 2b312477..00000000 --- a/templates/mail/virtual_alias_maps.cf +++ /dev/null @@ -1,5 +0,0 @@ -user = vimbadmin -password = password -hosts = 127.0.0.1 -dbname = vimbadmin -query = SELECT goto FROM alias WHERE address = '%s' AND active = '1' diff --git a/templates/mail/virtual_domains_maps.cf b/templates/mail/virtual_domains_maps.cf deleted file mode 100644 index a7c11133..00000000 --- a/templates/mail/virtual_domains_maps.cf +++ /dev/null @@ -1,5 +0,0 @@ -user = vimbadmin -password = password -hosts = 127.0.0.1 -dbname = vimbadmin -query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1' diff --git a/templates/mail/virtual_mailbox_maps.cf b/templates/mail/virtual_mailbox_maps.cf deleted file mode 100644 index e777f79d..00000000 --- a/templates/mail/virtual_mailbox_maps.cf +++ /dev/null @@ -1,7 +0,0 @@ -user = vimbadmin -password = password -hosts = 127.0.0.1 -dbname = vimbadmin -table = mailbox -select_field = maildir -where_field = username diff --git a/templates/mail/webmail b/templates/mail/webmail deleted file mode 100644 index b1b2b3a1..00000000 --- a/templates/mail/webmail +++ /dev/null @@ -1,23 +0,0 @@ -# Nginx Configuration to access webmail -# Don't modify this file, EasyEngine replaces it with new version - -server { - server_name webmail.*; - - access_log /var/log/nginx/webmail.access.log; - error_log /var/log/nginx/webmail.error.log; - - root /var/www/roundcubemail/htdocs/; - index index.php; - - location / { - try_files $uri $uri/ /index.php?$args; - } - - location ~ \.php$ { - try_files $uri =404; - include fastcgi_params; - fastcgi_pass 127.0.0.1:9000; - } - -} diff --git a/templates/nginx/22222 b/templates/nginx/22222 deleted file mode 100644 index 44e50952..00000000 --- a/templates/nginx/22222 +++ /dev/null @@ -1,61 +0,0 @@ -# EasyEngine admin NGINX CONFIGURATION - -server { - - listen 22222 default_server ssl spdy; - - access_log /var/log/nginx/22222.access.log rt_cache; - error_log /var/log/nginx/22222.error.log; - - ssl_certificate /var/www/22222/cert/22222.crt; - ssl_certificate_key /var/www/22222/cert/22222.key; - - # Force HTTP to HTTPS - error_page 497 =200 https://$host:22222$request_uri; - - root /var/www/22222/htdocs; - index index.php index.htm index.html; - - # Turn on directory listing - autoindex on; - - location / { - include common/acl.conf; - try_files $uri $uri/ /index.php?$args; - } - - location = /fpm/status/ {} - - location ~ /fpm/status/(.*) { - include fastcgi_params; - fastcgi_param SCRIPT_NAME /status; - fastcgi_pass $1; - } - - location ~ \.php$ { - include common/acl.conf; - try_files $uri =404; - include fastcgi_params; - fastcgi_pass php; - } - - # ViMbAdmin Rules - location = /vimbadmin/ { - return 301 $scheme://$host:22222/vimbadmin/public/; - } - - location ~* \.(js|css|jpg|gif|png)$ { - root /var/www/22222/htdocs/; - } - - location ~* /vimbadmin/public/(.*)/(.*) { - root /var/www/22222/htdocs/vimbadmin/public; - try_files $uri $uri/ /vimbadmin/public/index.php?$args; - } - - location ~* /vimbadmin/public/(.*) { - root /var/www/22222/htdocs/vimbadmin/public; - try_files $uri $uri/ /vimbadmin/public/index.php?$args; - } - -} diff --git a/templates/nginx/README.md b/templates/nginx/README.md deleted file mode 100644 index 27a68f8d..00000000 --- a/templates/nginx/README.md +++ /dev/null @@ -1,7 +0,0 @@ -1. **html** - HTML NGINX cofiguration -1. **mysql** - MySQL NGINX cofiguration -1. **php** - PHP NGINX cofiguration -1. **wp** - WordPress NGINX cofiguration -1. **wpsubdir** - WordPress Multisite (subdirectory) NGINX configuration -1. **wpsubdomain** - WordPress Subdomains NGINX configuration -1. **22222** - EasyEngine admin panel configuration diff --git a/templates/nginx/html/README.md b/templates/nginx/html/README.md deleted file mode 100644 index 4d9f0aed..00000000 --- a/templates/nginx/html/README.md +++ /dev/null @@ -1 +0,0 @@ -1. **basic.conf** - HTML NGINX configuration file. \ No newline at end of file diff --git a/templates/nginx/html/basic.conf b/templates/nginx/html/basic.conf deleted file mode 100644 index 7856f2fc..00000000 --- a/templates/nginx/html/basic.conf +++ /dev/null @@ -1,19 +0,0 @@ -# HTML NGINX CONFIGURATION - -server { - - server_name example.com www.example.com; - - access_log /var/log/nginx/example.com.access.log; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.html index.htm; - - location / { - try_files $uri $uri/ /index.html; - } - - include common/locations.conf; - -} diff --git a/templates/nginx/mysql/README.md b/templates/nginx/mysql/README.md deleted file mode 100644 index 23f83945..00000000 --- a/templates/nginx/mysql/README.md +++ /dev/null @@ -1 +0,0 @@ -1. **basic.conf** - MYSQL NGINX configuration \ No newline at end of file diff --git a/templates/nginx/mysql/basic.conf b/templates/nginx/mysql/basic.conf deleted file mode 100644 index 542fd96d..00000000 --- a/templates/nginx/mysql/basic.conf +++ /dev/null @@ -1,16 +0,0 @@ -# MYSQL NGINX CONFIGURATION - -server { - - server_name example.com www.example.com; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/php.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/php/README.md b/templates/nginx/php/README.md deleted file mode 100644 index 05626617..00000000 --- a/templates/nginx/php/README.md +++ /dev/null @@ -1 +0,0 @@ -1. **basic.conf** - PHP NGINX configuration file. \ No newline at end of file diff --git a/templates/nginx/php/basic.conf b/templates/nginx/php/basic.conf deleted file mode 100644 index d41768c9..00000000 --- a/templates/nginx/php/basic.conf +++ /dev/null @@ -1,16 +0,0 @@ -# PHP NGINX CONFIGURATION - -server { - - server_name example.com www.example.com; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/php.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wp/README.md b/templates/nginx/wp/README.md deleted file mode 100644 index abdce904..00000000 --- a/templates/nginx/wp/README.md +++ /dev/null @@ -1,4 +0,0 @@ -1. **basic.conf** - WordPress Single site BASIC NGINX configuration file. -1. **w3tc.conf** - WordPress Single site W3 Total Cache NGINX configuration file. -1. **wpfc.conf** - WordPress Single site FAST CGI NGINX configuration file. -1. **wpsc.conf** - WordPress Single site WP SUPER CACHE NGINX configuration file. \ No newline at end of file diff --git a/templates/nginx/wp/basic.conf b/templates/nginx/wp/basic.conf deleted file mode 100644 index 61e26f63..00000000 --- a/templates/nginx/wp/basic.conf +++ /dev/null @@ -1,17 +0,0 @@ -# WPSINGLE BASIC NGINX CONFIGURATION - -server { - - server_name example.com www.example.com; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/php.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wp/w3tc.conf b/templates/nginx/wp/w3tc.conf deleted file mode 100644 index f3f4da97..00000000 --- a/templates/nginx/wp/w3tc.conf +++ /dev/null @@ -1,17 +0,0 @@ -# WPSINGLE W3 TOTAL CACHE NGINX CONFIGURATION - -server { - - server_name example.com www.example.com; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/w3tc.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wp/wpfc.conf b/templates/nginx/wp/wpfc.conf deleted file mode 100644 index 68c33a51..00000000 --- a/templates/nginx/wp/wpfc.conf +++ /dev/null @@ -1,17 +0,0 @@ -# WPSINGLE FASTCGI NGINX CONFIGURATION - -server { - - server_name example.com www.example.com; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/wpfc.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wp/wpsc.conf b/templates/nginx/wp/wpsc.conf deleted file mode 100644 index aaff01e8..00000000 --- a/templates/nginx/wp/wpsc.conf +++ /dev/null @@ -1,17 +0,0 @@ -# WPSINGLE WP SUPER CACHE NGINX CONFIGURATION - -server { - - server_name example.com www.example.com; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/wpsc.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wpsubdir/README.md b/templates/nginx/wpsubdir/README.md deleted file mode 100644 index 1936822d..00000000 --- a/templates/nginx/wpsubdir/README.md +++ /dev/null @@ -1,4 +0,0 @@ -1. **basic.conf** - WPSUBDIR BASIC NGINX CONFIGURATION file. -1. **w3tc.conf** - WPSUBDIR W3 TOTAL CACHE NGINX CONFIGURATION file. -1. **wpfc.conf** - WPSUBDIR FAST CGI NGINX CONFIGURATION file. -1. **wpsc.conf** - WPSUBDIR WP SUPER CACHE NGINX CONFIGURATION file. \ No newline at end of file diff --git a/templates/nginx/wpsubdir/basic.conf b/templates/nginx/wpsubdir/basic.conf deleted file mode 100644 index c0ab710e..00000000 --- a/templates/nginx/wpsubdir/basic.conf +++ /dev/null @@ -1,24 +0,0 @@ -# WPSUBDIR BASIC NGINX CONFIGURATION - -server { - - # Uncomment the following line for domain mapping - # listen 80 default_server; - - server_name example.com *.example.com; - - # Uncomment the following line for domain mapping - #server_name_in_redirect off; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/php.conf; - include common/wpsubdir.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wpsubdir/w3tc.conf b/templates/nginx/wpsubdir/w3tc.conf deleted file mode 100644 index f61e520f..00000000 --- a/templates/nginx/wpsubdir/w3tc.conf +++ /dev/null @@ -1,24 +0,0 @@ -# WPSUBDIR W3 TOTAL CACHE NGINX CONFIGURATION - -server { - - # Uncomment the following line for domain mapping - # listen 80 default_server; - - server_name example.com *.example.com; - - # Uncomment the following line for domain mapping - #server_name_in_redirect off; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/w3tc.conf; - include common/wpsubdir.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wpsubdir/wpfc.conf b/templates/nginx/wpsubdir/wpfc.conf deleted file mode 100644 index 556cefda..00000000 --- a/templates/nginx/wpsubdir/wpfc.conf +++ /dev/null @@ -1,24 +0,0 @@ -# WPSUBDIR FASTCGI NGINX CONFIGURATION - -server { - - # Uncomment the following line for domain mapping - # listen 80 default_server; - - server_name example.com *.example.com; - - # Uncomment the following line for domain mapping - #server_name_in_redirect off; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/wpfc.conf; - include common/wpsubdir.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wpsubdir/wpsc.conf b/templates/nginx/wpsubdir/wpsc.conf deleted file mode 100644 index b5563c17..00000000 --- a/templates/nginx/wpsubdir/wpsc.conf +++ /dev/null @@ -1,24 +0,0 @@ -# WPSUBDIR WP SUPER CACHE NGINX CONFIGURATION - -server { - - # Uncomment the following line for domain mapping - # listen 80 default_server; - - server_name example.com *.example.com; - - # Uncomment the following line for domain mapping - #server_name_in_redirect off; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/wpsc.conf; - include common/wpsubdir.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wpsubdomain/README.md b/templates/nginx/wpsubdomain/README.md deleted file mode 100644 index 23dab6b8..00000000 --- a/templates/nginx/wpsubdomain/README.md +++ /dev/null @@ -1,4 +0,0 @@ -1. **basic.conf** - WP Subdomains basic NGINX configuration file. -1. **w3tc.conf** - WP Subdomains W3 Total Cache NGINX configuration file. -1. **wpfc.conf** - WP Subdomains FastCGI NGINX configuration file. -1. **wpsc.conf** - WP Subdomains WP Super Cache NGINX configuration file. \ No newline at end of file diff --git a/templates/nginx/wpsubdomain/basic.conf b/templates/nginx/wpsubdomain/basic.conf deleted file mode 100644 index ec6f3dea..00000000 --- a/templates/nginx/wpsubdomain/basic.conf +++ /dev/null @@ -1,23 +0,0 @@ -# WPSUBDOMAIN BASIC NGINX CONFIGURATION - -server { - - # Uncomment the following line for domain mapping - # listen 80 default_server; - - server_name example.com *.example.com; - - # Uncomment the following line for domain mapping - #server_name_in_redirect off; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/php.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wpsubdomain/w3tc.conf b/templates/nginx/wpsubdomain/w3tc.conf deleted file mode 100644 index 0fa01143..00000000 --- a/templates/nginx/wpsubdomain/w3tc.conf +++ /dev/null @@ -1,23 +0,0 @@ -# WPSUBDOMAIN W3 TOTAL CACHE NGINX CONFIGURATION - -server { - - # Uncomment the following line for domain mapping - # listen 80 default_server; - - server_name example.com *.example.com; - - # Uncomment the following line for domain mapping - #server_name_in_redirect off; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/w3tc.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wpsubdomain/wpfc.conf b/templates/nginx/wpsubdomain/wpfc.conf deleted file mode 100644 index a2e02c85..00000000 --- a/templates/nginx/wpsubdomain/wpfc.conf +++ /dev/null @@ -1,23 +0,0 @@ -# WPSUBDOMAIN FASTCGI NGINX CONFIGURATION - -server { - - # Uncomment the following line for domain mapping - # listen 80 default_server; - - server_name example.com *.example.com; - - # Uncomment the following line for domain mapping - #server_name_in_redirect off; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/wpfc.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} diff --git a/templates/nginx/wpsubdomain/wpsc.conf b/templates/nginx/wpsubdomain/wpsc.conf deleted file mode 100644 index b78e12f7..00000000 --- a/templates/nginx/wpsubdomain/wpsc.conf +++ /dev/null @@ -1,23 +0,0 @@ -# WPSUBDOMAIN WP SUPER CACHE NGINX CONFIGURATION - -server { - - # Uncomment the following line for domain mapping - # listen 80 default_server; - - server_name example.com *.example.com; - - # Uncomment the following line for domain mapping - #server_name_in_redirect off; - - access_log /var/log/nginx/example.com.access.log rt_cache; - error_log /var/log/nginx/example.com.error.log; - - root /var/www/example.com/htdocs; - index index.php index.htm index.html; - - include common/wpsc.conf; - include common/wpcommon.conf; - include common/locations.conf; - -} From c13eb205ca312c7d0b01e61f69739fbb121ff804 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Dec 2014 19:00:27 +0530 Subject: [PATCH 448/829] Updated travis --- .travis.yml | 139 ---------------------------------------------------- 1 file changed, 139 deletions(-) diff --git a/.travis.yml b/.travis.yml index f20bb3fe..b4f13db0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,143 +18,4 @@ before_script: script: - sudo echo -e "[user]\n\tname = Mitesh Shah\n\temail = root@localhost.com" > ~/.gitconfig - sudo echo "Travis Banch = $TRAVIS_BRANCH" -- sudo bash bin/install $TRAVIS_BRANCH -- sudo ee stack install - -- sudo bash ee site create html.com -- sudo bash ee site create html.net --html - -- sudo bash ee site create php.com --php - -- sudo bash ee site create mysql.com --mysql - -- sudo bash ee site create site1.com --wp -- sudo bash ee site create site1.net --basic -- sudo bash ee site create site1.org --wp --basic -- sudo bash ee site create site1.in --basic --wp -- sudo bash ee site create subdomain.site1.in --basic --wp - -- sudo bash ee site create site2.com --wpsc -- sudo bash ee site create site2.net --wp --wpsc -- sudo bash ee site create site2.org --wpsc --wp - -- sudo bash ee site create site3.com --w3tc -- sudo bash ee site create site3.net --wp --w3tc -- sudo bash ee site create site3.org --w3tc --wp - -- sudo bash ee site create site4.com --wpfc -- sudo bash ee site create site4.net --wp --wpfc -- sudo bash ee site create site4.org --wpfc --wp - -- sudo bash ee site create site5.com --wpsubdir -- sudo bash ee site create site5.net --wpsubdir --basic -- sudo bash ee site create site5.org --basic --wpsubdir -- sudo bash ee site create site5.in --wpsubdirectory -- sudo bash ee site create site5.co --wpsubdirectory --basic -- sudo bash ee site create site5.co.in --basic --wpsubdirector - -- sudo bash ee site create site6.com --wpsubdir --wpsc -- sudo bash ee site create site6.net --wpsc --wpsubdir -- sudo bash ee site create site6.org --wpsubdirectory --wpsc -- sudo bash ee site create site6.in --wpsc --wpsubdirectory - -- sudo bash ee site create site7.com --wpsubdir --w3tc -- sudo bash ee site create site7.net --w3tc --wpsubdir -- sudo bash ee site create site7.org --wpsubdirectory --w3tc -- sudo bash ee site create site7.in --w3tc --wpsubdirectory - -- sudo bash ee site create site8.com --wpsubdir --wpfc -- sudo bash ee site create site8.net --wpfc --wpsubdir -- sudo bash ee site create site8.org --wpsubdirectory --wpfc -- sudo bash ee site create site8.in --wpfc --wpsubdirectory - - -- sudo bash ee site create site9.com --wpsubdom -- sudo bash ee site create site9.net --wpsubdom --basic -- sudo bash ee site create site9.org --basic --wpsubdom -- sudo bash ee site create site9.in --wpsubdomain -- sudo bash ee site create site9.co --wpsubdomain --basic -- sudo bash ee site create site9.co.in --basic --wpsubdomain - -- sudo bash ee site create site10.com --wpsubdom --wpsc -- sudo bash ee site create site10.net --wpsc --wpsubdom -- sudo bash ee site create site10.org --wpsubdomain --wpsc -- sudo bash ee site create site10.in --wpsc --wpsubdomain - -- sudo bash ee site create site11.com --wpsubdom --w3tc -- sudo bash ee site create site11.net --w3tc --wpsubdom -- sudo bash ee site create site11.org --wpsubdomain --w3tc -- sudo bash ee site create site11.in --w3tc --wpsubdomain - -- sudo bash ee site create site12.com --wpsubdom --wpfc -- sudo bash ee site create site12.net --wpfc --wpsubdom -- sudo bash ee site create site12.org --wpsubdomain --wpfc -- sudo bash ee site create site12.in --wpfc --wpsubdomain - -- sudo bash ee debug --nginx -- sudo bash ee debug --nginx stop -- sudo bash ee debug --nginx site1.com -- sudo bash ee debug --nginx site1.com --stop - -- sudo bash ee debug -rewrite -- sudo bash ee debug -rewrite --stop -- sudo bash ee debug -rewrite site1.com -- sudo bash ee debug -rewrite site1.com --stop - -- sudo bash ee debug --php -- sudo bash ee debug --php --stop -- sudo bash ee debug --php site1.com -- sudo bash ee debug --php site1.com --stop - -- sudo bash ee debug --fpm -- sudo bash ee debug --fpm --stop -- sudo bash ee debug --fpm site1.com -- sudo bash ee debug --fpm site1.com --stop - -- sudo bash ee debug --mysql -- sudo bash ee debug --mysql --stop -- sudo bash ee debug --mysql site1.com -- sudo bash ee debug --mysql site1.com --smysql - - -- sudo bash ee debug --wp site1.com -- sudo bash ee debug --wp site1.com --stop - -- sudo bash ee debug -- sudo bash ee debug --stop - -- sudo bash ee site create 1.com --html -- sudo bash ee site create 2.com --php -- sudo bash ee site create 3.com --mysql - -- sudo bash ee site update 1.com --wp -- sudo bash ee site update 2.com --wpsubdir - -- sudo bash ee site update 3.com --wpsubdomain -- sudo bash ee site update site1.com --wp --wpfc -- sudo bash ee site update site1.com --wp --w3tc -- sudo bash ee site update site1.com --wp --wpsc - -- sudo bash ee site update site5.com --wpsubdir --wpfc -- sudo bash ee site update site5.com --wpsubdir --w3tc -- sudo bash ee site update site5.com --wpsubdir --wpsc - -- sudo bash ee site update site9.com --wpsubdom --wpfc -- sudo bash ee site update site9.com --wpsubdom --w3tc -- sudo bash ee site update site9.com --wpsubdom --wpsc - -- sudo ee site delete site12.com --no-prompt -- sudo ee site delete site12.net --no-prompt -- sudo ee site delete site12.org --no-prompt - -- sudo bash ee stack install mail - -- sudo bash -c 'cat /var/log/easyengine/*' - - -- sudo ls /var/www/ -- sudo mysql -e "show databases"; - - -- sudo wp --allow-root --info From b54591f5b8c47b15be3f6efaaf73e32590050f0f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 1 Dec 2014 19:16:30 +0530 Subject: [PATCH 449/829] Improved Directory structure --- .gitignore | 10 +++++----- easyengine/LICENSE => LICENSE | 0 {easyengine/config => config}/ee.conf | 0 {easyengine/config => config}/plugins.d/example.conf | 0 easyengine/README.md | 11 ----------- {easyengine/ee => ee}/__init__.py | 0 {easyengine/ee => ee}/cli/__init__.py | 0 {easyengine/ee => ee}/cli/bootstrap.py | 0 {easyengine/ee => ee}/cli/controllers/__init__.py | 0 {easyengine/ee => ee}/cli/controllers/base.py | 0 {easyengine/ee => ee}/cli/controllers/site.py | 0 {easyengine/ee => ee}/cli/ext/__init__.py | 0 {easyengine/ee => ee}/cli/main.py | 0 {easyengine/ee => ee}/cli/plugins/__init__.py | 0 {easyengine/ee => ee}/cli/plugins/example.py | 0 {easyengine/ee => ee}/cli/templates/__init__.py | 0 {easyengine/ee => ee}/core/__init__.py | 0 {easyengine/ee => ee}/core/exc.py | 0 {easyengine/ee => ee}/utils/__init__.py | 0 {easyengine/ee => ee}/utils/test.py | 0 easyengine/requirements.txt => requirements.txt | 0 easyengine/setup.cfg => setup.cfg | 0 easyengine/setup.py => setup.py | 0 {easyengine/tests => tests}/__init__.py | 0 {easyengine/tests => tests}/cli/__init__.py | 0 {easyengine/tests => tests}/cli/ext/__init__.py | 0 {easyengine/tests => tests}/cli/plugins/__init__.py | 0 .../tests => tests}/cli/plugins/test_example.py | 0 {easyengine/tests => tests}/cli/test_ee.py | 0 {easyengine/tests => tests}/core/__init__.py | 0 {easyengine/tests => tests}/core/test_exc.py | 0 31 files changed, 5 insertions(+), 16 deletions(-) rename easyengine/LICENSE => LICENSE (100%) rename {easyengine/config => config}/ee.conf (100%) rename {easyengine/config => config}/plugins.d/example.conf (100%) delete mode 100644 easyengine/README.md rename {easyengine/ee => ee}/__init__.py (100%) rename {easyengine/ee => ee}/cli/__init__.py (100%) rename {easyengine/ee => ee}/cli/bootstrap.py (100%) rename {easyengine/ee => ee}/cli/controllers/__init__.py (100%) rename {easyengine/ee => ee}/cli/controllers/base.py (100%) rename {easyengine/ee => ee}/cli/controllers/site.py (100%) rename {easyengine/ee => ee}/cli/ext/__init__.py (100%) rename {easyengine/ee => ee}/cli/main.py (100%) rename {easyengine/ee => ee}/cli/plugins/__init__.py (100%) rename {easyengine/ee => ee}/cli/plugins/example.py (100%) rename {easyengine/ee => ee}/cli/templates/__init__.py (100%) rename {easyengine/ee => ee}/core/__init__.py (100%) rename {easyengine/ee => ee}/core/exc.py (100%) rename {easyengine/ee => ee}/utils/__init__.py (100%) rename {easyengine/ee => ee}/utils/test.py (100%) rename easyengine/requirements.txt => requirements.txt (100%) rename easyengine/setup.cfg => setup.cfg (100%) rename easyengine/setup.py => setup.py (100%) rename {easyengine/tests => tests}/__init__.py (100%) rename {easyengine/tests => tests}/cli/__init__.py (100%) rename {easyengine/tests => tests}/cli/ext/__init__.py (100%) rename {easyengine/tests => tests}/cli/plugins/__init__.py (100%) rename {easyengine/tests => tests}/cli/plugins/test_example.py (100%) rename {easyengine/tests => tests}/cli/test_ee.py (100%) rename {easyengine/tests => tests}/core/__init__.py (100%) rename {easyengine/tests => tests}/core/test_exc.py (100%) diff --git a/.gitignore b/.gitignore index 7ae37858..d30a7b1f 100644 --- a/.gitignore +++ b/.gitignore @@ -58,8 +58,8 @@ target/ *.swp # Folder created for Nose testing -easyengine/bin/ -easyengine/coverage_report/ -easyengine/include/ -easyengine/local/ -easyengine/man/ +bin/ +coverage_report/ +include/ +local/ +man/ diff --git a/easyengine/LICENSE b/LICENSE similarity index 100% rename from easyengine/LICENSE rename to LICENSE diff --git a/easyengine/config/ee.conf b/config/ee.conf similarity index 100% rename from easyengine/config/ee.conf rename to config/ee.conf diff --git a/easyengine/config/plugins.d/example.conf b/config/plugins.d/example.conf similarity index 100% rename from easyengine/config/plugins.d/example.conf rename to config/plugins.d/example.conf diff --git a/easyengine/README.md b/easyengine/README.md deleted file mode 100644 index 5e127fd4..00000000 --- a/easyengine/README.md +++ /dev/null @@ -1,11 +0,0 @@ -EasyEngine -============================================================================== - -Installation ------------- - -``` -$ pip install -r requirements.txt - -$ python setup.py install -``` diff --git a/easyengine/ee/__init__.py b/ee/__init__.py similarity index 100% rename from easyengine/ee/__init__.py rename to ee/__init__.py diff --git a/easyengine/ee/cli/__init__.py b/ee/cli/__init__.py similarity index 100% rename from easyengine/ee/cli/__init__.py rename to ee/cli/__init__.py diff --git a/easyengine/ee/cli/bootstrap.py b/ee/cli/bootstrap.py similarity index 100% rename from easyengine/ee/cli/bootstrap.py rename to ee/cli/bootstrap.py diff --git a/easyengine/ee/cli/controllers/__init__.py b/ee/cli/controllers/__init__.py similarity index 100% rename from easyengine/ee/cli/controllers/__init__.py rename to ee/cli/controllers/__init__.py diff --git a/easyengine/ee/cli/controllers/base.py b/ee/cli/controllers/base.py similarity index 100% rename from easyengine/ee/cli/controllers/base.py rename to ee/cli/controllers/base.py diff --git a/easyengine/ee/cli/controllers/site.py b/ee/cli/controllers/site.py similarity index 100% rename from easyengine/ee/cli/controllers/site.py rename to ee/cli/controllers/site.py diff --git a/easyengine/ee/cli/ext/__init__.py b/ee/cli/ext/__init__.py similarity index 100% rename from easyengine/ee/cli/ext/__init__.py rename to ee/cli/ext/__init__.py diff --git a/easyengine/ee/cli/main.py b/ee/cli/main.py similarity index 100% rename from easyengine/ee/cli/main.py rename to ee/cli/main.py diff --git a/easyengine/ee/cli/plugins/__init__.py b/ee/cli/plugins/__init__.py similarity index 100% rename from easyengine/ee/cli/plugins/__init__.py rename to ee/cli/plugins/__init__.py diff --git a/easyengine/ee/cli/plugins/example.py b/ee/cli/plugins/example.py similarity index 100% rename from easyengine/ee/cli/plugins/example.py rename to ee/cli/plugins/example.py diff --git a/easyengine/ee/cli/templates/__init__.py b/ee/cli/templates/__init__.py similarity index 100% rename from easyengine/ee/cli/templates/__init__.py rename to ee/cli/templates/__init__.py diff --git a/easyengine/ee/core/__init__.py b/ee/core/__init__.py similarity index 100% rename from easyengine/ee/core/__init__.py rename to ee/core/__init__.py diff --git a/easyengine/ee/core/exc.py b/ee/core/exc.py similarity index 100% rename from easyengine/ee/core/exc.py rename to ee/core/exc.py diff --git a/easyengine/ee/utils/__init__.py b/ee/utils/__init__.py similarity index 100% rename from easyengine/ee/utils/__init__.py rename to ee/utils/__init__.py diff --git a/easyengine/ee/utils/test.py b/ee/utils/test.py similarity index 100% rename from easyengine/ee/utils/test.py rename to ee/utils/test.py diff --git a/easyengine/requirements.txt b/requirements.txt similarity index 100% rename from easyengine/requirements.txt rename to requirements.txt diff --git a/easyengine/setup.cfg b/setup.cfg similarity index 100% rename from easyengine/setup.cfg rename to setup.cfg diff --git a/easyengine/setup.py b/setup.py similarity index 100% rename from easyengine/setup.py rename to setup.py diff --git a/easyengine/tests/__init__.py b/tests/__init__.py similarity index 100% rename from easyengine/tests/__init__.py rename to tests/__init__.py diff --git a/easyengine/tests/cli/__init__.py b/tests/cli/__init__.py similarity index 100% rename from easyengine/tests/cli/__init__.py rename to tests/cli/__init__.py diff --git a/easyengine/tests/cli/ext/__init__.py b/tests/cli/ext/__init__.py similarity index 100% rename from easyengine/tests/cli/ext/__init__.py rename to tests/cli/ext/__init__.py diff --git a/easyengine/tests/cli/plugins/__init__.py b/tests/cli/plugins/__init__.py similarity index 100% rename from easyengine/tests/cli/plugins/__init__.py rename to tests/cli/plugins/__init__.py diff --git a/easyengine/tests/cli/plugins/test_example.py b/tests/cli/plugins/test_example.py similarity index 100% rename from easyengine/tests/cli/plugins/test_example.py rename to tests/cli/plugins/test_example.py diff --git a/easyengine/tests/cli/test_ee.py b/tests/cli/test_ee.py similarity index 100% rename from easyengine/tests/cli/test_ee.py rename to tests/cli/test_ee.py diff --git a/easyengine/tests/core/__init__.py b/tests/core/__init__.py similarity index 100% rename from easyengine/tests/core/__init__.py rename to tests/core/__init__.py diff --git a/easyengine/tests/core/test_exc.py b/tests/core/test_exc.py similarity index 100% rename from easyengine/tests/core/test_exc.py rename to tests/core/test_exc.py From dfa94df65e6e3ae403c284e531fe4cdb98479676 Mon Sep 17 00:00:00 2001 From: Harshad Yeola Date: Tue, 2 Dec 2014 11:17:41 +0530 Subject: [PATCH 450/829] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 2595f07c..39550f8b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,17 @@ +How To setup this version on your system?? + +```bash +git clone https://github.com/rtCamp/easyengine.git +cd easyengine +virtualenv ./env +source ./env/bin/activate +python setup.py develop +ee --help +``` + + + EasyEngine 3.x Developement version From f6f81cfc6c8a99726472d4587cc92ac0763b0a0b Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Tue, 2 Dec 2014 11:26:46 +0530 Subject: [PATCH 451/829] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 39550f8b..1d187770 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ git clone https://github.com/rtCamp/easyengine.git cd easyengine virtualenv ./env source ./env/bin/activate -python setup.py develop +pip3 install -r requirements.txt +python3 setup.py develop ee --help ``` From 20e0fb6397097b449e62b9c5bc64458aa88f1c5c Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Tue, 2 Dec 2014 11:28:11 +0530 Subject: [PATCH 452/829] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d187770..29495098 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ git clone https://github.com/rtCamp/easyengine.git cd easyengine virtualenv ./env source ./env/bin/activate -pip3 install -r requirements.txt -python3 setup.py develop +sudo pip3 install -r requirements.txt +sudo python3 setup.py develop ee --help ``` From f491be20858c0f83f23db2e1bea469ca48cf60e8 Mon Sep 17 00:00:00 2001 From: Harshad Yeola Date: Tue, 2 Dec 2014 11:32:58 +0530 Subject: [PATCH 453/829] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 29495098..30e80aba 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ How To setup this version on your system?? ```bash git clone https://github.com/rtCamp/easyengine.git cd easyengine +git checkout python virtualenv ./env source ./env/bin/activate sudo pip3 install -r requirements.txt From 0749939efc580a936fdfc106a6d58e76f8ef3381 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Dec 2014 11:52:00 +0530 Subject: [PATCH 454/829] Fixed Python3 dependecies --- ee/cli/controllers/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index 357c30ed..0b08fcb5 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -14,7 +14,7 @@ class EEBaseController(CementBaseController): @expose(hide=True) def default(self): - print "Inside EEBaseController.default()." + print("Inside EEBaseController.default().") # If using an output handler such as 'mustache', you could also # render a data dictionary using a template. For example: From 50626c8a2567f892e826d8a385c35e4dbffef0f5 Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Tue, 2 Dec 2014 11:53:29 +0530 Subject: [PATCH 455/829] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 30e80aba..074a3b83 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ How To setup this version on your system?? ```bash +sudo pip3 install virtulenv git clone https://github.com/rtCamp/easyengine.git cd easyengine git checkout python From c6a2d050a9aa70d723ecf2c7cba9ea80649261b1 Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Tue, 2 Dec 2014 11:58:32 +0530 Subject: [PATCH 456/829] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 074a3b83..7e9f57db 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ How To setup this version on your system?? ```bash -sudo pip3 install virtulenv +sudo pip3 install virtualenv git clone https://github.com/rtCamp/easyengine.git cd easyengine git checkout python From dd3b143a5fc6b4dbc36ed4c9714471b6a62dfed8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Dec 2014 12:09:35 +0530 Subject: [PATCH 457/829] Fixed Controller are not working --- ee/cli/bootstrap.py | 2 ++ ee/cli/controllers/site.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index 86fd4047..8364e54f 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -5,6 +5,8 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController +from ee.cli.controllers.site import EESiteController def load(app): handler.register(EEBaseController) + handler.register(EESiteController) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 4c691110..277f69f2 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -5,10 +5,10 @@ from cement.core.controller import CementBaseController, expose class EESiteController(CementBaseController): class Meta: label = 'site' - interface = controller.IController stacked_on = 'base' stacked_type = 'nested' description = 'site command manges website configuration with the help of the following subcommands' + arguments = [ (['-f', '--foo'], dict(help='the notorious foo option', dest='foo', action='store', metavar='TEXT') ), @@ -16,7 +16,7 @@ class EESiteController(CementBaseController): @expose(hide=True) def default(self): - print "Inside EESiteController.default()." + print("Inside EESiteController.default().") # If using an output handler such as 'mustache', you could also # render a data dictionary using a template. For example: From 980bb2da49c3abe3973e2e0b16ff239806b6d462 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 2 Dec 2014 12:55:49 +0530 Subject: [PATCH 458/829] More Controllers --- ee/cli/bootstrap.py | 6 ++++++ ee/cli/controllers/clean.py | 34 ++++++++++++++++++++++++++++++++++ ee/cli/controllers/debug.py | 34 ++++++++++++++++++++++++++++++++++ ee/cli/controllers/site.py | 6 +++++- ee/cli/controllers/stack.py | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 ee/cli/controllers/clean.py create mode 100644 ee/cli/controllers/debug.py create mode 100644 ee/cli/controllers/stack.py diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index 8364e54f..51f4bb7f 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -6,7 +6,13 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController from ee.cli.controllers.site import EESiteController +from ee.cli.controllers.stack import EEStackController +from ee.cli.controllers.debug import EEDebugController +from ee.cli.controllers.clean import EECleanController def load(app): handler.register(EEBaseController) handler.register(EESiteController) + handler.register(EEStackController) + handler.register(EEDebugController) + handler.register(EECleanController) diff --git a/ee/cli/controllers/clean.py b/ee/cli/controllers/clean.py new file mode 100644 index 00000000..5e5db335 --- /dev/null +++ b/ee/cli/controllers/clean.py @@ -0,0 +1,34 @@ +"""EasyEngine site controller.""" + +from cement.core.controller import CementBaseController, expose + +class EECleanController(CementBaseController): + class Meta: + label = 'clean' + interface = controller.IController + stacked_on = 'base' + stacked_type = 'nested' + description = 'clean command cleans different cache with following options' + (['-f', '--foo'], + dict(help='the notorious foo option', dest='foo', action='store', + metavar='TEXT') ), + ] + + @expose(hide=True) + def default(self): + # Default action for ee clean command + print ("Inside EECleanController.default().") + + # clean command Options and subcommand calls and definations to + # mention here + + # If using an output handler such as 'mustache', you could also + # render a data dictionary using a template. For example: + # + # data = dict(foo='bar') + # self.app.render(data, 'default.mustache') + # + # + # The 'default.mustache' file would be loaded from + # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + # diff --git a/ee/cli/controllers/debug.py b/ee/cli/controllers/debug.py new file mode 100644 index 00000000..84395f37 --- /dev/null +++ b/ee/cli/controllers/debug.py @@ -0,0 +1,34 @@ +"""EasyEngine site controller.""" + +from cement.core.controller import CementBaseController, expose + +class EEDebugController(CementBaseController): + class Meta: + label = 'debug' + interface = controller.IController + stacked_on = 'base' + stacked_type = 'nested' + description = 'debug command used for debugging issued with stack or site specific configuration' + (['-f', '--foo'], + dict(help='the notorious foo option', dest='foo', action='store', + metavar='TEXT') ), + ] + + @expose(hide=True) + def default(self): + # Default action for ee debug command + print ("Inside EEDebugController.default().") + + # debug command Options and subcommand calls and definations to + # mention here + + # If using an output handler such as 'mustache', you could also + # render a data dictionary using a template. For example: + # + # data = dict(foo='bar') + # self.app.render(data, 'default.mustache') + # + # + # The 'default.mustache' file would be loaded from + # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + # diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 277f69f2..82283b23 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -7,7 +7,7 @@ class EESiteController(CementBaseController): label = 'site' stacked_on = 'base' stacked_type = 'nested' - description = 'site command manges website configuration with the help of the following subcommands' + description = 'site command manages website configuration with the help of the following subcommands' arguments = [ (['-f', '--foo'], dict(help='the notorious foo option', dest='foo', action='store', @@ -16,8 +16,12 @@ class EESiteController(CementBaseController): @expose(hide=True) def default(self): + # Default action for ee site command print("Inside EESiteController.default().") + # site command Options and subcommand calls and definations to + # mention here + # If using an output handler such as 'mustache', you could also # render a data dictionary using a template. For example: # diff --git a/ee/cli/controllers/stack.py b/ee/cli/controllers/stack.py new file mode 100644 index 00000000..11f3c48f --- /dev/null +++ b/ee/cli/controllers/stack.py @@ -0,0 +1,34 @@ +"""EasyEngine site controller.""" + +from cement.core.controller import CementBaseController, expose + +class EEStackController(CementBaseController): + class Meta: + label = 'stack' + interface = controller.IController + stacked_on = 'base' + stacked_type = 'nested' + description = 'stack command manages stack operations' + (['-f', '--foo'], + dict(help='the notorious foo option', dest='foo', action='store', + metavar='TEXT') ), + ] + + @expose(hide=True) + def default(self): + # Default action for ee stack command + print ("Inside EEStackController.default().") + + # stack command Options and subcommand calls and definations to + # mention here + + # If using an output handler such as 'mustache', you could also + # render a data dictionary using a template. For example: + # + # data = dict(foo='bar') + # self.app.render(data, 'default.mustache') + # + # + # The 'default.mustache' file would be loaded from + # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + # From cdd611d0d9b247f96c665f66516afabc5ee957f4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Dec 2014 13:29:29 +0530 Subject: [PATCH 459/829] Fixed code --- ee/cli/controllers/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/controllers/stack.py b/ee/cli/controllers/stack.py index 11f3c48f..e83deb27 100644 --- a/ee/cli/controllers/stack.py +++ b/ee/cli/controllers/stack.py @@ -5,10 +5,10 @@ from cement.core.controller import CementBaseController, expose class EEStackController(CementBaseController): class Meta: label = 'stack' - interface = controller.IController stacked_on = 'base' stacked_type = 'nested' description = 'stack command manages stack operations' + arguments = [ (['-f', '--foo'], dict(help='the notorious foo option', dest='foo', action='store', metavar='TEXT') ), From 4b7709ced6e32cfc2ffd50affa11f1480d475b4c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Dec 2014 13:35:04 +0530 Subject: [PATCH 460/829] Fixed not working code --- ee/cli/controllers/clean.py | 2 +- ee/cli/controllers/debug.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/controllers/clean.py b/ee/cli/controllers/clean.py index 5e5db335..5a4db7c9 100644 --- a/ee/cli/controllers/clean.py +++ b/ee/cli/controllers/clean.py @@ -5,10 +5,10 @@ from cement.core.controller import CementBaseController, expose class EECleanController(CementBaseController): class Meta: label = 'clean' - interface = controller.IController stacked_on = 'base' stacked_type = 'nested' description = 'clean command cleans different cache with following options' + arguments = [ (['-f', '--foo'], dict(help='the notorious foo option', dest='foo', action='store', metavar='TEXT') ), diff --git a/ee/cli/controllers/debug.py b/ee/cli/controllers/debug.py index 84395f37..45be835c 100644 --- a/ee/cli/controllers/debug.py +++ b/ee/cli/controllers/debug.py @@ -5,10 +5,10 @@ from cement.core.controller import CementBaseController, expose class EEDebugController(CementBaseController): class Meta: label = 'debug' - interface = controller.IController stacked_on = 'base' stacked_type = 'nested' description = 'debug command used for debugging issued with stack or site specific configuration' + arguments = [ (['-f', '--foo'], dict(help='the notorious foo option', dest='foo', action='store', metavar='TEXT') ), From b44638b40e268937af08fdbaedb2166c98fcae66 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Dec 2014 15:24:24 +0530 Subject: [PATCH 461/829] Added Dummy core, so that we can write other core easily --- ee/cli/controllers/site.py | 2 ++ ee/core/dummy.py | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 ee/core/dummy.py diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 82283b23..3bc41b8c 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -1,6 +1,7 @@ """EasyEngine site controller.""" from cement.core.controller import CementBaseController, expose +from ee.core.dummy import EEDummy class EESiteController(CementBaseController): class Meta: @@ -18,6 +19,7 @@ class EESiteController(CementBaseController): def default(self): # Default action for ee site command print("Inside EESiteController.default().") + EEDummy.dummy() # site command Options and subcommand calls and definations to # mention here diff --git a/ee/core/dummy.py b/ee/core/dummy.py new file mode 100644 index 00000000..407187fd --- /dev/null +++ b/ee/core/dummy.py @@ -0,0 +1,9 @@ +"""EasyEngine dummy core classes.""" + +class EEDummy(): + """Generic errors.""" + def __init__(): + pass + + def dummy(): + print("Dummy Funtion") From 722d30b791c1acaa869311ef7592623c430f8675 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 2 Dec 2014 15:29:08 +0530 Subject: [PATCH 462/829] Typo :P --- ee/core/dummy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/dummy.py b/ee/core/dummy.py index 407187fd..9c7b423e 100644 --- a/ee/core/dummy.py +++ b/ee/core/dummy.py @@ -6,4 +6,4 @@ class EEDummy(): pass def dummy(): - print("Dummy Funtion") + print("Dummy Function") From 280c088982b0942f48d5627c4c59548d718e4fa0 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 2 Dec 2014 15:40:34 +0530 Subject: [PATCH 463/829] ee site subcommands --- ee/cli/controllers/site.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 3bc41b8c..9999a4dc 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -19,7 +19,42 @@ class EESiteController(CementBaseController): def default(self): # Default action for ee site command print("Inside EESiteController.default().") - EEDummy.dummy() + + def create(self): + # Write code for ee site create command here + print("Inside EESiteController.create().") + + def delete(self): + # Write code for ee site delete command here + print("Inside EESiteController.delete().") + + def enable(self): + # Write code for ee site enable command here + print("Inside EESiteController.enable().") + + def disable(self): + # Write code for ee site disable command here + print("Inside EESiteController.disable().") + + def info(self): + # Write code for ee site info command here + print("Inside EESiteController.info().") + + def log(self): + # Write code for ee site log command here + print("Inside EESiteController.log().") + + def edit(self): + # Write code for ee site edit command here + print("Inside EESiteController.edit().") + + def show(self): + # Write code for ee site edit command here + print("Inside EESiteController.show().") + + def list(self): + # Write code for ee site list command here + print("Inside EESiteController.list().") # site command Options and subcommand calls and definations to # mention here From 231782954680b6804029947221168d6a713d1729 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 2 Dec 2014 16:50:53 +0530 Subject: [PATCH 464/829] more ee site subcommands --- ee/cli/controllers/site.py | 39 ++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 9999a4dc..e3b69f6e 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -17,45 +17,64 @@ class EESiteController(CementBaseController): @expose(hide=True) def default(self): - # Default action for ee site command + # TODO Default action for ee site command print("Inside EESiteController.default().") + @expose(hide=True) def create(self): - # Write code for ee site create command here + # TODO Write code for ee site create command here print("Inside EESiteController.create().") + @expose(hide=True) def delete(self): - # Write code for ee site delete command here + # TODO Write code for ee site delete command here print("Inside EESiteController.delete().") + @expose(hide=True) def enable(self): - # Write code for ee site enable command here + # TODO Write code for ee site enable command here print("Inside EESiteController.enable().") + @expose(hide=True) def disable(self): - # Write code for ee site disable command here + # TODO Write code for ee site disable command here print("Inside EESiteController.disable().") + @expose(hide=True) def info(self): - # Write code for ee site info command here + # TODO Write code for ee site info command here print("Inside EESiteController.info().") + @expose(hide=True) def log(self): - # Write code for ee site log command here + # TODO Write code for ee site log command here print("Inside EESiteController.log().") + @expose(hide=True) def edit(self): - # Write code for ee site edit command here + # TODO Write code for ee site edit command here print("Inside EESiteController.edit().") + @expose(hide=True) def show(self): - # Write code for ee site edit command here + # TODO Write code for ee site edit command here print("Inside EESiteController.show().") + @expose(hide=True) def list(self): - # Write code for ee site list command here + # TODO Write code for ee site list command here print("Inside EESiteController.list().") + @expose(hide=True) + def cd(self): + # TODO Write code for ee site cd here + print("Inside EESiteController.cd().") + + @expose(hide=True) + def update(self): + # TODO Write code for ee site update here + print("Inside EESiteController.update().") + # site command Options and subcommand calls and definations to # mention here From b188e2c615bb3c01ad49d7d3ac56786458033083 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 2 Dec 2014 18:01:53 +0530 Subject: [PATCH 465/829] added to help --- ee/cli/controllers/site.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index e3b69f6e..e1ca53b5 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -20,57 +20,57 @@ class EESiteController(CementBaseController): # TODO Default action for ee site command print("Inside EESiteController.default().") - @expose(hide=True) + @expose(help="create site example.com") def create(self): # TODO Write code for ee site create command here print("Inside EESiteController.create().") - @expose(hide=True) + @expose(help="delete site example.com") def delete(self): # TODO Write code for ee site delete command here print("Inside EESiteController.delete().") - @expose(hide=True) + @expose(help="enable site example.com") def enable(self): # TODO Write code for ee site enable command here print("Inside EESiteController.enable().") - @expose(hide=True) + @expose(help="disable site example.com") def disable(self): # TODO Write code for ee site disable command here print("Inside EESiteController.disable().") - @expose(hide=True) + @expose(help="get example.com information") def info(self): # TODO Write code for ee site info command here print("Inside EESiteController.info().") - @expose(hide=True) + @expose(help="Monitor example.com logs") def log(self): # TODO Write code for ee site log command here print("Inside EESiteController.log().") - @expose(hide=True) + @expose(help="Edit example.com's nginx configuration") def edit(self): # TODO Write code for ee site edit command here print("Inside EESiteController.edit().") - @expose(hide=True) + @expose(help="Display example.com's nginx configuration") def show(self): # TODO Write code for ee site edit command here print("Inside EESiteController.show().") - @expose(hide=True) + @expose(help="list sites currently available") def list(self): # TODO Write code for ee site list command here print("Inside EESiteController.list().") - @expose(hide=True) + @expose(help="change to example.com's webroot") def cd(self): # TODO Write code for ee site cd here print("Inside EESiteController.cd().") - @expose(hide=True) + @expose(help="update example.com") def update(self): # TODO Write code for ee site update here print("Inside EESiteController.update().") From cc39662bc142a7acd96ad428f5c7a3d2dd7c306e Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 2 Dec 2014 18:56:16 +0530 Subject: [PATCH 466/829] ee site flags --- ee/cli/controllers/site.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index e1ca53b5..4d527c87 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -10,9 +10,13 @@ class EESiteController(CementBaseController): stacked_type = 'nested' description = 'site command manages website configuration with the help of the following subcommands' arguments = [ - (['-f', '--foo'], - dict(help='the notorious foo option', dest='foo', action='store', - metavar='TEXT') ), + (['site_name'], dict(help='the notorious foo option') ), + (['--html'], dict(help="html site", action='store_true')), + (['--php'], dict(help="php site", action='store_true')), + (['--mysql'], dict(help="mysql site", action='store_true')), + (['--wp'], dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], dict(help="wpsubdomain site", action='store_true')), ] @expose(hide=True) From 851c622d88e386df0c81c3a917e59e26664fabaa Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 3 Dec 2014 14:32:44 +0530 Subject: [PATCH 467/829] ee site controller complete --- ee/cli/bootstrap.py | 4 +++ ee/cli/controllers/site.py | 53 +++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index 51f4bb7f..ba825f6b 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -6,6 +6,8 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController from ee.cli.controllers.site import EESiteController +from ee.cli.controllers.site import EESiteCreateController +from ee.cli.controllers.site import EESiteUpdateController from ee.cli.controllers.stack import EEStackController from ee.cli.controllers.debug import EEDebugController from ee.cli.controllers.clean import EECleanController @@ -13,6 +15,8 @@ from ee.cli.controllers.clean import EECleanController def load(app): handler.register(EEBaseController) handler.register(EESiteController) + handler.register(EESiteCreateController) + handler.register(EESiteUpdateController) handler.register(EEStackController) handler.register(EEDebugController) handler.register(EECleanController) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 4d527c87..2de570af 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -11,12 +11,6 @@ class EESiteController(CementBaseController): description = 'site command manages website configuration with the help of the following subcommands' arguments = [ (['site_name'], dict(help='the notorious foo option') ), - (['--html'], dict(help="html site", action='store_true')), - (['--php'], dict(help="php site", action='store_true')), - (['--mysql'], dict(help="mysql site", action='store_true')), - (['--wp'], dict(help="wordpress site", action='store_true')), - (['--wpsubdir'], dict(help="wpsubdir site", action='store_true')), - (['--wpsubdomain'], dict(help="wpsubdomain site", action='store_true')), ] @expose(hide=True) @@ -24,11 +18,6 @@ class EESiteController(CementBaseController): # TODO Default action for ee site command print("Inside EESiteController.default().") - @expose(help="create site example.com") - def create(self): - # TODO Write code for ee site create command here - print("Inside EESiteController.create().") - @expose(help="delete site example.com") def delete(self): # TODO Write code for ee site delete command here @@ -74,10 +63,6 @@ class EESiteController(CementBaseController): # TODO Write code for ee site cd here print("Inside EESiteController.cd().") - @expose(help="update example.com") - def update(self): - # TODO Write code for ee site update here - print("Inside EESiteController.update().") # site command Options and subcommand calls and definations to # mention here @@ -92,3 +77,41 @@ class EESiteController(CementBaseController): # The 'default.mustache' file would be loaded from # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. # +class EESiteCreateController(CementBaseController): + class Meta: + label = 'create' + stacked_on = 'site' + stacked_type = 'nested' + description = 'create command manages website configuration with the help of the following subcommands' + arguments = [ + (['--html'], dict(help="html site", action='store_true')), + (['--php'], dict(help="php site", action='store_true')), + (['--mysql'], dict(help="mysql site", action='store_true')), + (['--wp'], dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], dict(help="wpsubdomain site", action='store_true')), + ] + + @expose(hide=True) + def default(self): + # TODO Default action for ee site command + print("Inside EESiteCreateController.default().") + +class EESiteUpdateController(CementBaseController): + class Meta: + label = 'update' + stacked_on = 'site' + stacked_type = 'nested' + description = 'update command manages website configuration with the help of the following subcommands' + arguments = [ + (['--html'], dict(help="html site", action='store_true')), + (['--php'], dict(help="php site", action='store_true')), + (['--mysql'], dict(help="mysql site", action='store_true')), + (['--wp'], dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], dict(help="wpsubdomain site", action='store_true')), + ] + @expose(help="update example.com") + def default(self): + # TODO Write code for ee site update here + print("Inside EESiteUpdateController.default().") From b699969ab3d0abe115734a162cb5fbfebfdabc09 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 3 Dec 2014 14:33:46 +0530 Subject: [PATCH 468/829] minor update --- ee/cli/controllers/site.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 2de570af..1ef80860 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -77,6 +77,7 @@ class EESiteController(CementBaseController): # The 'default.mustache' file would be loaded from # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. # + class EESiteCreateController(CementBaseController): class Meta: label = 'create' @@ -84,6 +85,7 @@ class EESiteCreateController(CementBaseController): stacked_type = 'nested' description = 'create command manages website configuration with the help of the following subcommands' arguments = [ + (['site_name'], dict(help='the notorious foo option') ), (['--html'], dict(help="html site", action='store_true')), (['--php'], dict(help="php site", action='store_true')), (['--mysql'], dict(help="mysql site", action='store_true')), @@ -104,6 +106,7 @@ class EESiteUpdateController(CementBaseController): stacked_type = 'nested' description = 'update command manages website configuration with the help of the following subcommands' arguments = [ + (['site_name'], dict(help='website name', nargs="1") ), (['--html'], dict(help="html site", action='store_true')), (['--php'], dict(help="php site", action='store_true')), (['--mysql'], dict(help="mysql site", action='store_true')), From 3bdfb2a17d27e704ed5f72bf2b8f87dd18dbc07a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 3 Dec 2014 18:15:10 +0530 Subject: [PATCH 469/829] ee subcommand controllers --- ee/cli/bootstrap.py | 6 +++ ee/cli/controllers/clean.py | 13 +++++-- ee/cli/controllers/debug.py | 17 +++++++-- ee/cli/controllers/info.py | 21 ++++++++++ ee/cli/controllers/isl.py | 21 ++++++++++ ee/cli/controllers/secure.py | 22 +++++++++++ ee/cli/controllers/site.py | 74 +++++++++++++++++++++++------------- ee/cli/controllers/stack.py | 11 ++++-- 8 files changed, 146 insertions(+), 39 deletions(-) create mode 100644 ee/cli/controllers/info.py create mode 100644 ee/cli/controllers/isl.py create mode 100644 ee/cli/controllers/secure.py diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index ba825f6b..c65a5d3f 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -11,6 +11,9 @@ from ee.cli.controllers.site import EESiteUpdateController from ee.cli.controllers.stack import EEStackController from ee.cli.controllers.debug import EEDebugController from ee.cli.controllers.clean import EECleanController +from ee.cli.controllers.secure import EESecureController +from ee.cli.controllers.isl import EEImportslowlogController +from ee.cli.controllers.info import EEInfoController def load(app): handler.register(EEBaseController) @@ -20,3 +23,6 @@ def load(app): handler.register(EEStackController) handler.register(EEDebugController) handler.register(EECleanController) + handler.register(EEInfoController) + handler.register(EEImportslowlogController) + handler.register(EESecureController) diff --git a/ee/cli/controllers/clean.py b/ee/cli/controllers/clean.py index 5a4db7c9..02fa508c 100644 --- a/ee/cli/controllers/clean.py +++ b/ee/cli/controllers/clean.py @@ -9,14 +9,19 @@ class EECleanController(CementBaseController): stacked_type = 'nested' description = 'clean command cleans different cache with following options' arguments = [ - (['-f', '--foo'], - dict(help='the notorious foo option', dest='foo', action='store', - metavar='TEXT') ), + (['--all'], + dict(help='clean all cache', action='store_true') ), + (['--fastcgi'], + dict(help='clean fastcgi cache', action='store_true')), + (['--memcache'], + dict(help='clean memcache', action='store_true')), + (['--opcache'], + dict(help='clean opcode cache cache', action='store_true')) ] @expose(hide=True) def default(self): - # Default action for ee clean command + # TODO Default action for ee clean command here print ("Inside EECleanController.default().") # clean command Options and subcommand calls and definations to diff --git a/ee/cli/controllers/debug.py b/ee/cli/controllers/debug.py index 45be835c..16022eba 100644 --- a/ee/cli/controllers/debug.py +++ b/ee/cli/controllers/debug.py @@ -9,14 +9,23 @@ class EEDebugController(CementBaseController): stacked_type = 'nested' description = 'debug command used for debugging issued with stack or site specific configuration' arguments = [ - (['-f', '--foo'], - dict(help='the notorious foo option', dest='foo', action='store', - metavar='TEXT') ), + (['--fpm'], + dict(help='debug fpm', action='store_true') ), + (['--mysql'], + dict(help='debug mysql', action='store_true') ), + (['--nginx'], + dict(help='debug nginx', action='store_true') ), + (['--php'], + dict(help='debug php', action='store_true') ), + (['--rewrite'], + dict(help='debug rewrite', action='store_true') ), + (['--stop'], + dict(help='stop debugging', action='store_true') ), ] @expose(hide=True) def default(self): - # Default action for ee debug command + # TODO Default action for ee debug command print ("Inside EEDebugController.default().") # debug command Options and subcommand calls and definations to diff --git a/ee/cli/controllers/info.py b/ee/cli/controllers/info.py new file mode 100644 index 00000000..a79562b1 --- /dev/null +++ b/ee/cli/controllers/info.py @@ -0,0 +1,21 @@ +from cement.core.controller import CementBaseController, expose + +class EEInfoController(CementBaseController): + class Meta: + label = 'info' + stacked_on = 'base' + stacked_type = 'nested' + description = 'info command used for debugging issued with stack or site specific configuration' + arguments = [ + (['--mysql'], + dict(help='get mysql configuration information', action='store_true') ), + (['--php'], + dict(help='get php configuration information', action='store_true') ), + (['--nginx'], + dict(help='get nginx configuration information', action='store_true') ), + ] + + @expose(hide=True) + def default(self): + # Default action for ee debug command + print ("Inside EEInfoController.default().") diff --git a/ee/cli/controllers/isl.py b/ee/cli/controllers/isl.py new file mode 100644 index 00000000..c1222c39 --- /dev/null +++ b/ee/cli/controllers/isl.py @@ -0,0 +1,21 @@ +from cement.core.controller import CementBaseController, expose + +class EEImportslowlogController(CementBaseController): + class Meta: + label = 'import_slow_log' + stacked_on = 'base' + stacked_type = 'nested' + description = 'info command used for debugging issued with stack or site specific configuration' + arguments = [ + (['--mysql'], + dict(help='get mysql configuration information', action='store_true') ), + (['--php'], + dict(help='get php configuration information', action='store_true') ), + (['--nginx'], + dict(help='get nginx configuration information', action='store_true') ), + ] + + @expose(hide=True) + def default(self): + # TODO Default action for ee debug command + print ("Inside EEImprtslowlogController.default().") diff --git a/ee/cli/controllers/secure.py b/ee/cli/controllers/secure.py new file mode 100644 index 00000000..578a5bc8 --- /dev/null +++ b/ee/cli/controllers/secure.py @@ -0,0 +1,22 @@ +from cement.core.controller import CementBaseController, expose + +class EESecureController(CementBaseController): + class Meta: + label = 'secure' + stacked_on = 'base' + stacked_type = 'nested' + description = 'secure command used for debugging issued with stack or site specific configuration' + arguments = [ + (['--ip'], + dict(help='whitelist ip addresses to access admin tools without authentication', + action='store_true') ), + (['--auth'], + dict(help='change http auth credentials', action='store_true') ), + (['--port'], + dict(help='change port for admin tools default is 22222', action='store_true') ), + ] + + @expose(hide=True) + def default(self): + # Default action for ee debug command + print ("Inside EESecureController.default().") diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 1ef80860..3d63d125 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -10,7 +10,8 @@ class EESiteController(CementBaseController): stacked_type = 'nested' description = 'site command manages website configuration with the help of the following subcommands' arguments = [ - (['site_name'], dict(help='the notorious foo option') ), + (['site_name'], + dict(help='website name') ), ] @expose(hide=True) @@ -64,19 +65,7 @@ class EESiteController(CementBaseController): print("Inside EESiteController.cd().") - # site command Options and subcommand calls and definations to - # mention here - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. - # class EESiteCreateController(CementBaseController): class Meta: @@ -85,13 +74,20 @@ class EESiteCreateController(CementBaseController): stacked_type = 'nested' description = 'create command manages website configuration with the help of the following subcommands' arguments = [ - (['site_name'], dict(help='the notorious foo option') ), - (['--html'], dict(help="html site", action='store_true')), - (['--php'], dict(help="php site", action='store_true')), - (['--mysql'], dict(help="mysql site", action='store_true')), - (['--wp'], dict(help="wordpress site", action='store_true')), - (['--wpsubdir'], dict(help="wpsubdir site", action='store_true')), - (['--wpsubdomain'], dict(help="wpsubdomain site", action='store_true')), + (['site_name'], + dict(help='the notorious foo option') ), + (['--html'], + dict(help="html site", action='store_true')), + (['--php'], + dict(help="php site", action='store_true')), + (['--mysql'], + dict(help="mysql site", action='store_true')), + (['--wp'], + dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], + dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], + dict(help="wpsubdomain site", action='store_true')), ] @expose(hide=True) @@ -106,15 +102,39 @@ class EESiteUpdateController(CementBaseController): stacked_type = 'nested' description = 'update command manages website configuration with the help of the following subcommands' arguments = [ - (['site_name'], dict(help='website name', nargs="1") ), - (['--html'], dict(help="html site", action='store_true')), - (['--php'], dict(help="php site", action='store_true')), - (['--mysql'], dict(help="mysql site", action='store_true')), - (['--wp'], dict(help="wordpress site", action='store_true')), - (['--wpsubdir'], dict(help="wpsubdir site", action='store_true')), - (['--wpsubdomain'], dict(help="wpsubdomain site", action='store_true')), + (['site_name'], + dict(help='website name', nargs="1") ), + (['--html'], + dict(help="html site", action='store_true')), + (['--php'], + dict(help="php site", action='store_true')), + (['--mysql'], + dict(help="mysql site", action='store_true')), + (['--wp'], + dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], + dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], + dict(help="wpsubdomain site", action='store_true')), ] @expose(help="update example.com") def default(self): # TODO Write code for ee site update here print("Inside EESiteUpdateController.default().") + + + + + # site command Options and subcommand calls and definations to + # mention here + + # If using an output handler such as 'mustache', you could also + # render a data dictionary using a template. For example: + # + # data = dict(foo='bar') + # self.app.render(data, 'default.mustache') + # + # + # The 'default.mustache' file would be loaded from + # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + # diff --git a/ee/cli/controllers/stack.py b/ee/cli/controllers/stack.py index e83deb27..495a3df3 100644 --- a/ee/cli/controllers/stack.py +++ b/ee/cli/controllers/stack.py @@ -9,14 +9,17 @@ class EEStackController(CementBaseController): stacked_type = 'nested' description = 'stack command manages stack operations' arguments = [ - (['-f', '--foo'], - dict(help='the notorious foo option', dest='foo', action='store', - metavar='TEXT') ), + (['--web'], + dict(help='Install web stack', action='store_true') ), + (['--admin'], + dict(help='Install admin tools stack', action='store_true') ), + (['--mail'], + dict(help='Install mail server stack', action='store_true') ), ] @expose(hide=True) def default(self): - # Default action for ee stack command + # TODO Default action for ee stack command print ("Inside EEStackController.default().") # stack command Options and subcommand calls and definations to From 6c1aa273fbed248c5dd8f550e3242ce51455f3b2 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 4 Dec 2014 11:23:56 +0530 Subject: [PATCH 470/829] modified help text for options in controllers --- ee/cli/controllers/info.py | 2 +- ee/cli/controllers/isl.py | 2 +- ee/cli/controllers/secure.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/cli/controllers/info.py b/ee/cli/controllers/info.py index a79562b1..e7ad9eb8 100644 --- a/ee/cli/controllers/info.py +++ b/ee/cli/controllers/info.py @@ -17,5 +17,5 @@ class EEInfoController(CementBaseController): @expose(hide=True) def default(self): - # Default action for ee debug command + # TODO Default action for ee debug command print ("Inside EEInfoController.default().") diff --git a/ee/cli/controllers/isl.py b/ee/cli/controllers/isl.py index c1222c39..3fffbf68 100644 --- a/ee/cli/controllers/isl.py +++ b/ee/cli/controllers/isl.py @@ -18,4 +18,4 @@ class EEImportslowlogController(CementBaseController): @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EEImprtslowlogController.default().") + print ("Inside EEImportslowlogController.default().") diff --git a/ee/cli/controllers/secure.py b/ee/cli/controllers/secure.py index 578a5bc8..122cfab9 100644 --- a/ee/cli/controllers/secure.py +++ b/ee/cli/controllers/secure.py @@ -18,5 +18,5 @@ class EESecureController(CementBaseController): @expose(hide=True) def default(self): - # Default action for ee debug command + # TODO Default action for ee debug command print ("Inside EESecureController.default().") From b9702673ac57f4c8751304b691803fd53376b058 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Dec 2014 14:01:56 +0530 Subject: [PATCH 471/829] Added apt-get core function structure --- ee/core/aptget.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ee/core/aptget.py diff --git a/ee/core/aptget.py b/ee/core/aptget.py new file mode 100644 index 00000000..aa64c8c0 --- /dev/null +++ b/ee/core/aptget.py @@ -0,0 +1,22 @@ +"""EasyEngine package installation using apt-get module.""" + +Class EEAptGet(): + """Generice apt-get intialisation""" + def __init__(): + # TODO Common method of apt-get module + pass + + """Installation of packages""" + def install(): + # TODO Method to install packages + pass + + """Removal of packages""" + def remove(): + # TODO Method to remove packages + pass + + """Purging of packages""" + def purge(): + # TODO Method to purge packages + pass From a3ddd80dfd34a6131c9b076db2ff3319cde3b3e1 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Dec 2014 14:19:48 +0530 Subject: [PATCH 472/829] Common function for service --- ee/core/services.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 ee/core/services.py diff --git a/ee/core/services.py b/ee/core/services.py new file mode 100644 index 00000000..4b1ca8d4 --- /dev/null +++ b/ee/core/services.py @@ -0,0 +1,6 @@ +"""EasyEngine service start/stop/restart module.""" +class EEService(): + + """Intialization for service""" + def ___init__(): + # TODO method for services From 79e41fc268ee8393932d489e30511b92e0f6bdcf Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Dec 2014 17:07:17 +0530 Subject: [PATCH 473/829] Added some core packages --- ee/core/checkpackage.py | 9 +++++++++ ee/core/domaincheck.py | 17 +++++++++++++++++ ee/core/dummy.py | 1 + ee/core/exc.py | 4 ++++ ee/core/info.py | 23 +++++++++++++++++++++++ ee/core/permissions.py | 8 ++++++++ ee/core/services.py | 4 +++- ee/core/swapcreation.py | 7 +++++++ 8 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 ee/core/checkpackage.py create mode 100644 ee/core/domaincheck.py create mode 100644 ee/core/info.py create mode 100644 ee/core/permissions.py create mode 100644 ee/core/swapcreation.py diff --git a/ee/core/checkpackage.py b/ee/core/checkpackage.py new file mode 100644 index 00000000..3d82150e --- /dev/null +++ b/ee/core/checkpackage.py @@ -0,0 +1,9 @@ +"""EasyEngine package check module.""" + + +class EEPackageCheck(): + + """Intialization for package check""" + def ___init__(): + # TODO Intialization for package check + pass diff --git a/ee/core/domaincheck.py b/ee/core/domaincheck.py new file mode 100644 index 00000000..62b40142 --- /dev/null +++ b/ee/core/domaincheck.py @@ -0,0 +1,17 @@ +"""EasyEngine domain check module.""" +class EEDomainCheck(): + + """Intialization domain check""" + def ___init__(): + # TODO Intialization for domain check + pass + + """Check for proper domain""" + def isdomain(): + # TODO method for doamin check + pass + + """Check for proper Fully qualified domain""" + def isfqdn(): + # TODO method for FQDN check + pass diff --git a/ee/core/dummy.py b/ee/core/dummy.py index 9c7b423e..7c260b6b 100644 --- a/ee/core/dummy.py +++ b/ee/core/dummy.py @@ -1,5 +1,6 @@ """EasyEngine dummy core classes.""" + class EEDummy(): """Generic errors.""" def __init__(): diff --git a/ee/core/exc.py b/ee/core/exc.py index c8a2feb4..06579f41 100644 --- a/ee/core/exc.py +++ b/ee/core/exc.py @@ -1,5 +1,6 @@ """EasyEngine exception classes.""" + class EEError(Exception): """Generic errors.""" def __init__(self, msg): @@ -9,14 +10,17 @@ class EEError(Exception): def __str__(self): return self.msg + class EEConfigError(EEError): """Config related errors.""" pass + class EERuntimeError(EEError): """Generic runtime errors.""" pass + class EEArgumentError(EEError): """Argument related errors.""" pass diff --git a/ee/core/info.py b/ee/core/info.py new file mode 100644 index 00000000..ce28cee8 --- /dev/null +++ b/ee/core/info.py @@ -0,0 +1,23 @@ +"""EasyEngine Nginx, PHP, MySQL info module.""" + + +class EEInfo(): + """Intialization for info""" + def ___init__(): + # TODO common method for info + pass + + """Method to disaply info for PHP""" + def infophp(): + # TODO info for php + pass + + """Method to disaply info for Nginx""" + def infonginx(): + # TODO info for Nginx + pass + + """Method to disaply info for MySQL""" + def infomysql(): + # TODO info for MySQL + pass diff --git a/ee/core/permissions.py b/ee/core/permissions.py new file mode 100644 index 00000000..d0f93623 --- /dev/null +++ b/ee/core/permissions.py @@ -0,0 +1,8 @@ +"""EasyEngine set permission module""" + + +class EESetPermission(): + """Intialization set permission""" + def ___init__(): + # TODO method for set permission + pass diff --git a/ee/core/services.py b/ee/core/services.py index 4b1ca8d4..7f5ac220 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -1,6 +1,8 @@ """EasyEngine service start/stop/restart module.""" -class EEService(): + +class EEService(): """Intialization for service""" def ___init__(): # TODO method for services + pass diff --git a/ee/core/swapcreation.py b/ee/core/swapcreation.py new file mode 100644 index 00000000..822b36ce --- /dev/null +++ b/ee/core/swapcreation.py @@ -0,0 +1,7 @@ +"""EasyEngine swap creation module.""" + +Class EESwapCreation(): + """Generice swap creation intialisation""" + def __init__(): + # TODO method for swap creation + pass From ffe887b82118828c121c5f6d5050fe185b490e54 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 4 Dec 2014 17:22:11 +0530 Subject: [PATCH 474/829] Addded more core modules --- ee/core/git.py | 8 ++++++++ ee/core/symboliclink.py | 8 ++++++++ ee/core/variables.py | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 ee/core/git.py create mode 100644 ee/core/symboliclink.py create mode 100644 ee/core/variables.py diff --git a/ee/core/git.py b/ee/core/git.py new file mode 100644 index 00000000..6a61cb91 --- /dev/null +++ b/ee/core/git.py @@ -0,0 +1,8 @@ +"""EasyEngine GIT module""" + + +class EEGit(): + """Intialization of core variables""" + def ___init__(): + # TODO method for core variables + pass diff --git a/ee/core/symboliclink.py b/ee/core/symboliclink.py new file mode 100644 index 00000000..7cacd2d8 --- /dev/null +++ b/ee/core/symboliclink.py @@ -0,0 +1,8 @@ +"""EasyEngine symbolic link creation module""" + + +class EESymbolicLink(): + """Intialization for symbolic link""" + def ___init__(): + # TODO method for symbolic link + pass diff --git a/ee/core/variables.py b/ee/core/variables.py new file mode 100644 index 00000000..0299fe69 --- /dev/null +++ b/ee/core/variables.py @@ -0,0 +1,8 @@ +"""EasyEngine core variable module""" + + +class EEVariables(): + """Intialization of core variables""" + def ___init__(): + # TODO method for core variables + pass From 7fb7f7dd42f9393bf0659e28ed031dd5a2496945 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 4 Dec 2014 17:44:21 +0530 Subject: [PATCH 475/829] pep8 standard organized code --- ee/cli/controllers/base.py | 7 ++++-- ee/cli/controllers/clean.py | 14 ++++++----- ee/cli/controllers/debug.py | 18 ++++++++------ ee/cli/controllers/info.py | 15 ++++++++---- ee/cli/controllers/isl.py | 15 ++++++++---- ee/cli/controllers/secure.py | 17 ++++++++----- ee/cli/controllers/site.py | 47 ++++++++++++++++++------------------ ee/cli/controllers/stack.py | 9 ++++--- ee/cli/main.py | 1 + ee/utils/test.py | 2 +- tests/cli/test_ee.py | 7 ++++++ 11 files changed, 92 insertions(+), 60 deletions(-) diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index 0b08fcb5..871b3e38 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -2,14 +2,17 @@ from cement.core.controller import CementBaseController, expose + class EEBaseController(CementBaseController): class Meta: label = 'base' - description = 'easyengine is the commandline tool to manage your websites based on wordpress and nginx with easy to use commands.' + description = 'easyengine is the commandline tool to manage your \ + websites based on wordpress and nginx with easy to \ + use commands.' arguments = [ (['-f', '--foo'], dict(help='the notorious foo option', dest='foo', action='store', - metavar='TEXT') ), + metavar='TEXT')), ] @expose(hide=True) diff --git a/ee/cli/controllers/clean.py b/ee/cli/controllers/clean.py index 02fa508c..52b9afdf 100644 --- a/ee/cli/controllers/clean.py +++ b/ee/cli/controllers/clean.py @@ -2,27 +2,29 @@ from cement.core.controller import CementBaseController, expose + class EECleanController(CementBaseController): class Meta: label = 'clean' stacked_on = 'base' stacked_type = 'nested' - description = 'clean command cleans different cache with following options' + description = 'clean command cleans different cache with following \ + options' arguments = [ (['--all'], - dict(help='clean all cache', action='store_true') ), + dict(help='clean all cache', action='store_true')), (['--fastcgi'], - dict(help='clean fastcgi cache', action='store_true')), + dict(help='clean fastcgi cache', action='store_true')), (['--memcache'], - dict(help='clean memcache', action='store_true')), + dict(help='clean memcache', action='store_true')), (['--opcache'], - dict(help='clean opcode cache cache', action='store_true')) + dict(help='clean opcode cache cache', action='store_true')) ] @expose(hide=True) def default(self): # TODO Default action for ee clean command here - print ("Inside EECleanController.default().") + print("Inside EECleanController.default().") # clean command Options and subcommand calls and definations to # mention here diff --git a/ee/cli/controllers/debug.py b/ee/cli/controllers/debug.py index 16022eba..1347c420 100644 --- a/ee/cli/controllers/debug.py +++ b/ee/cli/controllers/debug.py @@ -2,31 +2,33 @@ from cement.core.controller import CementBaseController, expose + class EEDebugController(CementBaseController): class Meta: label = 'debug' stacked_on = 'base' stacked_type = 'nested' - description = 'debug command used for debugging issued with stack or site specific configuration' + description = 'debug command used for debugging issued with stack or \ + site specific configuration' arguments = [ (['--fpm'], - dict(help='debug fpm', action='store_true') ), + dict(help='debug fpm', action='store_true')), (['--mysql'], - dict(help='debug mysql', action='store_true') ), + dict(help='debug mysql', action='store_true')), (['--nginx'], - dict(help='debug nginx', action='store_true') ), + dict(help='debug nginx', action='store_true')), (['--php'], - dict(help='debug php', action='store_true') ), + dict(help='debug php', action='store_true')), (['--rewrite'], - dict(help='debug rewrite', action='store_true') ), + dict(help='debug rewrite', action='store_true')), (['--stop'], - dict(help='stop debugging', action='store_true') ), + dict(help='stop debugging', action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EEDebugController.default().") + print("Inside EEDebugController.default().") # debug command Options and subcommand calls and definations to # mention here diff --git a/ee/cli/controllers/info.py b/ee/cli/controllers/info.py index e7ad9eb8..70e56ae3 100644 --- a/ee/cli/controllers/info.py +++ b/ee/cli/controllers/info.py @@ -1,21 +1,26 @@ from cement.core.controller import CementBaseController, expose + class EEInfoController(CementBaseController): class Meta: label = 'info' stacked_on = 'base' stacked_type = 'nested' - description = 'info command used for debugging issued with stack or site specific configuration' + description = 'info command used for debugging issued with stack or \ + site specific configuration' arguments = [ (['--mysql'], - dict(help='get mysql configuration information', action='store_true') ), + dict(help='get mysql configuration information', + action='store_true')), (['--php'], - dict(help='get php configuration information', action='store_true') ), + dict(help='get php configuration information', + action='store_true')), (['--nginx'], - dict(help='get nginx configuration information', action='store_true') ), + dict(help='get nginx configuration information', + action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EEInfoController.default().") + print("Inside EEInfoController.default().") diff --git a/ee/cli/controllers/isl.py b/ee/cli/controllers/isl.py index 3fffbf68..7ac8d40f 100644 --- a/ee/cli/controllers/isl.py +++ b/ee/cli/controllers/isl.py @@ -1,21 +1,26 @@ from cement.core.controller import CementBaseController, expose + class EEImportslowlogController(CementBaseController): class Meta: label = 'import_slow_log' stacked_on = 'base' stacked_type = 'nested' - description = 'info command used for debugging issued with stack or site specific configuration' + description = 'info command used for debugging issued with stack or \ + site specific configuration' arguments = [ (['--mysql'], - dict(help='get mysql configuration information', action='store_true') ), + dict(help='get mysql configuration information', + action='store_true')), (['--php'], - dict(help='get php configuration information', action='store_true') ), + dict(help='get php configuration information', + action='store_true')), (['--nginx'], - dict(help='get nginx configuration information', action='store_true') ), + dict(help='get nginx configuration information', + action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EEImportslowlogController.default().") + print("Inside EEImportslowlogController.default().") diff --git a/ee/cli/controllers/secure.py b/ee/cli/controllers/secure.py index 122cfab9..17688636 100644 --- a/ee/cli/controllers/secure.py +++ b/ee/cli/controllers/secure.py @@ -1,22 +1,27 @@ from cement.core.controller import CementBaseController, expose + class EESecureController(CementBaseController): class Meta: label = 'secure' stacked_on = 'base' stacked_type = 'nested' - description = 'secure command used for debugging issued with stack or site specific configuration' + description = 'secure command used for debugging issued with stack or \ + site specific configuration' arguments = [ (['--ip'], - dict(help='whitelist ip addresses to access admin tools without authentication', - action='store_true') ), + dict(help='whitelist ip addresses to access admin tools without \ + authentication', + action='store_true')), (['--auth'], - dict(help='change http auth credentials', action='store_true') ), + dict(help='change http auth credentials', + action='store_true')), (['--port'], - dict(help='change port for admin tools default is 22222', action='store_true') ), + dict(help='change port for admin tools default is 22222', + action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee debug command - print ("Inside EESecureController.default().") + print("Inside EESecureController.default().") diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 3d63d125..951e0896 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -3,15 +3,17 @@ from cement.core.controller import CementBaseController, expose from ee.core.dummy import EEDummy + class EESiteController(CementBaseController): class Meta: label = 'site' stacked_on = 'base' stacked_type = 'nested' - description = 'site command manages website configuration with the help of the following subcommands' + description = 'site command manages website configuration with the help \ + of the following subcommands' arguments = [ (['site_name'], - dict(help='website name') ), + dict(help='website name')), ] @expose(hide=True) @@ -65,29 +67,28 @@ class EESiteController(CementBaseController): print("Inside EESiteController.cd().") - - class EESiteCreateController(CementBaseController): class Meta: label = 'create' stacked_on = 'site' stacked_type = 'nested' - description = 'create command manages website configuration with the help of the following subcommands' + description = 'create command manages website configuration with the \ + help of the following subcommands' arguments = [ (['site_name'], - dict(help='the notorious foo option') ), + dict(help='the notorious foo option')), (['--html'], - dict(help="html site", action='store_true')), + dict(help="html site", action='store_true')), (['--php'], - dict(help="php site", action='store_true')), + dict(help="php site", action='store_true')), (['--mysql'], - dict(help="mysql site", action='store_true')), + dict(help="mysql site", action='store_true')), (['--wp'], - dict(help="wordpress site", action='store_true')), + dict(help="wordpress site", action='store_true')), (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), + dict(help="wpsubdir site", action='store_true')), (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), + dict(help="wpsubdomain site", action='store_true')), ] @expose(hide=True) @@ -95,36 +96,36 @@ class EESiteCreateController(CementBaseController): # TODO Default action for ee site command print("Inside EESiteCreateController.default().") + class EESiteUpdateController(CementBaseController): class Meta: label = 'update' stacked_on = 'site' stacked_type = 'nested' - description = 'update command manages website configuration with the help of the following subcommands' + description = 'update command manages website configuration with the \ + help of the following subcommands' arguments = [ (['site_name'], - dict(help='website name', nargs="1") ), + dict(help='website name', nargs="1")), (['--html'], - dict(help="html site", action='store_true')), + dict(help="html site", action='store_true')), (['--php'], - dict(help="php site", action='store_true')), + dict(help="php site", action='store_true')), (['--mysql'], - dict(help="mysql site", action='store_true')), + dict(help="mysql site", action='store_true')), (['--wp'], - dict(help="wordpress site", action='store_true')), + dict(help="wordpress site", action='store_true')), (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), + dict(help="wpsubdir site", action='store_true')), (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), + dict(help="wpsubdomain site", action='store_true')), ] + @expose(help="update example.com") def default(self): # TODO Write code for ee site update here print("Inside EESiteUpdateController.default().") - - - # site command Options and subcommand calls and definations to # mention here diff --git a/ee/cli/controllers/stack.py b/ee/cli/controllers/stack.py index 495a3df3..59b86adc 100644 --- a/ee/cli/controllers/stack.py +++ b/ee/cli/controllers/stack.py @@ -2,6 +2,7 @@ from cement.core.controller import CementBaseController, expose + class EEStackController(CementBaseController): class Meta: label = 'stack' @@ -10,17 +11,17 @@ class EEStackController(CementBaseController): description = 'stack command manages stack operations' arguments = [ (['--web'], - dict(help='Install web stack', action='store_true') ), + dict(help='Install web stack', action='store_true')), (['--admin'], - dict(help='Install admin tools stack', action='store_true') ), + dict(help='Install admin tools stack', action='store_true')), (['--mail'], - dict(help='Install mail server stack', action='store_true') ), + dict(help='Install mail server stack', action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee stack command - print ("Inside EEStackController.default().") + print("Inside EEStackController.default().") # stack command Options and subcommand calls and definations to # mention here diff --git a/ee/cli/main.py b/ee/cli/main.py index 15e59dd9..69cec1e9 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -48,6 +48,7 @@ class EETestApp(EEApp): # to import it as a global (rather than passing it into another class/func) app = EEApp() + def main(): try: # Default our exit status to 0 (non-error) diff --git a/ee/utils/test.py b/ee/utils/test.py index d49f4b88..c8925e97 100644 --- a/ee/utils/test.py +++ b/ee/utils/test.py @@ -3,6 +3,7 @@ from ee.cli.main import EETestApp from cement.utils.test import * + class EETestCase(CementTestCase): app_class = EETestApp @@ -13,4 +14,3 @@ class EETestCase(CementTestCase): def tearDown(self): """Override teardown actions (for every test).""" super(EETestCase, self).tearDown() - diff --git a/tests/cli/test_ee.py b/tests/cli/test_ee.py index 0ea3fef3..e79e172e 100644 --- a/tests/cli/test_ee.py +++ b/tests/cli/test_ee.py @@ -2,8 +2,15 @@ from ee.utils import test + class CliTestCase(test.EETestCase): def test_ee_cli(self): self.app.setup() self.app.run() self.app.close() + + def test_ee_cli_site_create(self): + self.app = EETestApp(argv=['site', 'create', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() From 6b62edc0e4ecf6f8335e90868120bd05b8d74ba2 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 5 Dec 2014 15:17:35 +0530 Subject: [PATCH 476/829] added test cases --- ee/cli/main.py | 5 +++++ ee/core/domaincheck.py | 2 ++ tests/cli/test_ee.py | 51 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/ee/cli/main.py b/ee/cli/main.py index 69cec1e9..5570b781 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -84,5 +84,10 @@ def main(): # Close the application app.close(code) + +def get_test_app(**kw): + app = EEApp(**kw) + return app + if __name__ == '__main__': main() diff --git a/ee/core/domaincheck.py b/ee/core/domaincheck.py index 62b40142..ea318af3 100644 --- a/ee/core/domaincheck.py +++ b/ee/core/domaincheck.py @@ -1,4 +1,6 @@ """EasyEngine domain check module.""" + + class EEDomainCheck(): """Intialization domain check""" diff --git a/tests/cli/test_ee.py b/tests/cli/test_ee.py index e79e172e..ad010863 100644 --- a/tests/cli/test_ee.py +++ b/tests/cli/test_ee.py @@ -1,6 +1,7 @@ """CLI tests for ee.""" from ee.utils import test +from ee.cli.main import get_test_app class CliTestCase(test.EETestCase): @@ -10,7 +11,55 @@ class CliTestCase(test.EETestCase): self.app.close() def test_ee_cli_site_create(self): - self.app = EETestApp(argv=['site', 'create', 'example.com']) + app = get_test_app(argv=['site', 'create', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update(self): + app = get_test_app(argv=['site', 'update', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_delete(self): + app = get_test_app(argv=['site', 'delete', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_cd(self): + app = get_test_app(argv=['site', 'cd', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_log(self): + app = get_test_app(argv=['site', 'log', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_info(self): + app = get_test_app(argv=['site', 'info', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_enable(self): + app = get_test_app(argv=['site', 'enable', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_disable(self): + app = get_test_app(argv=['site', 'disable', 'example.com']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_edit(self): + app = get_test_app(argv=['site', 'edit', 'example.com']) self.app.setup() self.app.run() self.app.close() From 6a1f7bd2cb742051e5c3ee113c834d18c5d2b3ed Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 8 Dec 2014 13:12:16 +0530 Subject: [PATCH 477/829] Output Handler Mustache --- ee/cli/templates/default.mustache | 1 + tests/cli/test_ee.py | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 ee/cli/templates/default.mustache diff --git a/ee/cli/templates/default.mustache b/ee/cli/templates/default.mustache new file mode 100644 index 00000000..c3bb921e --- /dev/null +++ b/ee/cli/templates/default.mustache @@ -0,0 +1 @@ +Inside {{foo}} diff --git a/tests/cli/test_ee.py b/tests/cli/test_ee.py index ad010863..f02da325 100644 --- a/tests/cli/test_ee.py +++ b/tests/cli/test_ee.py @@ -11,55 +11,57 @@ class CliTestCase(test.EETestCase): self.app.close() def test_ee_cli_site_create(self): - app = get_test_app(argv=['site', 'create', 'example.com']) + self.app = get_test_app(argv=['site', 'create', 'example.com']) self.app.setup() self.app.run() + data, output = self.app.last_rendered + self.eq(output, 'Inside EESiteCreateController.default().\n') self.app.close() def test_ee_cli_site_update(self): - app = get_test_app(argv=['site', 'update', 'example.com']) + self.app = get_test_app(argv=['site', 'update', 'example.com']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_delete(self): - app = get_test_app(argv=['site', 'delete', 'example.com']) + self.app = get_test_app(argv=['site', 'delete', 'example.com']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_cd(self): - app = get_test_app(argv=['site', 'cd', 'example.com']) + self.app = get_test_app(argv=['site', 'cd', 'example.com']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_log(self): - app = get_test_app(argv=['site', 'log', 'example.com']) + self.app = get_test_app(argv=['site', 'log', 'example.com']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_info(self): - app = get_test_app(argv=['site', 'info', 'example.com']) + self.app = get_test_app(argv=['site', 'info', 'example.com']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_enable(self): - app = get_test_app(argv=['site', 'enable', 'example.com']) + self.app = get_test_app(argv=['site', 'enable', 'example.com']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_disable(self): - app = get_test_app(argv=['site', 'disable', 'example.com']) + self.app = get_test_app(argv=['site', 'disable', 'example.com']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_edit(self): - app = get_test_app(argv=['site', 'edit', 'example.com']) + self.app = get_test_app(argv=['site', 'edit', 'example.com']) self.app.setup() self.app.run() self.app.close() From 5624c0eac7c340436c67c15f15ca1838f9ec9ac1 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 8 Dec 2014 13:59:49 +0530 Subject: [PATCH 478/829] Minor Update --- ee/cli/controllers/base.py | 5 ++++- ee/cli/controllers/site.py | 5 ++++- ee/cli/main.py | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index 871b3e38..d0ec86f2 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -17,7 +17,10 @@ class EEBaseController(CementBaseController): @expose(hide=True) def default(self): - print("Inside EEBaseController.default().") + data = dict(foo='EEBaseController.default().') + self.app.render((data), 'default.mustache') + + # print("Inside EEBaseController.default().") # If using an output handler such as 'mustache', you could also # render a data dictionary using a template. For example: diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 951e0896..00c92ea1 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -94,7 +94,10 @@ class EESiteCreateController(CementBaseController): @expose(hide=True) def default(self): # TODO Default action for ee site command - print("Inside EESiteCreateController.default().") + data = dict(foo='EESiteCreateController.default().') + self.app.render((data), 'default.mustache') + + # print("Inside EESiteCreateController.default().") class EESiteUpdateController(CementBaseController): diff --git a/ee/cli/main.py b/ee/cli/main.py index 5570b781..b27b734b 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -36,6 +36,11 @@ class EEApp(foundation.CementApp): # Internal plugins (ship with application code) plugin_bootstrap = 'ee.cli.plugins' + extensions = ['mustache', 'json'] + + # default output handler + output_handler = 'mustache' + class EETestApp(EEApp): """A test app that is better suited for testing.""" From cc5fcc4151662c896f235a59bcc1a1e299ed5c4b Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 8 Dec 2014 14:04:05 +0530 Subject: [PATCH 479/829] argument number bug fix --- ee/cli/controllers/site.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py index 00c92ea1..bee9cb9e 100644 --- a/ee/cli/controllers/site.py +++ b/ee/cli/controllers/site.py @@ -109,7 +109,7 @@ class EESiteUpdateController(CementBaseController): help of the following subcommands' arguments = [ (['site_name'], - dict(help='website name', nargs="1")), + dict(help='website name')), (['--html'], dict(help="html site", action='store_true')), (['--php'], From 31afeaa5cb9ecbbec07e5ec391c56e1da6553cdb Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 8 Dec 2014 14:58:47 +0530 Subject: [PATCH 480/829] Addded code for log writing --- ee/cli/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ee/cli/main.py b/ee/cli/main.py index b27b734b..cd2171e4 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -22,6 +22,11 @@ defaults['ee']['template_dir'] = '/var/lib/ee/templates' class EEApp(foundation.CementApp): class Meta: label = 'ee' + + # Log writing to file + #defaults = init_defaults('ee', 'log.logging') + #defaults['log.logging']['file'] = '/tmp/my.log' + config_defaults = defaults # All built-in application bootstrapping (always run) From 2b6be05ee9b317de183256d98926059e4ef8cfed Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Mon, 8 Dec 2014 18:10:21 +0530 Subject: [PATCH 481/829] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e9f57db..85979437 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ sudo pip3 install virtualenv git clone https://github.com/rtCamp/easyengine.git cd easyengine git checkout python -virtualenv ./env +virtualenv ./env --system-site-packages source ./env/bin/activate sudo pip3 install -r requirements.txt sudo python3 setup.py develop From 48094fa6a709b7d1c633d963a6fafc707b9f933d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 9 Dec 2014 17:15:53 +0530 Subject: [PATCH 482/829] Added apt-get --- ee/core/aptget.py | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index aa64c8c0..bcaa16c0 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -1,20 +1,48 @@ """EasyEngine package installation using apt-get module.""" +import apt +import sys -Class EEAptGet(): + +class EEAptGet: """Generice apt-get intialisation""" - def __init__(): - # TODO Common method of apt-get module - pass + + def __init__(self): + self.cache = apt.cache.Cache() """Installation of packages""" - def install(): - # TODO Method to install packages + def update(self): + self.cache.update() pass + """Installation of packages""" + def install(self, packages): + pkg = self.cache[packages] + if pkg.is_installed: + print("pkg already installed") + else: + pkg.mark_install() + try: + self.cache.commit(apt.progress.TextFetchProgress(), + apt.progress.InstallProgress()) + + except Exception as e: + print("Sorry, package installation failed [{err}]" + .format(err=str(e))) + """Removal of packages""" - def remove(): - # TODO Method to remove packages - pass + def remove(self, packages): + pkg = self.cache[packages] + if pkg.is_installed: + pkg.mark_delete() + try: + self.cache.commit() + + except Exception as e: + print("Sorry, package installation failed [{err}]" + .format(err=str(e))) + + else: + print("pkg not installed") """Purging of packages""" def purge(): From 7670c2eeba6a1840c644e5f903f84ca70896438c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 10 Dec 2014 13:05:00 +0530 Subject: [PATCH 483/829] Addded some EasyEngine variables to work with satck --- ee/core/variables.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 0299fe69..52e4fa62 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -4,5 +4,14 @@ class EEVariables(): """Intialization of core variables""" def ___init__(): - # TODO method for core variables - pass + + #EasyEngine core variables + ee_version + + #EasyEngine stack installation varibales + ee_nginx_repo = "ppa:rtcamp/nginx" + ee_nginx = "nginx-full" + ee_php_repo = "ppa:ondrej/php5" + ee_php = "php5" + ee_mysql_repo = "" + ee_mysql = "" From 3491337c692f30ab738f4b22f9449184bfb46698 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 10 Dec 2014 19:48:09 +0530 Subject: [PATCH 484/829] lib to apt-get --- ee/core/aptget.py | 107 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 27 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index bcaa16c0..ade902ca 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -4,47 +4,100 @@ import sys class EEAptGet: - """Generice apt-get intialisation""" + """Generic apt-get intialisation""" def __init__(self): - self.cache = apt.cache.Cache() + self.cache = apt.Cache() + self.fprogress = apt.progress.text.AcquireProgress() + self.iprogress = apt.progress.base.InstallProgress() - """Installation of packages""" def update(self): - self.cache.update() + """Similar to apt-get update""" + self.cache.update(self.fprogress) pass - """Installation of packages""" def install(self, packages): - pkg = self.cache[packages] - if pkg.is_installed: - print("pkg already installed") - else: - pkg.mark_install() - try: - self.cache.commit(apt.progress.TextFetchProgress(), - apt.progress.InstallProgress()) + """Installation of packages""" + my_selected_packages = [] + # Cache Initialization + self.cache = apt.Cache() + # Cache Read + self.cache.open() + for package in packages: + pkg = self.cache[package] + # Check Package Installed + if pkg.is_installed: + # Check Package is Upgradeble + if pkg.is_upgradable: + print("latest version of \'{package_name}\' available." + .format(package_name=pkg.installed)) + else: + print("\'{package_name}-{package_ver.version}\'" + "already the newest version" + .format(package_name=pkg.name, + package_ver=pkg.installed)) + else: + with self.cache.actiongroup(): + # Mark Package for Installation + pkg.mark_install() + my_selected_packages.append(pkg.name) + # Check if packages available for install. + if self.cache.install_count > 0: + print("The following NEW packages will be installed:" + "\n {pkg_name}" + .format(pkg_name=my_selected_packages)) + print("{pkg_install_count} newly installed." + .format(pkg_install_count=self.cache.install_count)) + print("Need to get {req_download} bytes of archives" + .format(req_download=self.cache.required_download)) + print("After this operation, {space} bytes of" + "additional disk space will be used." + .format(space=self.cache.required_space)) + try: + # Commit changes in cache (actually install) + self.cache.commit(self.fprogress, self.iprogress) except Exception as e: - print("Sorry, package installation failed [{err}]" + print("package installation failed[{err}]" .format(err=str(e))) - """Removal of packages""" - def remove(self, packages): - pkg = self.cache[packages] - if pkg.is_installed: - pkg.mark_delete() + def remove(self, packages, purge_value=False): + """Removal of packages Similar to apt-get remove""" + self.__init__() + my_selected_packages = [] + # apt cache Initialization + self.cache = apt.Cache() + # Read cache i.e package list + self.cache.open() + for package in packages: + pkg = self.cache[package] + # Check if packages installed + if pkg.is_installed: + with self.cache.actiongroup(): + # Mark packages for delete + # Mark to purge package if purge_value is True + pkg.mark_delete(purge=purge_value) + my_selected_packages.append(pkg.name) + else: + print("Package '{package_name}' is not installed," + " so not removed." + .format(package_name=packages)) + + # Check if packages available for remove/update. + if self.cache.delete_count > 0: + print("The following NEW packages will be REMOVED:" + "\n {pkg_name}" + .format(pkg_name=my_selected_packages)) + print("{pkg_remove_count} to remove." + .format(pkg_remove_count=self.cache.delete_count)) + print("After this operation, {space} bytes disk spac" + "e will be freed.".format(space=self.cache.required_space)) try: self.cache.commit() - except Exception as e: print("Sorry, package installation failed [{err}]" .format(err=str(e))) - else: - print("pkg not installed") - - """Purging of packages""" - def purge(): - # TODO Method to purge packages - pass + def purge(self, packages): + """Purging of packages similar to apt-get purge""" + self.remove(packages, purge_value=True) From e4e7dfd93233923bd2faf1ecb5a6f4cf9d2da7ac Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Dec 2014 11:47:04 +0530 Subject: [PATCH 485/829] Changed stack to work as plugin --- config/ee.conf | 2 -- config/plugins.d/example.conf | 2 +- config/plugins.d/stack.conf | 8 ++++++++ ee/cli/bootstrap.py | 3 +-- ee/cli/{controllers => plugins}/stack.py | 15 ++++++++++++++- 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 config/plugins.d/stack.conf rename ee/cli/{controllers => plugins}/stack.py (74%) diff --git a/config/ee.conf b/config/ee.conf index 6e2c379a..02078253 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -37,5 +37,3 @@ ### The maximun number of log files to maintain when rotating # max_files = 4 - - diff --git a/config/plugins.d/example.conf b/config/plugins.d/example.conf index 415e8499..b78a2ff5 100644 --- a/config/plugins.d/example.conf +++ b/config/plugins.d/example.conf @@ -5,7 +5,7 @@ ### If enabled, load a plugin named `example` either from the Python module ### `ee.cli.plugins.example` or from the file path ### `/var/lib/ee/plugins/example.py` -enable_plugin = true +enable_plugin = false ### Additional plugin configuration settings foo = bar diff --git a/config/plugins.d/stack.conf b/config/plugins.d/stack.conf new file mode 100644 index 00000000..f7bf9b80 --- /dev/null +++ b/config/plugins.d/stack.conf @@ -0,0 +1,8 @@ +### Example Plugin Configuration for EasyEngine + +[stack] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index c65a5d3f..de3c5108 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -8,19 +8,18 @@ from ee.cli.controllers.base import EEBaseController from ee.cli.controllers.site import EESiteController from ee.cli.controllers.site import EESiteCreateController from ee.cli.controllers.site import EESiteUpdateController -from ee.cli.controllers.stack import EEStackController from ee.cli.controllers.debug import EEDebugController from ee.cli.controllers.clean import EECleanController from ee.cli.controllers.secure import EESecureController from ee.cli.controllers.isl import EEImportslowlogController from ee.cli.controllers.info import EEInfoController + def load(app): handler.register(EEBaseController) handler.register(EESiteController) handler.register(EESiteCreateController) handler.register(EESiteUpdateController) - handler.register(EEStackController) handler.register(EEDebugController) handler.register(EECleanController) handler.register(EEInfoController) diff --git a/ee/cli/controllers/stack.py b/ee/cli/plugins/stack.py similarity index 74% rename from ee/cli/controllers/stack.py rename to ee/cli/plugins/stack.py index 59b86adc..2fff8c84 100644 --- a/ee/cli/controllers/stack.py +++ b/ee/cli/plugins/stack.py @@ -1,6 +1,11 @@ -"""EasyEngine site controller.""" +"""Example Plugin for EasyEngine.""" from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook + +def ee_stack_hook(app): + # do something with the ``app`` object here. + pass class EEStackController(CementBaseController): @@ -36,3 +41,11 @@ class EEStackController(CementBaseController): # The 'default.mustache' file would be loaded from # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. # + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EEStackController) + + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', ee_stack_hook) From 2eec88808bf0698725ec372d4887002c97a04904 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 11 Dec 2014 12:52:04 +0530 Subject: [PATCH 486/829] apt-get upgrade --- ee/core/aptget.py | 76 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 12 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index ade902ca..a67bb1b2 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -16,8 +16,8 @@ class EEAptGet: self.cache.update(self.fprogress) pass - def install(self, packages): - """Installation of packages""" + def upgrade(self, packages): + """Similar to apt-get update""" my_selected_packages = [] # Cache Initialization self.cache = apt.Cache() @@ -29,13 +29,59 @@ class EEAptGet: if pkg.is_installed: # Check Package is Upgradeble if pkg.is_upgradable: - print("latest version of \'{package_name}\' available." - .format(package_name=pkg.installed)) + with self.cache.actiongroup(): + # Mark Package for Upgrade + pkg.mark_upgrade() + my_selected_packages.append(pkg.installed) else: print("\'{package_name}-{package_ver.version}\'" "already the newest version" .format(package_name=pkg.name, package_ver=pkg.installed)) + + # Check if packages available for install. + if len(my_selected_packages) > 0: + print("The following packages will be upgraded:" + "\n {pkg_name}" + .format(pkg_name=my_selected_packages)) + print("{pkg_install_count} newly installed." + .format(pkg_upgrade_count=len(my_selected_packages))) + print("Need to get {req_download} bytes of archives" + .format(req_download=self.cache.required_download)) + print("After this operation, {space} bytes of" + "additional disk space will be used." + .format(space=self.cache.required_space)) + try: + # Commit changes in cache (actually install) + self.cache.commit(self.fprogress, self.iprogress) + except Exception as e: + print("package installation failed. [{err}]" + .format(err=str(e))) + return(False) + return(True) + + def install(self, packages): + """Installation of packages""" + my_selected_packages = [] + # Cache Initialization + self.cache = apt.Cache() + # Cache Read + self.cache.open() + for package in packages: + pkg = self.cache[package] + # Check Package Installed + if pkg.is_installed or pkg.marked_install: + # Check Package is Upgradeble + if pkg.is_upgradable: + print("latest version of \'{package_name}\' available." + .format(package_name=pkg.installed)) + else: + # Check if package already marked for install + if not pkg.marked_install: + print("\'{package_name}-{package_ver}\'" + "already the newest version" + .format(package_name=pkg.name, + package_ver=pkg.installed)) else: with self.cache.actiongroup(): # Mark Package for Installation @@ -58,8 +104,10 @@ class EEAptGet: # Commit changes in cache (actually install) self.cache.commit(self.fprogress, self.iprogress) except Exception as e: - print("package installation failed[{err}]" + print("package installation failed. [{err}]" .format(err=str(e))) + return(False) + return(True) def remove(self, packages, purge_value=False): """Removal of packages Similar to apt-get remove""" @@ -72,20 +120,22 @@ class EEAptGet: for package in packages: pkg = self.cache[package] # Check if packages installed - if pkg.is_installed: + if pkg.is_installed and not pkg.marked_delete: with self.cache.actiongroup(): # Mark packages for delete # Mark to purge package if purge_value is True pkg.mark_delete(purge=purge_value) my_selected_packages.append(pkg.name) else: - print("Package '{package_name}' is not installed," - " so not removed." - .format(package_name=packages)) + # Check If package not already marked for delete + if not pkg.marked_delete: + print("Package '{package_name}' is not installed," + " so not removed." + .format(package_name=package)) # Check if packages available for remove/update. if self.cache.delete_count > 0: - print("The following NEW packages will be REMOVED:" + print("The following packages will be REMOVED:" "\n {pkg_name}" .format(pkg_name=my_selected_packages)) print("{pkg_remove_count} to remove." @@ -93,11 +143,13 @@ class EEAptGet: print("After this operation, {space} bytes disk spac" "e will be freed.".format(space=self.cache.required_space)) try: - self.cache.commit() + self.cache.commit(self.fprogress, self.iprogress) except Exception as e: print("Sorry, package installation failed [{err}]" .format(err=str(e))) + return(False) + return(True) def purge(self, packages): """Purging of packages similar to apt-get purge""" - self.remove(packages, purge_value=True) + return(self.remove(packages, purge_value=True)) From ee8925c683e3037f2533a6d56156eab2eed9dba1 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 11 Dec 2014 14:07:16 +0530 Subject: [PATCH 487/829] ee stack install implimentation --- ee/cli/plugins/stack.py | 95 +++++++++++++++++++++++++++++++++++------ ee/core/variables.py | 29 ++++++++----- 2 files changed, 101 insertions(+), 23 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 2fff8c84..13724ce8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -2,6 +2,9 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook +from ee.core.variables import EEVariables +from ee.core.aptget import EEAptGet + def ee_stack_hook(app): # do something with the ``app`` object here. @@ -21,6 +24,14 @@ class EEStackController(CementBaseController): dict(help='Install admin tools stack', action='store_true')), (['--mail'], dict(help='Install mail server stack', action='store_true')), + (['--nginx'], + dict(help='Install Nginx stack', action='store_true')), + (['--php'], + dict(help='Install PHP stack', action='store_true')), + (['--mysql'], + dict(help='Install MySQL stack', action='store_true')), + (['--postfix'], + dict(help='Install Postfix stack', action='store_true')), ] @expose(hide=True) @@ -28,19 +39,77 @@ class EEStackController(CementBaseController): # TODO Default action for ee stack command print("Inside EEStackController.default().") - # stack command Options and subcommand calls and definations to - # mention here - - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. - # + @expose() + def install(self): + pkg = EEAptGet() + packages = [] + if self.app.pargs.web: + packages = (packages + EEVariables.ee_nginx + EEVariables.ee_php + + EEVariables.ee_mysql) + if self.app.pargs.admin: + pass + #packages = packages + EEVariables.ee_nginx + if self.app.pargs.mail: + pass + #packages = packages + EEVariables.ee_nginx + if self.app.pargs.nginx: + packages = packages + EEVariables.ee_nginx + if self.app.pargs.php: + packages = packages + EEVariables.ee_php + if self.app.pargs.mysql: + packages = packages + EEVariables.ee_mysql + if self.app.pargs.postfix: + packages = packages + EEVariables.ee_postfix + print(packages) + pkg.install(packages) + + @expose() + def remove(self): + pkg = EEAptGet() + packages = [] + if self.app.pargs.web: + packages = (packages + EEVariables.ee_nginx + EEVariables.ee_php + + EEVariables.ee_mysql) + if self.app.pargs.admin: + pass + #packages = packages + EEVariables.ee_nginx + if self.app.pargs.mail: + pass + #packages = packages + EEVariables.ee_nginx + if self.app.pargs.nginx: + packages = packages + EEVariables.ee_nginx + if self.app.pargs.php: + packages = packages + EEVariables.ee_php + if self.app.pargs.mysql: + packages = packages + EEVariables.ee_mysql + if self.app.pargs.postfix: + packages = packages + EEVariables.ee_postfix + print(packages) + pkg.remove(packages) + + @expose() + def purge(self): + pkg = EEAptGet() + packages = [] + if self.app.pargs.web: + packages = (packages + EEVariables.ee_nginx + EEVariables.ee_php + + EEVariables.ee_mysql) + if self.app.pargs.admin: + pass + #packages = packages + EEVariables.ee_nginx + if self.app.pargs.mail: + pass + #packages = packages + EEVariables.ee_nginx + if self.app.pargs.nginx: + packages = packages + EEVariables.ee_nginx + if self.app.pargs.php: + packages = packages + EEVariables.ee_php + if self.app.pargs.mysql: + packages = packages + EEVariables.ee_mysql + if self.app.pargs.postfix: + packages = packages + EEVariables.ee_postfix + print(packages) + pkg.purge(packages) def load(app): diff --git a/ee/core/variables.py b/ee/core/variables.py index 52e4fa62..020927c4 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -3,15 +3,24 @@ class EEVariables(): """Intialization of core variables""" - def ___init__(): - #EasyEngine core variables - ee_version + # EasyEngine core variables + ee_version = "3.0.0" - #EasyEngine stack installation varibales - ee_nginx_repo = "ppa:rtcamp/nginx" - ee_nginx = "nginx-full" - ee_php_repo = "ppa:ondrej/php5" - ee_php = "php5" - ee_mysql_repo = "" - ee_mysql = "" + # EasyEngine stack installation varibales + # Nginx repo and packages + ee_nginx_repo = "ppa:rtcamp/nginx" + ee_nginx = ["nginx-custom"] + + # PHP repo and packages + ee_php_repo = "ppa:ondrej/php5" + ee_php = ["php5-curl", "php5-gd", "php5-cli", "php5-fpm", "php5-imap", + "php5-mcrypt", "php5-xdebug"] + + # MySQL repo and packages + ee_mysql_repo = "" + ee_mysql = ["mysql-server-5.6"] + + # Postfix repo and packages + ee_postfix_repo = "" + ee_postfix = ["postfix"] From 0619d5fb0a067c8fd5f4c2fa4680aed71a94933c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 11 Dec 2014 20:11:57 +0530 Subject: [PATCH 488/829] add repo --- ee/core/apt-repo.py | 29 +++++++++++++++++++++++++++++ ee/core/swapcreation.py | 3 ++- ee/core/variables.py | 7 ++++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 ee/core/apt-repo.py diff --git a/ee/core/apt-repo.py b/ee/core/apt-repo.py new file mode 100644 index 00000000..eae22a2d --- /dev/null +++ b/ee/core/apt-repo.py @@ -0,0 +1,29 @@ + +from ee.core.variables import EEVariables + + +class EERepo(): + """Manage Repositories""" + + def __init__(self): + """Initialize """ + pass + + def add(self, repo_url=None, codename=None, repo_type=None, ppa=None): + # TODO add repository code + repo_file_path = ("/etc/apt/sources.list.d/" + + EEVariables().ee_repo_file) + try: + with open(repo_file_path, "a") as repofile: + repofile.write("\n" + repo_url + " " + codename + + " " + repo_type) + repofile.close() + except Exception as e: + raise + + def remove(self, repo_url=None, codename=None, repo_type=None, ppa=None): + # TODO remove repository + pass + +# if __name__ == '__main__': +# EERepo().add(repo_url="http://ds.asf", codename="trusty", repo_type="main") diff --git a/ee/core/swapcreation.py b/ee/core/swapcreation.py index 822b36ce..ea26542e 100644 --- a/ee/core/swapcreation.py +++ b/ee/core/swapcreation.py @@ -1,6 +1,7 @@ """EasyEngine swap creation module.""" -Class EESwapCreation(): + +class EESwapCreation(): """Generice swap creation intialisation""" def __init__(): # TODO method for swap creation diff --git a/ee/core/variables.py b/ee/core/variables.py index 020927c4..6fb3160f 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -5,7 +5,6 @@ class EEVariables(): """Intialization of core variables""" # EasyEngine core variables - ee_version = "3.0.0" # EasyEngine stack installation varibales # Nginx repo and packages @@ -24,3 +23,9 @@ class EEVariables(): # Postfix repo and packages ee_postfix_repo = "" ee_postfix = ["postfix"] + + # Repo + ee_repo_file = "ee-repo.list" + + def __init__(self): + pass From 5f4b3218158a49570086bf1109677c04afbbb26e Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 12 Dec 2014 15:15:40 +0530 Subject: [PATCH 489/829] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85979437..5399829d 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ How To setup this version on your system?? ```bash +sudo apt-get install python3-pip git sudo pip3 install virtualenv -git clone https://github.com/rtCamp/easyengine.git +git clone -b python https://github.com/rtCamp/easyengine.git cd easyengine -git checkout python virtualenv ./env --system-site-packages source ./env/bin/activate sudo pip3 install -r requirements.txt From aa9e6e30455fbbe3334073e81f63493790fea5a5 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 12 Dec 2014 15:18:37 +0530 Subject: [PATCH 490/829] Added pystache --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 24fb2218..740029cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ cement>=2.4.0 +pystache From e0c5eef84d17c7c12a831742a56cb12a9937f392 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 12 Dec 2014 15:42:54 +0530 Subject: [PATCH 491/829] added python3-apt pystache in setup.py --- setup.py | 67 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/setup.py b/setup.py index 99863cdd..df196b60 100644 --- a/setup.py +++ b/setup.py @@ -1,34 +1,41 @@ from setuptools import setup, find_packages -import sys, os +import sys +import os + setup(name='ee', - version='3.0', - description="EasyEngine is the commandline tool to manage your Websites based on WordPress and NGINX with easy to use commands.", - long_description="EasyEngine is the commandline tool to manage your Websites based on WordPress and NGINX with easy to use commands.", - classifiers=[], - keywords='', - author='rtCamp Soultions Pvt. LTD', - author_email='sys@rtcamp.com', - url='http://rtcamp.com/easyengine', - license='GPL', - packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), - include_package_data=True, - zip_safe=False, - test_suite='nose.collector', - install_requires=[ - ### Required to build documentation - # "Sphinx >= 1.0", - ### Required for testing - # "nose", - # "coverage", - ### Required to function - 'cement', - ], - setup_requires=[], - entry_points=""" - [console_scripts] - ee = ee.cli.main:main - """, - namespace_packages=[], - ) + version='3.0', + description="EasyEngine is the commandline tool to manage your Websites" + " based on WordPress and NGINX with easy to use commands.", + long_description="EasyEngine is the commandline tool to manage your " + "Websites based on WordPress and NGINX with easy" + " to use commands.", + classifiers=[], + keywords='', + author='rtCamp Soultions Pvt. LTD', + author_email='sys@rtcamp.com', + url='http://rtcamp.com/easyengine', + license='GPL', + packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), + include_package_data=True, + zip_safe=False, + test_suite='nose.collector', + install_requires=[ + # Required to build documentation + # "Sphinx >= 1.0", + # Required for testing + # "nose", + # "coverage", + # Required to function + 'cement>=2.4', + 'pystache' + 'python3-apt' + ], + setup_requires=[], + entry_points=""" + [console_scripts] + ee = ee.cli.main:main + """, + namespace_packages=[], + ) From 6d88081a336adae54b80ce9054051b9d4d04732e Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 12 Dec 2014 17:23:30 +0530 Subject: [PATCH 492/829] Removed pystache @harshad added pystache in setup.py --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 740029cd..24fb2218 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ cement>=2.4.0 -pystache From e43862744a8e94631c55b1394a3bbb3d42412d95 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Dec 2014 14:55:41 +0530 Subject: [PATCH 493/829] Core function to download content --- ee/core/download.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ee/core/download.py diff --git a/ee/core/download.py b/ee/core/download.py new file mode 100644 index 00000000..945768f5 --- /dev/null +++ b/ee/core/download.py @@ -0,0 +1,24 @@ +"""EasyEngine download core classes.""" +import urllib.request +import urllib.error + + +class EEDownload(): + """Method to download using urllib""" + def __init__(self): + pass + + def download(self, url, filename): + try: + urllib.request.urlretrieve(url, filename) + return True + except urllib.error.URLError as e: + print("Unable to donwload file, [{err}]".format(err=str(e.reason))) + return False + except urllib.error.HTTPError as e: + print("Package download failed. [{err}]".format(err=str(e.reason))) + return False + except urllib.error.ContentTooShortError as e: + print("Package download failed. The amount of the downloaded data" + "is less than the expected amount") + return False From 115677f8c1f6d398c52b3532a766adc2b304b4d7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Dec 2014 17:12:09 +0530 Subject: [PATCH 494/829] More stuff for ee stack install --- ee/cli/plugins/stack.py | 24 +++++++++++++++++++++++- ee/core/download.py | 4 ++-- ee/core/shellexec.py | 12 ++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 ee/core/shellexec.py diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 13724ce8..104fe1a3 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -4,6 +4,9 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.variables import EEVariables from ee.core.aptget import EEAptGet +from ee.core.donwload import EEDownload +import random +import string def ee_stack_hook(app): @@ -39,6 +42,25 @@ class EEStackController(CementBaseController): # TODO Default action for ee stack command print("Inside EEStackController.default().") + @expose(hide=True) + def preseed_pref(self, packages): + if "postfix" in packages: + EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type" + "string \'Internet Site\'\" | " + "debconf-set-selections") + EEShellExec.cmd_exec("echo \"postfix postfix/mailname string" + "$(hostname -f)\" | debconf-set-selections") + if "mysql" in packages: + chars = ''.join(random.sample(string.letters, 8)) + EEShellExec.cmd_exec("echo \"percona-server-server-5.6" + "percona-server-server/root_password" + "password {pass}\"" + "| debconf-set-selections".format(pass=chars)) + EEShellExec.cmd_exec("echo \"percona-server-server-5.6" + "percona-server-server/root_password_again" + "password {pass}\"" + "| debconf-set-selections".format(pass=chars)) + @expose() def install(self): pkg = EEAptGet() @@ -60,7 +82,7 @@ class EEStackController(CementBaseController): packages = packages + EEVariables.ee_mysql if self.app.pargs.postfix: packages = packages + EEVariables.ee_postfix - print(packages) + self.preseed_pref(packages) pkg.install(packages) @expose() diff --git a/ee/core/download.py b/ee/core/download.py index 945768f5..0f2f45ab 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -5,10 +5,10 @@ import urllib.error class EEDownload(): """Method to download using urllib""" - def __init__(self): + def __init__(): pass - def download(self, url, filename): + def download(url, filename): try: urllib.request.urlretrieve(url, filename) return True diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py new file mode 100644 index 00000000..c95c5645 --- /dev/null +++ b/ee/core/shellexec.py @@ -0,0 +1,12 @@ +"""EasyEngine shell executaion functions.""" +import os + + +class EEShellExec(): + """Method to run shell commands""" + def __init__(): + pass + + def cmd_exec(command): + os.system(command) + From cadca38e524046086b8bc41d84be0253275776f4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Dec 2014 17:41:14 +0530 Subject: [PATCH 495/829] Fixed various typos --- ee/cli/plugins/stack.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 104fe1a3..817c1542 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -4,7 +4,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.variables import EEVariables from ee.core.aptget import EEAptGet -from ee.core.donwload import EEDownload +from ee.core.download import EEDownload import random import string @@ -54,12 +54,12 @@ class EEStackController(CementBaseController): chars = ''.join(random.sample(string.letters, 8)) EEShellExec.cmd_exec("echo \"percona-server-server-5.6" "percona-server-server/root_password" - "password {pass}\"" - "| debconf-set-selections".format(pass=chars)) + "password {chars}\" |" + "debconf-set-selections".format(chars=chars)) EEShellExec.cmd_exec("echo \"percona-server-server-5.6" "percona-server-server/root_password_again" - "password {pass}\"" - "| debconf-set-selections".format(pass=chars)) + "password {chars}\" |" + "debconf-set-selections".format(chars=chars)) @expose() def install(self): From 9e437825c0c2eaf28e74e25f2489a11b46799d5e Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Dec 2014 18:02:22 +0530 Subject: [PATCH 496/829] Fixed: set-debconf not working --- ee/cli/plugins/stack.py | 19 ++++++++++--------- ee/core/shellexec.py | 1 - 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 817c1542..20c1d528 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -5,6 +5,7 @@ from cement.core import handler, hook from ee.core.variables import EEVariables from ee.core.aptget import EEAptGet from ee.core.download import EEDownload +from ee.core.shellexec import EEShellExec import random import string @@ -45,20 +46,20 @@ class EEStackController(CementBaseController): @expose(hide=True) def preseed_pref(self, packages): if "postfix" in packages: - EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type" - "string \'Internet Site\'\" | " + EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type " + "string 'Internet Site'\" | " "debconf-set-selections") - EEShellExec.cmd_exec("echo \"postfix postfix/mailname string" + EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") if "mysql" in packages: chars = ''.join(random.sample(string.letters, 8)) - EEShellExec.cmd_exec("echo \"percona-server-server-5.6" - "percona-server-server/root_password" - "password {chars}\" |" + EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " + "percona-server-server/root_password " + "password {chars}\" | " "debconf-set-selections".format(chars=chars)) - EEShellExec.cmd_exec("echo \"percona-server-server-5.6" - "percona-server-server/root_password_again" - "password {chars}\" |" + EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " + "percona-server-server/root_password_again " + "password {chars}\" | " "debconf-set-selections".format(chars=chars)) @expose() diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index c95c5645..0cf149b3 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -9,4 +9,3 @@ class EEShellExec(): def cmd_exec(command): os.system(command) - From fa8088a3ebb23c7ea1d3a673a4fc638fd043ff24 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Dec 2014 18:49:43 +0530 Subject: [PATCH 497/829] More refined code --- ee/core/download.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ee/core/download.py b/ee/core/download.py index 0f2f45ab..f8bea58b 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -1,6 +1,7 @@ """EasyEngine download core classes.""" import urllib.request import urllib.error +import os class EEDownload(): @@ -10,6 +11,9 @@ class EEDownload(): def download(url, filename): try: + directory = os.path.dirname(filename) + if not os.path.exists(directory): + os.makedirs(directory) urllib.request.urlretrieve(url, filename) return True except urllib.error.URLError as e: From 98a0a9d18085ee3ad0125375f48dc9b0a43bddb8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Dec 2014 19:53:51 +0530 Subject: [PATCH 498/829] More tweaks to ee stack install --- ee/cli/plugins/stack.py | 80 ++++++++++++++++++++++------------------- ee/core/download.py | 39 +++++++++++--------- 2 files changed, 66 insertions(+), 53 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 20c1d528..e3d95bf9 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -44,14 +44,14 @@ class EEStackController(CementBaseController): print("Inside EEStackController.default().") @expose(hide=True) - def preseed_pref(self, packages): - if "postfix" in packages: + def pre_pref(self, apt-packages): + if "postfix" in apt-packages: EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type " "string 'Internet Site'\" | " "debconf-set-selections") EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") - if "mysql" in packages: + if "mysql" in apt-packages: chars = ''.join(random.sample(string.letters, 8)) EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " @@ -65,74 +65,82 @@ class EEStackController(CementBaseController): @expose() def install(self): pkg = EEAptGet() - packages = [] + apt-packages = [] + if self.app.pargs.web: - packages = (packages + EEVariables.ee_nginx + EEVariables.ee_php + - EEVariables.ee_mysql) + apt-packages = (apt-packages + EEVariables.ee_nginx + + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #packages = packages + EEVariables.ee_nginx + #apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #packages = packages + EEVariables.ee_nginx + #apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.nginx: - packages = packages + EEVariables.ee_nginx + apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.php: - packages = packages + EEVariables.ee_php + apt-packages = apt-packages + EEVariables.ee_php if self.app.pargs.mysql: - packages = packages + EEVariables.ee_mysql + apt-packages = apt-packages + EEVariables.ee_mysql if self.app.pargs.postfix: - packages = packages + EEVariables.ee_postfix - self.preseed_pref(packages) - pkg.install(packages) + apt-packages = apt-packages + EEVariables.ee_postfix + if self.app.pargs.wpcli: + packages = packages + [['url', 'path']] + + self.pre_pref(apt-packages) + if len(apt-packages) not 0: + pkg.install(apt-packages) + if len(packages) not 0: + EEDownload.download(packages) + self.post_pref(apt-packages, packages) @expose() def remove(self): pkg = EEAptGet() - packages = [] + apt-packages = [] if self.app.pargs.web: - packages = (packages + EEVariables.ee_nginx + EEVariables.ee_php + - EEVariables.ee_mysql) + apt-packages = (apt-packages + EEVariables.ee_nginx + + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #packages = packages + EEVariables.ee_nginx + #apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #packages = packages + EEVariables.ee_nginx + #apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.nginx: - packages = packages + EEVariables.ee_nginx + apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.php: - packages = packages + EEVariables.ee_php + apt-packages = apt-packages + EEVariables.ee_php if self.app.pargs.mysql: - packages = packages + EEVariables.ee_mysql + apt-packages = apt-packages + EEVariables.ee_mysql if self.app.pargs.postfix: - packages = packages + EEVariables.ee_postfix - print(packages) - pkg.remove(packages) + apt-packages = apt-packages + EEVariables.ee_postfix + if self.app.pargs.wpcli: + pass + pkg.remove(apt-packages) @expose() def purge(self): pkg = EEAptGet() - packages = [] + apt-packages = [] if self.app.pargs.web: - packages = (packages + EEVariables.ee_nginx + EEVariables.ee_php + - EEVariables.ee_mysql) + apt-packages = (apt-packages + EEVariables.ee_nginx + + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #packages = packages + EEVariables.ee_nginx + #apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #packages = packages + EEVariables.ee_nginx + #apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.nginx: - packages = packages + EEVariables.ee_nginx + apt-packages = apt-packages + EEVariables.ee_nginx if self.app.pargs.php: - packages = packages + EEVariables.ee_php + apt-packages = apt-packages + EEVariables.ee_php if self.app.pargs.mysql: - packages = packages + EEVariables.ee_mysql + apt-packages = apt-packages + EEVariables.ee_mysql if self.app.pargs.postfix: - packages = packages + EEVariables.ee_postfix - print(packages) - pkg.purge(packages) + apt-packages = apt-packages + EEVariables.ee_postfix + pkg.purge(apt-packages) def load(app): diff --git a/ee/core/download.py b/ee/core/download.py index f8bea58b..cc1a0168 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -9,20 +9,25 @@ class EEDownload(): def __init__(): pass - def download(url, filename): - try: - directory = os.path.dirname(filename) - if not os.path.exists(directory): - os.makedirs(directory) - urllib.request.urlretrieve(url, filename) - return True - except urllib.error.URLError as e: - print("Unable to donwload file, [{err}]".format(err=str(e.reason))) - return False - except urllib.error.HTTPError as e: - print("Package download failed. [{err}]".format(err=str(e.reason))) - return False - except urllib.error.ContentTooShortError as e: - print("Package download failed. The amount of the downloaded data" - "is less than the expected amount") - return False + def download(packages): + for package in packages: + url = package[0] + filename = package[1] + try: + directory = os.path.dirname(filename) + if not os.path.exists(directory): + os.makedirs(directory) + urllib.request.urlretrieve(url, filename) + return True + except urllib.error.URLError as e: + print("Unable to donwload file, [{err}]" + .format(err=str(e.reason))) + return False + except urllib.error.HTTPError as e: + print("Package download failed. [{err}]" + .format(err=str(e.reason))) + return False + except urllib.error.ContentTooShortError as e: + print("Package download failed. The amount of the + "downloaded data is less than the expected amount") + return False From 4534d4ef18dd402d0a47d9d30d8759cdb71d5e97 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 15 Dec 2014 20:06:40 +0530 Subject: [PATCH 499/829] Added ee stack install --wpcli and more similar commands :) --- ee/cli/plugins/stack.py | 79 +++++++++++++++++++++++------------------ ee/core/download.py | 28 +++++++-------- 2 files changed, 58 insertions(+), 49 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index e3d95bf9..4a9f9d0b 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -36,6 +36,8 @@ class EEStackController(CementBaseController): dict(help='Install MySQL stack', action='store_true')), (['--postfix'], dict(help='Install Postfix stack', action='store_true')), + (['--wpcli'], + dict(help='Install WPCLI stack', action='store_true')), ] @expose(hide=True) @@ -44,14 +46,14 @@ class EEStackController(CementBaseController): print("Inside EEStackController.default().") @expose(hide=True) - def pre_pref(self, apt-packages): - if "postfix" in apt-packages: + def pre_pref(self, apt_packages): + if "postfix" in apt_packages: EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type " "string 'Internet Site'\" | " "debconf-set-selections") EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") - if "mysql" in apt-packages: + if "mysql" in apt_packages: chars = ''.join(random.sample(string.letters, 8)) EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " @@ -62,85 +64,92 @@ class EEStackController(CementBaseController): "password {chars}\" | " "debconf-set-selections".format(chars=chars)) + @expose(hide=True) + def post_pref(self, packages): + pass + @expose() def install(self): pkg = EEAptGet() - apt-packages = [] + apt_packages = [] + packages = [] if self.app.pargs.web: - apt-packages = (apt-packages + EEVariables.ee_nginx + + apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #apt-packages = apt-packages + EEVariables.ee_nginx + #apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #apt-packages = apt-packages + EEVariables.ee_nginx + #apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.nginx: - apt-packages = apt-packages + EEVariables.ee_nginx + apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: - apt-packages = apt-packages + EEVariables.ee_php + apt_packages = apt_packages + EEVariables.ee_php if self.app.pargs.mysql: - apt-packages = apt-packages + EEVariables.ee_mysql + apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: - apt-packages = apt-packages + EEVariables.ee_postfix + apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: - packages = packages + [['url', 'path']] + packages = packages + [["https://github.com/wp-cli/wp-cli/releases" + "/download/v0.17.1/wp-cli.phar", + "/usr/bin/wp"]] - self.pre_pref(apt-packages) - if len(apt-packages) not 0: - pkg.install(apt-packages) - if len(packages) not 0: + self.pre_pref(apt_packages) + if len(apt_packages): + pkg.install(apt_packages) + if len(packages): EEDownload.download(packages) - self.post_pref(apt-packages, packages) + self.post_pref(apt_packages, packages) @expose() def remove(self): pkg = EEAptGet() - apt-packages = [] + apt_packages = [] if self.app.pargs.web: - apt-packages = (apt-packages + EEVariables.ee_nginx + + apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #apt-packages = apt-packages + EEVariables.ee_nginx + #apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #apt-packages = apt-packages + EEVariables.ee_nginx + #apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.nginx: - apt-packages = apt-packages + EEVariables.ee_nginx + apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: - apt-packages = apt-packages + EEVariables.ee_php + apt_packages = apt_packages + EEVariables.ee_php if self.app.pargs.mysql: - apt-packages = apt-packages + EEVariables.ee_mysql + apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: - apt-packages = apt-packages + EEVariables.ee_postfix + apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: pass - pkg.remove(apt-packages) + pkg.remove(apt_packages) @expose() def purge(self): pkg = EEAptGet() - apt-packages = [] + apt_packages = [] if self.app.pargs.web: - apt-packages = (apt-packages + EEVariables.ee_nginx + apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #apt-packages = apt-packages + EEVariables.ee_nginx + #apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #apt-packages = apt-packages + EEVariables.ee_nginx + #apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.nginx: - apt-packages = apt-packages + EEVariables.ee_nginx + apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: - apt-packages = apt-packages + EEVariables.ee_php + apt_packages = apt_packages + EEVariables.ee_php if self.app.pargs.mysql: - apt-packages = apt-packages + EEVariables.ee_mysql + apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: - apt-packages = apt-packages + EEVariables.ee_postfix - pkg.purge(apt-packages) + apt_packages = apt_packages + EEVariables.ee_postfix + pkg.purge(apt_packages) def load(app): diff --git a/ee/core/download.py b/ee/core/download.py index cc1a0168..62b48dc7 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -17,17 +17,17 @@ class EEDownload(): directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) - urllib.request.urlretrieve(url, filename) - return True - except urllib.error.URLError as e: - print("Unable to donwload file, [{err}]" - .format(err=str(e.reason))) - return False - except urllib.error.HTTPError as e: - print("Package download failed. [{err}]" - .format(err=str(e.reason))) - return False - except urllib.error.ContentTooShortError as e: - print("Package download failed. The amount of the - "downloaded data is less than the expected amount") - return False + urllib.request.urlretrieve(url, filename) + return True + except urllib.error.URLError as e: + print("Unable to donwload file, [{err}]" + .format(err=str(e.reason))) + return False + except urllib.error.HTTPError as e: + print("Package download failed. [{err}]" + .format(err=str(e.reason))) + return False + except urllib.error.ContentTooShortError as e: + print("Package download failed. The amount of the" + "downloaded data is less than the expected amount") + return False From e18d6a0b9d9cb0c196a6f42fc4eec1de664e8367 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 15 Dec 2014 20:19:52 +0530 Subject: [PATCH 500/829] add apt-repo library --- ee/core/apt-repo.py | 29 ----------------------------- ee/core/apt_repo.py | 43 +++++++++++++++++++++++++++++++++++++++++++ ee/core/variables.py | 5 +++++ 3 files changed, 48 insertions(+), 29 deletions(-) delete mode 100644 ee/core/apt-repo.py create mode 100644 ee/core/apt_repo.py diff --git a/ee/core/apt-repo.py b/ee/core/apt-repo.py deleted file mode 100644 index eae22a2d..00000000 --- a/ee/core/apt-repo.py +++ /dev/null @@ -1,29 +0,0 @@ - -from ee.core.variables import EEVariables - - -class EERepo(): - """Manage Repositories""" - - def __init__(self): - """Initialize """ - pass - - def add(self, repo_url=None, codename=None, repo_type=None, ppa=None): - # TODO add repository code - repo_file_path = ("/etc/apt/sources.list.d/" - + EEVariables().ee_repo_file) - try: - with open(repo_file_path, "a") as repofile: - repofile.write("\n" + repo_url + " " + codename + - " " + repo_type) - repofile.close() - except Exception as e: - raise - - def remove(self, repo_url=None, codename=None, repo_type=None, ppa=None): - # TODO remove repository - pass - -# if __name__ == '__main__': -# EERepo().add(repo_url="http://ds.asf", codename="trusty", repo_type="main") diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py new file mode 100644 index 00000000..55fc0a11 --- /dev/null +++ b/ee/core/apt_repo.py @@ -0,0 +1,43 @@ + +import os.path +from ee.core.shellexec import EEShellExec +from ee.core.variables import EEVariables + + +class EERepo(): + """Manage Repositories""" + + def __init__(self): + """Initialize """ + pass + + def add(self, repo_url=None, ppa=None): + # TODO add repository code + + if repo_url is not None: + repo_file_path = ("/etc/apt/sources.list.d/" + + EEVariables().ee_repo_file) + try: + with open(repo_file_path, "a") as repofile: + repofile.write(repo_url) + repofile.close() + return True + except IOError as e: + print("File I/O error({0}): {1}".format(e.errno, e.strerror)) + except Exception as e: + print("{error}".format(error=e)) + return False + if ppa is not None: + if EEVariables.ee_platform_distro is not 'Ubuntu': + EEShellExec.cmd_exec("add-apt-repository -y {ppa_name}" + .format(ppa_name=ppa)) + else: + print("Cannot add repo for {distro}" + .format(distro=EEVariables.ee_platform_distro)) + + def remove(self, repo_url=None, codename=None, repo_type=None, ppa=None): + # TODO remove repository + pass + +# if __name__ == '__main__': +# EERepo().add(repo_url="http://ds.asf", codename="trusty", repo_type="main") diff --git a/ee/core/variables.py b/ee/core/variables.py index 6fb3160f..e202645a 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -1,4 +1,5 @@ """EasyEngine core variable module""" +import platform class EEVariables(): @@ -24,6 +25,10 @@ class EEVariables(): ee_postfix_repo = "" ee_postfix = ["postfix"] + ee_platform_distro = platform.linux_distribution()[0] + ee_platform_version = platform.linux_distribution()[1] + ee_platform_codename = platform.linux_distribution()[2] + # Repo ee_repo_file = "ee-repo.list" From 47db325974d8399a0c23af513931527176908c69 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 16 Dec 2014 17:29:26 +0530 Subject: [PATCH 501/829] Improved donwload actions.. --- ee/cli/plugins/stack.py | 9 ++++++++- ee/core/download.py | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 4a9f9d0b..c201b76f 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -65,7 +65,14 @@ class EEStackController(CementBaseController): "debconf-set-selections".format(chars=chars)) @expose(hide=True) - def post_pref(self, packages): + def post_pref(self, apt_packages, packages): + if len(apt_packages): + if "postfix" in apt_packages: + pass + pass + if len(packages): + if any('/usr/bin/wp' == x[1] for x in packages): + EEShellExec.cmd_exec("chmod +x /usr/bin/wp") pass @expose() diff --git a/ee/core/download.py b/ee/core/download.py index 62b48dc7..24a7f9da 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -17,7 +17,9 @@ class EEDownload(): directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) + print("Downloading "+os.path.basename(url)) urllib.request.urlretrieve(url, filename) + print("Done") return True except urllib.error.URLError as e: print("Unable to donwload file, [{err}]" From 2e4f6d0ce02574c59909b78aec1bbfeedfff7afa Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 16 Dec 2014 18:19:16 +0530 Subject: [PATCH 502/829] Done with package remove --- ee/cli/plugins/stack.py | 21 ++++++++++++++++++--- ee/core/download.py | 3 +-- ee/core/fileutils.py | 25 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 ee/core/fileutils.py diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c201b76f..9f0e7fa0 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -6,6 +6,7 @@ from ee.core.variables import EEVariables from ee.core.aptget import EEAptGet from ee.core.download import EEDownload from ee.core.shellexec import EEShellExec +from ee.core.fileutils import EEFileUtils import random import string @@ -114,6 +115,8 @@ class EEStackController(CementBaseController): def remove(self): pkg = EEAptGet() apt_packages = [] + packages = [] + if self.app.pargs.web: apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) @@ -132,13 +135,19 @@ class EEStackController(CementBaseController): if self.app.pargs.postfix: apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: - pass - pkg.remove(apt_packages) + packages = packages + ['/usr/bin/wp'] + + if len(apt_packages): + pkg.remove(apt_packages) + if len(packages): + EEFileUtils.remove(packages) @expose() def purge(self): pkg = EEAptGet() apt_packages = [] + packages = [] + if self.app.pargs.web: apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) @@ -156,7 +165,13 @@ class EEStackController(CementBaseController): apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: apt_packages = apt_packages + EEVariables.ee_postfix - pkg.purge(apt_packages) + if self.app.pargs.wpcli: + packages = packages + ['/usr/bin/wp'] + + if len(apt_packages): + pkg.purge(apt_packages) + if len(packages): + EEFileUtils.remove(packages) def load(app): diff --git a/ee/core/download.py b/ee/core/download.py index 24a7f9da..ff6291da 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -17,10 +17,9 @@ class EEDownload(): directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) - print("Downloading "+os.path.basename(url)) + print("Downloading "+os.path.basename(url)+" ...") urllib.request.urlretrieve(url, filename) print("Done") - return True except urllib.error.URLError as e: print("Unable to donwload file, [{err}]" .format(err=str(e.reason))) diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py new file mode 100644 index 00000000..b9e0d189 --- /dev/null +++ b/ee/core/fileutils.py @@ -0,0 +1,25 @@ +"""EasyEngine file utils core classes.""" +import shutil +import os + + +class EEFileUtils(): + """Method to operate on files""" + def __init__(): + pass + + def remove(filelist): + for file in filelist: + if os.path.isfile(file): + print("Removing "+os.path.basename(file)+" ...") + os.remove(file) + print("Done") + if os.path.isdir(file): + try: + print("Removing "+os.path.basename(file)+" ...") + shutil.rmtree(file) + print("Done") + except shutil.Error as e: + print("Unable to remove file, [{err}]" + .format(err=str(e.reason))) + return False From c2f870aed7702863b1711255028da8b19645eafd Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 17 Dec 2014 11:55:04 +0530 Subject: [PATCH 503/829] apt-repo --- ee/core/apt_repo.py | 6 ++++-- ee/core/variables.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 55fc0a11..dec6448b 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -11,7 +11,7 @@ class EERepo(): """Initialize """ pass - def add(self, repo_url=None, ppa=None): + def add(repo_url=None, ppa=None): # TODO add repository code if repo_url is not None: @@ -35,8 +35,10 @@ class EERepo(): print("Cannot add repo for {distro}" .format(distro=EEVariables.ee_platform_distro)) - def remove(self, repo_url=None, codename=None, repo_type=None, ppa=None): + def remove(repo_url=None): # TODO remove repository + EEShellExec.cmd_exec("add-apt-repository -y" + "--remove '{ppa_name}'".format(ppa_name=repo_url)) pass # if __name__ == '__main__': diff --git a/ee/core/variables.py b/ee/core/variables.py index e202645a..358a3dc1 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -31,6 +31,7 @@ class EEVariables(): # Repo ee_repo_file = "ee-repo.list" + ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file) def __init__(self): pass From 9bec17ef7665640e25b18fdee0d29a75962588de Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Wed, 17 Dec 2014 12:06:41 +0530 Subject: [PATCH 504/829] Update setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index df196b60..bec2285d 100644 --- a/setup.py +++ b/setup.py @@ -29,8 +29,8 @@ setup(name='ee', # "coverage", # Required to function 'cement>=2.4', - 'pystache' - 'python3-apt' + 'pystache', + 'python3-apt', ], setup_requires=[], entry_points=""" From 828d00eb805fcb93072a78a4b0544811977ec06f Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Wed, 17 Dec 2014 12:08:58 +0530 Subject: [PATCH 505/829] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bec2285d..7d7c04e5 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ setup(name='ee', # Required to function 'cement>=2.4', 'pystache', - 'python3-apt', + 'python-apt', ], setup_requires=[], entry_points=""" From b549c105247e8e7003e45e4f824a887d7f011c95 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Dec 2014 17:25:10 +0530 Subject: [PATCH 506/829] Done Nginx configuration --- ee/cli/main.py | 4 +-- ee/cli/plugins/stack.py | 37 +++++++++++++++++++++----- ee/cli/templates/nginx-core.mustache | 39 ++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 ee/cli/templates/nginx-core.mustache diff --git a/ee/cli/main.py b/ee/cli/main.py index cd2171e4..64755ee1 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -24,8 +24,8 @@ class EEApp(foundation.CementApp): label = 'ee' # Log writing to file - #defaults = init_defaults('ee', 'log.logging') - #defaults['log.logging']['file'] = '/tmp/my.log' + # defaults = init_defaults('ee', 'log.logging') + # defaults['log.logging']['file'] = '/tmp/my.log' config_defaults = defaults diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9f0e7fa0..5deeb3ee 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -7,6 +7,7 @@ from ee.core.aptget import EEAptGet from ee.core.download import EEDownload from ee.core.shellexec import EEShellExec from ee.core.fileutils import EEFileUtils +from pynginxconfig import NginxConfig import random import string @@ -68,9 +69,31 @@ class EEStackController(CementBaseController): @expose(hide=True) def post_pref(self, apt_packages, packages): if len(apt_packages): + print("In post") + print(apt_packages) if "postfix" in apt_packages: pass - pass + if 'nginx-custom' in apt_packages: + # Nginx core configuration change using configparser + nc = NginxConfig() + print('in nginx') + nc.loadf('/etc/nginx/nginx.conf') + nc.set('worker_processes', 'auto') + nc.append(('worker_rlimit_nofile', '100000'), position=2) + nc.remove(('events', '')) + nc.append({'name': 'events', 'param': '', 'value': + [('worker_connections', '4096'), + ('multi_accept', 'on')]}, position=4) + nc.set([('http',), 'keepalive_timeout'], '30') + nc.savef('/etc/nginx/nginx.conf') + + # Custom Nginx configuration by EasyEngine + data = dict(version='EasyEngine 3.0.1') + ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf','w') + ee_nginx.write(self.app.render((data), 'nginx-core.mustache')) + ee_nginx.close() + + pass if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") @@ -87,10 +110,10 @@ class EEStackController(CementBaseController): EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #apt_packages = apt_packages + EEVariables.ee_nginx + # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #apt_packages = apt_packages + EEVariables.ee_nginx + # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: @@ -122,10 +145,10 @@ class EEStackController(CementBaseController): EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #apt_packages = apt_packages + EEVariables.ee_nginx + # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #apt_packages = apt_packages + EEVariables.ee_nginx + # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: @@ -153,10 +176,10 @@ class EEStackController(CementBaseController): + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: pass - #apt_packages = apt_packages + EEVariables.ee_nginx + # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: pass - #apt_packages = apt_packages + EEVariables.ee_nginx + # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: diff --git a/ee/cli/templates/nginx-core.mustache b/ee/cli/templates/nginx-core.mustache new file mode 100644 index 00000000..a3442847 --- /dev/null +++ b/ee/cli/templates/nginx-core.mustache @@ -0,0 +1,39 @@ +## +# EasyEngine Settings +## + +server_tokens off; +reset_timedout_connection on; +add_header X-Powered-By "{{version}}"; +add_header rt-Fastcgi-Cache $upstream_cache_status; + +# Limit Request +limit_req_status 403; +limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; + +# Proxy Settings +# set_real_ip_from proxy-server-ip; +# real_ip_header X-Forwarded-For; + +fastcgi_read_timeout 300; +client_max_body_size 100m; + +# SSL Settings +ssl_session_cache shared:SSL:20m; +ssl_session_timeout 10m; +ssl_prefer_server_ciphers on; +ssl_ciphers HIGH:!aNULL:!MD5:!kEDH; + +# Log format Settings +log_format rt_cache '$remote_addr $upstream_response_time $upstream_cache_status [$time_local] ' +'$http_host "$request" $status $body_bytes_sent ' +'"$http_referer" "$http_user_agent"'; + + +# GZip settings +gzip_vary on; +gzip_proxied any; +gzip_comp_level 6; +gzip_buffers 16 8k; +gzip_http_version 1.1; +gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; From 204e0f4e1b0aaf9a4b075c441db2fa77ad4fc89e Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 17 Dec 2014 17:28:48 +0530 Subject: [PATCH 507/829] added gpg key add manually --- ee/cli/plugins/stack.py | 5 ++++- ee/core/apt_repo.py | 15 +++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 5deeb3ee..ba6de30e 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -56,6 +56,9 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") if "mysql" in apt_packages: + EERepo.add(repo_url="deb http://repo.percona.com/apt " + + EEVariables.ee_platform_codename + " main") + EERepo.add_key('hkp://keys.gnupg.net', '1C4CBDCDCD2EFD2A ') chars = ''.join(random.sample(string.letters, 8)) EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " @@ -89,7 +92,7 @@ class EEStackController(CementBaseController): # Custom Nginx configuration by EasyEngine data = dict(version='EasyEngine 3.0.1') - ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf','w') + ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') ee_nginx.write(self.app.render((data), 'nginx-core.mustache')) ee_nginx.close() diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index dec6448b..0449a0fc 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -1,5 +1,6 @@ import os.path +import gnupg from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables @@ -28,12 +29,12 @@ class EERepo(): print("{error}".format(error=e)) return False if ppa is not None: - if EEVariables.ee_platform_distro is not 'Ubuntu': - EEShellExec.cmd_exec("add-apt-repository -y {ppa_name}" - .format(ppa_name=ppa)) - else: + if EEVariables.ee_platform_distro == 'squeeze': print("Cannot add repo for {distro}" .format(distro=EEVariables.ee_platform_distro)) + else: + EEShellExec.cmd_exec("add-apt-repository -y {ppa_name}" + .format(ppa_name=ppa)) def remove(repo_url=None): # TODO remove repository @@ -41,5 +42,11 @@ class EERepo(): "--remove '{ppa_name}'".format(ppa_name=repo_url)) pass + def add_key(keyserver, keyids): + EEShellExec.cmd_exec("gpg --keyserver {0}".format(keyserver) + "--recv-keys {0}".format(keyids)) + EEShellExec.cmd_exec("gpg -a --export --armor {0}".format(keyids) + "| apt-key add - ") + # if __name__ == '__main__': # EERepo().add(repo_url="http://ds.asf", codename="trusty", repo_type="main") From 59fad213c693bc897344e97139ea7bd74d64d0a3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Dec 2014 18:21:51 +0530 Subject: [PATCH 508/829] Improved ee stack install --- ee/cli/plugins/stack.py | 14 +++++++------- ee/core/apt_repo.py | 12 +++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index ba6de30e..04e2567f 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -7,6 +7,7 @@ from ee.core.aptget import EEAptGet from ee.core.download import EEDownload from ee.core.shellexec import EEShellExec from ee.core.fileutils import EEFileUtils +from ee.core.apt_repo import EERepo from pynginxconfig import NginxConfig import random import string @@ -49,16 +50,17 @@ class EEStackController(CementBaseController): @expose(hide=True) def pre_pref(self, apt_packages): - if "postfix" in apt_packages: + if set(EEVariables.ee_postfix).issubset(set(apt_packages)): EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type " "string 'Internet Site'\" | " "debconf-set-selections") EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") - if "mysql" in apt_packages: - EERepo.add(repo_url="deb http://repo.percona.com/apt " + if set(EEVariables.ee_mysql).issubset(set(apt_packages)): + EERepo.add(ppa='deb http://repo.percona.com/apt ' + EEVariables.ee_platform_codename + " main") EERepo.add_key('hkp://keys.gnupg.net', '1C4CBDCDCD2EFD2A ') + chars = ''.join(random.sample(string.letters, 8)) EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " @@ -72,11 +74,9 @@ class EEStackController(CementBaseController): @expose(hide=True) def post_pref(self, apt_packages, packages): if len(apt_packages): - print("In post") - print(apt_packages) - if "postfix" in apt_packages: + if set(EEVariables.ee_postfix).issubset(set(apt_packages)): pass - if 'nginx-custom' in apt_packages: + if set(EEVariables.ee_nginx).issubset(set(apt_packages)): # Nginx core configuration change using configparser nc = NginxConfig() print('in nginx') diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 0449a0fc..70b1ef49 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -1,6 +1,4 @@ - import os.path -import gnupg from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables @@ -33,20 +31,20 @@ class EERepo(): print("Cannot add repo for {distro}" .format(distro=EEVariables.ee_platform_distro)) else: - EEShellExec.cmd_exec("add-apt-repository -y {ppa_name}" + EEShellExec.cmd_exec("add-apt-repository -y '{ppa_name}'" .format(ppa_name=ppa)) def remove(repo_url=None): # TODO remove repository - EEShellExec.cmd_exec("add-apt-repository -y" + EEShellExec.cmd_exec("add-apt-repository -y " "--remove '{ppa_name}'".format(ppa_name=repo_url)) pass def add_key(keyserver, keyids): - EEShellExec.cmd_exec("gpg --keyserver {0}".format(keyserver) - "--recv-keys {0}".format(keyids)) + EEShellExec.cmd_exec("gpg --keyserver {serv}".format(serv=keyserver) + + " --recv-keys {key}".format(key=keyids)) EEShellExec.cmd_exec("gpg -a --export --armor {0}".format(keyids) - "| apt-key add - ") + + " | apt-key add - ") # if __name__ == '__main__': # EERepo().add(repo_url="http://ds.asf", codename="trusty", repo_type="main") From c123cc433a4176637c3ac08c81e5fd6c980205b5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 17 Dec 2014 18:29:44 +0530 Subject: [PATCH 509/829] Fixed minor letters error --- ee/cli/plugins/stack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 04e2567f..8f22f90a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -60,8 +60,8 @@ class EEStackController(CementBaseController): EERepo.add(ppa='deb http://repo.percona.com/apt ' + EEVariables.ee_platform_codename + " main") EERepo.add_key('hkp://keys.gnupg.net', '1C4CBDCDCD2EFD2A ') - - chars = ''.join(random.sample(string.letters, 8)) + + chars = ''.join(random.sample(string.ascii_letters, 8)) EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " "password {chars}\" | " From e340630224829a6854b0729b162a3ea539b6c8f7 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 18 Dec 2014 13:01:02 +0530 Subject: [PATCH 510/829] git conflict resolve --- ee/cli/plugins/stack.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 8f22f90a..79ec3aca 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -57,10 +57,8 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): - EERepo.add(ppa='deb http://repo.percona.com/apt ' - + EEVariables.ee_platform_codename + " main") - EERepo.add_key('hkp://keys.gnupg.net', '1C4CBDCDCD2EFD2A ') - + EERepo.add(ppa=EEVariables.ee_mysql_repo) + EERepo.add_key('hkp://keys.gnupg.net', '1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " From 51e093dab10fb6c4be54f82f4a0bf37a2a39178d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 18 Dec 2014 14:42:05 +0530 Subject: [PATCH 511/829] nginx repo add code --- ee/cli/plugins/stack.py | 9 +++++++++ ee/core/apt_repo.py | 13 ++++++++----- ee/core/variables.py | 13 ++++++++----- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 79ec3aca..c8a1a9f8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -51,15 +51,18 @@ class EEStackController(CementBaseController): @expose(hide=True) def pre_pref(self, apt_packages): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): + print("Pre-seeding postfix variables ... ") EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type " "string 'Internet Site'\" | " "debconf-set-selections") EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): + print("Adding repository for mysql ... ") EERepo.add(ppa=EEVariables.ee_mysql_repo) EERepo.add_key('hkp://keys.gnupg.net', '1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) + print("Pre-seeding mysql variables ... ") EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " "password {chars}\" | " @@ -68,6 +71,12 @@ class EEStackController(CementBaseController): "percona-server-server/root_password_again " "password {chars}\" | " "debconf-set-selections".format(chars=chars)) + if set(EEVariables.ee_nginx).issubset(set(apt_packages)): + print("Adding repository for nginx ... ") + if EEVariables.ee_platform_codename == 'squeeze': + EERepo.add(repo_url=EEVariables.ee_mysql_repo) + else: + EERepo.add(repo_url=EEVariables.ee_mysql_repo) @expose(hide=True) def post_pref(self, apt_packages, packages): diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 70b1ef49..66857782 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -40,11 +40,14 @@ class EERepo(): "--remove '{ppa_name}'".format(ppa_name=repo_url)) pass - def add_key(keyserver, keyids): - EEShellExec.cmd_exec("gpg --keyserver {serv}".format(serv=keyserver) - + " --recv-keys {key}".format(key=keyids)) - EEShellExec.cmd_exec("gpg -a --export --armor {0}".format(keyids) - + " | apt-key add - ") + def add_key(keyserver=None, keyids): + if keyserver is None: + EEShellExec.cmd_exec("gpg --keyserver {serv}" + .format(serv=(keyserver + or "hkp://keys.gnupg.net")) + + " --recv-keys {key}".format(key=keyids)) + EEShellExec.cmd_exec("gpg -a --export --armor {0}".format(keyids) + + " | apt-key add - ") # if __name__ == '__main__': # EERepo().add(repo_url="http://ds.asf", codename="trusty", repo_type="main") diff --git a/ee/core/variables.py b/ee/core/variables.py index 358a3dc1..86ef0bd4 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -6,10 +6,17 @@ class EEVariables(): """Intialization of core variables""" # EasyEngine core variables + ee_platform_distro = platform.linux_distribution()[0] + ee_platform_version = platform.linux_distribution()[1] + ee_platform_codename = platform.linux_distribution()[2] # EasyEngine stack installation varibales # Nginx repo and packages - ee_nginx_repo = "ppa:rtcamp/nginx" + if ee_platform_distro == 'Ubuntu': + ee_nginx_repo = "ppa:rtcamp/nginx" + elif ee_platform_distro == 'Debian': + ee_nginx_repo = ("deb http://packages.dotdeb.org {codename} all" + .format(codename=ee_platform_codename)) ee_nginx = ["nginx-custom"] # PHP repo and packages @@ -25,10 +32,6 @@ class EEVariables(): ee_postfix_repo = "" ee_postfix = ["postfix"] - ee_platform_distro = platform.linux_distribution()[0] - ee_platform_version = platform.linux_distribution()[1] - ee_platform_codename = platform.linux_distribution()[2] - # Repo ee_repo_file = "ee-repo.list" ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file) From c341373395da2965236616f8db605a40883e83d6 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 18 Dec 2014 15:02:30 +0530 Subject: [PATCH 512/829] fixed default argument sequence --- ee/cli/plugins/stack.py | 2 +- ee/core/apt_repo.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c8a1a9f8..7586abf6 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -60,7 +60,7 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_mysql).issubset(set(apt_packages)): print("Adding repository for mysql ... ") EERepo.add(ppa=EEVariables.ee_mysql_repo) - EERepo.add_key('hkp://keys.gnupg.net', '1C4CBDCDCD2EFD2A') + EERepo.add_key('1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) print("Pre-seeding mysql variables ... ") EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 66857782..0ed5c554 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -40,7 +40,7 @@ class EERepo(): "--remove '{ppa_name}'".format(ppa_name=repo_url)) pass - def add_key(keyserver=None, keyids): + def add_key(keyids, keyserver=None): if keyserver is None: EEShellExec.cmd_exec("gpg --keyserver {serv}" .format(serv=(keyserver From 9db0adccaf2341cdf7f03a11a5aa2b2066aac0d2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Dec 2014 15:05:19 +0530 Subject: [PATCH 513/829] Hiding render output from screen --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 7586abf6..68951f37 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -100,7 +100,7 @@ class EEStackController(CementBaseController): # Custom Nginx configuration by EasyEngine data = dict(version='EasyEngine 3.0.1') ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') - ee_nginx.write(self.app.render((data), 'nginx-core.mustache')) + self.app.render((data), 'nginx-core.mustache', out=ee_nginx) ee_nginx.close() pass From 74d8150c17e46e235390372e2d092b9d31255c08 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Dec 2014 15:27:36 +0530 Subject: [PATCH 514/829] Added PHP configuration part --- ee/cli/plugins/stack.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 68951f37..191b7183 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -103,7 +103,40 @@ class EEStackController(CementBaseController): self.app.render((data), 'nginx-core.mustache', out=ee_nginx) ee_nginx.close() - pass + if set(EEVariables.ee_php).issubset(set(apt_packages)): + # Parse etc/php5/fpm/php.ini + config.read("/etc/php5/fpm/php.ini") + config['PHP']['expose_php'] = 'Off' + config['PHP']['post_max_size'] = '100M' + config['PHP']['upload_max_filesize'] = '100M' + config['PHP']['max_execution_time'] = '300' + config['PHP']['date.timezone'] = time.tzname[time.daylight] + with open('/etc/php5/fpm/php.ini', 'w') as configfile: + config.write(configfile) + + # Prase /etc/php5/fpm/php-fpm.conf + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/php-fpm.conf') + config['global']['error_log'] = '/var/log/php5/fpm.log' + with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: + config.write() + + # Parse /etc/php5/fpm/pool.d/www.conf + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/pool.d/www.conf') + config['www']['ping.path'] = '/ping' + config['www']['pm.status_path'] = '/status' + config['www']['pm.max_requests'] = '500' + config['www']['pm.max_children'] = '' + config['www']['pm.start_servers'] = '20' + config['www']['pm.min_spare_servers'] = '10' + config['www']['pm.max_spare_servers'] = '30' + config['www']['request_terminate_timeout'] = '300' + config['www']['pm'] = 'ondemand' + config['www']['listen'] = '127.0.0.1:9000' + with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile: + config.write() + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") From a670b4726569539166ea764d184d8a444737c913 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 18 Dec 2014 15:36:32 +0530 Subject: [PATCH 515/829] added php repo --- ee/cli/plugins/stack.py | 4 ++++ ee/core/variables.py | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 7586abf6..30759dd5 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -78,6 +78,9 @@ class EEStackController(CementBaseController): else: EERepo.add(repo_url=EEVariables.ee_mysql_repo) + if set(EEVariables.ee_php).issubset(set(apt_packages)): + print("Adding repository for php ... ") + @expose(hide=True) def post_pref(self, apt_packages, packages): if len(apt_packages): @@ -139,6 +142,7 @@ class EEStackController(CementBaseController): self.pre_pref(apt_packages) if len(apt_packages): + pkg.update() pkg.install(apt_packages) if len(packages): EEDownload.download(packages) diff --git a/ee/core/variables.py b/ee/core/variables.py index 86ef0bd4..efb9a6f0 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -20,13 +20,20 @@ class EEVariables(): ee_nginx = ["nginx-custom"] # PHP repo and packages - ee_php_repo = "ppa:ondrej/php5" + if ee_platform_distro == 'Ubuntu': + ee_php_repo = "ppa:ondrej/php5" + elif ee_platform_codename == 'squeeze': + ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php54 all" + .format(codename=ee_platform_codename)) + elif ee_platform_codename == 'wheezy': + ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all" + .format(codename=ee_platform_codename)) ee_php = ["php5-curl", "php5-gd", "php5-cli", "php5-fpm", "php5-imap", "php5-mcrypt", "php5-xdebug"] # MySQL repo and packages ee_mysql_repo = "" - ee_mysql = ["mysql-server-5.6"] + ee_mysql = ["percona-server-server-5.6"] # Postfix repo and packages ee_postfix_repo = "" From 0ca7a5bb0700733282a947f452facfd923303fd9 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Dec 2014 15:56:58 +0530 Subject: [PATCH 516/829] MySQL configuration added --- ee/cli/plugins/stack.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 191b7183..bf4b197a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -137,6 +137,15 @@ class EEStackController(CementBaseController): with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile: config.write() + if set(EEVariables.ee_mysql).issubset(set(apt_packages)): + config = configparser.ConfigParser() + config.read('/etc/mysql/my.cnf') + config['mysqld']['wait_timeout'] = 30 + config['mysqld']['interactive_timeout'] = 60 + config['mysqld']['performance_schema'] = 0 + with open('/etc/mysql/my.cnf', 'w') as configfile: + config.write() + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") From 2091f990c6ef8be4de817314b80c198cc3815342 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 18 Dec 2014 15:59:11 +0530 Subject: [PATCH 517/829] minor changes --- ee/cli/plugins/stack.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index b496fd70..bade6cef 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -73,13 +73,18 @@ class EEStackController(CementBaseController): "debconf-set-selections".format(chars=chars)) if set(EEVariables.ee_nginx).issubset(set(apt_packages)): print("Adding repository for nginx ... ") - if EEVariables.ee_platform_codename == 'squeeze': + if EEVariables.ee_platform_distro == 'Debian': EERepo.add(repo_url=EEVariables.ee_mysql_repo) else: - EERepo.add(repo_url=EEVariables.ee_mysql_repo) + EERepo.add(ppa=EEVariables.ee_mysql_repo) if set(EEVariables.ee_php).issubset(set(apt_packages)): print("Adding repository for php ... ") + if EEVariables.ee_platform_distro == 'Debian': + EERepo.add_key('89DF5277') + EERepo.add(repo_url=EEVariables.ee_mysql_repo) + else: + EERepo.add(ppa=EEVariables.ee_mysql_repo) @expose(hide=True) def post_pref(self, apt_packages, packages): From 97a60fbb87da10571dcdae35cfa983f46cb7ebea Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 18 Dec 2014 16:24:40 +0530 Subject: [PATCH 518/829] minor fix --- ee/cli/plugins/stack.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9b8a9c78..c3de8c66 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -74,17 +74,17 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_nginx).issubset(set(apt_packages)): print("Adding repository for nginx ... ") if EEVariables.ee_platform_distro == 'Debian': - EERepo.add(repo_url=EEVariables.ee_mysql_repo) + EERepo.add(repo_url=EEVariables.ee_nginx_repo) else: - EERepo.add(ppa=EEVariables.ee_mysql_repo) + EERepo.add(ppa=EEVariables.ee_nginx_repo) if set(EEVariables.ee_php).issubset(set(apt_packages)): print("Adding repository for php ... ") if EEVariables.ee_platform_distro == 'Debian': + EERepo.add(repo_url=EEVariables.ee_php_repo) EERepo.add_key('89DF5277') - EERepo.add(repo_url=EEVariables.ee_mysql_repo) else: - EERepo.add(ppa=EEVariables.ee_mysql_repo) + EERepo.add(ppa=EEVariables.ee_php_repo) @expose(hide=True) def post_pref(self, apt_packages, packages): From e032e93be829144189f0f0aeb330cf0ad2170390 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Dec 2014 17:07:30 +0530 Subject: [PATCH 519/829] Fixed various small issue --- ee/cli/plugins/stack.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c3de8c66..853e9373 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -11,6 +11,8 @@ from ee.core.apt_repo import EERepo from pynginxconfig import NginxConfig import random import string +import configparser +import time def ee_stack_hook(app): @@ -113,7 +115,8 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_php).issubset(set(apt_packages)): # Parse etc/php5/fpm/php.ini - config.read("/etc/php5/fpm/php.ini") + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/php.ini') config['PHP']['expose_php'] = 'Off' config['PHP']['post_max_size'] = '100M' config['PHP']['upload_max_filesize'] = '100M' @@ -127,7 +130,7 @@ class EEStackController(CementBaseController): config.read('/etc/php5/fpm/php-fpm.conf') config['global']['error_log'] = '/var/log/php5/fpm.log' with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: - config.write() + config.write(configfile) # Parse /etc/php5/fpm/pool.d/www.conf config = configparser.ConfigParser() @@ -143,7 +146,7 @@ class EEStackController(CementBaseController): config['www']['pm'] = 'ondemand' config['www']['listen'] = '127.0.0.1:9000' with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile: - config.write() + config.write(configfile) if set(EEVariables.ee_mysql).issubset(set(apt_packages)): config = configparser.ConfigParser() @@ -152,7 +155,7 @@ class EEStackController(CementBaseController): config['mysqld']['interactive_timeout'] = 60 config['mysqld']['performance_schema'] = 0 with open('/etc/mysql/my.cnf', 'w') as configfile: - config.write() + config.write(configfile) if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): From 9f3e4ce634e15359fe90405fa485a7d940a52480 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 18 Dec 2014 20:04:57 +0530 Subject: [PATCH 520/829] Code for extraction --- ee/core/extract.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ee/core/extract.py diff --git a/ee/core/extract.py b/ee/core/extract.py new file mode 100644 index 00000000..af2d001c --- /dev/null +++ b/ee/core/extract.py @@ -0,0 +1,15 @@ +"""EasyEngine extarct core classes.""" + + +class EEExtract(): + """Method to extract from tar.gz file""" + + def extract(file, path): + try: + tar = tarfile.open(file) + tar.extractall(path=path) + tar.close() + return True + except tarfile.TarError as e: + print("Unable to extract file "+file) + return False From 78bfca6919bc11293f445c8c6c7b02d5121ffb65 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Dec 2014 14:22:04 +0530 Subject: [PATCH 521/829] Added PMA --- ee/cli/plugins/stack.py | 20 ++++++++++++++++++++ ee/core/extract.py | 3 +++ 2 files changed, 23 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 853e9373..26e1afc7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -8,11 +8,16 @@ from ee.core.download import EEDownload from ee.core.shellexec import EEShellExec from ee.core.fileutils import EEFileUtils from ee.core.apt_repo import EERepo +from ee.core.extract import EEExtract from pynginxconfig import NginxConfig import random import string import configparser import time +import shutil +import os +import pwd +import grp def ee_stack_hook(app): @@ -43,6 +48,8 @@ class EEStackController(CementBaseController): dict(help='Install Postfix stack', action='store_true')), (['--wpcli'], dict(help='Install WPCLI stack', action='store_true')), + (['--phpmyadmin'], + dict(help='Install PHPMyAdmin stack', action='store_true')), ] @expose(hide=True) @@ -160,6 +167,15 @@ class EEStackController(CementBaseController): if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") + if any('/tmp/pma.tar.gz' == x[1] + for x in packages): + EEExtract.extract('/tmp/pma.tar.gz', '/tmp/') + if not os.path.exists('/var/www/22222/htdocs/db'): + os.makedirs('/var/www/22222/htdocs/db') + shutil.move('/tmp/phpmyadmin-STABLE/', + '/var/www/22222/htdocs/db/pma/') + EEShellExec.cmd_exec('chown -R www-data:www-data ' + '/var/www/22222/htdocs/db/pma') pass @expose() @@ -189,6 +205,10 @@ class EEStackController(CementBaseController): packages = packages + [["https://github.com/wp-cli/wp-cli/releases" "/download/v0.17.1/wp-cli.phar", "/usr/bin/wp"]] + if self.app.pargs.phpmyadmin: + packages = packages + [["https://github.com/phpmyadmin/phpmyadmin" + "/archive/STABLE.tar.gz", + "/tmp/pma.tar.gz"]] self.pre_pref(apt_packages) if len(apt_packages): diff --git a/ee/core/extract.py b/ee/core/extract.py index af2d001c..48fbc138 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -1,4 +1,6 @@ """EasyEngine extarct core classes.""" +import tarfile +import os class EEExtract(): @@ -9,6 +11,7 @@ class EEExtract(): tar = tarfile.open(file) tar.extractall(path=path) tar.close() + os.remove(file) return True except tarfile.TarError as e: print("Unable to extract file "+file) From 4f6997982e566baf0b97f61760d28f4727a15676 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Dec 2014 14:24:39 +0530 Subject: [PATCH 522/829] Added remove and purge for PMA --- ee/cli/plugins/stack.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 26e1afc7..51827c02 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -243,6 +243,8 @@ class EEStackController(CementBaseController): apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: packages = packages + ['/usr/bin/wp'] + if self.app.pargs.phpmyadmin: + packages = packages + ['/var/www/22222/htdocs/db/pma'] if len(apt_packages): pkg.remove(apt_packages) @@ -274,6 +276,8 @@ class EEStackController(CementBaseController): apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: packages = packages + ['/usr/bin/wp'] + if self.app.pargs.phpmyadmin: + packages = packages + ['/var/www/22222/htdocs/db/pma'] if len(apt_packages): pkg.purge(apt_packages) From 9c6ee62112ae468d8ced1932d45723a199bed8dc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Dec 2014 14:43:02 +0530 Subject: [PATCH 523/829] Added adminer --- ee/cli/plugins/stack.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 51827c02..b3db5d3c 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -50,6 +50,8 @@ class EEStackController(CementBaseController): dict(help='Install WPCLI stack', action='store_true')), (['--phpmyadmin'], dict(help='Install PHPMyAdmin stack', action='store_true')), + (['--adminer'], + dict(help='Install Adminer stack', action='store_true')), ] @expose(hide=True) @@ -210,6 +212,11 @@ class EEStackController(CementBaseController): "/archive/STABLE.tar.gz", "/tmp/pma.tar.gz"]] + if self.app.pargs.adminer: + packages = packages + [["http://downloads.sourceforge.net/adminer" + "/adminer-4.1.0.php", "/var/www/22222/" + "htdocs/db/adminer/index.php"]] + self.pre_pref(apt_packages) if len(apt_packages): pkg.update() @@ -245,6 +252,9 @@ class EEStackController(CementBaseController): packages = packages + ['/usr/bin/wp'] if self.app.pargs.phpmyadmin: packages = packages + ['/var/www/22222/htdocs/db/pma'] + if self.app.pargs.adminer: + packages = packages + ['/var/www/22222/htdocs/db/adminer' + '/index.php'] if len(apt_packages): pkg.remove(apt_packages) @@ -278,6 +288,9 @@ class EEStackController(CementBaseController): packages = packages + ['/usr/bin/wp'] if self.app.pargs.phpmyadmin: packages = packages + ['/var/www/22222/htdocs/db/pma'] + if self.app.pargs.adminer: + packages = packages + ['/var/www/22222/htdocs/db/adminer' + '/index.php'] if len(apt_packages): pkg.purge(apt_packages) From 47f1c5e1457058e4d4a760a93c648047f7db9794 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 19 Dec 2014 15:44:48 +0530 Subject: [PATCH 524/829] subprocess replacing system --- ee/core/fileutils.py | 22 +++++++++---------- ee/core/services.py | 52 ++++++++++++++++++++++++++++++++++++++++++++ ee/core/shellexec.py | 8 ++++++- 3 files changed, 70 insertions(+), 12 deletions(-) diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index b9e0d189..4853d01b 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -10,16 +10,16 @@ class EEFileUtils(): def remove(filelist): for file in filelist: - if os.path.isfile(file): + if os.path.isfile(file): + print("Removing "+os.path.basename(file)+" ...") + os.remove(file) + print("Done") + if os.path.isdir(file): + try: print("Removing "+os.path.basename(file)+" ...") - os.remove(file) + shutil.rmtree(file) print("Done") - if os.path.isdir(file): - try: - print("Removing "+os.path.basename(file)+" ...") - shutil.rmtree(file) - print("Done") - except shutil.Error as e: - print("Unable to remove file, [{err}]" - .format(err=str(e.reason))) - return False + except shutil.Error as e: + print("Unable to remove file, [{err}]" + .format(err=str(e.reason))) + return False diff --git a/ee/core/services.py b/ee/core/services.py index 7f5ac220..a1a3deb1 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -1,4 +1,8 @@ """EasyEngine service start/stop/restart module.""" +import os +import sys +import subprocess +from subprocess import Popen class EEService(): @@ -6,3 +10,51 @@ class EEService(): def ___init__(): # TODO method for services pass + + def start_service(service_name): + try: + retcode = subprocess.getstatusoutput('service {0} start' + .format(service_name)) + if retcode[0] == 0: + print("Started : {0}".format(service_name)) + else: + print(retcode[1]) + except OSError as e: + print("Execution failed:", e) + return False + + def stop_service(service_name): + try: + retcode = subprocess.getstatusoutput('service {0} stop' + .format(service_name)) + if retcode[0] == 0: + print("Stopped : {0}".format(service_name)) + return True + else: + return False + except OSError as e: + print("Execution failed:", e) + return False + + def restart_service(service_name): + try: + stop_service(service_name) + start_service(service_name) + except OSError as e: + print("Execution failed:", e) + + def get_service_status(service_name): + try: + is_exist = subprocess.getstatusoutput('which {0}' + .format(service_name))[0] + if is_exist == 0: + retcode = subprocess.getstatusoutput('service {0} status' + .format(service_name)) + if retcode[0] == 0: + return True + else: + return False + else: + return False + except OSError as e: + return False diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 0cf149b3..5f16bbc3 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -1,5 +1,8 @@ """EasyEngine shell executaion functions.""" import os +import sys +import subprocess +from subprocess import Popen class EEShellExec(): @@ -8,4 +11,7 @@ class EEShellExec(): pass def cmd_exec(command): - os.system(command) + try: + retcode = subprocess.getstatusoutput(command) + except OSError as e: + print(e) From f087458d4022d4c9ee5c055624d54a727a50a75f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Dec 2014 15:52:40 +0530 Subject: [PATCH 525/829] Added Utils download code --- ee/cli/plugins/stack.py | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index b3db5d3c..40c96160 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -52,6 +52,8 @@ class EEStackController(CementBaseController): dict(help='Install PHPMyAdmin stack', action='store_true')), (['--adminer'], dict(help='Install Adminer stack', action='store_true')), + (['--utils'], + dict(help='Install Utils stack', action='store_true')), ] @expose(hide=True) @@ -217,6 +219,32 @@ class EEStackController(CementBaseController): "/adminer-4.1.0.php", "/var/www/22222/" "htdocs/db/adminer/index.php"]] + if self.app.pargs.utils: + packages = packages + [["http://phpmemcacheadmin.googlecode.com/" + "files/phpMemcachedAdmin-1.2.2" + "-r262.tar.gz", "/tmp/memcache.tar.gz"], + ["https://raw.githubusercontent.com/rtCamp/" + "eeadmin/master/cache/nginx/clean.php", + "/var/www/22222/htdocs/cache/" + "nginx/clean.php"], + ["https://raw.github.com/rlerdorf/opcache-" + "status/master/opcache.php", + "/var/www/22222/htdocs/cache/" + "opcache/opcache.php"], + ["https://raw.github.com/amnuts/opcache-gui" + "/master/index.php", + "/var/www/22222/htdocs/" + "cache/opcache/opgui.php"], + ["https://gist.github.com/ck-on/4959032/raw" + "/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb" + "/ocp.php", + "/var/www/22222/htdocs/cache/" + "opcache/ocp.php"], + ["https://github.com/jokkedk/webgrind/" + "archive/master.tar.gz", + "/tmp/webgrid.zip"] + ] + self.pre_pref(apt_packages) if len(apt_packages): pkg.update() @@ -253,8 +281,7 @@ class EEStackController(CementBaseController): if self.app.pargs.phpmyadmin: packages = packages + ['/var/www/22222/htdocs/db/pma'] if self.app.pargs.adminer: - packages = packages + ['/var/www/22222/htdocs/db/adminer' - '/index.php'] + packages = packages + ['/var/www/22222/htdocs/db/adminer'] if len(apt_packages): pkg.remove(apt_packages) @@ -289,8 +316,7 @@ class EEStackController(CementBaseController): if self.app.pargs.phpmyadmin: packages = packages + ['/var/www/22222/htdocs/db/pma'] if self.app.pargs.adminer: - packages = packages + ['/var/www/22222/htdocs/db/adminer' - '/index.php'] + packages = packages + ['/var/www/22222/htdocs/db/adminer'] if len(apt_packages): pkg.purge(apt_packages) From d4d408b0d0b8614fe75b76de8b244b8c9b7bf6a3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Dec 2014 17:22:32 +0530 Subject: [PATCH 526/829] More stuff to utils --- ee/cli/plugins/stack.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 40c96160..df0d5c19 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -169,6 +169,7 @@ class EEStackController(CementBaseController): config.write(configfile) if len(packages): + print(packages) if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] @@ -180,6 +181,24 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/db/pma/') EEShellExec.cmd_exec('chown -R www-data:www-data ' '/var/www/22222/htdocs/db/pma') + if any('/tmp/memcache.tar.gz' == x[1] + for x in packages): + EEExtract.extract('/tmp/memcache.tar.gz', + '/var/www/22222/htdocs/cache/memcache') + EEShellExec.cmd_exec('chown -R www-data:www-data ' + '/var/www/22222/htdocs/cache/memcache') + + if any('/tmp/webgrind.tar.gz' == x[1] + for x in packages): + EEExtract.extract('/tmp/webgrind.tar.gz', '/tmp/') + if not os.path.exists('/var/www/22222/htdocs/php'): + os.makedirs('/var/www/22222/htdocs/php') + shutil.move('/tmp/webgrind-master/', + '/var/www/22222/htdocs/php/webgrind') + + EEShellExec.cmd_exec('chown -R www-data:www-data ' + '/var/www/22222/htdocs/php/webgrind/') + pass @expose() @@ -222,7 +241,7 @@ class EEStackController(CementBaseController): if self.app.pargs.utils: packages = packages + [["http://phpmemcacheadmin.googlecode.com/" "files/phpMemcachedAdmin-1.2.2" - "-r262.tar.gz", "/tmp/memcache.tar.gz"], + "-r262.tar.gz", '/tmp/memcache.tar.gz'], ["https://raw.githubusercontent.com/rtCamp/" "eeadmin/master/cache/nginx/clean.php", "/var/www/22222/htdocs/cache/" @@ -242,7 +261,7 @@ class EEStackController(CementBaseController): "opcache/ocp.php"], ["https://github.com/jokkedk/webgrind/" "archive/master.tar.gz", - "/tmp/webgrid.zip"] + '/tmp/webgrind.tar.gz'] ] self.pre_pref(apt_packages) From 5765496b56883c076d1a538bdca01a98e4669125 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Dec 2014 17:26:04 +0530 Subject: [PATCH 527/829] Utils remove and purge --- ee/cli/plugins/stack.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index df0d5c19..3b57343f 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -301,6 +301,12 @@ class EEStackController(CementBaseController): packages = packages + ['/var/www/22222/htdocs/db/pma'] if self.app.pargs.adminer: packages = packages + ['/var/www/22222/htdocs/db/adminer'] + if self.app.pargs.utils: + packages = packages + ['/var/www/22222/htdocs/php/webgrind/', + '/var/www/22222/htdocs/cache/opcache', + '/var/www/22222/htdocs/cache/nginx/' + 'clean.php', + '/var/www/22222/htdocs/cache/memcache'] if len(apt_packages): pkg.remove(apt_packages) @@ -336,6 +342,12 @@ class EEStackController(CementBaseController): packages = packages + ['/var/www/22222/htdocs/db/pma'] if self.app.pargs.adminer: packages = packages + ['/var/www/22222/htdocs/db/adminer'] + if self.app.pargs.utils: + packages = packages + ['/var/www/22222/htdocs/php/webgrind/', + '/var/www/22222/htdocs/cache/opcache', + '/var/www/22222/htdocs/cache/nginx/' + 'clean.php', + '/var/www/22222/htdocs/cache/memcache'] if len(apt_packages): pkg.purge(apt_packages) From f100b8edea73b4e26ad0f7c1ac736ea8ab8b0742 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 19 Dec 2014 18:23:29 +0530 Subject: [PATCH 528/829] Added Anemometer --- ee/cli/plugins/stack.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 3b57343f..af17ce70 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -54,6 +54,8 @@ class EEStackController(CementBaseController): dict(help='Install Adminer stack', action='store_true')), (['--utils'], dict(help='Install Utils stack', action='store_true')), + (['--anemometer'], + dict(help='Install Utils stack', action='store_true')), ] @expose(hide=True) @@ -169,7 +171,6 @@ class EEStackController(CementBaseController): config.write(configfile) if len(packages): - print(packages) if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] @@ -195,10 +196,16 @@ class EEStackController(CementBaseController): os.makedirs('/var/www/22222/htdocs/php') shutil.move('/tmp/webgrind-master/', '/var/www/22222/htdocs/php/webgrind') - EEShellExec.cmd_exec('chown -R www-data:www-data ' '/var/www/22222/htdocs/php/webgrind/') + if any('/tmp/anemometer.tar.gz' == x[1] + for x in packages): + EEExtract.extract('/tmp/anemometer.tar.gz', '/tmp/') + if not os.path.exists('/var/www/22222/htdocs/db/'): + os.makedirs('/var/www/22222/htdocs/db/') + shutil.move('/tmp/Anemometer-master', + '/var/www/22222/htdocs/db/anemometer') pass @expose() @@ -263,6 +270,10 @@ class EEStackController(CementBaseController): "archive/master.tar.gz", '/tmp/webgrind.tar.gz'] ] + if self.app.pargs.anemometer: + packages = packages + [["https://github.com/box/Anemometer/archive" + "/master.tar.gz", + '/tmp/anemometer.tar.gz']] self.pre_pref(apt_packages) if len(apt_packages): @@ -307,6 +318,8 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/cache/nginx/' 'clean.php', '/var/www/22222/htdocs/cache/memcache'] + if self.app.pargs.anemometer: + packages = packages + ['/var/www/22222/htdocs/db/anemometer'] if len(apt_packages): pkg.remove(apt_packages) @@ -348,6 +361,8 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/cache/nginx/' 'clean.php', '/var/www/22222/htdocs/cache/memcache'] + if self.app.pargs.anemometer: + packages = packages + ['/var/www/22222/htdocs/db/anemometer'] if len(apt_packages): pkg.purge(apt_packages) From 91b00aed8e4cc9d6cc8548c7245c937029705738 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 22 Dec 2014 11:33:13 +0530 Subject: [PATCH 529/829] Update setup.py: --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 7d7c04e5..d7121598 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ setup(name='ee', 'cement>=2.4', 'pystache', 'python-apt', + 'pynxconfig', ], setup_requires=[], entry_points=""" From ed8fbe15f138f12e6e38cbebf446e9bd6e3f9cd7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 22 Dec 2014 11:55:05 +0530 Subject: [PATCH 530/829] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d7121598..b06392fe 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ setup(name='ee', 'cement>=2.4', 'pystache', 'python-apt', - 'pynxconfig', + 'pynginxconfig', ], setup_requires=[], entry_points=""" From 95ef1b08ae73b028df0e432bfb67d59ececd3950 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 22 Dec 2014 14:18:22 +0530 Subject: [PATCH 531/829] Added EE MySQL code --- ee/core/mysql.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 ee/core/mysql.py diff --git a/ee/core/mysql.py b/ee/core/mysql.py new file mode 100644 index 00000000..88598ce6 --- /dev/null +++ b/ee/core/mysql.py @@ -0,0 +1,40 @@ +"""EasyEngine MySQL core classes.""" +import pymysql +import configparser +from os.path import expanduser + + +class EEMysql(): + """Method for MySQL connection""" + + def __init__(self): + config = configparser.RawConfigParser() + cnfpath = expanduser("~")+"/.my.cnf" + if [cnfpath] == config.read(cnfpath): + user = config.get('client', 'user') + passwd = config.get('client', 'password') + try: + host = config.get('client', 'host') + except configparser.NoOptionError as e: + host = 'localhost' + + try: + port = config.get('client', 'port') + except configparser.NoOptionError as e: + port = '3306' + + try: + self.conn = pymysql.connect(host=host, port=int(port), + user=user, passwd=passwd) + self.cur = self.conn.cursor() + except Exception as e: + print("Unable to connect to database") + return False + + def execute(self, statement): + try: + self.cur.execute(statement) + return True + except Exception as e: + print("Error occured while executing "+statement) + return False From 243dc842e156619dc9b7bf50f3a7fdc5631a1b59 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 22 Dec 2014 14:36:29 +0530 Subject: [PATCH 532/829] added ee stack services --- ee/cli/plugins/stack.py | 2 + ee/cli/plugins/stack_services.py | 81 ++++++++++++++++++++++++++++++++ ee/core/aptget.py | 1 + ee/core/services.py | 4 +- ee/core/shellexec.py | 5 ++ 5 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 ee/cli/plugins/stack_services.py diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index af17ce70..cc9b90c2 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -18,6 +18,7 @@ import shutil import os import pwd import grp +from ee.cli.plugins.stack_services import EEStackStatusController def ee_stack_hook(app): @@ -373,6 +374,7 @@ class EEStackController(CementBaseController): def load(app): # register the plugin class.. this only happens if the plugin is enabled handler.register(EEStackController) + handler.register(EEStackStatusController) # register a hook (function) to run after arguments are parsed. hook.register('post_argument_parsing', ee_stack_hook) diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py new file mode 100644 index 00000000..2e154042 --- /dev/null +++ b/ee/cli/plugins/stack_services.py @@ -0,0 +1,81 @@ +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +from ee.core.services import EEService + + +class EEStackStatusController(CementBaseController): + class Meta: + label = 'stack_services' + stacked_on = 'stack' + stacked_type = 'embedded' + description = 'stack command manages stack operations' + arguments = [ + (['--memcache'], + dict(help='start/stop/restart stack', action='store_true')), + (['--dovecot'], + dict(help='start/stop/restart dovecot', action='store_true')), + ] + + @expose(help="start stack services") + def start(self): + services = [] + if self.app.pargs.nginx: + services = services + ['nginx'] + elif self.app.pargs.php: + services = services + ['php5-fpm'] + elif self.app.pargs.mysql: + services = services + ['mysql'] + elif self.app.pargs.postfix: + services = services + ['postfix'] + elif self.app.pargs.memcache: + services = services + ['memcached'] + elif self.app.pargs.dovecot: + services = services + ['dovecot'] + else: + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] + for service in services: + EEService.start_service(service) + + @expose(help="stop stack services") + def stop(self): + services = [] + if self.app.pargs.nginx: + services = services + ['nginx'] + elif self.app.pargs.php: + services = services + ['php5-fpm'] + elif self.app.pargs.mysql: + services = services + ['mysql'] + elif self.app.pargs.postfix: + services = services + ['postfix'] + elif self.app.pargs.memcache: + services = services + ['memcached'] + elif self.app.pargs.dovecot: + services = services + ['dovecot'] + else: + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] + for service in services: + EEService.stop_service(service) + + @expose(help="restart stack services") + def restart(self): + services = [] + if self.app.pargs.nginx: + services = services + ['nginx'] + elif self.app.pargs.php: + services = services + ['php5-fpm'] + elif self.app.pargs.mysql: + services = services + ['mysql'] + elif self.app.pargs.postfix: + services = services + ['postfix'] + elif self.app.pargs.memcache: + services = services + ['memcached'] + elif self.app.pargs.dovecot: + services = services + ['dovecot'] + else: + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] + for service in services: + EEService.restart_service(service) + + @expose(help="get stack status") + def status(self): + pass diff --git a/ee/core/aptget.py b/ee/core/aptget.py index a67bb1b2..dd6d5886 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -1,5 +1,6 @@ """EasyEngine package installation using apt-get module.""" import apt +import apt_pkg import sys diff --git a/ee/core/services.py b/ee/core/services.py index a1a3deb1..63c488b5 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -38,8 +38,8 @@ class EEService(): def restart_service(service_name): try: - stop_service(service_name) - start_service(service_name) + EEService.stop_service(service_name) + EEService.start_service(service_name) except OSError as e: print("Execution failed:", e) diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 5f16bbc3..9368f667 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -13,5 +13,10 @@ class EEShellExec(): def cmd_exec(command): try: retcode = subprocess.getstatusoutput(command) + if retcode[0] == 0: + return True + else: + return False except OSError as e: print(e) + return False From e1fcb26eeb0651b2a6b72bfae4c1ad44948dc2ea Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 22 Dec 2014 16:27:24 +0530 Subject: [PATCH 533/829] Atlast anemometer done :) --- ee/cli/plugins/stack.py | 39 +++- ee/cli/templates/anemometer.mustache | 255 +++++++++++++++++++++++++++ ee/core/mysql.py | 5 + 3 files changed, 292 insertions(+), 7 deletions(-) create mode 100644 ee/cli/templates/anemometer.mustache diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index cc9b90c2..96861825 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -9,6 +9,7 @@ from ee.core.shellexec import EEShellExec from ee.core.fileutils import EEFileUtils from ee.core.apt_repo import EERepo from ee.core.extract import EEExtract +from ee.core.mysql import EEMysql from pynginxconfig import NginxConfig import random import string @@ -55,8 +56,6 @@ class EEStackController(CementBaseController): dict(help='Install Adminer stack', action='store_true')), (['--utils'], dict(help='Install Utils stack', action='store_true')), - (['--anemometer'], - dict(help='Install Utils stack', action='store_true')), ] @expose(hide=True) @@ -207,6 +206,28 @@ class EEStackController(CementBaseController): os.makedirs('/var/www/22222/htdocs/db/') shutil.move('/tmp/Anemometer-master', '/var/www/22222/htdocs/db/anemometer') + chars = ''.join(random.sample(string.ascii_letters, 8)) + anemometer_db = EEMysql() + EEShellExec.cmd_exec('mysql < /var/www/22222/htdocs/db' + '/anemometer/install.sql') + anemometer_db.execute('grant select on *.* to \'anemometer\'' + '@\'localhost\'') + anemometer_db.execute('grant all on slow_query_log.* to' + '\'anemometer\'@\'localhost\' IDENTIFIED' + ' BY \''+chars+'\'') + anemometer_db.close() + # Custom Anemometer configuration + data = dict(host='localhost', port='3306', user='anemometer', + password=chars) + ee_anemometer = open('/var/www/22222/htdocs/db/anemometer' + '/conf/config.inc.php', 'w') + self.app.render((data), 'anemometer.mustache', + out=ee_anemometer) + ee_anemometer.close() + + if any('/usr/bin/pt-query-advisor' == x[1] + for x in packages): + EEShellExec.cmd_exec("chmod +x /usr/bin/pt-query-advisor") pass @expose() @@ -269,12 +290,16 @@ class EEStackController(CementBaseController): "opcache/ocp.php"], ["https://github.com/jokkedk/webgrind/" "archive/master.tar.gz", - '/tmp/webgrind.tar.gz'] - ] - if self.app.pargs.anemometer: - packages = packages + [["https://github.com/box/Anemometer/archive" + '/tmp/webgrind.tar.gz'], + ["http://bazaar.launchpad.net/~percona-too" + "lkit-dev/percona-toolkit/2.1/download/he" + "ad:/ptquerydigest-20110624220137-or26tn4" + "expb9ul2a-16/pt-query-digest", + "/usr/bin/pt-query-advisor"], + ["https://github.com/box/Anemometer/archive" "/master.tar.gz", - '/tmp/anemometer.tar.gz']] + '/tmp/anemometer.tar.gz'] + ] self.pre_pref(apt_packages) if len(apt_packages): diff --git a/ee/cli/templates/anemometer.mustache b/ee/cli/templates/anemometer.mustache new file mode 100644 index 00000000..e082ce50 --- /dev/null +++ b/ee/cli/templates/anemometer.mustache @@ -0,0 +1,255 @@ + '{{host}}', + 'port' => '{{port}}', + 'db' => 'slow_query_log', + 'user' => '{{user}}', + 'password' => '{{password}}', + 'tables' => array( + 'global_query_review' => 'fact', + 'global_query_review_history' => 'dimension' + ), + 'source_type' => 'slow_query_log' +); + +$conf['default_report_action'] = 'report'; + +$conf['reviewers'] = array( 'dba1','dba2'); +$conf['review_types'] = array( 'good', 'bad', 'ticket-created', 'needs-fix', 'fixed', 'needs-analysis', 'review-again'); + +$conf['history_defaults'] = array( + 'output' => 'table', + 'fact-group' => 'date', + 'fact-order' => 'date DESC', + 'fact-limit' => '90', + 'dimension-ts_min_start' => date("Y-m-d H:i:s", strtotime( '-90 day')), + 'dimension-ts_min_end' => date("Y-m-d H:i:s"), + 'table_fields' => array('date', 'index_ratio','query_time_avg','rows_sent_avg','ts_cnt','Query_time_sum','Lock_time_sum','Rows_sent_sum','Rows_examined_sum','Tmp_table_sum','Filesort_sum','Full_scan_sum') +); + +$conf['report_defaults'] = array( + 'fact-group' => 'checksum', + 'fact-order' => 'Query_time_sum DESC', + 'fact-limit' => '20', + 'dimension-ts_min_start' => date("Y-m-d H:i:s", strtotime( '-1 day')), + 'dimension-ts_min_end' => date("Y-m-d H:i:s"), + 'table_fields' => array('checksum','snippet', 'index_ratio','query_time_avg','rows_sent_avg','ts_cnt','Query_time_sum','Lock_time_sum','Rows_sent_sum','Rows_examined_sum','Tmp_table_sum','Filesort_sum','Full_scan_sum'), + 'dimension-pivot-hostname_max' => null +); + +$conf['graph_defaults'] = array( + 'fact-group' => 'minute_ts', + 'fact-order' => 'minute_ts', + 'fact-limit' => '', + 'dimension-ts_min_start' => date("Y-m-d H:i:s", strtotime( '-7 day')), + 'dimension-ts_min_end' => date("Y-m-d H:i:s"), + 'table_fields' => array('minute_ts'), + 'plot_field' => 'Query_time_sum', +); + +$conf['report_defaults']['performance_schema'] = array( + 'fact-order' => 'SUM_TIMER_WAIT DESC', + 'fact-limit' => '20', + 'fact-group' => 'DIGEST', + 'table_fields' => array( 'DIGEST', 'snippet', 'index_ratio', 'COUNT_STAR', 'SUM_TIMER_WAIT', 'SUM_LOCK_TIME','SUM_ROWS_AFFECTED','SUM_ROWS_SENT','SUM_ROWS_EXAMINED','SUM_CREATED_TMP_TABLES','SUM_SORT_SCAN','SUM_NO_INDEX_USED' ) +); + +$conf['history_defaults']['performance_schema'] = array( + 'fact-order' => 'SUM_TIMER_WAIT DESC', + 'fact-limit' => '20', + 'fact-group' => 'DIGEST', + 'table_fields' => array( 'DIGEST', 'index_ratio', 'COUNT_STAR', 'SUM_LOCK_TIME','SUM_ROWS_AFFECTED','SUM_ROWS_SENT','SUM_ROWS_EXAMINED','SUM_CREATED_TMP_TABLES','SUM_SORT_SCAN','SUM_NO_INDEX_USED' ) +); + +$conf['report_defaults']['performance_schema_history'] = array( + 'fact-group' => 'DIGEST', + 'fact-order' => 'SUM_TIMER_WAIT DESC', + 'fact-limit' => '20', + 'dimension-FIRST_SEEN_start' => date("Y-m-d H:i:s", strtotime( '-1 day')), + 'dimension-FIRST_SEEN_end' => date("Y-m-d H:i:s"), + 'table_fields' => array( 'DIGEST', 'snippet', 'index_ratio', 'COUNT_STAR', 'SUM_LOCK_TIME','SUM_ROWS_AFFECTED','SUM_ROWS_SENT','SUM_ROWS_EXAMINED','SUM_CREATED_TMP_TABLES','SUM_SORT_SCAN','SUM_NO_INDEX_USED' ) +); + +$conf['graph_defaults']['performance_schema_history'] = array( + 'fact-group' => 'minute_ts', + 'fact-order' => 'minute_ts', + 'fact-limit' => '', + 'dimension-FIRST_SEEN_start' => date("Y-m-d H:i:s", strtotime( '-7 day')), + 'dimension-FIRST_SEEN_end' => date("Y-m-d H:i:s"), + 'table_fields' => array('minute_ts'), + 'plot_field' => 'SUM_TIMER_WAIT', + 'dimension-pivot-hostname_max' => null +); + +$conf['history_defaults']['performance_schema_history'] = array( + 'output' => 'table', + 'fact-group' => 'date', + 'fact-order' => 'date DESC', + 'fact-limit' => '90', + 'dimension-FIRST_SEEN_start' => date("Y-m-d H:i:s", strtotime( '-90 day')), + 'dimension-FIRST_SEEN_end' => date("Y-m-d H:i:s"), + 'table_fields' => array( 'date', 'snippet', 'index_ratio', 'COUNT_STAR', 'SUM_LOCK_TIME','SUM_ROWS_AFFECTED','SUM_ROWS_SENT','SUM_ROWS_EXAMINED','SUM_CREATED_TMP_TABLES','SUM_SORT_SCAN','SUM_NO_INDEX_USED' ) +); +$conf['plugins'] = array( + + 'visual_explain' => '/usr/bin/pt-visual-explain', + 'query_advisor' => '/usr/bin/pt-query-advisor', + + 'show_create' => true, + 'show_status' => true, + + 'explain' => function ($sample) { + $conn = array(); + + if (!array_key_exists('hostname_max',$sample) or strlen($sample['hostname_max']) < 5) + { + return; + } + + $pos = strpos($sample['hostname_max'], ':'); + if ($pos === false) + { + $conn['port'] = 3306; + $conn['host'] = $sample['hostname_max']; + } + else + { + $parts = preg_split("/:/", $sample['hostname_max']); + $conn['host'] = $parts[0]; + $conn['port'] = $parts[1]; + } + + $conn['db'] = 'mysql'; + if ($sample['db_max'] != '') + { + $conn['db'] = $sample['db_max']; + } + + $conn['user'] = 'root'; + $conn['password'] = ''; + + return $conn; + }, +); + +$conf['reports']['slow_query_log'] = array( + 'join' => array ( + 'dimension' => 'USING (`checksum`)' + ), + 'fields' => array( + 'fact' => array( + 'group' => 'group', + 'order' => 'order', + 'having' => 'having', + 'limit' => 'limit', + 'first_seen'=> 'clear|reldate|ge|where', + 'where' => 'raw_where', + 'sample' => 'clear|like|where', + 'checksum' => 'clear|where', + 'reviewed_status' => 'clear|where', + + ), + + 'dimension' => array( + 'extra_fields' => 'where', + 'hostname_max' => 'clear|where', + 'ts_min' => 'date_range|reldate|clear|where', + 'pivot-hostname_max' => 'clear|pivot|select', + 'pivot-checksum' => 'clear|pivot|select', + ), + ), + 'custom_fields' => array( + 'checksum' => 'checksum', + 'date' => 'DATE(ts_min)', + 'hour' => 'substring(ts_min,1,13)', + 'hour_ts' => 'round(unix_timestamp(substring(ts_min,1,13)))', + 'minute_ts' => 'round(unix_timestamp(substring(ts_min,1,16)))', + 'minute' => 'substring(ts_min,1,16)', + 'snippet' => 'LEFT(dimension.sample,20)', + 'index_ratio' =>'ROUND(SUM(Rows_examined_sum)/SUM(rows_sent_sum),2)', + 'query_time_avg' => 'SUM(Query_time_sum) / SUM(ts_cnt)', + 'rows_sent_avg' => 'ROUND(SUM(Rows_sent_sum)/SUM(ts_cnt),0)', + ), + + 'callbacks' => array( + 'table' => array( + 'date' => function ($x) { $type=''; if ( date('N',strtotime($x)) >= 6) { $type = 'weekend'; } return array($x,$type); }, + 'checksum' => function ($x) { return array(dec2hex($x), ''); } + ) + ) + +); + +$conf['reports']['performance_schema'] = array( + 'fields' => array( + 'fact' => array( + 'order' => 'order', + 'having' => 'having', + 'limit' => 'limit', + 'first_seen' => 'date_range|reldate|clear|where', + 'where' => 'raw_where', + 'DIGEST' => 'clear|where', + 'DIGEST_TEXT' => 'clear|like|where', + 'group' => 'group', + ), + ), + 'custom_fields' => array( + 'snippet' => 'LEFT(fact.DIGEST_TEXT,20)', + 'index_ratio' =>'ROUND(SUM_ROWS_EXAMINED/SUM_ROWS_SENT,2)', + 'rows_sent_avg' => 'ROUND(SUM_ROWS_SENT/COUNT_STAR,0)', + + ), + + 'special_field_names' => array( + 'time' => 'FIRST_SEEN', + 'checksum' => 'DIGEST', + 'sample' => 'DIGEST_TEXT', + 'fingerprint' => 'DIGEST_TEXT', + ), +); + +$conf['reports']['performance_schema_history'] = array( + 'join' => array ( + 'dimension' => 'USING (`DIGEST`)' + ), + 'fields' => array( + 'fact' => array( + 'group' => 'group', + 'order' => 'order', + 'having' => 'having', + 'limit' => 'limit', + 'first_seen'=> 'clear|reldate|ge|where', + 'where' => 'raw_where', + 'DIGEST_TEXT' => 'clear|like|where', + 'DIGEST' => 'clear|where', + 'reviewed_status' => 'clear|where', + + ), + + 'dimension' => array( + 'extra_fields' => 'where', + 'hostname' => 'clear|where', + 'FIRST_SEEN' => 'date_range|reldate|clear|where', + 'pivot-hostname' => 'clear|pivot|select', + ), + ), + 'custom_fields' => array( + 'date' => 'DATE(fact.FIRST_SEEN)', + 'snippet' => 'LEFT(fact.DIGEST_TEXT,20)', + 'index_ratio' =>'ROUND(SUM_ROWS_EXAMINED/SUM_ROWS_SENT,2)', + 'rows_sent_avg' => 'ROUND(SUM_ROWS_SENT/COUNT_STAR,0)', + 'hour' => 'substring(dimension.FIRST_SEEN,1,13)', + 'hour_ts' => 'round(unix_timestamp(substring(dimension.FIRST_SEEN,1,13)))', + 'minute_ts' => 'round(unix_timestamp(substring(dimension.FIRST_SEEN,1,16)))', + 'minute' => 'substring(dimension.FIRST_SEEN,1,16)', + ), + + 'special_field_names' => array( + 'time' => 'FIRST_SEEN', + 'checksum' => 'DIGEST', + 'hostname' => 'hostname', + 'sample' => 'DIGEST_TEXT' + ), +); + +?> diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 88598ce6..e2b80922 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -38,3 +38,8 @@ class EEMysql(): except Exception as e: print("Error occured while executing "+statement) return False + + def close(self): + self.cur.close() + self.conn.close() + From 46cb343d725bb6bbf9aa632350c68672a4721fea Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 22 Dec 2014 16:32:15 +0530 Subject: [PATCH 534/829] Added code to remove Anemometer --- ee/cli/plugins/stack.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 96861825..135e62e0 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -343,9 +343,9 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/cache/opcache', '/var/www/22222/htdocs/cache/nginx/' 'clean.php', - '/var/www/22222/htdocs/cache/memcache'] - if self.app.pargs.anemometer: - packages = packages + ['/var/www/22222/htdocs/db/anemometer'] + '/var/www/22222/htdocs/cache/memcache', + '/usr/bin/pt-query-advisor', + '/var/www/22222/htdocs/db/anemometer'] if len(apt_packages): pkg.remove(apt_packages) @@ -386,9 +386,10 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/cache/opcache', '/var/www/22222/htdocs/cache/nginx/' 'clean.php', - '/var/www/22222/htdocs/cache/memcache'] - if self.app.pargs.anemometer: - packages = packages + ['/var/www/22222/htdocs/db/anemometer'] + '/var/www/22222/htdocs/cache/memcache', + '/usr/bin/pt-query-advisor', + '/var/www/22222/htdocs/db/anemometer' + ] if len(apt_packages): pkg.purge(apt_packages) From c0b633f462bad3fca2792938f25fde07bb0da3a8 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 22 Dec 2014 16:48:31 +0530 Subject: [PATCH 535/829] added ee stack status --- ee/cli/plugins/stack_services.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index 2e154042..b82e91a2 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -78,4 +78,21 @@ class EEStackStatusController(CementBaseController): @expose(help="get stack status") def status(self): - pass + services = [] + if self.app.pargs.nginx: + services = services + ['nginx'] + elif self.app.pargs.php: + services = services + ['php5-fpm'] + elif self.app.pargs.mysql: + services = services + ['mysql'] + elif self.app.pargs.postfix: + services = services + ['postfix'] + elif self.app.pargs.memcache: + services = services + ['memcached'] + elif self.app.pargs.dovecot: + services = services + ['dovecot'] + else: + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] + for service in services: + if EEService.get_service_status(service): + print("{0}: Running".format(service)) From a326c5fa12906d6b335bd51562ec2e8f3140bce6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 22 Dec 2014 17:59:06 +0530 Subject: [PATCH 536/829] Updated setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index b06392fe..fe9b3c7a 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ setup(name='ee', 'pystache', 'python-apt', 'pynginxconfig', + 'pymysql3', ], setup_requires=[], entry_points=""" From cc6c41729846c703820ef4b3f01a59809d9f487b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 22 Dec 2014 18:35:35 +0530 Subject: [PATCH 537/829] Dovecot setup --- ee/cli/plugins/stack.py | 15 +++++++++++++-- ee/core/variables.py | 8 ++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 135e62e0..c2f86606 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -101,6 +101,18 @@ class EEStackController(CementBaseController): else: EERepo.add(ppa=EEVariables.ee_php_repo) + if set(EEVariables.ee_dovecot).issubset(set(apt_packages)): + if EEVariables.ee_platform_codename == 'squeeze': + print("Adding repository for dovecot ... ") + EERepo.add(repo_url=EEVariables.ee_dovecot_repo) + + EEShellExec.cmd_exec("echo \"dovecot-core dovecot-core/" + "create-ssl-cert boolean yes\" " + "| debconf-set-selections") + EEShellExec.cmd_exec("echo \"dovecot-core dovecot-core/ssl-cert-" + "name string $(hostname -f)\"" + " | debconf-set-selections") + @expose(hide=True) def post_pref(self, apt_packages, packages): if len(apt_packages): @@ -243,8 +255,7 @@ class EEStackController(CementBaseController): pass # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: - pass - # apt_packages = apt_packages + EEVariables.ee_nginx + apt_packages = apt_packages + EEVariables.ee_dovecot if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: diff --git a/ee/core/variables.py b/ee/core/variables.py index efb9a6f0..3618388d 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -39,6 +39,14 @@ class EEVariables(): ee_postfix_repo = "" ee_postfix = ["postfix"] + # Dovecot repo and packages + ee_dovecot_repo = ("deb http://http.debian.net/debian-backports {codename}" + "-backports main".format(codename=ee_platform_codename)) + + ee_dovecot = ["dovecot-core", "dovecot-imapd", "dovecot-pop3d", + "dovecot-lmtpd", "dovecot-mysql", "dovecot-sieve", + "dovecot-managesieved"] + # Repo ee_repo_file = "ee-repo.list" ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file) From 75a2faa35f3c3eb493517b51ea64de10204c20ef Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 22 Dec 2014 19:46:43 +0530 Subject: [PATCH 538/829] Addded Dovecot template --- ee/cli/templates/dovecot.mustache | 48 +++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ee/cli/templates/dovecot.mustache diff --git a/ee/cli/templates/dovecot.mustache b/ee/cli/templates/dovecot.mustache new file mode 100644 index 00000000..c4062322 --- /dev/null +++ b/ee/cli/templates/dovecot.mustache @@ -0,0 +1,48 @@ +protocols = imap pop3 lmtp sieve + +mail_location = maildir:/var/vmail/%d/%n + +disable_plaintext_auth = no +auth_mechanisms = plain login +#!include auth-system.conf.ext +!include auth-sql.conf.ext + +ssl_protocols = !SSLv2 !SSLv3 + +service lmtp { + unix_listener /var/spool/postfix/private/dovecot-lmtp { + mode = 0600 + user = postfix + group = postfix + } +} +service auth { + unix_listener /var/spool/postfix/private/auth { + mode = 0666 + user = postfix + group = postfix + } + unix_listener auth-userdb { + mode = 0600 + user = vmail + } + user = dovecot +} +service auth-worker { + user = vmail +} + +log_path = /var/log/dovecot.log + +mail_plugins = $mail_plugins autocreate + +plugin { + autocreate = Trash + autocreate2 = Junk + autocreate3 = Drafts + autocreate4 = Sent + autosubscribe = Trash + autosubscribe2 = Junk + autosubscribe3 = Drafts + autosubscribe4 = Sent +} From 7bc3eb121f49e71d050a51d7fc118be3255104e4 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Dec 2014 11:55:37 +0530 Subject: [PATCH 539/829] Improved ee stack purge --- ee/cli/plugins/stack.py | 2 +- ee/core/aptget.py | 100 ++++++++++++++++++++++++++++++---------- 2 files changed, 76 insertions(+), 26 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 135e62e0..c35df985 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -392,7 +392,7 @@ class EEStackController(CementBaseController): ] if len(apt_packages): - pkg.purge(apt_packages) + pkg.remove(apt_packages, purge=True) if len(packages): EEFileUtils.remove(packages) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index dd6d5886..5c10b1e9 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -1,6 +1,5 @@ """EasyEngine package installation using apt-get module.""" import apt -import apt_pkg import sys @@ -110,29 +109,84 @@ class EEAptGet: return(False) return(True) - def remove(self, packages, purge_value=False): - """Removal of packages Similar to apt-get remove""" - self.__init__() + def __dependencies_loop(self, deplist, pkg, onelevel=False): + """ Loops through pkg's dependencies. + Returns a list with every package found. """ + if not self.cache: + self.cache = apt.Cache() + if onelevel: + onelevellist = [] + if not pkg.is_installed: + return + for depf in pkg.installed.dependencies: + for dep in depf: + if (dep.name in self.cache and not self.cache[dep.name] + in deplist): + deplist.append(self.cache[dep.name]) + self.__dependencies_loop(deplist, self.cache[dep.name]) + if onelevel: + if dep.name in self.cache: + onelevellist.append(self.cache[dep.name]) + if onelevel: + return onelevellist + + def remove(self, packages, auto=True, purge=False): my_selected_packages = [] - # apt cache Initialization - self.cache = apt.Cache() - # Read cache i.e package list - self.cache.open() for package in packages: - pkg = self.cache[package] - # Check if packages installed - if pkg.is_installed and not pkg.marked_delete: - with self.cache.actiongroup(): - # Mark packages for delete - # Mark to purge package if purge_value is True - pkg.mark_delete(purge=purge_value) - my_selected_packages.append(pkg.name) + print("processing", package) + package = self.cache[package] + if not package.is_installed: + print("Package '{package_name}' is not installed," + " so not removed." + .format(package_name=package.name)) + continue + if package.marked_delete: + continue + else: + my_selected_packages.append(package.name) + # How logic works: + # 1) We loop trough dependencies's dependencies and add them to + # the list. + # 2) We sequentially remove every package in list + # - via is_auto_installed we check if we can safely remove it + deplist = [] + onelevel = self.__dependencies_loop(deplist, package, + onelevel=True) + # Mark for deletion the first package, to fire up auto_removable + # Purge? + if purge: + package.mark_delete(purge=True) else: - # Check If package not already marked for delete - if not pkg.marked_delete: - print("Package '{package_name}' is not installed," - " so not removed." - .format(package_name=package)) + package.mark_delete(purge=False) + # Also ensure we remove AT LEAST the first level of dependencies + # (that is, the actual package's dependencies). + if auto: + markedauto = [] + for pkg in onelevel: + if (not pkg.marked_install and pkg.is_installed + and not pkg.is_auto_installed): + pkg.mark_auto() + markedauto.append(pkg) + + for pkg in deplist: + if (not pkg.marked_install and pkg.is_installed and + pkg.is_auto_removable): + # Purge? + if purge: + pkg.mark_delete(purge=True) + else: + pkg.mark_delete(purge=False) + # Restore auted items + for pkg in markedauto: + if not pkg.marked_delete: + pkg.mark_auto(False) + else: + # We need to ensure that the onelevel packages are not marked + # as automatically installed, otherwise the user may drop + # them via autoremove or aptitude. + for pkg in onelevel: + if pkg.is_installed and pkg.is_auto_installed: + pkg.mark_auto(auto=False) # Check if packages available for remove/update. if self.cache.delete_count > 0: @@ -150,7 +204,3 @@ class EEAptGet: .format(err=str(e))) return(False) return(True) - - def purge(self, packages): - """Purging of packages similar to apt-get purge""" - return(self.remove(packages, purge_value=True)) From 9f818ee227af5883625cb013d16e1263586dfc83 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Dec 2014 13:29:44 +0530 Subject: [PATCH 540/829] enabled logging --- ee/cli/main.py | 4 ++-- ee/cli/plugins/stack_services.py | 8 ++++---- ee/core/services.py | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ee/cli/main.py b/ee/cli/main.py index 64755ee1..f5c84d76 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -24,8 +24,8 @@ class EEApp(foundation.CementApp): label = 'ee' # Log writing to file - # defaults = init_defaults('ee', 'log.logging') - # defaults['log.logging']['file'] = '/tmp/my.log' + defaults = init_defaults('ee', 'log.logging') + defaults['log.logging']['file'] = '/tmp/my.log' config_defaults = defaults diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index b82e91a2..ee23866c 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -34,7 +34,7 @@ class EEStackStatusController(CementBaseController): else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: - EEService.start_service(service) + EEService.start_service(self, service) @expose(help="stop stack services") def stop(self): @@ -54,7 +54,7 @@ class EEStackStatusController(CementBaseController): else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: - EEService.stop_service(service) + EEService.stop_service(self, service) @expose(help="restart stack services") def restart(self): @@ -74,7 +74,7 @@ class EEStackStatusController(CementBaseController): else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: - EEService.restart_service(service) + EEService.restart_service(self, service) @expose(help="get stack status") def status(self): @@ -94,5 +94,5 @@ class EEStackStatusController(CementBaseController): else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: - if EEService.get_service_status(service): + if EEService.get_service_status(self, service): print("{0}: Running".format(service)) diff --git a/ee/core/services.py b/ee/core/services.py index 63c488b5..99638476 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -11,19 +11,19 @@ class EEService(): # TODO method for services pass - def start_service(service_name): + def start_service(self, service_name): try: retcode = subprocess.getstatusoutput('service {0} start' .format(service_name)) if retcode[0] == 0: print("Started : {0}".format(service_name)) else: - print(retcode[1]) + self.app.log.error(retcode[1]) except OSError as e: - print("Execution failed:", e) + self.app.log.error("Execution failed:", e) return False - def stop_service(service_name): + def stop_service(self, service_name): try: retcode = subprocess.getstatusoutput('service {0} stop' .format(service_name)) @@ -33,17 +33,17 @@ class EEService(): else: return False except OSError as e: - print("Execution failed:", e) + self.app.log.error("Execution failed:", e) return False - def restart_service(service_name): + def restart_service(self, service_name): try: EEService.stop_service(service_name) EEService.start_service(service_name) except OSError as e: - print("Execution failed:", e) + self.app.log.error("Execution failed:", e) - def get_service_status(service_name): + def get_service_status(self, service_name): try: is_exist = subprocess.getstatusoutput('which {0}' .format(service_name))[0] From 3802ef87f47972f4217255e326a34bf477154766 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 14:08:30 +0530 Subject: [PATCH 541/829] More tweaks to ee stack install --- ee/cli/plugins/stack.py | 11 +++++++++++ ee/cli/templates/auth-sql-conf.mustache | 11 +++++++++++ ee/cli/templates/dovecot-sql-conf.mustache | 12 ++++++++++++ ee/core/variables.py | 14 +++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 ee/cli/templates/auth-sql-conf.mustache create mode 100644 ee/cli/templates/dovecot-sql-conf.mustache diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c2f86606..90769bb4 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -182,6 +182,17 @@ class EEStackController(CementBaseController): with open('/etc/mysql/my.cnf', 'w') as configfile: config.write(configfile) + if set(EEVariables.ee_dovecot).issubset(set(apt_packages)): + EEShellExec.cmd_exec("adduser --uid 5000 --home /var/vmail" + "--disabled-password --gecos '' vmail") + EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" + "-subj /commonName={HOSTNAME}/emailAddres" + "s={EMAIL} -out /etc/ssl/certs/dovecot." + "pem -keyout /etc/ssl/private/dovecot.pem" + .format(HOSTNAME=EEVariables.ee_fqdn, + EMAIL=EEVariables.ee_email)) + EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/dovecot.pem") + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") diff --git a/ee/cli/templates/auth-sql-conf.mustache b/ee/cli/templates/auth-sql-conf.mustache new file mode 100644 index 00000000..8854747b --- /dev/null +++ b/ee/cli/templates/auth-sql-conf.mustache @@ -0,0 +1,11 @@ +passdb { + driver = sql + args = /etc/dovecot/dovecot-sql.conf.ext +} +userdb { + driver = prefetch +} +userdb { + driver = sql + args = /etc/dovecot/dovecot-sql.conf.ext +} diff --git a/ee/cli/templates/dovecot-sql-conf.mustache b/ee/cli/templates/dovecot-sql-conf.mustache new file mode 100644 index 00000000..8c76123d --- /dev/null +++ b/ee/cli/templates/dovecot-sql-conf.mustache @@ -0,0 +1,12 @@ +driver = mysql +connect = host=localhost user=vimbadmin password={{password}} dbname=vimbadmin +default_pass_scheme = MD5 +password_query = SELECT username as user, password as password, \ +homedir AS home, maildir AS mail, \ +concat('*:bytes=', quota) as quota_rule, uid, gid \ +FROM mailbox \ +WHERE username = '%Lu' AND active = '1' \ +AND ( access_restriction = 'ALL' OR LOCATE( access_restriction, '%Us' ) > 0 ) +user_query = SELECT homedir AS home, maildir AS mail, \ +concat('*:bytes=', quota) as quota_rule, uid, gid \ +FROM mailbox WHERE username = '%u' diff --git a/ee/core/variables.py b/ee/core/variables.py index 3618388d..71bb0072 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -1,15 +1,27 @@ """EasyEngine core variable module""" import platform +import socket +import confiparser +import os class EEVariables(): """Intialization of core variables""" + config = configparser.ConfigParser() + config.read(os.path.expanduser("~")+'/.gitconfig') # EasyEngine core variables ee_platform_distro = platform.linux_distribution()[0] ee_platform_version = platform.linux_distribution()[1] ee_platform_codename = platform.linux_distribution()[2] + # Get FQDN of system + ee_fqdn = socket.getfqdn() + + # Get git user name and EMail + ee_user = config['user']['name'] + ee_email = config['user']['email'] + # EasyEngine stack installation varibales # Nginx repo and packages if ee_platform_distro == 'Ubuntu': @@ -42,7 +54,7 @@ class EEVariables(): # Dovecot repo and packages ee_dovecot_repo = ("deb http://http.debian.net/debian-backports {codename}" "-backports main".format(codename=ee_platform_codename)) - + ee_dovecot = ["dovecot-core", "dovecot-imapd", "dovecot-pop3d", "dovecot-lmtpd", "dovecot-mysql", "dovecot-sieve", "dovecot-managesieved"] From 7b344662269d0a3d0c97bdefa89027cc4189c624 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 15:01:45 +0530 Subject: [PATCH 542/829] Some more tweaks to installation --- ee/cli/plugins/stack.py | 12 +++++++++++- ee/core/variables.py | 5 +++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 014a2d60..82f27dee 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -74,7 +74,7 @@ class EEStackController(CementBaseController): "$(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): print("Adding repository for mysql ... ") - EERepo.add(ppa=EEVariables.ee_mysql_repo) + EERepo.add(repo_url=EEVariables.ee_mysql_repo) EERepo.add_key('1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) print("Pre-seeding mysql variables ... ") @@ -86,6 +86,16 @@ class EEStackController(CementBaseController): "percona-server-server/root_password_again " "password {chars}\" | " "debconf-set-selections".format(chars=chars)) + mysql_config = """ + [mysqld] + user = root + password = {chars} + """.format(chars=chars) + config = configparser.ConfigParser() + config.read_string(mysql_config) + with open(os.path.expanduser("~")+'/.my.cnf', 'w') as configfile: + config.write(configfile) + if set(EEVariables.ee_nginx).issubset(set(apt_packages)): print("Adding repository for nginx ... ") if EEVariables.ee_platform_distro == 'Debian': diff --git a/ee/core/variables.py b/ee/core/variables.py index 71bb0072..d67f4028 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -1,7 +1,7 @@ """EasyEngine core variable module""" import platform import socket -import confiparser +import configparser import os @@ -44,7 +44,8 @@ class EEVariables(): "php5-mcrypt", "php5-xdebug"] # MySQL repo and packages - ee_mysql_repo = "" + ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main" + .format(codename=ee_platform_codename)) ee_mysql = ["percona-server-server-5.6"] # Postfix repo and packages From 44aeb1c9f5c93ac38df52a72e2b33fa35a33ad33 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 15:22:48 +0530 Subject: [PATCH 543/829] Dovecot Done --- ee/cli/plugins/stack.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 82f27dee..ad8f12b1 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -196,13 +196,19 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("adduser --uid 5000 --home /var/vmail" "--disabled-password --gecos '' vmail") EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" - "-subj /commonName={HOSTNAME}/emailAddres" - "s={EMAIL} -out /etc/ssl/certs/dovecot." + " -subj /commonName={HOSTNAME}/emailAddre" + "ss={EMAIL} -out /etc/ssl/certs/dovecot." "pem -keyout /etc/ssl/private/dovecot.pem" .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/dovecot.pem") + # Custom Dovecot configuration by EasyEngine + data = dict() + ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf', 'w') + self.app.render((data), 'dovecot.mustache', out=ee_dovecot) + ee_dovecot.close() + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") From a5abc3dbaab2690c756ac8140cff78ac52d52358 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Dec 2014 15:28:45 +0530 Subject: [PATCH 544/829] minor changes --- ee/cli/plugins/stack.py | 1 - ee/core/aptget.py | 14 +++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 7e33e81d..1e35b2ed 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -314,7 +314,6 @@ class EEStackController(CementBaseController): self.pre_pref(apt_packages) if len(apt_packages): - pkg.update() pkg.install(apt_packages) if len(packages): EEDownload.download(packages) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 5c10b1e9..285c3a96 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -14,13 +14,14 @@ class EEAptGet: def update(self): """Similar to apt-get update""" self.cache.update(self.fprogress) - pass + self.cache.open() def upgrade(self, packages): """Similar to apt-get update""" my_selected_packages = [] # Cache Initialization - self.cache = apt.Cache() + if not self.cache: + self.cache = apt.Cache() # Cache Read self.cache.open() for package in packages: @@ -64,9 +65,11 @@ class EEAptGet: """Installation of packages""" my_selected_packages = [] # Cache Initialization - self.cache = apt.Cache() + if not self.cache: + self.cache = apt.Cache() # Cache Read self.cache.open() + for package in packages: pkg = self.cache[package] # Check Package Installed @@ -132,6 +135,11 @@ class EEAptGet: def remove(self, packages, auto=True, purge=False): my_selected_packages = [] + # Cache Initialization + if not self.cache: + self.cache = apt.Cache() + # Cache Read + self.cache.open() for package in packages: print("processing", package) package = self.cache[package] From b345c9fa75ae60170458bbac3121df11610f5c55 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 15:36:04 +0530 Subject: [PATCH 545/829] Exception for git --- ee/cli/plugins/stack.py | 3 +++ ee/core/variables.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index ad8f12b1..2be850e8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -209,6 +209,9 @@ class EEStackController(CementBaseController): self.app.render((data), 'dovecot.mustache', out=ee_dovecot) ee_dovecot.close() + # Custom Postfix configuration needed with Dovecot + + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") diff --git a/ee/core/variables.py b/ee/core/variables.py index d67f4028..aadb60a6 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -3,6 +3,7 @@ import platform import socket import configparser import os +import sys class EEVariables(): @@ -19,8 +20,12 @@ class EEVariables(): ee_fqdn = socket.getfqdn() # Get git user name and EMail - ee_user = config['user']['name'] - ee_email = config['user']['email'] + try: + ee_user = config['user']['name'] + ee_email = config['user']['email'] + except KeyError as e: + print("Unable to find GIT user name and Email") + sys.exit(1) # EasyEngine stack installation varibales # Nginx repo and packages From 976cf5a874ed3222e4cace876765e55df2fcd598 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 23 Dec 2014 15:48:59 +0530 Subject: [PATCH 546/829] test case --- tests/cli/test_stack.py | 76 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/cli/test_stack.py diff --git a/tests/cli/test_stack.py b/tests/cli/test_stack.py new file mode 100644 index 00000000..a108e594 --- /dev/null +++ b/tests/cli/test_stack.py @@ -0,0 +1,76 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseStack(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_web(self): + self.app = get_test_app(argv=['stack', 'install', '--web']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_admin(self): + self.app = get_test_app(argv=['stack', 'install', '--admin']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_mail(self): + self.app = get_test_app(argv=['stack', 'install', '--mail']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_nginx(self): + self.app = get_test_app(argv=['stack', 'install', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_php(self): + self.app = get_test_app(argv=['stack', 'install', '--php']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_mysql(self): + self.app = get_test_app(argv=['stack', 'install', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_postfix(self): + self.app = get_test_app(argv=['stack', 'install', '--postfix']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_wpcli(self): + self.app = get_test_app(argv=['stack', 'install', '--wpcli']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_phpmyadmin(self): + self.app = get_test_app(argv=['stack', 'install', '--phpmyadmin']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_adminer(self): + self.app = get_test_app(argv=['stack', 'install', '--adminer']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_utils(self): + self.app = get_test_app(argv=['stack', 'install', '--utils']) + self.app.setup() + self.app.run() + self.app.close() From 4499c088acd34c5ae5f5f43600b9df08d67fc0a6 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Dec 2014 15:56:00 +0530 Subject: [PATCH 547/829] Exception handling while package install --- ee/core/aptget.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 285c3a96..efa35f41 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -71,7 +71,10 @@ class EEAptGet: self.cache.open() for package in packages: - pkg = self.cache[package] + try: + pkg = self.cache[package] + except KeyError as e: + continue # Check Package Installed if pkg.is_installed or pkg.marked_install: # Check Package is Upgradeble @@ -83,7 +86,7 @@ class EEAptGet: if not pkg.marked_install: print("\'{package_name}-{package_ver}\'" "already the newest version" - .format(package_name=pkg.name, + .format(package_name=pkg.shortname, package_ver=pkg.installed)) else: with self.cache.actiongroup(): From d24c791e3e0bec88be944d1d88ab1d8d2734f11f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 15:56:10 +0530 Subject: [PATCH 548/829] Postfix configuration --- ee/cli/plugins/stack.py | 12 +++++++++++- ee/core/variables.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 2be850e8..e0b82e14 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -210,7 +210,17 @@ class EEStackController(CementBaseController): ee_dovecot.close() # Custom Postfix configuration needed with Dovecot - + # Changes in master.cf + # TODO: Find alternative for sed in Python + EEShellExec.cmd_exec("sed -i 's/#submission/submission/'" + "/etc/postfix/master.cf") + EEShellExec.cmd_exec("sed -i 's/#smtps/smtps/'" + " /etc/postfix/master.cf") + + EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_type =" + " dovecot\"") + EEShellExec.cmd_ + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): diff --git a/ee/core/variables.py b/ee/core/variables.py index aadb60a6..5f39abb5 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -63,7 +63,7 @@ class EEVariables(): ee_dovecot = ["dovecot-core", "dovecot-imapd", "dovecot-pop3d", "dovecot-lmtpd", "dovecot-mysql", "dovecot-sieve", - "dovecot-managesieved"] + "dovecot-managesieved", "postfix-mysql"] # Repo ee_repo_file = "ee-repo.list" From 89730d899a33f1a2fa15a9679308bfa42a431acc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 16:52:29 +0530 Subject: [PATCH 549/829] Postfix configuration --- ee/cli/plugins/stack.py | 50 +++++++++++++++++-- ee/cli/templates/virtual_alias_maps.mustache | 5 ++ .../templates/virtual_domains_maps.mustache | 5 ++ .../templates/virtual_mailbox_maps.mustache | 7 +++ 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 ee/cli/templates/virtual_alias_maps.mustache create mode 100644 ee/cli/templates/virtual_domains_maps.mustache create mode 100644 ee/cli/templates/virtual_mailbox_maps.mustache diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index b4954546..cd394959 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -217,10 +217,52 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("sed -i 's/#smtps/smtps/'" " /etc/postfix/master.cf") - EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_type =" - " dovecot\"") - EEShellExec.cmd_ - + EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_type = " + "dovecot\"") + EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_path = " + "private/auth\"") + EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_auth_enable = " + "yes\"") + EEShellExec.cmd_exec("postconf -e \"smtpd_relay_restrictions =" + " permit_sasl_authenticated, " + "permit_mynetworks, " + "reject_unauth_destination\"") + EEShellExec.cmd_exec("postconf -e \"smtpd_tls_mandatory_" + "protocols = !SSLv2,!SSLv3"") + EEShellExec.cmd_exec("postconf -e \"smtp_tls_mandatory_" + "protocols = !SSLv2,!SSLv3"") + EEShellExec.cmd_exec("postconf -e \"smtpd_tls_protocols " + "= !SSLv2,!SSLv3\"") + EEShellExec.cmd_exec("postconf -e \"smtp_tls_protocols " + "= !SSLv2,!SSLv3\"") + EEShellExec.cmd_exec("postconf -e \"mydestination " + "= localhost\"") + EEShellExec.cmd_exec("postconf -e \"virtual_transport " + "= lmtp:unix:private/dovecot-lmtp\"") + EEShellExec.cmd_exec("postconf -e \"virtual_uid_maps " + "= static:5000\"") + EEShellExec.cmd_exec("postconf -e \"virtual_gid_maps " + "= static:500\"") + EEShellExec.cmd_exec("postconf -e \"virtual_mailbox_domains = " + "mysql:/etc/postfix/mysql/virtual_" + "domains_maps.cf\"") + EEShellExec.cmd_exec("postconf -e \"virtual_mailbox_maps = " + "mysql:/etc/postfix/mysql/virtual_" + "mailbox_maps.cf\"") + EEShellExec.cmd_exec("postconf -e \"virtual_alias_maps = " + "mysql:/etc/postfix/mysql/virtual_" + "alias_maps.cf\"") + EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" + "-subj /commonName={HOSTNAME}/emailAddres" + "s={EMAIL} -out /etc/ssl/certs/postfix.pe" + "m -keyout /etc/ssl/private/postfix.pem" + .format(HOSTNAME=EEVariables.ee_fqdn, + EMAIL=EEVariables.ee_email)) + EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/postfix.pem") + EEShellExec.cmd_exec("postconf -e smtpd_tls_cert_file = " + "/etc/ssl/certs/postfix.pem") + EEShellExec.cmd_exec("postconf -e smtpd_tls_key_file = " + "/etc/ssl/private/postfix.pem") if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): diff --git a/ee/cli/templates/virtual_alias_maps.mustache b/ee/cli/templates/virtual_alias_maps.mustache new file mode 100644 index 00000000..f155569d --- /dev/null +++ b/ee/cli/templates/virtual_alias_maps.mustache @@ -0,0 +1,5 @@ +user = vimbadmin +password = {{password}} +hosts = 127.0.0.1 +dbname = vimbadmin +query = SELECT goto FROM alias WHERE address = '%s' AND active = '1' diff --git a/ee/cli/templates/virtual_domains_maps.mustache b/ee/cli/templates/virtual_domains_maps.mustache new file mode 100644 index 00000000..5ca23900 --- /dev/null +++ b/ee/cli/templates/virtual_domains_maps.mustache @@ -0,0 +1,5 @@ +user = vimbadmin +password = {{password}} +hosts = 127.0.0.1 +dbname = vimbadmin +query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1' diff --git a/ee/cli/templates/virtual_mailbox_maps.mustache b/ee/cli/templates/virtual_mailbox_maps.mustache new file mode 100644 index 00000000..bb2e8b1b --- /dev/null +++ b/ee/cli/templates/virtual_mailbox_maps.mustache @@ -0,0 +1,7 @@ +user = vimbadmin +password = {{password}} +hosts = 127.0.0.1 +dbname = vimbadmin +table = mailbox +select_field = maildir +where_field = username From 3e20f85dec66f9672b91ba52b858b2baa254a1d1 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 16:59:47 +0530 Subject: [PATCH 550/829] Fixed typos --- ee/cli/plugins/stack.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index cd394959..3e1f57d7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -228,9 +228,9 @@ class EEStackController(CementBaseController): "permit_mynetworks, " "reject_unauth_destination\"") EEShellExec.cmd_exec("postconf -e \"smtpd_tls_mandatory_" - "protocols = !SSLv2,!SSLv3"") + "protocols = !SSLv2,!SSLv3\"") EEShellExec.cmd_exec("postconf -e \"smtp_tls_mandatory_" - "protocols = !SSLv2,!SSLv3"") + "protocols = !SSLv2,!SSLv3\"") EEShellExec.cmd_exec("postconf -e \"smtpd_tls_protocols " "= !SSLv2,!SSLv3\"") EEShellExec.cmd_exec("postconf -e \"smtp_tls_protocols " @@ -253,9 +253,9 @@ class EEStackController(CementBaseController): "mysql:/etc/postfix/mysql/virtual_" "alias_maps.cf\"") EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" - "-subj /commonName={HOSTNAME}/emailAddres" - "s={EMAIL} -out /etc/ssl/certs/postfix.pe" - "m -keyout /etc/ssl/private/postfix.pem" + " -subj /commonName={HOSTNAME}/emailAddre" + "ss={EMAIL} -out /etc/ssl/certs/postfix." + "pem -keyout /etc/ssl/private/postfix.pem" .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/postfix.pem") From bbdc8cf05c3d9ddb4b029d5d8b82ccb7ebb0be58 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Dec 2014 18:35:10 +0530 Subject: [PATCH 551/829] moved site controller to plugins --- ee/cli/bootstrap.py | 6 -- ee/cli/controllers/site.py | 144 ------------------------------------- 2 files changed, 150 deletions(-) delete mode 100644 ee/cli/controllers/site.py diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index de3c5108..b22b6ca3 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -5,9 +5,6 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController -from ee.cli.controllers.site import EESiteController -from ee.cli.controllers.site import EESiteCreateController -from ee.cli.controllers.site import EESiteUpdateController from ee.cli.controllers.debug import EEDebugController from ee.cli.controllers.clean import EECleanController from ee.cli.controllers.secure import EESecureController @@ -17,9 +14,6 @@ from ee.cli.controllers.info import EEInfoController def load(app): handler.register(EEBaseController) - handler.register(EESiteController) - handler.register(EESiteCreateController) - handler.register(EESiteUpdateController) handler.register(EEDebugController) handler.register(EECleanController) handler.register(EEInfoController) diff --git a/ee/cli/controllers/site.py b/ee/cli/controllers/site.py deleted file mode 100644 index bee9cb9e..00000000 --- a/ee/cli/controllers/site.py +++ /dev/null @@ -1,144 +0,0 @@ -"""EasyEngine site controller.""" - -from cement.core.controller import CementBaseController, expose -from ee.core.dummy import EEDummy - - -class EESiteController(CementBaseController): - class Meta: - label = 'site' - stacked_on = 'base' - stacked_type = 'nested' - description = 'site command manages website configuration with the help \ - of the following subcommands' - arguments = [ - (['site_name'], - dict(help='website name')), - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee site command - print("Inside EESiteController.default().") - - @expose(help="delete site example.com") - def delete(self): - # TODO Write code for ee site delete command here - print("Inside EESiteController.delete().") - - @expose(help="enable site example.com") - def enable(self): - # TODO Write code for ee site enable command here - print("Inside EESiteController.enable().") - - @expose(help="disable site example.com") - def disable(self): - # TODO Write code for ee site disable command here - print("Inside EESiteController.disable().") - - @expose(help="get example.com information") - def info(self): - # TODO Write code for ee site info command here - print("Inside EESiteController.info().") - - @expose(help="Monitor example.com logs") - def log(self): - # TODO Write code for ee site log command here - print("Inside EESiteController.log().") - - @expose(help="Edit example.com's nginx configuration") - def edit(self): - # TODO Write code for ee site edit command here - print("Inside EESiteController.edit().") - - @expose(help="Display example.com's nginx configuration") - def show(self): - # TODO Write code for ee site edit command here - print("Inside EESiteController.show().") - - @expose(help="list sites currently available") - def list(self): - # TODO Write code for ee site list command here - print("Inside EESiteController.list().") - - @expose(help="change to example.com's webroot") - def cd(self): - # TODO Write code for ee site cd here - print("Inside EESiteController.cd().") - - -class EESiteCreateController(CementBaseController): - class Meta: - label = 'create' - stacked_on = 'site' - stacked_type = 'nested' - description = 'create command manages website configuration with the \ - help of the following subcommands' - arguments = [ - (['site_name'], - dict(help='the notorious foo option')), - (['--html'], - dict(help="html site", action='store_true')), - (['--php'], - dict(help="php site", action='store_true')), - (['--mysql'], - dict(help="mysql site", action='store_true')), - (['--wp'], - dict(help="wordpress site", action='store_true')), - (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), - (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee site command - data = dict(foo='EESiteCreateController.default().') - self.app.render((data), 'default.mustache') - - # print("Inside EESiteCreateController.default().") - - -class EESiteUpdateController(CementBaseController): - class Meta: - label = 'update' - stacked_on = 'site' - stacked_type = 'nested' - description = 'update command manages website configuration with the \ - help of the following subcommands' - arguments = [ - (['site_name'], - dict(help='website name')), - (['--html'], - dict(help="html site", action='store_true')), - (['--php'], - dict(help="php site", action='store_true')), - (['--mysql'], - dict(help="mysql site", action='store_true')), - (['--wp'], - dict(help="wordpress site", action='store_true')), - (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), - (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), - ] - - @expose(help="update example.com") - def default(self): - # TODO Write code for ee site update here - print("Inside EESiteUpdateController.default().") - - # site command Options and subcommand calls and definations to - # mention here - - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. - # From 5e5c4560bd2c79d5821febf7034549b78604120e Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 23 Dec 2014 19:11:13 +0530 Subject: [PATCH 552/829] minor update --- ee/cli/plugins/site.py | 158 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 ee/cli/plugins/site.py diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py new file mode 100644 index 00000000..7848c305 --- /dev/null +++ b/ee/cli/plugins/site.py @@ -0,0 +1,158 @@ +"""EasyEngine site controller.""" +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook + + +def ee_site_hook(app): + # do something with the ``app`` object here. + pass + + +class EESiteController(CementBaseController): + class Meta: + label = 'site' + stacked_on = 'base' + stacked_type = 'nested' + description = ('site command manages website configuration' + 'with the help of the following subcommands') + arguments = [ + (['site_name'], + dict(help='website name')), + ] + + @expose(hide=True) + def default(self): + # TODO Default action for ee site command + print("Inside EESiteController.default().") + + @expose(help="delete site example.com") + def delete(self): + # TODO Write code for ee site delete command here + print("Inside EESiteController.delete().") + + @expose(help="enable site example.com") + def enable(self): + # TODO Write code for ee site enable command here + print("Inside EESiteController.enable().") + + @expose(help="disable site example.com") + def disable(self): + # TODO Write code for ee site disable command here + print("Inside EESiteController.disable().") + + @expose(help="get example.com information") + def info(self): + # TODO Write code for ee site info command here + print("Inside EESiteController.info().") + + @expose(help="Monitor example.com logs") + def log(self): + # TODO Write code for ee site log command here + print("Inside EESiteController.log().") + + @expose(help="Edit example.com's nginx configuration") + def edit(self): + # TODO Write code for ee site edit command here + print("Inside EESiteController.edit().") + + @expose(help="Display example.com's nginx configuration") + def show(self): + # TODO Write code for ee site edit command here + print("Inside EESiteController.show().") + + @expose(help="list sites currently available") + def list(self): + # TODO Write code for ee site list command here + print("Inside EESiteController.list().") + + @expose(help="change to example.com's webroot") + def cd(self): + # TODO Write code for ee site cd here + print("Inside EESiteController.cd().") + + +class EESiteCreateController(CementBaseController): + class Meta: + label = 'create' + stacked_on = 'site' + stacked_type = 'nested' + description = 'create command manages website configuration with the \ + help of the following subcommands' + arguments = [ + (['site_name'], + dict(help='the notorious foo option')), + (['--html'], + dict(help="html site", action='store_true')), + (['--php'], + dict(help="php site", action='store_true')), + (['--mysql'], + dict(help="mysql site", action='store_true')), + (['--wp'], + dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], + dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], + dict(help="wpsubdomain site", action='store_true')), + ] + + @expose(hide=True) + def default(self): + # TODO Default action for ee site command + data = dict(foo='EESiteCreateController.default().') + self.app.render((data), 'default.mustache') + + # print("Inside EESiteCreateController.default().") + + +class EESiteUpdateController(CementBaseController): + class Meta: + label = 'update' + stacked_on = 'site' + stacked_type = 'nested' + description = 'update command manages website configuration with the \ + help of the following subcommands' + arguments = [ + (['site_name'], + dict(help='website name')), + (['--html'], + dict(help="html site", action='store_true')), + (['--php'], + dict(help="php site", action='store_true')), + (['--mysql'], + dict(help="mysql site", action='store_true')), + (['--wp'], + dict(help="wordpress site", action='store_true')), + (['--wpsubdir'], + dict(help="wpsubdir site", action='store_true')), + (['--wpsubdomain'], + dict(help="wpsubdomain site", action='store_true')), + ] + + @expose(help="update example.com") + def default(self): + # TODO Write code for ee site update here + print("Inside EESiteUpdateController.default().") + + # site command Options and subcommand calls and definations to + # mention here + + # If using an output handler such as 'mustache', you could also + # render a data dictionary using a template. For example: + # + # data = dict(foo='bar') + # self.app.render(data, 'default.mustache') + # + # + # The 'default.mustache' file would be loaded from + # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + # + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EESiteController) + handler.register(EESiteCreateController) + handler.register(EESiteUpdateController) + + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', ee_site_hook) From 6601c88cf792658858cd50bcb8d8c25308669a70 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 23 Dec 2014 19:17:28 +0530 Subject: [PATCH 553/829] added test cases for ee stack start/stop/remove/purge/status/restart --- tests/cli/test_stack_purge.py | 76 ++++++++++++++++++++++++ tests/cli/test_stack_remove.py | 76 ++++++++++++++++++++++++ tests/cli/test_stack_services_restart.py | 52 ++++++++++++++++ tests/cli/test_stack_services_start.py | 52 ++++++++++++++++ tests/cli/test_stack_services_status.py | 52 ++++++++++++++++ tests/cli/test_stack_services_stop.py | 52 ++++++++++++++++ 6 files changed, 360 insertions(+) create mode 100644 tests/cli/test_stack_purge.py create mode 100644 tests/cli/test_stack_remove.py create mode 100644 tests/cli/test_stack_services_restart.py create mode 100644 tests/cli/test_stack_services_start.py create mode 100644 tests/cli/test_stack_services_status.py create mode 100644 tests/cli/test_stack_services_stop.py diff --git a/tests/cli/test_stack_purge.py b/tests/cli/test_stack_purge.py new file mode 100644 index 00000000..433b23d4 --- /dev/null +++ b/tests/cli/test_stack_purge.py @@ -0,0 +1,76 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseStack(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_web(self): + self.app = get_test_app(argv=['stack', 'purge', '--web']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_admin(self): + self.app = get_test_app(argv=['stack', 'purge', '--admin']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_mail(self): + self.app = get_test_app(argv=['stack', 'purge', '--mail']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_nginx(self): + self.app = get_test_app(argv=['stack', 'purge', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_php(self): + self.app = get_test_app(argv=['stack', 'purge', '--php']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_mysql(self): + self.app = get_test_app(argv=['stack', 'purge', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_postfix(self): + self.app = get_test_app(argv=['stack', 'purge', '--postfix']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_wpcli(self): + self.app = get_test_app(argv=['stack', 'purge', '--wpcli']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_phpmyadmin(self): + self.app = get_test_app(argv=['stack', 'purge', '--phpmyadmin']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_adminer(self): + self.app = get_test_app(argv=['stack', 'purge', '--adminer']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_purge_utils(self): + self.app = get_test_app(argv=['stack', 'purge', '--utils']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_stack_remove.py b/tests/cli/test_stack_remove.py new file mode 100644 index 00000000..54338373 --- /dev/null +++ b/tests/cli/test_stack_remove.py @@ -0,0 +1,76 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseStack(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_remove_web(self): + self.app = get_test_app(argv=['stack', 'remove', '--web']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_admin(self): + self.app = get_test_app(argv=['stack', 'remove', '--admin']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_mail(self): + self.app = get_test_app(argv=['stack', 'remove', '--mail']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_nginx(self): + self.app = get_test_app(argv=['stack', 'remove', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_php(self): + self.app = get_test_app(argv=['stack', 'remove', '--php']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_mysql(self): + self.app = get_test_app(argv=['stack', 'remove', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_postfix(self): + self.app = get_test_app(argv=['stack', 'remove', '--postfix']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_wpcli(self): + self.app = get_test_app(argv=['stack', 'remove', '--wpcli']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_phpmyadmin(self): + self.app = get_test_app(argv=['stack', 'remove', '--phpmyadmin']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_adminer(self): + self.app = get_test_app(argv=['stack', 'remove', '--adminer']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_install_utils(self): + self.app = get_test_app(argv=['stack', 'remove', '--utils']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_stack_services_restart.py b/tests/cli/test_stack_services_restart.py new file mode 100644 index 00000000..dfe24081 --- /dev/null +++ b/tests/cli/test_stack_services_restart.py @@ -0,0 +1,52 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseStack(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_restart_nginx(self): + self.app = get_test_app(argv=['stack', 'restart', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_restart_php5_fpm(self): + self.app = get_test_app(argv=['stack', 'restart', '--php5-fpm']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_restart_mysql(self): + self.app = get_test_app(argv=['stack', 'restart', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_restart_postfix(self): + self.app = get_test_app(argv=['stack', 'restart', '--postfix']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_restart_memcached(self): + self.app = get_test_app(argv=['stack', 'restart', '--memcached']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_restart_dovecot(self): + self.app = get_test_app(argv=['stack', 'restart', '--dovecot']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_restart_all(self): + self.app = get_test_app(argv=['stack', 'restart']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_stack_services_start.py b/tests/cli/test_stack_services_start.py new file mode 100644 index 00000000..d37519ee --- /dev/null +++ b/tests/cli/test_stack_services_start.py @@ -0,0 +1,52 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseStack(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_start_nginx(self): + self.app = get_test_app(argv=['stack', 'start', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_start_php5_fpm(self): + self.app = get_test_app(argv=['stack', 'start', '--php5-fpm']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_start_mysql(self): + self.app = get_test_app(argv=['stack', 'start', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_start_postfix(self): + self.app = get_test_app(argv=['stack', 'start', '--postfix']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_start_memcached(self): + self.app = get_test_app(argv=['stack', 'start', '--memcached']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_start_dovecot(self): + self.app = get_test_app(argv=['stack', 'start', '--dovecot']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_start_all(self): + self.app = get_test_app(argv=['stack', 'start']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_stack_services_status.py b/tests/cli/test_stack_services_status.py new file mode 100644 index 00000000..acf73ca3 --- /dev/null +++ b/tests/cli/test_stack_services_status.py @@ -0,0 +1,52 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseStack(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_status_nginx(self): + self.app = get_test_app(argv=['stack', 'status', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_status_php5_fpm(self): + self.app = get_test_app(argv=['stack', 'status', '--php5-fpm']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_status_mysql(self): + self.app = get_test_app(argv=['stack', 'status', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_status_postfix(self): + self.app = get_test_app(argv=['stack', 'status', '--postfix']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_status_memcached(self): + self.app = get_test_app(argv=['stack', 'status', '--memcached']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_status_dovecot(self): + self.app = get_test_app(argv=['stack', 'status', '--dovecot']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_status_all(self): + self.app = get_test_app(argv=['stack', 'status']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_stack_services_stop.py b/tests/cli/test_stack_services_stop.py new file mode 100644 index 00000000..0eaef4e8 --- /dev/null +++ b/tests/cli/test_stack_services_stop.py @@ -0,0 +1,52 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseStack(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_stop_nginx(self): + self.app = get_test_app(argv=['stack', 'stop', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_stop_php5_fpm(self): + self.app = get_test_app(argv=['stack', 'stop', '--php5-fpm']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_stop_mysql(self): + self.app = get_test_app(argv=['stack', 'stop', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_stop_postfix(self): + self.app = get_test_app(argv=['stack', 'stop', '--postfix']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_stop_memcached(self): + self.app = get_test_app(argv=['stack', 'stop', '--memcached']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_stop_dovecot(self): + self.app = get_test_app(argv=['stack', 'stop', '--dovecot']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_stack_services_stop_all(self): + self.app = get_test_app(argv=['stack', 'stop']) + self.app.setup() + self.app.run() + self.app.close() From ee0e9293e1e26d27c4fac6b1e31ae390d4cdf2f6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 23 Dec 2014 19:42:56 +0530 Subject: [PATCH 554/829] ViMbAdmin settigns --- ee/cli/plugins/stack.py | 63 ++++++++++++++++++++++++++++++++++++++--- ee/core/variables.py | 11 +++---- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 3e1f57d7..08780d34 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -111,7 +111,7 @@ class EEStackController(CementBaseController): else: EERepo.add(ppa=EEVariables.ee_php_repo) - if set(EEVariables.ee_dovecot).issubset(set(apt_packages)): + if set(EEVariables.ee_mail).issubset(set(apt_packages)): if EEVariables.ee_platform_codename == 'squeeze': print("Adding repository for dovecot ... ") EERepo.add(repo_url=EEVariables.ee_dovecot_repo) @@ -192,7 +192,7 @@ class EEStackController(CementBaseController): with open('/etc/mysql/my.cnf', 'w') as configfile: config.write(configfile) - if set(EEVariables.ee_dovecot).issubset(set(apt_packages)): + if set(EEVariables.ee_mail).issubset(set(apt_packages)): EEShellExec.cmd_exec("adduser --uid 5000 --home /var/vmail" "--disabled-password --gecos '' vmail") EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" @@ -322,7 +322,60 @@ class EEStackController(CementBaseController): if any('/usr/bin/pt-query-advisor' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/pt-query-advisor") - pass + + if any('/tmp/vimbadmin.tar.gz' == x[1] + for x in packages): + # Extract ViMbAdmin + EEExtract.extract('/tmp/vimbadmin.tar.gz', '/tmp/') + if not os.path.exists('/var/www/22222/htdocs/'): + os.makedirs('/var/www/22222/htdocs/') + shutil.move('/tmp/ViMbAdmin-3.0.10/', + '/var/www/22222/htdocs/vimbadmin/') + + # Donwload composer and install ViMbAdmin + EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin; curl" + " -sS https://getcomposer.org/installer |" + " php") + EEShellExec.cmd_exec("php composer.phar install --prefer-dist"" + " --no-dev; rm -f /var/www/22222/htdocs" + "/vimbadmin/composer.phar") + + # Configure ViMbAdmin settings + config = configparser.ConfigParser() + config.read('/var/www/22222/htdocs/vimbadmin/application/' + 'configs/application.ini.dist') + config['user']['defaults.mailbox.uid'] = 5000 + config['user']['defaults.mailbox.gid'] = 5000 + config['user']['defaults.mailbox.maildir'] = ("maildir:/var/" + "vmail/%d/%u") + config['user']['defaults.mailbox.homedir'] = "/srv/vmail/%d/%u" + config['user']['resources.doctrine2.connection.' + 'options.driver'] = 'mysqli' + config['user']['resources.doctrine2.connection.' + 'options.password'] = 'password' + config['user']['resources.doctrine2.connection.' + 'options.host'] = 'localhost' + config['user']['defaults.mailbox.password_scheme'] = 'md5' + config['user']['securitysalt'] = ('' + .join(random + .sample(string. + ascii_letters, + 64))) + config['user']['resources.auth.' + 'oss.rememberme.salt'] = (''.join(random.sample + (string.ascii_letters, + 64))) + config['user']['defaults.mailbox.' + 'password_salt'] = (''.join(random.sample + (string.ascii_letters, + 64))) + shutil.copyfile("/var/www/22222/htdocs/vimbadmin/public/" + ".htaccess.dist", + "/var/www/22222/htdocs/vimbadmin/public/" + ".htaccess") + EEShellExec.cmd_exec("/var/www/22222/htdocs/vimbadmin/bin" + "/doctrine2-cli.php orm:schema-tool:" + "create") @expose() def install(self): @@ -333,11 +386,13 @@ class EEStackController(CementBaseController): if self.app.pargs.web: apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) + packages = [["https://github.com/opensolutions/ViMbAdmin/archive/" + "3.0.10.tar.gz", "/tmp/vimbadmin.tar.gz"]] if self.app.pargs.admin: pass # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: - apt_packages = apt_packages + EEVariables.ee_dovecot + apt_packages = apt_packages + EEVariables.ee_mail if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: diff --git a/ee/core/variables.py b/ee/core/variables.py index 5f39abb5..76de0d55 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -58,12 +58,13 @@ class EEVariables(): ee_postfix = ["postfix"] # Dovecot repo and packages - ee_dovecot_repo = ("deb http://http.debian.net/debian-backports {codename}" - "-backports main".format(codename=ee_platform_codename)) + ee_mail_repo = ("deb http://http.debian.net/debian-backports {codename}" + "-backports main".format(codename=ee_platform_codename)) - ee_dovecot = ["dovecot-core", "dovecot-imapd", "dovecot-pop3d", - "dovecot-lmtpd", "dovecot-mysql", "dovecot-sieve", - "dovecot-managesieved", "postfix-mysql"] + ee_mail = ["dovecot-core", "dovecot-imapd", "dovecot-pop3d", + "dovecot-lmtpd", "dovecot-mysql", "dovecot-sieve", + "dovecot-managesieved", "postfix-mysql", "php5-cgi", + "php5-json", "php-gettext"] # Repo ee_repo_file = "ee-repo.list" From c50136b5d02cde37b06bc3a27e77af556e54aa42 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Dec 2014 12:42:00 +0530 Subject: [PATCH 555/829] Updated ViMbAdmin --- ee/cli/plugins/stack.py | 45 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 08780d34..f8007b2a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -336,10 +336,19 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin; curl" " -sS https://getcomposer.org/installer |" " php") - EEShellExec.cmd_exec("php composer.phar install --prefer-dist"" + EEShellExec.cmd_exec("php composer.phar install --prefer-dist" " --no-dev; rm -f /var/www/22222/htdocs" "/vimbadmin/composer.phar") + # Configure vimbadmin database + vm_passwd = ''.join(random.sample(string.ascii_letters, 64)) + vm_mysql = EEMysql() + + vm_mysql.execute("create database \`vimbadmin\`") + vm_mysql.execute("grant all privileges on vimbadmin.* to" + " vimbadmin@localhost IDENTIFIED BY" + " {password}".format(password=vm_passwd)) + # Configure ViMbAdmin settings config = configparser.ConfigParser() config.read('/var/www/22222/htdocs/vimbadmin/application/' @@ -352,7 +361,7 @@ class EEStackController(CementBaseController): config['user']['resources.doctrine2.connection.' 'options.driver'] = 'mysqli' config['user']['resources.doctrine2.connection.' - 'options.password'] = 'password' + 'options.password'] = vm_passwd config['user']['resources.doctrine2.connection.' 'options.host'] = 'localhost' config['user']['defaults.mailbox.password_scheme'] = 'md5' @@ -369,6 +378,10 @@ class EEStackController(CementBaseController): 'password_salt'] = (''.join(random.sample (string.ascii_letters, 64))) + with open('var/www/22222/htdocs/vimbadmin/application' + '/configs/application.ini', 'w') as configfile: + config.write(configfile) + shutil.copyfile("/var/www/22222/htdocs/vimbadmin/public/" ".htaccess.dist", "/var/www/22222/htdocs/vimbadmin/public/" @@ -377,6 +390,34 @@ class EEStackController(CementBaseController): "/doctrine2-cli.php orm:schema-tool:" "create") + # Copy Dovecot and Postfix templates which are depednet on + # Vimbadmin + os.makedirs('/etc/postfix/mysql/') + data = dict(password=vm_passwd) + vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf', + 'w') + self.app.render((data), 'virtual_alias_maps.mustache', + out=vm_config) + vm_config.close() + + vm_config = open('/etc/postfix/mysql/virtual_domains_maps.cf', + 'w') + self.app.render((data), 'virtual_domains_maps.mustache', + out=vm_config) + vm_config.close() + + vm_config = open('/etc/postfix/mysql/virtual_mailbox_maps.cf', + 'w') + self.app.render((data), 'virtual_mailbox_maps.mustache', + out=vm_config) + vm_config.close() + + vm_config = open('/etc/dovecot/dovecot-sql.conf.ext', + 'w') + self.app.render((data), 'dovecot-sql-conf.mustache', + out=vm_config) + vm_config.close() + @expose() def install(self): pkg = EEAptGet() From 82c2d693a900a6f020c7274136a4781027fe7f7f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Dec 2014 13:20:03 +0530 Subject: [PATCH 556/829] added single template for all sites nginx conf --- ee/cli/templates/virtualconf.mustache | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ee/cli/templates/virtualconf.mustache diff --git a/ee/cli/templates/virtualconf.mustache b/ee/cli/templates/virtualconf.mustache new file mode 100644 index 00000000..d51b0acd --- /dev/null +++ b/ee/cli/templates/virtualconf.mustache @@ -0,0 +1,32 @@ + +server { + +{{#multisite}} +# Uncomment the following line for domain mapping +# listen 80 default_server; +{{/multisite}} + +server_name {{site_name}} {{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{site_name}}; + +{{#multisite}} +# Uncomment the following line for domain mapping +#server_name_in_redirect off; +{{/multisite}} + +access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}}; +error_log /var/log/nginx/{{site_name}}.error.log; +root /var/www/{{site_name}}/htdocs; + +index {{^static}}index.php{{/static}} index.html index.htm; + +{{#static}} +location / { +try_files $uri $uri/ /index.html; +} +{{/static}} + +include {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} +{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}} +{{#wp}}include common/wpcommon.conf;{{/wp}} +include common/locations.conf; +} From 0ad796b39cd158a68a3f48261eff105632e9cc8d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Dec 2014 16:52:15 +0530 Subject: [PATCH 557/829] Fixed ViMbadmin conmfiguration issue --- ee/cli/plugins/stack.py | 81 ++++++++++++++++++++++------------------- ee/core/mysql.py | 24 ++++++------ ee/core/shellexec.py | 1 + 3 files changed, 57 insertions(+), 49 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index f8007b2a..efbb1d8a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -212,9 +212,9 @@ class EEStackController(CementBaseController): # Custom Postfix configuration needed with Dovecot # Changes in master.cf # TODO: Find alternative for sed in Python - EEShellExec.cmd_exec("sed -i 's/#submission/submission/'" - "/etc/postfix/master.cf") - EEShellExec.cmd_exec("sed -i 's/#smtps/smtps/'" + EEShellExec.cmd_exec("sed -i \'s/#submission/submission/\'" + " /etc/postfix/master.cf") + EEShellExec.cmd_exec("sed -i \'s/#smtps/smtps/\'" " /etc/postfix/master.cf") EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_type = " @@ -242,7 +242,7 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("postconf -e \"virtual_uid_maps " "= static:5000\"") EEShellExec.cmd_exec("postconf -e \"virtual_gid_maps " - "= static:500\"") + "= static:5000\"") EEShellExec.cmd_exec("postconf -e \"virtual_mailbox_domains = " "mysql:/etc/postfix/mysql/virtual_" "domains_maps.cf\"") @@ -259,10 +259,10 @@ class EEStackController(CementBaseController): .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/postfix.pem") - EEShellExec.cmd_exec("postconf -e smtpd_tls_cert_file = " - "/etc/ssl/certs/postfix.pem") - EEShellExec.cmd_exec("postconf -e smtpd_tls_key_file = " - "/etc/ssl/private/postfix.pem") + EEShellExec.cmd_exec("postconf -e \"smtpd_tls_cert_file = " + "/etc/ssl/certs/postfix.pem\"") + EEShellExec.cmd_exec("postconf -e \"smtpd_tls_key_file = " + "/etc/ssl/private/postfix.pem\"") if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): @@ -301,15 +301,14 @@ class EEStackController(CementBaseController): shutil.move('/tmp/Anemometer-master', '/var/www/22222/htdocs/db/anemometer') chars = ''.join(random.sample(string.ascii_letters, 8)) - anemometer_db = EEMysql() EEShellExec.cmd_exec('mysql < /var/www/22222/htdocs/db' '/anemometer/install.sql') - anemometer_db.execute('grant select on *.* to \'anemometer\'' - '@\'localhost\'') - anemometer_db.execute('grant all on slow_query_log.* to' - '\'anemometer\'@\'localhost\' IDENTIFIED' - ' BY \''+chars+'\'') - anemometer_db.close() + EEMysql.execute('grant select on *.* to \'anemometer\'' + '@\'localhost\'') + EEMysql.execute('grant all on slow_query_log.* to' + '\'anemometer\'@\'localhost\' IDENTIFIED' + ' BY \''+chars+'\'') + # Custom Anemometer configuration data = dict(host='localhost', port='3306', user='anemometer', password=chars) @@ -336,28 +335,29 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin; curl" " -sS https://getcomposer.org/installer |" " php") - EEShellExec.cmd_exec("php composer.phar install --prefer-dist" + EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin;" + "php composer.phar install --prefer-dist" " --no-dev; rm -f /var/www/22222/htdocs" "/vimbadmin/composer.phar") # Configure vimbadmin database - vm_passwd = ''.join(random.sample(string.ascii_letters, 64)) - vm_mysql = EEMysql() + vm_passwd = ''.join(random.sample(string.ascii_letters, 8)) - vm_mysql.execute("create database \`vimbadmin\`") - vm_mysql.execute("grant all privileges on vimbadmin.* to" - " vimbadmin@localhost IDENTIFIED BY" - " {password}".format(password=vm_passwd)) + EEMysql.execute("create database if not exists vimbadmin") + EEMysql.execute("grant all privileges on vimbadmin.* to" + " vimbadmin@localhost IDENTIFIED BY" + " '{password}'".format(password=vm_passwd)) # Configure ViMbAdmin settings - config = configparser.ConfigParser() + config = configparser.ConfigParser(strict=False) config.read('/var/www/22222/htdocs/vimbadmin/application/' 'configs/application.ini.dist') - config['user']['defaults.mailbox.uid'] = 5000 - config['user']['defaults.mailbox.gid'] = 5000 - config['user']['defaults.mailbox.maildir'] = ("maildir:/var/" - "vmail/%d/%u") - config['user']['defaults.mailbox.homedir'] = "/srv/vmail/%d/%u" + config['user']['defaults.mailbox.uid'] = '5000' + config['user']['defaults.mailbox.gid'] = '5000' + config['user']['defaults.mailbox.maildir'] = ("maildir:/var/v" + + "mail/%%d/%%u") + config['user']['defaults.mailbox.homedir'] = ("/srv/vmail/" + + "%%d/%%u") config['user']['resources.doctrine2.connection.' 'options.driver'] = 'mysqli' config['user']['resources.doctrine2.connection.' @@ -365,20 +365,22 @@ class EEStackController(CementBaseController): config['user']['resources.doctrine2.connection.' 'options.host'] = 'localhost' config['user']['defaults.mailbox.password_scheme'] = 'md5' - config['user']['securitysalt'] = ('' - .join(random - .sample(string. - ascii_letters, - 64))) + config['user']['securitysalt'] = (''.join(random.sample + (string.ascii_letters + + string.ascii_letters, + 64))) config['user']['resources.auth.' 'oss.rememberme.salt'] = (''.join(random.sample - (string.ascii_letters, + (string.ascii_letters + + string. + ascii_letters, 64))) config['user']['defaults.mailbox.' 'password_salt'] = (''.join(random.sample - (string.ascii_letters, + (string.ascii_letters + + string.ascii_letters, 64))) - with open('var/www/22222/htdocs/vimbadmin/application' + with open('/var/www/22222/htdocs/vimbadmin/application' '/configs/application.ini', 'w') as configfile: config.write(configfile) @@ -427,13 +429,16 @@ class EEStackController(CementBaseController): if self.app.pargs.web: apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) - packages = [["https://github.com/opensolutions/ViMbAdmin/archive/" - "3.0.10.tar.gz", "/tmp/vimbadmin.tar.gz"]] + if self.app.pargs.admin: pass # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: apt_packages = apt_packages + EEVariables.ee_mail + packages = packages + [["https://github.com/opensolutions/ViMbAdmi" + "n/archive/3.0.10.tar.gz", "/tmp/vimbadmin" + ".tar.gz"]] + if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: diff --git a/ee/core/mysql.py b/ee/core/mysql.py index e2b80922..59e6c802 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -7,7 +7,7 @@ from os.path import expanduser class EEMysql(): """Method for MySQL connection""" - def __init__(self): + def execute(statement): config = configparser.RawConfigParser() cnfpath = expanduser("~")+"/.my.cnf" if [cnfpath] == config.read(cnfpath): @@ -24,22 +24,24 @@ class EEMysql(): port = '3306' try: - self.conn = pymysql.connect(host=host, port=int(port), - user=user, passwd=passwd) - self.cur = self.conn.cursor() + conn = pymysql.connect(host=host, port=int(port), + user=user, passwd=passwd) + cur = conn.cursor() except Exception as e: print("Unable to connect to database") return False - def execute(self, statement): try: - self.cur.execute(statement) - return True + cur.execute(statement) except Exception as e: print("Error occured while executing "+statement) + cur.close() + conn.close() return False - def close(self): - self.cur.close() - self.conn.close() - + cur.close() + conn.close() + +# def __del__(self): +# self.cur.close() +# self.conn.close() diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 9368f667..301ae4c1 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -16,6 +16,7 @@ class EEShellExec(): if retcode[0] == 0: return True else: + print(retcode[1]) return False except OSError as e: print(e) From ee7aadc632ae465d6fc375516ff1fc5ead7be2e6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Dec 2014 18:08:37 +0530 Subject: [PATCH 558/829] Roundcube done --- ee/cli/plugins/stack.py | 46 +++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index efbb1d8a..5920111a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -322,8 +322,7 @@ class EEStackController(CementBaseController): for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/pt-query-advisor") - if any('/tmp/vimbadmin.tar.gz' == x[1] - for x in packages): + if any('/tmp/vimbadmin.tar.gz' == x[1] for x in packages): # Extract ViMbAdmin EEExtract.extract('/tmp/vimbadmin.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/'): @@ -335,9 +334,9 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin; curl" " -sS https://getcomposer.org/installer |" " php") - EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin;" + EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin && " "php composer.phar install --prefer-dist" - " --no-dev; rm -f /var/www/22222/htdocs" + " --no-dev && rm -f /var/www/22222/htdocs" "/vimbadmin/composer.phar") # Configure vimbadmin database @@ -394,7 +393,8 @@ class EEStackController(CementBaseController): # Copy Dovecot and Postfix templates which are depednet on # Vimbadmin - os.makedirs('/etc/postfix/mysql/') + if not os.path.exists('/etc/postfix/mysql/'): + os.makedirs('/etc/postfix/mysql/') data = dict(password=vm_passwd) vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf', 'w') @@ -420,6 +420,35 @@ class EEStackController(CementBaseController): out=vm_config) vm_config.close() + if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): + # Extract RoundCubemail + EEExtract.extract('/tmp/roundcube.tar.gz', '/tmp/') + if not os.path.exists('/var/www/22222/htdocs/'): + os.makedirs('/var/www/22222/htdocs/') + shutil.move('/tmp/roundcubemail-1.0.4/', + '/var/www/22222/htdocs/roundcubemail/') + + # Configure roundcube database + rc_passwd = ''.join(random.sample(string.ascii_letters, 8)) + EEMysql.execute("create database if not exists roundcubemail") + EEMysql.execute("grant all privileges on roundcubemail.* to " + " roundcube@localhost IDENTIFIED BY " + "{password}".format(password=rc_passwd)) + EEShellExec.cmd_exec("mysql roundcubemail < /var/www/" + "roundcubemail/htdocs/SQL/mysql" + ".initial.sql") + + shutil.copyfile("/var/www/roundcubemail/htdocs/config/" + "config.inc.php.sample", + "/var/www/roundcubemail/htdocs/config/" + "config.inc.php") + EEShellExec.cmd_exec("sed -i \"s\'mysql://roundcube:pass@" + "localhost/roundcubemail\'mysql://" + "roundcube:${password}@localhost/" + "roundcubemail\'\" /var/www/roundcubemail" + "/htdocs/config/config." + "inc.php".format(password=rc_passwd)) + @expose() def install(self): pkg = EEAptGet() @@ -437,7 +466,12 @@ class EEStackController(CementBaseController): apt_packages = apt_packages + EEVariables.ee_mail packages = packages + [["https://github.com/opensolutions/ViMbAdmi" "n/archive/3.0.10.tar.gz", "/tmp/vimbadmin" - ".tar.gz"]] + ".tar.gz"], + ["https://github.com/roundcube/" + "roundcubemail/releases/download/" + "1.0.4/roundcubemail-1.0.4.tar.gz", + "/tmp/roundcube.tar.gz"] + ] if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx From 8353004cb023ccf9ffb81e3c2d02733b6f0ef075 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Dec 2014 18:22:43 +0530 Subject: [PATCH 559/829] Fixed Roundcube paths --- ee/cli/plugins/stack.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 5920111a..ac735745 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -423,10 +423,10 @@ class EEStackController(CementBaseController): if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): # Extract RoundCubemail EEExtract.extract('/tmp/roundcube.tar.gz', '/tmp/') - if not os.path.exists('/var/www/22222/htdocs/'): - os.makedirs('/var/www/22222/htdocs/') + if not os.path.exists('/var/www/roundcubemail'): + os.makedirs('/var/www/roundcubemail/') shutil.move('/tmp/roundcubemail-1.0.4/', - '/var/www/22222/htdocs/roundcubemail/') + '/var/www/roundcubemail/htdocs') # Configure roundcube database rc_passwd = ''.join(random.sample(string.ascii_letters, 8)) From 4d3193ce264b9bd96a07134290f3d57ac636cbfc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 24 Dec 2014 19:13:00 +0530 Subject: [PATCH 560/829] Added Sieve configuration --- ee/cli/plugins/stack.py | 29 +++++++++++++++++++++++-- ee/cli/templates/default-sieve.mustache | 4 ++++ ee/cli/templates/dovecot.mustache | 12 ++++++++++ ee/core/variables.py | 10 +++++++-- 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 ee/cli/templates/default-sieve.mustache diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index ac735745..61322e83 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -264,6 +264,22 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("postconf -e \"smtpd_tls_key_file = " "/etc/ssl/private/postfix.pem\"") + # Sieve configuration + if not os.path.exists('/var/lib/dovecot/sieve/'): + os.makedirs('/var/lib/dovecot/sieve/') + + # Custom sieve configuration by EasyEngine + data = dict() + ee_sieve = open('/var/lib/dovecot/sieve/default.sieve', 'w') + self.app.render((data), 'default-sieve.mustache', + out=ee_sieve) + ee_sieve.close() + + # Compile sieve rules + EEShellExec.cmd_exec("chown -R vmail:vmail /var/lib/dovecot") + EEShellExec.cmd_exec("sievec /var/lib/dovecot/sieve/" + "default.sieve") + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") @@ -433,7 +449,7 @@ class EEStackController(CementBaseController): EEMysql.execute("create database if not exists roundcubemail") EEMysql.execute("grant all privileges on roundcubemail.* to " " roundcube@localhost IDENTIFIED BY " - "{password}".format(password=rc_passwd)) + "'{password}'".format(password=rc_passwd)) EEShellExec.cmd_exec("mysql roundcubemail < /var/www/" "roundcubemail/htdocs/SQL/mysql" ".initial.sql") @@ -444,11 +460,20 @@ class EEStackController(CementBaseController): "config.inc.php") EEShellExec.cmd_exec("sed -i \"s\'mysql://roundcube:pass@" "localhost/roundcubemail\'mysql://" - "roundcube:${password}@localhost/" + "roundcube:{password}@localhost/" "roundcubemail\'\" /var/www/roundcubemail" "/htdocs/config/config." "inc.php".format(password=rc_passwd)) + # Sieve plugin configuration in roundcube + EEShellExec.cmd_exec("sed -i \"s:\$config\['plugins'\] = array" + "(:\$config\['plugins'\] = array(\n " + "'sieverules',:\" /var/www/roundcubemail" + "/htdocs/config/config.inc.php") + EEShellExec.cmd_exec("echo \"\$config['sieverules_port'] = " + "4190;\" >> /var/www/roundcubemail/htdocs" + "/config/config.inc.php") + @expose() def install(self): pkg = EEAptGet() diff --git a/ee/cli/templates/default-sieve.mustache b/ee/cli/templates/default-sieve.mustache new file mode 100644 index 00000000..62532322 --- /dev/null +++ b/ee/cli/templates/default-sieve.mustache @@ -0,0 +1,4 @@ +require "fileinto"; +if header :contains "X-Spam-Flag" "YES" { + fileinto "Junk"; +} diff --git a/ee/cli/templates/dovecot.mustache b/ee/cli/templates/dovecot.mustache index c4062322..f7370da8 100644 --- a/ee/cli/templates/dovecot.mustache +++ b/ee/cli/templates/dovecot.mustache @@ -46,3 +46,15 @@ plugin { autosubscribe3 = Drafts autosubscribe4 = Sent } + +protocol lmtp { + postmaster_address = {{email}} + mail_plugins = $mail_plugins sieve +} + +plugin { + sieve = ~/.dovecot.sieve + sieve_global_path = /var/lib/dovecot/sieve/default.sieve + sieve_global_dir = /var/lib/dovecot/sieve/ + sieve_dir = ~/sieve +} diff --git a/ee/core/variables.py b/ee/core/variables.py index 76de0d55..0271c0b5 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -57,7 +57,7 @@ class EEVariables(): ee_postfix_repo = "" ee_postfix = ["postfix"] - # Dovecot repo and packages + # Mail repo and packages ee_mail_repo = ("deb http://http.debian.net/debian-backports {codename}" "-backports main".format(codename=ee_platform_codename)) @@ -66,7 +66,13 @@ class EEVariables(): "dovecot-managesieved", "postfix-mysql", "php5-cgi", "php5-json", "php-gettext"] - # Repo + # Mailscanner repo and packages + ee_mailscanner_repo = () + ee_mailscanner = ["amavisd-new", "spamassassin", "clamav", "clamav-daemon", + "arj", "zoo", "nomarch", "cpio", "lzop", + "cabextract", "p7zip", "rpm", "unrar-free"] + + # Repo path ee_repo_file = "ee-repo.list" ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file) From f10f2de9682dff1ec5c54fddf0d6e6e69f9255c9 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 24 Dec 2014 19:14:47 +0530 Subject: [PATCH 561/829] ee site create command started --- config/plugins.d/site.conf | 8 +++ ee/cli/plugins/site.py | 72 +++++++++++++++++++++++++-- ee/cli/templates/virtualconf.mustache | 2 +- 3 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 config/plugins.d/site.conf diff --git a/config/plugins.d/site.conf b/config/plugins.d/site.conf new file mode 100644 index 00000000..2fb468fe --- /dev/null +++ b/config/plugins.d/site.conf @@ -0,0 +1,8 @@ +### Example Plugin Configuration for EasyEngine + +[site] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 7848c305..cd0c9c6b 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -1,6 +1,7 @@ """EasyEngine site controller.""" from cement.core.controller import CementBaseController, expose from cement.core import handler, hook +import sys def ee_site_hook(app): @@ -93,15 +94,72 @@ class EESiteCreateController(CementBaseController): dict(help="wpsubdir site", action='store_true')), (['--wpsubdomain'], dict(help="wpsubdomain site", action='store_true')), + (['--w3tc'], + dict(help="w3tc", action='store_true')), + (['--wpfc'], + dict(help="wpfc", action='store_true')), + (['--wpsc'], + dict(help="wpsc", action='store_true')), ] @expose(hide=True) def default(self): # TODO Default action for ee site command - data = dict(foo='EESiteCreateController.default().') - self.app.render((data), 'default.mustache') - - # print("Inside EESiteCreateController.default().") + # data = dict(foo='EESiteCreateController.default().') + # self.app.render((data), 'default.mustache') + if self.app.pargs.html: + data = dict(site_name=self.app.pargs.site_name, + static=True, basic=False, wp=False, w3tc=False, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False) + + if self.app.pargs.php: + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=True, wp=False, w3tc=False, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False) + + if self.app.pargs.mysql: + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=True, wp=False, w3tc=False, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False) + + if (self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc + or self.app.pargs.wpsc): + if self.app.pargs.wp: + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False) + if self.app.pargs.w3tc: + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=True, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False) + if self.app.pargs.wpfc: + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=False, + wpfc=True, wpsc=False, multisite=False, + wpsubdir=False) + if self.app.pargs.wpsc: + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=False, + wpfc=False, wpsc=True, multisite=False, + wpsubdir=False) + + if self.app.pargs.wpsubdir: + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=True) + + if self.app.pargs.wpsubdomain: + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=False) + self.app.render((data), 'virtualconf.mustache') class EESiteUpdateController(CementBaseController): @@ -126,6 +184,12 @@ class EESiteUpdateController(CementBaseController): dict(help="wpsubdir site", action='store_true')), (['--wpsubdomain'], dict(help="wpsubdomain site", action='store_true')), + (['--w3tc'], + dict(help="w3tc", action='store_true')), + (['--wpfc'], + dict(help="wpfc", action='store_true')), + (['--wpsc'], + dict(help="wpsc", action='store_true')), ] @expose(help="update example.com") diff --git a/ee/cli/templates/virtualconf.mustache b/ee/cli/templates/virtualconf.mustache index d51b0acd..2ad0278d 100644 --- a/ee/cli/templates/virtualconf.mustache +++ b/ee/cli/templates/virtualconf.mustache @@ -25,7 +25,7 @@ try_files $uri $uri/ /index.html; } {{/static}} -include {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} +{{^static}}include{{/static}} {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}} {{#wp}}include common/wpcommon.conf;{{/wp}} include common/locations.conf; From 1835842d236a44378012ae26c5d00ad4c9b2c904 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Dec 2014 15:54:13 +0530 Subject: [PATCH 562/829] Added Mailscanner --- ee/cli/plugins/stack.py | 38 +++++++++++++++++++ .../templates/15-content_filter_mode.mustache | 27 +++++++++++++ ee/cli/templates/50-user.mustache | 17 +++++++++ ee/core/variables.py | 5 +++ setup.py | 1 + 5 files changed, 88 insertions(+) create mode 100644 ee/cli/templates/15-content_filter_mode.mustache create mode 100644 ee/cli/templates/50-user.mustache diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 61322e83..f04d89b4 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -280,8 +280,35 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("sievec /var/lib/dovecot/sieve/" "default.sieve") + if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): + # Set up Custom amavis configuration + data = dict() + ee_amavis = open('/etc/amavis/conf.d/15-content_filter_mode', + 'w') + self.app.render((data), '15-content_filter_mode.mustache', + out=ee_amavis) + ee_amavis.close() + + # Amavis postfix configuration + EEShellExec.cmd_exec("postconf -e \"content_filter = " + "smtp-amavis:[127.0.0.1]:10024\"") + EEShellExec.cmd_exec("sed -i \"s/1 pickup/1 pickup" + "\n -o content_filter=\n -o" + " receive_override_options=no_header_body" + "_checks/\" /etc/postfix/master.cf") + + # Amavis ClamAV configuration + EEShellExec.cmd_exec("adduser clamav amavis") + EEShellExec.cmd_exec("adduser amavis clamav") + EEShellExec.cmd_exec("chmod -R 775 /var/lib/amavis/tmp") + + # Update ClamAV database + EEShellExec.cmd_exec("freshclam") + EEShellExec.cmd_exec("service clamav-daemon restart") + if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): + EEShellExec.cmd_exec("chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] for x in packages): @@ -436,6 +463,15 @@ class EEStackController(CementBaseController): out=vm_config) vm_config.close() + # If Amavis is going to be installed then configure Vimabadmin + # Amvis settings + if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): + vm_config = open('/etc/amavis/conf.d/50-user', + 'w') + self.app.render((data), '50-user.mustache', + out=vm_config) + vm_config.close() + if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): # Extract RoundCubemail EEExtract.extract('/tmp/roundcube.tar.gz', '/tmp/') @@ -497,6 +533,8 @@ class EEStackController(CementBaseController): "1.0.4/roundcubemail-1.0.4.tar.gz", "/tmp/roundcube.tar.gz"] ] + if EEVariables.ee_ram > 1024: + apt_packages = apt_packages + EEVariables.ee_mailscanner if self.app.pargs.nginx: apt_packages = apt_packages + EEVariables.ee_nginx diff --git a/ee/cli/templates/15-content_filter_mode.mustache b/ee/cli/templates/15-content_filter_mode.mustache new file mode 100644 index 00000000..6fd8f218 --- /dev/null +++ b/ee/cli/templates/15-content_filter_mode.mustache @@ -0,0 +1,27 @@ +use strict; + +# You can modify this file to re-enable SPAM checking through spamassassin +# and to re-enable antivirus checking. + +# +# Default antivirus checking mode +# Please note, that anti-virus checking is DISABLED by +# default. +# If You wish to enable it, please uncomment the following lines: + + +@bypass_virus_checks_maps = ( + \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re); + + +# +# Default SPAM checking mode +# Please note, that anti-spam checking is DISABLED by +# default. +# If You wish to enable it, please uncomment the following lines: + + +@bypass_spam_checks_maps = ( + \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re); + +1; # ensure a defined return diff --git a/ee/cli/templates/50-user.mustache b/ee/cli/templates/50-user.mustache new file mode 100644 index 00000000..e0e0c625 --- /dev/null +++ b/ee/cli/templates/50-user.mustache @@ -0,0 +1,17 @@ +use strict; +$sa_spam_subject_tag = undef; +$spam_quarantine_to = undef; +$sa_tag_level_deflt = undef; + +# Prevent spams from automatically rejected by mail-server +$final_spam_destiny = D_PASS; + +# We need to provide list of domains for which filtering need to be done +@lookup_sql_dsn = ( +['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306', +'vimbadmin', +'{{password}}']); + +$sql_select_policy = 'SELECT domain FROM domain WHERE CONCAT("@",domain) IN (%k)'; + +1; # ensure a defined return diff --git a/ee/core/variables.py b/ee/core/variables.py index 0271c0b5..f6fe0d05 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -4,6 +4,7 @@ import socket import configparser import os import sys +import psutil class EEVariables(): @@ -27,6 +28,10 @@ class EEVariables(): print("Unable to find GIT user name and Email") sys.exit(1) + # Get System RAM and SWAP details + ee_ram = psutil.virtual_memory().total / (1024 * 1024) + ee_swap = psutil.swap_memory().total / (1024 * 1024) + # EasyEngine stack installation varibales # Nginx repo and packages if ee_platform_distro == 'Ubuntu': diff --git a/setup.py b/setup.py index fe9b3c7a..3722d0c2 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ setup(name='ee', 'python-apt', 'pynginxconfig', 'pymysql3', + 'psutil', ], setup_requires=[], entry_points=""" From bd29593465d7c3ad9d6b5c16538c64c9534c5b18 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 26 Dec 2014 16:00:57 +0530 Subject: [PATCH 563/829] site nginx virtual conf --- ee/cli/plugins/site.py | 108 +++++++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 20 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index cd0c9c6b..6466ac12 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -107,59 +107,127 @@ class EESiteCreateController(CementBaseController): # TODO Default action for ee site command # data = dict(foo='EESiteCreateController.default().') # self.app.render((data), 'default.mustache') - if self.app.pargs.html: + if (self.app.pargs.html and not (self.app.pargs.php or + self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc or + self.app.pargs.wsubdir or self.app.pargs.wsubdomain)): data = dict(site_name=self.app.pargs.site_name, static=True, basic=False, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) - if self.app.pargs.php: + if (self.app.pargs.php and not (self.app.pargs.html or + self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc or + self.app.pargs.wsubdir or self.app.pargs.wsubdomain)): data = dict(site_name=self.app.pargs.site_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) - if self.app.pargs.mysql: + if (self.app.pargs.mysql and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc or + self.app.pargs.wsubdir or self.app.pargs.wsubdomain)): data = dict(site_name=self.app.pargs.site_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) - if (self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc - or self.app.pargs.wpsc): - if self.app.pargs.wp: + if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or + self.app.pargs.wpsc) and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.mysql or + self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + if (self.app.pargs.wp and not (self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=self.app.pargs.site_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) - if self.app.pargs.w3tc: + if (self.app.pargs.w3tc and not + (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=self.app.pargs.site_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) - if self.app.pargs.wpfc: + if (self.app.pargs.wpfc and not + (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=self.app.pargs.site_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=False, wpsubdir=False) - if self.app.pargs.wpsc: + if (self.app.pargs.wpsc and not + (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=self.app.pargs.site_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=False, wpsubdir=False) - if self.app.pargs.wpsubdir: - data = dict(site_name=self.app.pargs.site_name, - static=False, basic=True, wp=True, w3tc=False, - wpfc=False, wpsc=False, multisite=True, - wpsubdir=True) + if (self.app.pargs.wpsubdir and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.mysql or + self.app.pargs.wpsubdomain or self.app.pargs.wp)): + if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=True) + if (self.app.pargs.w3tc and not + (self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=True, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=True) + if (self.app.pargs.wpfc and not + (self.app.pargs.wpsc or self.app.pargs.w3tc)): + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=False, + wpfc=True, wpsc=False, multisite=True, + wpsubdir=True) + if (self.app.pargs.wpsc and not + (self.app.pargs.w3tc or self.app.pargs.wpfc)): + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=False, + wpfc=False, wpsc=True, multisite=True, + wpsubdir=True) - if self.app.pargs.wpsubdomain: - data = dict(site_name=self.app.pargs.site_name, - static=False, basic=True, wp=True, w3tc=False, - wpfc=False, wpsc=False, multisite=True, - wpsubdir=False) - self.app.render((data), 'virtualconf.mustache') + if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.mysql or + self.app.pargs.wpsubdir or self.app.pargs.wp)): + if (self.app.pargs.wpsubdomain and not (self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=False) + if (self.app.pargs.w3tc and not + (self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=True, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=False) + if (self.app.pargs.wpfc and not + (self.app.pargs.wpsc or self.app.pargs.w3tc)): + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=False, + wpfc=True, wpsc=False, multisite=True, + wpsubdir=False) + if (self.app.pargs.wpsc and not + (self.app.pargs.w3tc or self.app.pargs.wpfc)): + data = dict(site_name=self.app.pargs.site_name, + static=False, basic=False, wp=True, w3tc=False, + wpfc=False, wpsc=True, multisite=True, + wpsubdir=False) + + try: + ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}.conf' + .format(self.app.pargs.site_name), 'w') + + self.app.render((data), 'virtualconf.mustache', + out=ee_site_nginx_conf) + ee_site_nginx_conf.close() + except Exception as e: + print("Select proper options for creating site") class EESiteUpdateController(CementBaseController): From fe9bb101b6c1918112df8d4a70fda408d467574a Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Fri, 26 Dec 2014 18:55:20 +0530 Subject: [PATCH 564/829] adding log messages --- ee/cli/plugins/stack.py | 129 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 122 insertions(+), 7 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 61322e83..e98fc3a3 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -73,11 +73,12 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " "$(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): - print("Adding repository for mysql ... ") + print("Adding repository for MySQL ... ") EERepo.add(repo_url=EEVariables.ee_mysql_repo) + self.app.log.debug('Adding key of MySQL.') EERepo.add_key('1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) - print("Pre-seeding mysql variables ... ") + print("Pre-seeding MySQL variables ... ") EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " "percona-server-server/root_password " "password {chars}\" | " @@ -93,29 +94,35 @@ class EEStackController(CementBaseController): """.format(chars=chars) config = configparser.ConfigParser() config.read_string(mysql_config) + self.app.log.debug('writting configartion into MySQL file.') with open(os.path.expanduser("~")+'/.my.cnf', 'w') as configfile: config.write(configfile) if set(EEVariables.ee_nginx).issubset(set(apt_packages)): - print("Adding repository for nginx ... ") + print("Adding repository for Nginx ... ") if EEVariables.ee_platform_distro == 'Debian': + self.app.log.debug('Adding Dotdeb/nginx GPG key') EERepo.add(repo_url=EEVariables.ee_nginx_repo) else: + self.app.log.debug('Adding ppa of Nginx') EERepo.add(ppa=EEVariables.ee_nginx_repo) if set(EEVariables.ee_php).issubset(set(apt_packages)): - print("Adding repository for php ... ") + print("Adding repository for PHP ... ") if EEVariables.ee_platform_distro == 'Debian': + self.app.log.debug('Adding repo_url of php for Debian') EERepo.add(repo_url=EEVariables.ee_php_repo) + self.app.log.debug('Adding Dotdeb/php GPG key') EERepo.add_key('89DF5277') else: + self.app.log.debug('Adding ppa for PHP') EERepo.add(ppa=EEVariables.ee_php_repo) if set(EEVariables.ee_mail).issubset(set(apt_packages)): if EEVariables.ee_platform_codename == 'squeeze': print("Adding repository for dovecot ... ") EERepo.add(repo_url=EEVariables.ee_dovecot_repo) - + self.app.log.debug('Executing the command debconf-set-selections.') EEShellExec.cmd_exec("echo \"dovecot-core dovecot-core/" "create-ssl-cert boolean yes\" " "| debconf-set-selections") @@ -132,6 +139,7 @@ class EEStackController(CementBaseController): # Nginx core configuration change using configparser nc = NginxConfig() print('in nginx') + self.app.log.debug('Loading file /etc/nginx/nginx.conf ') nc.loadf('/etc/nginx/nginx.conf') nc.set('worker_processes', 'auto') nc.append(('worker_rlimit_nofile', '100000'), position=2) @@ -140,10 +148,14 @@ class EEStackController(CementBaseController): [('worker_connections', '4096'), ('multi_accept', 'on')]}, position=4) nc.set([('http',), 'keepalive_timeout'], '30') + self.app.log.debug("Writting nginx configration to " + "file /etc/nginx/nginx.conf ") nc.savef('/etc/nginx/nginx.conf') # Custom Nginx configuration by EasyEngine data = dict(version='EasyEngine 3.0.1') + self.app.log.debug('writting the nginx configration to file' + '/etc/nginx/conf.d/ee-nginx.conf ') ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') self.app.render((data), 'nginx-core.mustache', out=ee_nginx) ee_nginx.close() @@ -151,6 +163,7 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_php).issubset(set(apt_packages)): # Parse etc/php5/fpm/php.ini config = configparser.ConfigParser() + self.app.log.debug("configring php file /etc/php5/fpm/php.ini") config.read('/etc/php5/fpm/php.ini') config['PHP']['expose_php'] = 'Off' config['PHP']['post_max_size'] = '100M' @@ -158,6 +171,8 @@ class EEStackController(CementBaseController): config['PHP']['max_execution_time'] = '300' config['PHP']['date.timezone'] = time.tzname[time.daylight] with open('/etc/php5/fpm/php.ini', 'w') as configfile: + self.app.log.debug("writting configration of php in to" + "file /etc/php5/fpm/php.ini") config.write(configfile) # Prase /etc/php5/fpm/php-fpm.conf @@ -165,6 +180,8 @@ class EEStackController(CementBaseController): config.read('/etc/php5/fpm/php-fpm.conf') config['global']['error_log'] = '/var/log/php5/fpm.log' with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: + self.app.log.debug("writting php5 configartion into " + " /etc/php5/fpm/php-fpm.conf") config.write(configfile) # Parse /etc/php5/fpm/pool.d/www.conf @@ -181,6 +198,8 @@ class EEStackController(CementBaseController): config['www']['pm'] = 'ondemand' config['www']['listen'] = '127.0.0.1:9000' with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile: + self.app.log.debug("writting PHP5 configartion into " + " /etc/php5/fpm/pool.d/www.conf") config.write(configfile) if set(EEVariables.ee_mysql).issubset(set(apt_packages)): @@ -193,6 +212,7 @@ class EEStackController(CementBaseController): config.write(configfile) if set(EEVariables.ee_mail).issubset(set(apt_packages)): + self.app.log.debug("Executing mail commands") EEShellExec.cmd_exec("adduser --uid 5000 --home /var/vmail" "--disabled-password --gecos '' vmail") EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" @@ -201,10 +221,14 @@ class EEStackController(CementBaseController): "pem -keyout /etc/ssl/private/dovecot.pem" .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) + self.app.log.debug("Adding Privillages to file " + "/etc/ssl/private/dovecot.pem ") EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/dovecot.pem") # Custom Dovecot configuration by EasyEngine data = dict() + self.app.log.debug("Writting configration into file" + "/etc/dovecot/conf.d/99-ee.conf ") ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf', 'w') self.app.render((data), 'dovecot.mustache', out=ee_dovecot) ee_dovecot.close() @@ -266,16 +290,21 @@ class EEStackController(CementBaseController): # Sieve configuration if not os.path.exists('/var/lib/dovecot/sieve/'): + self.app.log.debug('Creating directory' + '/var/lib/dovecot/sieve/ ') os.makedirs('/var/lib/dovecot/sieve/') # Custom sieve configuration by EasyEngine data = dict() + self.app.log.debug("Writting configaration of EasyEngine into" + "file /var/lib/dovecot/sieve/default.sieve") ee_sieve = open('/var/lib/dovecot/sieve/default.sieve', 'w') self.app.render((data), 'default-sieve.mustache', out=ee_sieve) ee_sieve.close() # Compile sieve rules + self.app.log.debug("Privillages to dovecot ") EEShellExec.cmd_exec("chown -R vmail:vmail /var/lib/dovecot") EEShellExec.cmd_exec("sievec /var/lib/dovecot/sieve/" "default.sieve") @@ -286,33 +315,52 @@ class EEStackController(CementBaseController): if any('/tmp/pma.tar.gz' == x[1] for x in packages): EEExtract.extract('/tmp/pma.tar.gz', '/tmp/') + self.app.log.debug('Extracting file /tmp/pma.tar.gz to ' + 'loaction /tmp/') if not os.path.exists('/var/www/22222/htdocs/db'): + self.app.log.debug("Creating new directory " + "/var/www/22222/htdocs/db") os.makedirs('/var/www/22222/htdocs/db') shutil.move('/tmp/phpmyadmin-STABLE/', '/var/www/22222/htdocs/db/pma/') + self.app.log.debug('Privillages to www-data:www-data ' + '/var/www/22222/htdocs/db/pma ') EEShellExec.cmd_exec('chown -R www-data:www-data ' '/var/www/22222/htdocs/db/pma') if any('/tmp/memcache.tar.gz' == x[1] for x in packages): + self.app.log.debug("Extracting memcache.tar.gz to location" + " /var/www/22222/htdocs/cache/memcache ") EEExtract.extract('/tmp/memcache.tar.gz', '/var/www/22222/htdocs/cache/memcache') + self.app.log.debug("Privillages to" + " /var/www/22222/htdocs/cache/memcache") EEShellExec.cmd_exec('chown -R www-data:www-data ' '/var/www/22222/htdocs/cache/memcache') if any('/tmp/webgrind.tar.gz' == x[1] for x in packages): + self.app.log.debug("Extracting file webgrind.tar.gz to " + "location /tmp/ ") EEExtract.extract('/tmp/webgrind.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/php'): + self.app.log.debug("Creating directroy " + "/var/www/22222/htdocs/php") os.makedirs('/var/www/22222/htdocs/php') shutil.move('/tmp/webgrind-master/', '/var/www/22222/htdocs/php/webgrind') + self.app.log.debug("Privillages www-data:www-data " + "/var/www/22222/htdocs/php/webgrind/ ") EEShellExec.cmd_exec('chown -R www-data:www-data ' '/var/www/22222/htdocs/php/webgrind/') if any('/tmp/anemometer.tar.gz' == x[1] for x in packages): + self.app.log.debug("Extracting file anemometer.tar.gz to " + "location /tmp/ ") EEExtract.extract('/tmp/anemometer.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/db/'): + self.app.log.debug("Creating directory") os.makedirs('/var/www/22222/htdocs/db/') shutil.move('/tmp/Anemometer-master', '/var/www/22222/htdocs/db/anemometer') @@ -326,6 +374,7 @@ class EEStackController(CementBaseController): ' BY \''+chars+'\'') # Custom Anemometer configuration + self.app.log.debug("configration Anemometer") data = dict(host='localhost', port='3306', user='anemometer', password=chars) ee_anemometer = open('/var/www/22222/htdocs/db/anemometer' @@ -340,16 +389,23 @@ class EEStackController(CementBaseController): if any('/tmp/vimbadmin.tar.gz' == x[1] for x in packages): # Extract ViMbAdmin + self.app.log.debug("Extracting ViMbAdmin.tar.gz to " + "location /tmp/") EEExtract.extract('/tmp/vimbadmin.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/'): + self.app.log.debug("Creating directory " + " /var/www/22222/htdocs/") os.makedirs('/var/www/22222/htdocs/') shutil.move('/tmp/ViMbAdmin-3.0.10/', '/var/www/22222/htdocs/vimbadmin/') # Donwload composer and install ViMbAdmin + self.app.log.debug("Downloading composer " + "https://getcomposer.org/installer | php ") EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin; curl" " -sS https://getcomposer.org/installer |" " php") + self.app.log.debug("installation of composer") EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin && " "php composer.phar install --prefer-dist" " --no-dev && rm -f /var/www/22222/htdocs" @@ -357,14 +413,16 @@ class EEStackController(CementBaseController): # Configure vimbadmin database vm_passwd = ''.join(random.sample(string.ascii_letters, 8)) - + self.app.log.debug("Creating vimbadmin database if not exist") EEMysql.execute("create database if not exists vimbadmin") + self.app.log.debug("Granting all privileges on vimbadmin ") EEMysql.execute("grant all privileges on vimbadmin.* to" " vimbadmin@localhost IDENTIFIED BY" " '{password}'".format(password=vm_passwd)) # Configure ViMbAdmin settings config = configparser.ConfigParser(strict=False) + self.app.log.debug("configuring ViMbAdmin ") config.read('/var/www/22222/htdocs/vimbadmin/application/' 'configs/application.ini.dist') config['user']['defaults.mailbox.uid'] = '5000' @@ -395,6 +453,9 @@ class EEStackController(CementBaseController): (string.ascii_letters + string.ascii_letters, 64))) + self.app.log.debug("Writting configration to file " + "/var/www/22222/htdocs/vimbadmin" + "/application/configs/application.ini ") with open('/var/www/22222/htdocs/vimbadmin/application' '/configs/application.ini', 'w') as configfile: config.write(configfile) @@ -403,13 +464,20 @@ class EEStackController(CementBaseController): ".htaccess.dist", "/var/www/22222/htdocs/vimbadmin/public/" ".htaccess") + self.app.log.debug("Executing command " + "/var/www/22222/htdocs/vimbadmin/bin" + "/doctrine2-cli.php orm:schema-tool:" + "create" ") EEShellExec.cmd_exec("/var/www/22222/htdocs/vimbadmin/bin" "/doctrine2-cli.php orm:schema-tool:" "create") # Copy Dovecot and Postfix templates which are depednet on # Vimbadmin + if not os.path.exists('/etc/postfix/mysql/'): + self.app.log.debug("Creating directory " + "/etc/postfix/mysql/") os.makedirs('/etc/postfix/mysql/') data = dict(password=vm_passwd) vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf', @@ -418,18 +486,25 @@ class EEStackController(CementBaseController): out=vm_config) vm_config.close() + self.app.log.debug("Configration of file " + "/etc/postfix/mysql" + "/virtual_domains_maps.cf") vm_config = open('/etc/postfix/mysql/virtual_domains_maps.cf', 'w') self.app.render((data), 'virtual_domains_maps.mustache', out=vm_config) vm_config.close() + self.app.log.debug("Configation of file " + "/etc/postfix/mysql" + "/virtual_mailbox_maps.cf ") vm_config = open('/etc/postfix/mysql/virtual_mailbox_maps.cf', 'w') self.app.render((data), 'virtual_mailbox_maps.mustache', out=vm_config) vm_config.close() + self.app.log.debug("Configration of file ") vm_config = open('/etc/dovecot/dovecot-sql.conf.ext', 'w') self.app.render((data), 'dovecot-sql-conf.mustache', @@ -438,15 +513,21 @@ class EEStackController(CementBaseController): if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): # Extract RoundCubemail + self.app.log.debug("Extracting file /tmp/roundcube.tar.gz " + "to location /tmp/ ") EEExtract.extract('/tmp/roundcube.tar.gz', '/tmp/') if not os.path.exists('/var/www/roundcubemail'): + self.app.log.debug("Creating new directory " + " /var/www/roundcubemail/") os.makedirs('/var/www/roundcubemail/') shutil.move('/tmp/roundcubemail-1.0.4/', '/var/www/roundcubemail/htdocs') # Configure roundcube database rc_passwd = ''.join(random.sample(string.ascii_letters, 8)) + self.app.log.debug("Creating Database roundcubemail") EEMysql.execute("create database if not exists roundcubemail") + self.app.log.debug("Grant all privileges on roundcubemail") EEMysql.execute("grant all privileges on roundcubemail.* to " " roundcube@localhost IDENTIFIED BY " "'{password}'".format(password=rc_passwd)) @@ -481,6 +562,8 @@ class EEStackController(CementBaseController): packages = [] if self.app.pargs.web: + self.app.log.debug("Setting apt_packages variable for Nginx ,PHP" + " ,MySQL ") apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) @@ -489,6 +572,7 @@ class EEStackController(CementBaseController): # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: apt_packages = apt_packages + EEVariables.ee_mail + self.app.log.debug("Setting apt_packages variable for mail") packages = packages + [["https://github.com/opensolutions/ViMbAdmi" "n/archive/3.0.10.tar.gz", "/tmp/vimbadmin" ".tar.gz"], @@ -499,28 +583,36 @@ class EEStackController(CementBaseController): ] if self.app.pargs.nginx: + self.app.log.debug("Setting apt_packages variable for Nginx") apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: + self.app.log.debug("Setting apt_packages variable for PHP") apt_packages = apt_packages + EEVariables.ee_php if self.app.pargs.mysql: + self.app.log.debug("Setting apt_packages variable for MySQL") apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: + self.app.log.debug("Setting apt_packages variable for PostFix") apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: + self.app.log.debug("Setting packages variable for WPCLI") packages = packages + [["https://github.com/wp-cli/wp-cli/releases" "/download/v0.17.1/wp-cli.phar", "/usr/bin/wp"]] if self.app.pargs.phpmyadmin: + self.app.log.debug("Setting packages varible for phpMyAdmin ") packages = packages + [["https://github.com/phpmyadmin/phpmyadmin" "/archive/STABLE.tar.gz", "/tmp/pma.tar.gz"]] if self.app.pargs.adminer: + self.app.log.debug("Setting packages variable for Adminer ") packages = packages + [["http://downloads.sourceforge.net/adminer" "/adminer-4.1.0.php", "/var/www/22222/" "htdocs/db/adminer/index.php"]] if self.app.pargs.utils: + self.app.log.debug("Setting packages variable for utils") packages = packages + [["http://phpmemcacheadmin.googlecode.com/" "files/phpMemcachedAdmin-1.2.2" "-r262.tar.gz", '/tmp/memcache.tar.gz'], @@ -553,12 +645,15 @@ class EEStackController(CementBaseController): "/master.tar.gz", '/tmp/anemometer.tar.gz'] ] - + self.app.log.debug("Calling pre_pref ") self.pre_pref(apt_packages) if len(apt_packages): + self.app.log.debug("Installing all apt_packages") pkg.install(apt_packages) if len(packages): + self.app.log.debug("Downloading all packages") EEDownload.download(packages) + self.app.log.debug("Calling post_pref") self.post_pref(apt_packages, packages) @expose() @@ -568,6 +663,8 @@ class EEStackController(CementBaseController): packages = [] if self.app.pargs.web: + self.app.log.debug("Removing apt_packages variable of Nginx " + ",PHP,MySQL") apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: @@ -577,20 +674,28 @@ class EEStackController(CementBaseController): pass # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.nginx: + self.app.log.debug("Removing apt_packages variable of Nginx") apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: + self.app.log.debug("Removing apt_packages variable of PHP") apt_packages = apt_packages + EEVariables.ee_php if self.app.pargs.mysql: + self.app.log.debug("Removing apt_packages variable of MySQL") apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: + self.app.log.debug("Removing apt_packages variable of Postfix") apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: + self.app.log.debug("Removing package variable of WPCLI ") packages = packages + ['/usr/bin/wp'] if self.app.pargs.phpmyadmin: + self.app.log.debug("Removing package variable of phpMyAdmin ") packages = packages + ['/var/www/22222/htdocs/db/pma'] if self.app.pargs.adminer: + self.app.log.debug("Removing package variable of Adminer ") packages = packages + ['/var/www/22222/htdocs/db/adminer'] if self.app.pargs.utils: + self.app.log.debug("Removing package variable of utils ") packages = packages + ['/var/www/22222/htdocs/php/webgrind/', '/var/www/22222/htdocs/cache/opcache', '/var/www/22222/htdocs/cache/nginx/' @@ -600,6 +705,7 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/db/anemometer'] if len(apt_packages): + self.app.log.debug("Removing apt_packages") pkg.remove(apt_packages) if len(packages): EEFileUtils.remove(packages) @@ -611,6 +717,7 @@ class EEStackController(CementBaseController): packages = [] if self.app.pargs.web: + self.app.log.debug("Purge Nginx,PHP,MySQL") apt_packages = (apt_packages + EEVariables.ee_nginx + EEVariables.ee_php + EEVariables.ee_mysql) if self.app.pargs.admin: @@ -620,20 +727,28 @@ class EEStackController(CementBaseController): pass # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.nginx: + self.app.log.debug("Purge apt_packages variable of Nginx") apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: + self.app.log.debug("Purge apt_packages variable PHP") apt_packages = apt_packages + EEVariables.ee_php if self.app.pargs.mysql: + self.app.log.debug("Purge apt_packages variable MySQL") apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: + self.app.log.debug("Purge apt_packages variable PostFix") apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: + self.app.log.debug("Purge package variable WPCLI") packages = packages + ['/usr/bin/wp'] if self.app.pargs.phpmyadmin: packages = packages + ['/var/www/22222/htdocs/db/pma'] + self.app.log.debug("Purge package variable phpMyAdmin") if self.app.pargs.adminer: + self.app.log.debug("Purge package variable Adminer") packages = packages + ['/var/www/22222/htdocs/db/adminer'] if self.app.pargs.utils: + self.app.log.debug("Purge package variable utils") packages = packages + ['/var/www/22222/htdocs/php/webgrind/', '/var/www/22222/htdocs/cache/opcache', '/var/www/22222/htdocs/cache/nginx/' From 490b1c50fa7662e774ae4ed88d48c4893fe9d1b4 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Fri, 26 Dec 2014 19:06:21 +0530 Subject: [PATCH 565/829] adding more log messages --- ee/cli/plugins/stack.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 16e8b36d..0f19eae6 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -312,6 +312,8 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): # Set up Custom amavis configuration data = dict() + self.app.log.debug("Configuring file /etc/amavis/conf.d" + "/15-content_filter_mode") ee_amavis = open('/etc/amavis/conf.d/15-content_filter_mode', 'w') self.app.render((data), '15-content_filter_mode.mustache', @@ -327,17 +329,22 @@ class EEStackController(CementBaseController): "_checks/\" /etc/postfix/master.cf") # Amavis ClamAV configuration + self.app.log.debug("Adding new user clamav amavis") EEShellExec.cmd_exec("adduser clamav amavis") + self.app.log.debug("Adding new user amavis clamav") EEShellExec.cmd_exec("adduser amavis clamav") + self.app.log.debug("Privillages to file /var/lib/amavis/tmp ") EEShellExec.cmd_exec("chmod -R 775 /var/lib/amavis/tmp") # Update ClamAV database + self.app.log.debug("Updating database") EEShellExec.cmd_exec("freshclam") + self.app.log.debug("Restarting service clamav-daemon") EEShellExec.cmd_exec("service clamav-daemon restart") if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): - + self.app.log.debug("Privillages to /usr/bin/wp ") EEShellExec.cmd_exec("chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] for x in packages): From 733381f86e46e842d0112ff425bb4110473a3d9c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 26 Dec 2014 19:24:29 +0530 Subject: [PATCH 566/829] Updated setup.py to work with CI --- setup.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3722d0c2..013c9806 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,17 @@ from setuptools import setup, find_packages import sys import os +import glob +conf = [] +templates = [] + + +for name in glob.glob('config/plugins.d/*.conf'): + conf.insert(1, name) + +for name in glob.glob('ee/cli/templates/*.mustache'): + templates.insert(1, name) setup(name='ee', version='3.0', @@ -17,7 +27,8 @@ setup(name='ee', author_email='sys@rtcamp.com', url='http://rtcamp.com/easyengine', license='GPL', - packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), + packages=find_packages(exclude=['ez_setup', 'examples', 'tests', + 'templates']), include_package_data=True, zip_safe=False, test_suite='nose.collector', @@ -35,6 +46,9 @@ setup(name='ee', 'pymysql3', 'psutil', ], + data_files=[('/etc/ee', ['config/ee.conf']), + ('/etc/ee/plugins.d', conf), + ('/usr/lib/ee/templates', templates)], setup_requires=[], entry_points=""" [console_scripts] From 834fd40692d820d02be0d1f2d7ddab1c8a8f090f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 29 Dec 2014 12:29:09 +0530 Subject: [PATCH 567/829] Fixed code issue --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 0f19eae6..a39e4d82 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -501,7 +501,7 @@ class EEStackController(CementBaseController): self.app.log.debug("Executing command " "/var/www/22222/htdocs/vimbadmin/bin" "/doctrine2-cli.php orm:schema-tool:" - "create" ") + "create") EEShellExec.cmd_exec("/var/www/22222/htdocs/vimbadmin/bin" "/doctrine2-cli.php orm:schema-tool:" "create") From f038463b28d06352c2097a64255f2d42296c061d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 29 Dec 2014 16:44:58 +0530 Subject: [PATCH 568/829] domain validate code --- ee/cli/plugins/site.py | 4 ++++ ee/core/domainvalidate.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 ee/core/domainvalidate.py diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 6466ac12..fd6aad6c 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -1,6 +1,7 @@ """EasyEngine site controller.""" from cement.core.controller import CementBaseController, expose from cement.core import handler, hook +from ee.core.domainvalidate import validate_domain import sys @@ -107,6 +108,9 @@ class EESiteCreateController(CementBaseController): # TODO Default action for ee site command # data = dict(foo='EESiteCreateController.default().') # self.app.render((data), 'default.mustache') + # Check domain name validation + ee_domain_name = validate_domain(self.app.pargs.site_name) + if (self.app.pargs.html and not (self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or diff --git a/ee/core/domainvalidate.py b/ee/core/domainvalidate.py new file mode 100644 index 00000000..8f7057ca --- /dev/null +++ b/ee/core/domainvalidate.py @@ -0,0 +1,20 @@ +from urllib.parse import urlparse + + +def validate_domain(url): + + # Check if http:// or https:// present remove it if present + domain_name = url.split('/') + if 'http:' in domain_name or 'https:' in domain_name: + domain_name = domain_name[2] + else: + domain_name = domain_name[0] + + www_domain_name = domain_name.split('.') + final_domain = '' + if www_domain_name[0] == 'www': + final_domain = '.'.join(www_domain_name[1:]) + return final_domain + else: + final_domain = domain_name + return final_domain From e8e70145c9b616fda4ead9c93665c4e6028a5b60 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 29 Dec 2014 18:39:42 +0530 Subject: [PATCH 569/829] Added hack to get work with Travis --- .travis.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b4f13db0..10993c41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,13 +9,25 @@ notifications: language: bash before_install: -- rm -rf ~/.gnupg + - rm -rf ~/.gnupg before_script: -- sudo apt-get -qq purge mysql* graphviz* -- sudo apt-get -qq autoremove + - sudo apt-get -qq purge mysql* graphviz* + - sudo apt-get -qq autoremove script: -- sudo echo -e "[user]\n\tname = Mitesh Shah\n\temail = root@localhost.com" > ~/.gitconfig -- sudo echo "Travis Banch = $TRAVIS_BRANCH" - + - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig + - sudo echo "Travis Banch = $TRAVIS_BRANCH" + - sudo apt-get install git python3-setuptools python3-dev python3-apt + - sudo easy_install3 pip + - sudo pip3 install virtualenv + - virtualenv ./env --system-site-packages + - source ./env/bin/activate + - sudo pip3 install -r requirements.txt + - sudo python3 setup.py develop + - mkdir ~/.ee + - ln -s /home/travis/build/shitalp/easyengine/config/plugins.d ~/.ee/plugins.d + - ln -s /home/travis/build/shitalp/easyengineee/cli/plugins ~/.ee/plugins + - ee --help + - sudo pip3 install nose coverage + - nosetests From 0ab6899eba36d7964ac06502fbc5f365ead732a1 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 29 Dec 2014 18:54:19 +0530 Subject: [PATCH 570/829] Fixed travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 10993c41..82bac45e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,8 +26,8 @@ script: - sudo pip3 install -r requirements.txt - sudo python3 setup.py develop - mkdir ~/.ee - - ln -s /home/travis/build/shitalp/easyengine/config/plugins.d ~/.ee/plugins.d - - ln -s /home/travis/build/shitalp/easyengineee/cli/plugins ~/.ee/plugins + - ln -s /home/travis/build/rtCamp/easyengine/config/plugins.d ~/.ee/plugins.d + - ln -s /home/travis/build/rtCamp/easyengineee/cli/plugins ~/.ee/plugins - ee --help - sudo pip3 install nose coverage - nosetests From 81e1890cabfd3f7fb05d8ffc55511a58ae61de9a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 29 Dec 2014 19:05:06 +0530 Subject: [PATCH 571/829] Added sudo for nosetests --- .travis.yml | 2 +- ee/cli/plugins/stack.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82bac45e..181138e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,4 +30,4 @@ script: - ln -s /home/travis/build/rtCamp/easyengineee/cli/plugins ~/.ee/plugins - ee --help - sudo pip3 install nose coverage - - nosetests + - sudo nosetests diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index a39e4d82..27f22e10 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -599,11 +599,8 @@ class EEStackController(CementBaseController): "/config/config.inc.php") @expose() - def install(self): + def install(self, packages=[], apt_packages=[]): pkg = EEAptGet() - apt_packages = [] - packages = [] - if self.app.pargs.web: self.app.log.debug("Setting apt_packages variable for Nginx ,PHP" " ,MySQL ") From 76848ee6a67fae029c83621f2bb7044934f767e2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 29 Dec 2014 19:32:02 +0530 Subject: [PATCH 572/829] Added function for package check --- ee/cli/plugins/stack.py | 5 +++++ ee/core/aptget.py | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 27f22e10..01c00bcb 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -58,6 +58,11 @@ class EEStackController(CementBaseController): dict(help='Install Utils stack', action='store_true')), ] + @expose(hide=True) + def package_check(self, packages=[]): + # Function for packages check + pass + @expose(hide=True) def default(self): # TODO Default action for ee stack command diff --git a/ee/core/aptget.py b/ee/core/aptget.py index efa35f41..e2ed5960 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -215,3 +215,16 @@ class EEAptGet: .format(err=str(e))) return(False) return(True) + + def is_installed(self, package): + # Cache Initialization + if not self.cache: + self.cache = apt.Cache() + # Cache Read + self.cache.open() + pkg = self.cache[package] + # Check Package Installed + if pkg.is_installed: + return True + else: + return False From bf93dd33e114876cb02bcf7fe0e062f89064d338 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 30 Dec 2014 14:18:53 +0530 Subject: [PATCH 573/829] creating symbolic link --- ee/cli/plugins/site.py | 47 +++++++++++++--------- ee/cli/templates/virtualconf.mustache | 56 +++++++++++++-------------- ee/core/fileutils.py | 9 +++++ 3 files changed, 66 insertions(+), 46 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index fd6aad6c..86726405 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -2,6 +2,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.domainvalidate import validate_domain +from ee.core.fileutils import EEFileUtils import sys @@ -111,11 +112,12 @@ class EESiteCreateController(CementBaseController): # Check domain name validation ee_domain_name = validate_domain(self.app.pargs.site_name) + # setup nginx configuration for site if (self.app.pargs.html and not (self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or - self.app.pargs.wsubdir or self.app.pargs.wsubdomain)): - data = dict(site_name=self.app.pargs.site_name, + self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + data = dict(site_name=ee_domain_name, static=True, basic=False, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) @@ -124,7 +126,7 @@ class EESiteCreateController(CementBaseController): self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or self.app.pargs.wsubdir or self.app.pargs.wsubdomain)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) @@ -133,7 +135,7 @@ class EESiteCreateController(CementBaseController): self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or self.app.pargs.wsubdir or self.app.pargs.wsubdomain)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) @@ -144,25 +146,25 @@ class EESiteCreateController(CementBaseController): self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): if (self.app.pargs.wp and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=False, wpsubdir=False) if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=False, wpsubdir=False) if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=False, wpsubdir=False) @@ -172,25 +174,25 @@ class EESiteCreateController(CementBaseController): self.app.pargs.wpsubdomain or self.app.pargs.wp)): if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=True, wpsubdir=True) if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, wpsubdir=True) if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, wpsubdir=True) if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, wpsubdir=True) @@ -200,38 +202,47 @@ class EESiteCreateController(CementBaseController): self.app.pargs.wpsubdir or self.app.pargs.wp)): if (self.app.pargs.wpsubdomain and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=True, wpsubdir=False) if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, wpsubdir=False) if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, wpsubdir=False) if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - data = dict(site_name=self.app.pargs.site_name, + data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, wpsubdir=False) try: ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}.conf' - .format(self.app.pargs.site_name), 'w') + .format(ee_domain_name), 'w') self.app.render((data), 'virtualconf.mustache', out=ee_site_nginx_conf) ee_site_nginx_conf.close() + except IOError as e: + print("Unable to create nginx conf for {2} ({0}): {1}" + .format(e.errno, e.strerror)) except Exception as e: - print("Select proper options for creating site") + print("{0}".format(e)) + + # create symbolic link + EEFileUtils.create_symlink(['/etc/nginx/sites-available/{0}.conf' + .format(ee_domain_name), + '/etc/nginx/sites-enabled/{0}.conf' + .format(ee_domain_name)]) class EESiteUpdateController(CementBaseController): diff --git a/ee/cli/templates/virtualconf.mustache b/ee/cli/templates/virtualconf.mustache index 2ad0278d..fb7e92d3 100644 --- a/ee/cli/templates/virtualconf.mustache +++ b/ee/cli/templates/virtualconf.mustache @@ -1,32 +1,32 @@ server { -{{#multisite}} -# Uncomment the following line for domain mapping -# listen 80 default_server; -{{/multisite}} - -server_name {{site_name}} {{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{site_name}}; - -{{#multisite}} -# Uncomment the following line for domain mapping -#server_name_in_redirect off; -{{/multisite}} - -access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}}; -error_log /var/log/nginx/{{site_name}}.error.log; -root /var/www/{{site_name}}/htdocs; - -index {{^static}}index.php{{/static}} index.html index.htm; - -{{#static}} -location / { -try_files $uri $uri/ /index.html; -} -{{/static}} - -{{^static}}include{{/static}} {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} -{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}} -{{#wp}}include common/wpcommon.conf;{{/wp}} -include common/locations.conf; + {{#multisite}} + # Uncomment the following line for domain mapping + # listen 80 default_server; + {{/multisite}} + + server_name {{site_name}} {{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{site_name}}; + + {{#multisite}} + # Uncomment the following line for domain mapping + #server_name_in_redirect off; + {{/multisite}} + + access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}}; + error_log /var/log/nginx/{{site_name}}.error.log; + root /var/www/{{site_name}}/htdocs; + + index {{^static}}index.php{{/static}} index.html index.htm; + + {{#static}} + location / { + try_files $uri $uri/ /index.html; + } + {{/static}} + + {{^static}}include{{/static}} {{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} + {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}} + {{#wp}}include common/wpcommon.conf;{{/wp}} + include common/locations.conf; } diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 4853d01b..4bd6a9de 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -1,6 +1,7 @@ """EasyEngine file utils core classes.""" import shutil import os +import glob class EEFileUtils(): @@ -23,3 +24,11 @@ class EEFileUtils(): print("Unable to remove file, [{err}]" .format(err=str(e.reason))) return False + + def create_symlink(paths): + src = paths[0] + dst = paths[1] + try: + os.symlink(src, dst) + except Exception as e: + print("Unable to create sybolic link for {0}".format(e)) From f7a1fca6840c1764ac33ae6bf3dbefce780f8b87 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 30 Dec 2014 17:22:56 +0530 Subject: [PATCH 574/829] updated --- ee/cli/plugins/stack.py | 122 +++++++++++++++++-------------- ee/cli/plugins/stack_services.py | 28 +++++++ ee/core/aptget.py | 4 + ee/core/download.py | 25 ++++--- ee/core/extract.py | 5 +- ee/core/fileutils.py | 17 +++-- ee/core/mysql.py | 8 +- ee/core/services.py | 4 +- ee/core/shellexec.py | 6 +- ee/core/variables.py | 1 + 10 files changed, 140 insertions(+), 80 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index a39e4d82..9e31aabe 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -67,10 +67,10 @@ class EEStackController(CementBaseController): def pre_pref(self, apt_packages): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): print("Pre-seeding postfix variables ... ") - EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type " - "string 'Internet Site'\" | " + EEShellExec.cmd_exec(self, "echo \"postfix postfix " + "/main_mailer_typestring 'Internet Site'\" | " "debconf-set-selections") - EEShellExec.cmd_exec("echo \"postfix postfix/mailname string " + EEShellExec.cmd_exec(self, "echo \"postfix postfix/mailname string" "$(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): print("Adding repository for MySQL ... ") @@ -79,11 +79,11 @@ class EEStackController(CementBaseController): EERepo.add_key('1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) print("Pre-seeding MySQL variables ... ") - EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " + EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " "percona-server-server/root_password " "password {chars}\" | " "debconf-set-selections".format(chars=chars)) - EEShellExec.cmd_exec("echo \"percona-server-server-5.6 " + EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " "percona-server-server/root_password_again " "password {chars}\" | " "debconf-set-selections".format(chars=chars)) @@ -101,7 +101,8 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_nginx).issubset(set(apt_packages)): print("Adding repository for Nginx ... ") if EEVariables.ee_platform_distro == 'Debian': - self.app.log.debug('Adding Dotdeb/nginx GPG key') + s + elf.app.log.debug('Adding Dotdeb/nginx GPG key') EERepo.add(repo_url=EEVariables.ee_nginx_repo) else: self.app.log.debug('Adding ppa of Nginx') @@ -123,11 +124,11 @@ class EEStackController(CementBaseController): print("Adding repository for dovecot ... ") EERepo.add(repo_url=EEVariables.ee_dovecot_repo) self.app.log.debug('Executing the command debconf-set-selections.') - EEShellExec.cmd_exec("echo \"dovecot-core dovecot-core/" + EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/" "create-ssl-cert boolean yes\" " "| debconf-set-selections") - EEShellExec.cmd_exec("echo \"dovecot-core dovecot-core/ssl-cert-" - "name string $(hostname -f)\"" + EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core" + "/ssl-cert-name string $(hostname -f)\"" " | debconf-set-selections") @expose(hide=True) @@ -213,17 +214,20 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_mail).issubset(set(apt_packages)): self.app.log.debug("Executing mail commands") - EEShellExec.cmd_exec("adduser --uid 5000 --home /var/vmail" - "--disabled-password --gecos '' vmail") - EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" - " -subj /commonName={HOSTNAME}/emailAddre" - "ss={EMAIL} -out /etc/ssl/certs/dovecot." + EEShellExec.cmd_exec(self, "adduser --uid 5000 --home /var" + "/vmail--disabled-password --gecos ''" + " vmail") + EEShellExec.cmd_exec(self, "openssl req -new -x509 -days 3650 " + "-nodes -subj /commonName={HOSTNAME}" + "/emailAddre ss={EMAIL} -out /etc/ssl" + "/certs/dovecot." "pem -keyout /etc/ssl/private/dovecot.pem" .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) self.app.log.debug("Adding Privillages to file " "/etc/ssl/private/dovecot.pem ") - EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/dovecot.pem") + EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private" + "/dovecot.pem") # Custom Dovecot configuration by EasyEngine data = dict() @@ -236,24 +240,28 @@ class EEStackController(CementBaseController): # Custom Postfix configuration needed with Dovecot # Changes in master.cf # TODO: Find alternative for sed in Python - EEShellExec.cmd_exec("sed -i \'s/#submission/submission/\'" + EEShellExec.cmd_exec(self, "sed -i \'s/#submission/submission" + "/\'" " /etc/postfix/master.cf") - EEShellExec.cmd_exec("sed -i \'s/#smtps/smtps/\'" + EEShellExec.cmd_exec(self, "sed -i \'s/#smtps/smtps/\'" " /etc/postfix/master.cf") - EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_type = " + EEShellExec.cmd_exec(self, "postconf -e \"smtpd_sasl_type = " "dovecot\"") - EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_path = " + EEShellExec.cmd_exec(self, "postconf -e \"smtpd_sasl_path = " "private/auth\"") - EEShellExec.cmd_exec("postconf -e \"smtpd_sasl_auth_enable = " + EEShellExec.cmd_exec(self, "postconf -e \"" + "smtpd_sasl_auth_enable = " "yes\"") - EEShellExec.cmd_exec("postconf -e \"smtpd_relay_restrictions =" - " permit_sasl_authenticated, " - "permit_mynetworks, " - "reject_unauth_destination\"") - EEShellExec.cmd_exec("postconf -e \"smtpd_tls_mandatory_" - "protocols = !SSLv2,!SSLv3\"") - EEShellExec.cmd_exec("postconf -e \"smtp_tls_mandatory_" + EEShellExec.cmd_exec(self, "postconf -e \"" + "smtpd_relay_restrictions =" + "permit_sasl_authenticated, " + "permit_mynetworks, " + "reject_unauth_destination\"") + "protocols = !SSLv2,!SSLv3\"") + EEShellExec.cmd_exec(self, "postconf -e \"" + "smtpd_tls_mandatory_") + EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls_mandatory_" "protocols = !SSLv2,!SSLv3\"") EEShellExec.cmd_exec("postconf -e \"smtpd_tls_protocols " "= !SSLv2,!SSLv3\"") @@ -348,7 +356,7 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec("chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] for x in packages): - EEExtract.extract('/tmp/pma.tar.gz', '/tmp/') + EEExtract.extract(self, '/tmp/pma.tar.gz', '/tmp/') self.app.log.debug('Extracting file /tmp/pma.tar.gz to ' 'loaction /tmp/') if not os.path.exists('/var/www/22222/htdocs/db'): @@ -365,7 +373,7 @@ class EEStackController(CementBaseController): for x in packages): self.app.log.debug("Extracting memcache.tar.gz to location" " /var/www/22222/htdocs/cache/memcache ") - EEExtract.extract('/tmp/memcache.tar.gz', + EEExtract.extract(self, '/tmp/memcache.tar.gz', '/var/www/22222/htdocs/cache/memcache') self.app.log.debug("Privillages to" " /var/www/22222/htdocs/cache/memcache") @@ -376,7 +384,7 @@ class EEStackController(CementBaseController): for x in packages): self.app.log.debug("Extracting file webgrind.tar.gz to " "location /tmp/ ") - EEExtract.extract('/tmp/webgrind.tar.gz', '/tmp/') + EEExtract.extract(self, '/tmp/webgrind.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/php'): self.app.log.debug("Creating directroy " "/var/www/22222/htdocs/php") @@ -392,7 +400,7 @@ class EEStackController(CementBaseController): for x in packages): self.app.log.debug("Extracting file anemometer.tar.gz to " "location /tmp/ ") - EEExtract.extract('/tmp/anemometer.tar.gz', '/tmp/') + EEExtract.extract(self, '/tmp/anemometer.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/db/'): self.app.log.debug("Creating directory") os.makedirs('/var/www/22222/htdocs/db/') @@ -401,9 +409,9 @@ class EEStackController(CementBaseController): chars = ''.join(random.sample(string.ascii_letters, 8)) EEShellExec.cmd_exec('mysql < /var/www/22222/htdocs/db' '/anemometer/install.sql') - EEMysql.execute('grant select on *.* to \'anemometer\'' + EEMysql.execute(self, 'grant select on *.* to \'anemometer\'' '@\'localhost\'') - EEMysql.execute('grant all on slow_query_log.* to' + EEMysql.execute(self, 'grant all on slow_query_log.* to' '\'anemometer\'@\'localhost\' IDENTIFIED' ' BY \''+chars+'\'') @@ -425,7 +433,7 @@ class EEStackController(CementBaseController): # Extract ViMbAdmin self.app.log.debug("Extracting ViMbAdmin.tar.gz to " "location /tmp/") - EEExtract.extract('/tmp/vimbadmin.tar.gz', '/tmp/') + EEExtract.extract(self, '/tmp/vimbadmin.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/'): self.app.log.debug("Creating directory " " /var/www/22222/htdocs/") @@ -448,9 +456,10 @@ class EEStackController(CementBaseController): # Configure vimbadmin database vm_passwd = ''.join(random.sample(string.ascii_letters, 8)) self.app.log.debug("Creating vimbadmin database if not exist") - EEMysql.execute("create database if not exists vimbadmin") + EEMysql.execute(self, "create database if not exists" + " vimbadmin") self.app.log.debug("Granting all privileges on vimbadmin ") - EEMysql.execute("grant all privileges on vimbadmin.* to" + EEMysql.execute(self, "grant all privileges on vimbadmin.* to" " vimbadmin@localhost IDENTIFIED BY" " '{password}'".format(password=vm_passwd)) @@ -502,8 +511,8 @@ class EEStackController(CementBaseController): "/var/www/22222/htdocs/vimbadmin/bin" "/doctrine2-cli.php orm:schema-tool:" "create") - EEShellExec.cmd_exec("/var/www/22222/htdocs/vimbadmin/bin" - "/doctrine2-cli.php orm:schema-tool:" + EEShellExec.cmd_exec(self, "/var/www/22222/htdocs/vimbadmin" + "/bin/doctrine2-cli.php orm:schema-tool:" "create") # Copy Dovecot and Postfix templates which are depednet on @@ -558,7 +567,7 @@ class EEStackController(CementBaseController): # Extract RoundCubemail self.app.log.debug("Extracting file /tmp/roundcube.tar.gz " "to location /tmp/ ") - EEExtract.extract('/tmp/roundcube.tar.gz', '/tmp/') + EEExtract.extract(self, '/tmp/roundcube.tar.gz', '/tmp/') if not os.path.exists('/var/www/roundcubemail'): self.app.log.debug("Creating new directory " " /var/www/roundcubemail/") @@ -569,12 +578,14 @@ class EEStackController(CementBaseController): # Configure roundcube database rc_passwd = ''.join(random.sample(string.ascii_letters, 8)) self.app.log.debug("Creating Database roundcubemail") - EEMysql.execute("create database if not exists roundcubemail") + EEMysql.execute(self, "create database if not exists " + " roundcubemail") self.app.log.debug("Grant all privileges on roundcubemail") - EEMysql.execute("grant all privileges on roundcubemail.* to " + EEMysql.execute(self, "grant all privileges" + " on roundcubemail.* to " " roundcube@localhost IDENTIFIED BY " "'{password}'".format(password=rc_passwd)) - EEShellExec.cmd_exec("mysql roundcubemail < /var/www/" + EEShellExec.cmd_exec(self, "mysql roundcubemail < /var/www/" "roundcubemail/htdocs/SQL/mysql" ".initial.sql") @@ -582,21 +593,22 @@ class EEStackController(CementBaseController): "config.inc.php.sample", "/var/www/roundcubemail/htdocs/config/" "config.inc.php") - EEShellExec.cmd_exec("sed -i \"s\'mysql://roundcube:pass@" - "localhost/roundcubemail\'mysql://" + EEShellExec.cmd_exec(self, "sed -i \"s\'mysql://roundcube:" + "pass@localhost/roundcubemail\'mysql://" "roundcube:{password}@localhost/" "roundcubemail\'\" /var/www/roundcubemail" "/htdocs/config/config." "inc.php".format(password=rc_passwd)) # Sieve plugin configuration in roundcube - EEShellExec.cmd_exec("sed -i \"s:\$config\['plugins'\] = array" - "(:\$config\['plugins'\] = array(\n " - "'sieverules',:\" /var/www/roundcubemail" + EEShellExec.cmd_exec(self, "sed -i \"s:\$config\['plugins'\] " + "= array(:\$config\['plugins'\] = " + "array(\n'sieverules',:\" /var/www" + "/roundcubemail/htdocs/config" + "/config.inc.php") + EEShellExec.cmd_exec(self, "echo \"\$config['sieverules_port']" + "=4190;\" >> /var/www/roundcubemail" "/htdocs/config/config.inc.php") - EEShellExec.cmd_exec("echo \"\$config['sieverules_port'] = " - "4190;\" >> /var/www/roundcubemail/htdocs" - "/config/config.inc.php") @expose() def install(self): @@ -697,7 +709,7 @@ class EEStackController(CementBaseController): pkg.install(apt_packages) if len(packages): self.app.log.debug("Downloading all packages") - EEDownload.download(packages) + EEDownload.download(self, packages) self.app.log.debug("Calling post_pref") self.post_pref(apt_packages, packages) @@ -751,9 +763,9 @@ class EEStackController(CementBaseController): if len(apt_packages): self.app.log.debug("Removing apt_packages") - pkg.remove(apt_packages) + pkg.remove(self, apt_packages) if len(packages): - EEFileUtils.remove(packages) + EEFileUtils.remove(self, packages) @expose() def purge(self): @@ -804,9 +816,9 @@ class EEStackController(CementBaseController): ] if len(apt_packages): - pkg.remove(apt_packages, purge=True) + pkg.remove(self, apt_packages, purge=True) if len(packages): - EEFileUtils.remove(packages) + EEFileUtils.remove(self, packages) def load(app): diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index ee23866c..650027b1 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -20,18 +20,25 @@ class EEStackStatusController(CementBaseController): def start(self): services = [] if self.app.pargs.nginx: + self.app.log.debug("nginx service start") services = services + ['nginx'] elif self.app.pargs.php: + self.app.log.debug("php5-fpm service start") services = services + ['php5-fpm'] elif self.app.pargs.mysql: + self.app.log.debug("mysql service start") services = services + ['mysql'] elif self.app.pargs.postfix: + self.app.log.debug("postfix service start") services = services + ['postfix'] elif self.app.pargs.memcache: + self.app.log.debug("memcached service start") services = services + ['memcached'] elif self.app.pargs.dovecot: + self.app.log.debug("dovecot service start") services = services + ['dovecot'] else: + self.app.log.debug("nginx,php5-fpm,mysql,postfix services start") services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: EEService.start_service(self, service) @@ -40,19 +47,26 @@ class EEStackStatusController(CementBaseController): def stop(self): services = [] if self.app.pargs.nginx: + self.app.log.debug("nginx service stop") services = services + ['nginx'] elif self.app.pargs.php: + self.app.log.debug("php5-fpm service stop") services = services + ['php5-fpm'] elif self.app.pargs.mysql: + self.app.log.debug("mysql service stop") services = services + ['mysql'] elif self.app.pargs.postfix: + self.app.log.debug("postfix service stop") services = services + ['postfix'] elif self.app.pargs.memcache: + self.app.log.debug("memcached service stop") services = services + ['memcached'] elif self.app.pargs.dovecot: + self.app.log.debug("dovecot service stop") services = services + ['dovecot'] else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] + self.app.log.debug("nginx,php5-fpm,mysql,postfix services stop") for service in services: EEService.stop_service(self, service) @@ -60,38 +74,52 @@ class EEStackStatusController(CementBaseController): def restart(self): services = [] if self.app.pargs.nginx: + self.app.log.debug("nginx service restart") services = services + ['nginx'] elif self.app.pargs.php: + self.app.log.debug("php5-fpm service restart") services = services + ['php5-fpm'] elif self.app.pargs.mysql: + self.app.log.debug("mysql service restart") services = services + ['mysql'] elif self.app.pargs.postfix: + self.app.log.debug("postfix service restart") services = services + ['postfix'] elif self.app.pargs.memcache: + self.app.log.debug("memcached service restart") services = services + ['memcached'] elif self.app.pargs.dovecot: + self.app.log.debug("dovecot service restart") services = services + ['dovecot'] else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: + self.app.log.debug("nginx,php5-fpm,mysql,postfix services restart") EEService.restart_service(self, service) @expose(help="get stack status") def status(self): services = [] if self.app.pargs.nginx: + self.app.log.debug("nginx service status") services = services + ['nginx'] elif self.app.pargs.php: + self.app.log.debug("php5-fpm service status") services = services + ['php5-fpm'] elif self.app.pargs.mysql: + self.app.log.debug("mysql service status") services = services + ['mysql'] elif self.app.pargs.postfix: services = services + ['postfix'] + self.app.log.debug("postfix service status") elif self.app.pargs.memcache: + self.app.log.debug("memcached service status") services = services + ['memcached'] elif self.app.pargs.dovecot: + self.app.log.debug("dovecot service status") services = services + ['dovecot'] else: + self.app.log.debug("nginx,php5-fpm,mysql,postfix services status") services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: if EEService.get_service_status(self, service): diff --git a/ee/core/aptget.py b/ee/core/aptget.py index efa35f41..72bd7f18 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -13,6 +13,7 @@ class EEAptGet: def update(self): """Similar to apt-get update""" + self.app.log.debug("Update cache") self.cache.update(self.fprogress) self.cache.open() @@ -201,16 +202,19 @@ class EEAptGet: # Check if packages available for remove/update. if self.cache.delete_count > 0: + self.app.log.debug('packages will be REMOVED ') print("The following packages will be REMOVED:" "\n {pkg_name}" .format(pkg_name=my_selected_packages)) print("{pkg_remove_count} to remove." .format(pkg_remove_count=self.cache.delete_count)) + self.app.log.debug('bytes disk space will be freed') print("After this operation, {space} bytes disk spac" "e will be freed.".format(space=self.cache.required_space)) try: self.cache.commit(self.fprogress, self.iprogress) except Exception as e: + self.app.log.error('Sorry, package installation failed ') print("Sorry, package installation failed [{err}]" .format(err=str(e))) return(False) diff --git a/ee/core/download.py b/ee/core/download.py index ff6291da..2ab6375b 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -9,7 +9,7 @@ class EEDownload(): def __init__(): pass - def download(packages): + def download(self, packages): for package in packages: url = package[0] filename = package[1] @@ -17,18 +17,25 @@ class EEDownload(): directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) - print("Downloading "+os.path.basename(url)+" ...") + self.app.log.info("Downloading "+os.path.basename(url)+" ...") urllib.request.urlretrieve(url, filename) - print("Done") + self.app.log.info("Done") except urllib.error.URLError as e: - print("Unable to donwload file, [{err}]" - .format(err=str(e.reason))) + self.app.log.error("Error is :" + + os.path.basename(url)+e.reason()) + self.app.log.info("Unable to donwload file, [{err}]" + .format(err=str(e.reason))) return False except urllib.error.HTTPError as e: - print("Package download failed. [{err}]" - .format(err=str(e.reason))) + self.app.log.error("Package download failed", e.reason()) + self.app.log.info("Package download failed. [{err}]" + .format(err=str(e.reason))) return False except urllib.error.ContentTooShortError as e: - print("Package download failed. The amount of the" - "downloaded data is less than the expected amount") + self.app.log.error("Package download failed. The amount of the" + " downloaded data is less than " + "the expected amount"+e.reason()) + self.app.log.info("Package download failed. The amount of the" + "downloaded data is less than" + " the expected amount") return False diff --git a/ee/core/extract.py b/ee/core/extract.py index 48fbc138..ab5d9169 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -6,7 +6,7 @@ import os class EEExtract(): """Method to extract from tar.gz file""" - def extract(file, path): + def extract(self, file, path): try: tar = tarfile.open(file) tar.extractall(path=path) @@ -14,5 +14,6 @@ class EEExtract(): os.remove(file) return True except tarfile.TarError as e: - print("Unable to extract file "+file) + self.app.log.error('Unable to extract file', e.reason()) + self.app.log.info("Unable to extract file "+file) return False diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 4853d01b..9b32c417 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -8,18 +8,23 @@ class EEFileUtils(): def __init__(): pass - def remove(filelist): + def remove(self, filelist): for file in filelist: if os.path.isfile(file): - print("Removing "+os.path.basename(file)+" ...") + self.app.log.debug('Removing file') + self.app.log.info("Removing "+os.path.basename(file)+" ...") os.remove(file) - print("Done") + self.app.log.debug('file Removed') + self.app.log.info("Done") if os.path.isdir(file): try: + self.app.log.debug('Removing file') print("Removing "+os.path.basename(file)+" ...") shutil.rmtree(file) - print("Done") + self.app.log.info("Done") except shutil.Error as e: - print("Unable to remove file, [{err}]" - .format(err=str(e.reason))) + self.app.log.error('Unable to Remove file' + + os.path.basename(file)+e.reason()) + self.app.log.info("Unable to remove file, [{err}]" + .format(err=str(e.reason))) return False diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 59e6c802..19381f4b 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -7,7 +7,7 @@ from os.path import expanduser class EEMysql(): """Method for MySQL connection""" - def execute(statement): + def execute(self, statement): config = configparser.RawConfigParser() cnfpath = expanduser("~")+"/.my.cnf" if [cnfpath] == config.read(cnfpath): @@ -28,13 +28,15 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() except Exception as e: - print("Unable to connect to database") + self.app.log.error('Unable to connect to database', e.reason()) + self.app.log.info("Unable to connect to database") return False try: cur.execute(statement) except Exception as e: - print("Error occured while executing "+statement) + self.app.log.error('Error occured while executing', e.reason()) + self.app.log.info("Error occured while executing "+statement) cur.close() conn.close() return False diff --git a/ee/core/services.py b/ee/core/services.py index 99638476..e6b8de58 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -16,7 +16,7 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} start' .format(service_name)) if retcode[0] == 0: - print("Started : {0}".format(service_name)) + self.app.log.info("Started : {0}".format(service_name)) else: self.app.log.error(retcode[1]) except OSError as e: @@ -28,7 +28,7 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} stop' .format(service_name)) if retcode[0] == 0: - print("Stopped : {0}".format(service_name)) + self.app.log.info("Stopped : {0}".format(service_name)) return True else: return False diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 301ae4c1..1b9f6e98 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -10,14 +10,14 @@ class EEShellExec(): def __init__(): pass - def cmd_exec(command): + def cmd_exec(self, command): try: retcode = subprocess.getstatusoutput(command) if retcode[0] == 0: return True else: - print(retcode[1]) + self.app.log.info(retcode[1]) return False except OSError as e: - print(e) + self.app.log.info(e) return False diff --git a/ee/core/variables.py b/ee/core/variables.py index f6fe0d05..1cbd96c6 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -25,6 +25,7 @@ class EEVariables(): ee_user = config['user']['name'] ee_email = config['user']['email'] except KeyError as e: + self.app.log.error('Unable to find GIT user name and Email', e) print("Unable to find GIT user name and Email") sys.exit(1) From 33698d594983b33fc8e69f6e1bd10d1f6b5e7240 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 30 Dec 2014 18:50:43 +0530 Subject: [PATCH 575/829] Fixed Nginx missing config, started work on ee debug --- config/plugins.d/debug.conf | 8 +++ ee/cli/bootstrap.py | 2 - ee/cli/controllers/debug.py | 45 ---------------- ee/cli/plugins/debug.py | 48 +++++++++++++++++ ee/cli/plugins/stack.py | 84 +++++++++++++++++++++++++++++ ee/cli/templates/acl.mustache | 8 +++ ee/cli/templates/blockips.mustache | 2 + ee/cli/templates/fastcgi.mustache | 9 ++++ ee/cli/templates/locations.mustache | 65 ++++++++++++++++++++++ ee/cli/templates/php.mustache | 10 ++++ ee/cli/templates/upstream.mustache | 9 ++++ ee/cli/templates/w3tc.mustache | 31 +++++++++++ ee/cli/templates/wpcommon.mustache | 35 ++++++++++++ ee/cli/templates/wpfc.mustache | 36 +++++++++++++ ee/cli/templates/wpsc.mustache | 31 +++++++++++ ee/cli/templates/wpsubdir.mustache | 10 ++++ 16 files changed, 386 insertions(+), 47 deletions(-) create mode 100644 config/plugins.d/debug.conf delete mode 100644 ee/cli/controllers/debug.py create mode 100644 ee/cli/plugins/debug.py create mode 100644 ee/cli/templates/acl.mustache create mode 100644 ee/cli/templates/blockips.mustache create mode 100644 ee/cli/templates/fastcgi.mustache create mode 100644 ee/cli/templates/locations.mustache create mode 100644 ee/cli/templates/php.mustache create mode 100644 ee/cli/templates/upstream.mustache create mode 100644 ee/cli/templates/w3tc.mustache create mode 100644 ee/cli/templates/wpcommon.mustache create mode 100644 ee/cli/templates/wpfc.mustache create mode 100644 ee/cli/templates/wpsc.mustache create mode 100644 ee/cli/templates/wpsubdir.mustache diff --git a/config/plugins.d/debug.conf b/config/plugins.d/debug.conf new file mode 100644 index 00000000..9ccdf106 --- /dev/null +++ b/config/plugins.d/debug.conf @@ -0,0 +1,8 @@ +### Example Plugin Configuration for EasyEngine + +[debug] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index b22b6ca3..07250f46 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -5,7 +5,6 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController -from ee.cli.controllers.debug import EEDebugController from ee.cli.controllers.clean import EECleanController from ee.cli.controllers.secure import EESecureController from ee.cli.controllers.isl import EEImportslowlogController @@ -14,7 +13,6 @@ from ee.cli.controllers.info import EEInfoController def load(app): handler.register(EEBaseController) - handler.register(EEDebugController) handler.register(EECleanController) handler.register(EEInfoController) handler.register(EEImportslowlogController) diff --git a/ee/cli/controllers/debug.py b/ee/cli/controllers/debug.py deleted file mode 100644 index 1347c420..00000000 --- a/ee/cli/controllers/debug.py +++ /dev/null @@ -1,45 +0,0 @@ -"""EasyEngine site controller.""" - -from cement.core.controller import CementBaseController, expose - - -class EEDebugController(CementBaseController): - class Meta: - label = 'debug' - stacked_on = 'base' - stacked_type = 'nested' - description = 'debug command used for debugging issued with stack or \ - site specific configuration' - arguments = [ - (['--fpm'], - dict(help='debug fpm', action='store_true')), - (['--mysql'], - dict(help='debug mysql', action='store_true')), - (['--nginx'], - dict(help='debug nginx', action='store_true')), - (['--php'], - dict(help='debug php', action='store_true')), - (['--rewrite'], - dict(help='debug rewrite', action='store_true')), - (['--stop'], - dict(help='stop debugging', action='store_true')), - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee debug command - print("Inside EEDebugController.default().") - - # debug command Options and subcommand calls and definations to - # mention here - - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. - # diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py new file mode 100644 index 00000000..bcdaf710 --- /dev/null +++ b/ee/cli/plugins/debug.py @@ -0,0 +1,48 @@ +"""Debug Plugin for EasyEngine.""" + +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook + + +def debug_plugin_hook(app): + # do something with the ``app`` object here. + pass + + +class EEDebugController(CementBaseController): + class Meta: + label = 'debug' + description = 'debug command enables/disbaled stack debug' + stacked_on = 'base' + stacked_type = 'nested' + arguments = [ + (['--stop'], + dict(help='Install web stack', action='store_true')), + (['--start'], + dict(help='Install admin tools stack', action='store_true')), + (['--nginx'], + dict(help='Install mail server stack', action='store_true')), + (['--php'], + dict(help='Install Nginx stack', action='store_true')), + (['--fpm'], + dict(help='Install PHP stack', action='store_true')), + (['--mysql'], + dict(help='Install MySQL stack', action='store_true')), + (['--wp'], + dict(help='Install Postfix stack', action='store_true')), + (['--rewrite'], + dict(help='Install WPCLI stack', action='store_true')), + (['-i', '--interactive'], + dict(help='Install WPCLI stack', action='store_true')), + ] + + @expose(hide=True) + def default(self): + print("Inside Debug") + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EEDebugController) + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', debug_plugin_hook) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 01c00bcb..f7a065df 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -165,6 +165,88 @@ class EEStackController(CementBaseController): self.app.render((data), 'nginx-core.mustache', out=ee_nginx) ee_nginx.close() + data = dict() + self.app.log.debug('writting the nginx configration to file' + '/etc/nginx/conf.d/blockips.conf ') + ee_nginx = open('/etc/nginx/conf.d/blockips.conf', 'w') + self.app.render((data), 'blockips.mustache', out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('writting the nginx configration to file' + '/etc/nginx/conf.d/fastcgi.conf ') + ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf', 'w') + self.app.render((data), 'fastcgi.mustache', out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('writting the nginx configration to file' + '/etc/nginx/conf.d/upstream.conf ') + ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') + self.app.render((data), 'upstream.mustache', out=ee_nginx) + ee_nginx.close() + + # Setup Nginx common directory + if not os.path.exists('/etc/nginx/common'): + self.app.log.debug('Creating directory' + '/etc/nginx/common') + os.makedirs('/etc/nginx/common') + + data = dict() + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/acl.conf') + ee_nginx = open('/etc/nginx/common/acl.conf', 'w') + self.app.render((data), 'acl.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/locations.conf') + ee_nginx = open('/etc/nginx/common/locations.conf', 'w') + self.app.render((data), 'locations.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/ php.conf') + ee_nginx = open('/etc/nginx/common/php.conf', 'w') + self.app.render((data), 'php.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/w3tc.conf') + ee_nginx = open('/etc/nginx/common/w3tc.conf', 'w') + self.app.render((data), 'w3tc.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/wpcommon.conf') + ee_nginx = open('/etc/nginx/common/wpcommon.conf', 'w') + self.app.render((data), 'wpcommon.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/wpfc.conf') + ee_nginx = open('/etc/nginx/common/wpfc.conf', 'w') + self.app.render((data), 'wpfc.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/wpsc.conf') + ee_nginx = open('/etc/nginx/common/wpsc.conf', 'w') + self.app.render((data), 'wpsc.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/wpsubdir.conf') + ee_nginx = open('/etc/nginx/common/wpsubdir.conf', 'w') + self.app.render((data), 'wpsubdir.mustache', + out=ee_nginx) + ee_nginx.close() + if set(EEVariables.ee_php).issubset(set(apt_packages)): # Parse etc/php5/fpm/php.ini config = configparser.ConfigParser() @@ -695,6 +777,8 @@ class EEStackController(CementBaseController): self.app.log.debug("Calling pre_pref ") self.pre_pref(apt_packages) if len(apt_packages): + self.app.log.debug("Updating apt-cache") + pkg.update() self.app.log.debug("Installing all apt_packages") pkg.install(apt_packages) if len(packages): diff --git a/ee/cli/templates/acl.mustache b/ee/cli/templates/acl.mustache new file mode 100644 index 00000000..122675f9 --- /dev/null +++ b/ee/cli/templates/acl.mustache @@ -0,0 +1,8 @@ +# EasyEngine (ee) protect locations using +# HTTP authentication || IP address +satisfy any; +auth_basic "Restricted Area"; +auth_basic_user_file htpasswd-ee; +# Allowed IP Address List +allow 127.0.0.1; +deny all; diff --git a/ee/cli/templates/blockips.mustache b/ee/cli/templates/blockips.mustache new file mode 100644 index 00000000..8228bedb --- /dev/null +++ b/ee/cli/templates/blockips.mustache @@ -0,0 +1,2 @@ +# Block IP Address +# deny 1.1.1.1; diff --git a/ee/cli/templates/fastcgi.mustache b/ee/cli/templates/fastcgi.mustache new file mode 100644 index 00000000..37f06e0f --- /dev/null +++ b/ee/cli/templates/fastcgi.mustache @@ -0,0 +1,9 @@ +# FastCGI cache settings +fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:50m inactive=60m; +fastcgi_cache_key "$scheme$request_method$host$request_uri"; +fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503; +fastcgi_cache_valid any 1h; +fastcgi_buffers 16 16k; +fastcgi_buffer_size 32k; +fastcgi_param SERVER_NAME $http_host; +fastcgi_ignore_headers Cache-Control Expires Set-Cookie; diff --git a/ee/cli/templates/locations.mustache b/ee/cli/templates/locations.mustache new file mode 100644 index 00000000..c8414fb2 --- /dev/null +++ b/ee/cli/templates/locations.mustache @@ -0,0 +1,65 @@ +# NGINX CONFIGURATION FOR COMMON LOCATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +# Basic locations files +location = /favicon.ico { + access_log off; + log_not_found off; + expires max; +} +location = /robots.txt { + # Some WordPress plugin gererate robots.txt file + # Refer #340 issue + try_files $uri $uri/ /index.php?$args; + access_log off; + log_not_found off; +} +# Cache static files +location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ { + add_header "Access-Control-Allow-Origin" "*"; + access_log off; + log_not_found off; + expires max; +} +# Security settings for better privacy +# Deny hidden files +location ~ /\. { + deny all; + access_log off; + log_not_found off; +} +# Deny backup extensions & log files +location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp|sql)$ { + deny all; + access_log off; + log_not_found off; +} +# Return 403 forbidden for readme.(txt|html) or license.(txt|html) +if ($request_uri ~* "^.+(readme|license)\.(txt|html)$") { + return 403; +} +# Status pages +location /nginx_status { + stub_status on; + access_log off; + include common/acl.conf; +} +location ~ ^/(status|ping) { + include fastcgi_params; + fastcgi_pass php; + include common/acl.conf; +} +# EasyEngine (ee) utilities +# phpMyAdmin settings +location /pma { + return 301 https://$host:22222/db/pma; +} +location /phpMyAdmin { + return 301 https://$host:22222/db/pma; +} +location /phpmyadmin { + return 301 https://$host:22222/db/pma; +} +# Adminer settings +location /adminer { + return 301 https://$host:22222/db/adminer; +} diff --git a/ee/cli/templates/php.mustache b/ee/cli/templates/php.mustache new file mode 100644 index 00000000..3546f571 --- /dev/null +++ b/ee/cli/templates/php.mustache @@ -0,0 +1,10 @@ +# PHP NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +location / { + try_files $uri $uri/ /index.php?$args; +} +location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass php; +} diff --git a/ee/cli/templates/upstream.mustache b/ee/cli/templates/upstream.mustache new file mode 100644 index 00000000..d147724e --- /dev/null +++ b/ee/cli/templates/upstream.mustache @@ -0,0 +1,9 @@ +# Common upstream settings +upstream php { +# server unix:/run/php5-fpm.sock; +server 127.0.0.1:9000; +} +upstream debug { +# Debug Pool +server 127.0.0.1:9001; +} diff --git a/ee/cli/templates/w3tc.mustache b/ee/cli/templates/w3tc.mustache new file mode 100644 index 00000000..5b162822 --- /dev/null +++ b/ee/cli/templates/w3tc.mustache @@ -0,0 +1,31 @@ + +# W3TC NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +set $cache_uri $request_uri; +# POST requests and URL with a query string should always go to php +if ($request_method = POST) { + set $cache_uri 'null cache'; +} +if ($query_string != "") { + set $cache_uri 'null cache'; +} +# Don't cache URL containing the following segments +if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { + set $cache_uri 'null cache'; +} +# Don't use the cache for logged in users or recent commenter +if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { + set $cache_uri 'null cache'; +} +# Use cached or actual file if they exists, Otherwise pass request to WordPress +location / { + try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args; +} +location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ { + try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1; +} +location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass php; +} diff --git a/ee/cli/templates/wpcommon.mustache b/ee/cli/templates/wpcommon.mustache new file mode 100644 index 00000000..e6b34782 --- /dev/null +++ b/ee/cli/templates/wpcommon.mustache @@ -0,0 +1,35 @@ +# WordPress COMMON SETTINGS +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +# Limit access to avoid brute force attack +location = /wp-login.php { + limit_req zone=one burst=1 nodelay; + include fastcgi_params; + fastcgi_pass php; +} +# Disable wp-config.txt +location = /wp-config.txt { + deny all; + access_log off; + log_not_found off; +} +# Disallow php in upload folder +location /wp-content/uploads/ { + location ~ \.php$ { + #Prevent Direct Access Of PHP Files From Web Browsers + deny all; + } +} +# Yoast sitemap +location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ { + rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent; + rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last; + # Rules for yoast sitemap with wp|wpsubdir|wpsubdomain + rewrite ^.*/sitemap_index\.xml$ /index.php?sitemap=1 last; + rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; + # Following lines are options. Needed for WordPress seo addons + rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last; + rewrite ^/locations\.kml$ /index.php?sitemap=wpseo_local_kml last; + rewrite ^/geo_sitemap\.xml$ /index.php?sitemap=wpseo_local last; + rewrite ^/video-sitemap\.xsl$ /index.php?xsl=video last; + access_log off; +} diff --git a/ee/cli/templates/wpfc.mustache b/ee/cli/templates/wpfc.mustache new file mode 100644 index 00000000..ff5240c7 --- /dev/null +++ b/ee/cli/templates/wpfc.mustache @@ -0,0 +1,36 @@ +# WPFC NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +set $skip_cache 0; +# POST requests and URL with a query string should always go to php +if ($request_method = POST) { + set $skip_cache 1; +} +if ($query_string != "") { + set $skip_cache 1; +} +# Don't cache URL containing the following segments +if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { + set $skip_cache 1; +} +# Don't use the cache for logged in users or recent commenter +if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { + set $skip_cache 1; +} +# Use cached or actual file if they exists, Otherwise pass request to WordPress +location / { + try_files $uri $uri/ /index.php?$args; +} +location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ { + try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1; +} +location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass php; + fastcgi_cache_bypass $skip_cache; + fastcgi_no_cache $skip_cache; + fastcgi_cache WORDPRESS; +} +location ~ /purge(/.*) { + fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; +} diff --git a/ee/cli/templates/wpsc.mustache b/ee/cli/templates/wpsc.mustache new file mode 100644 index 00000000..2600a795 --- /dev/null +++ b/ee/cli/templates/wpsc.mustache @@ -0,0 +1,31 @@ +# WPSC NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +set $cache_uri $request_uri; +# POST requests and URL with a query string should always go to php +if ($request_method = POST) { + set $cache_uri 'null cache'; +} +if ($query_string != "") { + set $cache_uri 'null cache'; +} +# Don't cache URL containing the following segments +if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { + set $cache_uri 'null cache'; +} +# Don't use the cache for logged in users or recent commenter +if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { + set $cache_uri 'null cache'; +} +# Use cached or actual file if they exists, Otherwise pass request to WordPress +location / { + # If we add index.php?$args its break WooCommerce like plugins + # Ref: #330 + try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php; +} +location ~ \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_pass php; + # Following line is needed by WP Super Cache plugin + fastcgi_param SERVER_NAME $http_host; +} diff --git a/ee/cli/templates/wpsubdir.mustache b/ee/cli/templates/wpsubdir.mustache new file mode 100644 index 00000000..7b65841f --- /dev/null +++ b/ee/cli/templates/wpsubdir.mustache @@ -0,0 +1,10 @@ +# WPSUBDIRECTORY NGINX CONFIGURATION +# DO NOT MODIFY, ALL CHNAGES LOST AFTER UPDATE EasyEngine (ee) +if (!-e $request_filename) { + # Redirect wp-admin to wp-admin/ + rewrite /wp-admin$ $scheme://$host$uri/ permanent; + # Redirect wp-* files/folders + rewrite ^(/[^/]+)?(/wp-.*) $2 last; + # Redirect other php files + rewrite ^(/[^/]+)?(/.*\.php) $2 last; +} From 5982ea7e76413b07cc41e959798aa6c1bc38781c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 30 Dec 2014 19:38:45 +0530 Subject: [PATCH 576/829] ee domain setup module --- config/ee.conf | 22 ++++++++++ ee/cli/plugins/site.py | 62 ++++++++++++--------------- ee/cli/plugins/site_functions.py | 53 +++++++++++++++++++++++ ee/cli/templates/virtualconf.mustache | 2 +- ee/core/fileutils.py | 10 ++++- ee/core/variables.py | 2 + 6 files changed, 115 insertions(+), 36 deletions(-) create mode 100644 ee/cli/plugins/site_functions.py diff --git a/config/ee.conf b/config/ee.conf index 02078253..dddf28f1 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -37,3 +37,25 @@ ### The maximun number of log files to maintain when rotating # max_files = 4 + +[stack] + + # ip-address = + +[mysql] + +grant-host = localhost + +db-name = false + +db-user = false + +[wordpress] + +prefix = false + +user = + +password = + +email = diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 86726405..fd9d5bab 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -1,9 +1,12 @@ """EasyEngine site controller.""" from cement.core.controller import CementBaseController, expose from cement.core import handler, hook +from ee.core.variables import EEVariables from ee.core.domainvalidate import validate_domain from ee.core.fileutils import EEFileUtils +from ee.cli.plugins.site_functions import setup_domain import sys +import os def ee_site_hook(app): @@ -111,6 +114,14 @@ class EESiteCreateController(CementBaseController): # self.app.render((data), 'default.mustache') # Check domain name validation ee_domain_name = validate_domain(self.app.pargs.site_name) + ee_site_webroot = EEVariables.ee_webroot + ee_domain_name + + # Check if doain previously exists or not + if os.path.isfile('/etc/nginx/sites-available/{0}.conf' + .format(ee_domain_name)): + self.app.log.error("site {0} already exists" + .format(ee_domain_name)) + return False # setup nginx configuration for site if (self.app.pargs.html and not (self.app.pargs.php or @@ -120,7 +131,7 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=True, basic=False, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.php and not (self.app.pargs.html or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc @@ -129,7 +140,7 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.mysql and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc @@ -138,7 +149,7 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc) and not (self.app.pargs.html or @@ -149,25 +160,25 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=False, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=False, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.wpsubdir and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or @@ -177,25 +188,25 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=True, - wpsubdir=True) + wpsubdir=True, webroot=ee_site_webroot) if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, - wpsubdir=True) + wpsubdir=True, webroot=ee_site_webroot) if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, - wpsubdir=True) + wpsubdir=True, webroot=ee_site_webroot) if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, - wpsubdir=True) + wpsubdir=True, webroot=ee_site_webroot) if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or @@ -205,44 +216,27 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=True, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, - wpsubdir=False) + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, - wpsubdir=False) - - try: - ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}.conf' - .format(ee_domain_name), 'w') - - self.app.render((data), 'virtualconf.mustache', - out=ee_site_nginx_conf) - ee_site_nginx_conf.close() - except IOError as e: - print("Unable to create nginx conf for {2} ({0}): {1}" - .format(e.errno, e.strerror)) - except Exception as e: - print("{0}".format(e)) - - # create symbolic link - EEFileUtils.create_symlink(['/etc/nginx/sites-available/{0}.conf' - .format(ee_domain_name), - '/etc/nginx/sites-enabled/{0}.conf' - .format(ee_domain_name)]) + wpsubdir=False, webroot=ee_site_webroot) + + setup_domain(self, data) class EESiteUpdateController(CementBaseController): diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py new file mode 100644 index 00000000..11a12a28 --- /dev/null +++ b/ee/cli/plugins/site_functions.py @@ -0,0 +1,53 @@ +import os +from ee.core.fileutils import EEFileUtils + + +def setup_domain(self, data): + + ee_domain_name = data['site_name'] + ee_site_webroot = data['webroot'] + print("Creating {0}, please wait...".format(ee_domain_name)) + # write nginx config for file + try: + ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}.conf' + .format(ee_domain_name), 'w') + + self.app.render((data), 'virtualconf.mustache', + out=ee_site_nginx_conf) + ee_site_nginx_conf.close() + except IOError as e: + print("Unable to create nginx conf for {2} ({0}): {1}" + .format(e.errno, e.strerror)) + except Exception as e: + print("{0}".format(e)) + + # create symbolic link for + EEFileUtils.create_symlink(['/etc/nginx/sites-available/{0}.conf' + .format(ee_domain_name), + '/etc/nginx/sites-enabled/{0}.conf' + .format(ee_domain_name)]) + + # Creating htdocs & logs directory + try: + if not os.path.exists('{0}/htdocs'.format(ee_site_webroot)): + os.makedirs('{0}/htdocs'.format(ee_site_webroot)) + if not os.path.exists('{0}/logs'.format(ee_site_webroot)): + os.makedirs('{0}/logs'.format(ee_site_webroot)) + except Exception as e: + print("{0}".format(e)) + + EEFileUtils.create_symlink(['/var/log/nginx/{0}.access.log' + .format(ee_domain_name), + '{0}/logs/access.log' + .format(ee_site_webroot)]) + EEFileUtils.create_symlink(['/var/log/nginx/{0}.error.log' + .format(ee_domain_name), + '{0}/logs/error.log' + .format(ee_site_webroot)]) + + +def setup_database(self, data): + ee_domain_name = data['site_name'] + ee_random = (''.join(random.sample(string.ascii_uppercase + + string.ascii_lowercase + string.digits, 64))) + ee_replace_dot = ee_domain_name.replace('.', '_') diff --git a/ee/cli/templates/virtualconf.mustache b/ee/cli/templates/virtualconf.mustache index fb7e92d3..3f6790fc 100644 --- a/ee/cli/templates/virtualconf.mustache +++ b/ee/cli/templates/virtualconf.mustache @@ -15,7 +15,7 @@ server { access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}}; error_log /var/log/nginx/{{site_name}}.error.log; - root /var/www/{{site_name}}/htdocs; + root {{webroot}}/htdocs; index {{^static}}index.php{{/static}} index.html index.htm; diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 4bd6a9de..5d142995 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -31,4 +31,12 @@ class EEFileUtils(): try: os.symlink(src, dst) except Exception as e: - print("Unable to create sybolic link for {0}".format(e)) + print("Unable to create symbolic link ...\n {0} " + .format(e.reason)) + + def remove_symlink(filepath): + try: + os.unlink(path) + except Exception as e: + print("Unable to reomove symbolic link ...\n {0} " + .format(e.reason)) diff --git a/ee/core/variables.py b/ee/core/variables.py index f6fe0d05..043e69f9 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -20,6 +20,8 @@ class EEVariables(): # Get FQDN of system ee_fqdn = socket.getfqdn() + ee_webroot = '/var/www/' + # Get git user name and EMail try: ee_user = config['user']['name'] From 920c957bb5554c441868656ed2bef9f02b00ac3c Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 31 Dec 2014 11:16:12 +0530 Subject: [PATCH 577/829] update --- ee/cli/plugins/stack.py | 98 ++++++++++++++++++++++------------------- ee/core/variables.py | 1 - 2 files changed, 53 insertions(+), 46 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c3f9f92c..dcfd85e4 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -259,47 +259,50 @@ class EEStackController(CementBaseController): "smtpd_sasl_auth_enable = " "yes\"") EEShellExec.cmd_exec(self, "postconf -e \"" - "smtpd_relay_restrictions =" - "permit_sasl_authenticated, " - "permit_mynetworks, " - "reject_unauth_destination\"") - "protocols = !SSLv2,!SSLv3\"") + " smtpd_relay_restrictions =" + " permit_sasl_authenticated, " + " permit_mynetworks, " + " reject_unauth_destination\"" + " protocols = !SSLv2,!SSLv3\"") EEShellExec.cmd_exec(self, "postconf -e \"" "smtpd_tls_mandatory_") EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls_mandatory_" - "protocols = !SSLv2,!SSLv3\"") - EEShellExec.cmd_exec("postconf -e \"smtpd_tls_protocols " + " protocols = !SSLv2,!SSLv3\"") + EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_protocols " + " = !SSLv2,!SSLv3\"") + EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls_protocols " "= !SSLv2,!SSLv3\"") - EEShellExec.cmd_exec("postconf -e \"smtp_tls_protocols " - "= !SSLv2,!SSLv3\"") - EEShellExec.cmd_exec("postconf -e \"mydestination " + EEShellExec.cmd_exec(self, "postconf -e \"mydestination " "= localhost\"") - EEShellExec.cmd_exec("postconf -e \"virtual_transport " + EEShellExec.cmd_exec(self, "postconf -e \"virtual_transport " "= lmtp:unix:private/dovecot-lmtp\"") - EEShellExec.cmd_exec("postconf -e \"virtual_uid_maps " + EEShellExec.cmd_exec(self, "postconf -e \"virtual_uid_maps " "= static:5000\"") - EEShellExec.cmd_exec("postconf -e \"virtual_gid_maps " + EEShellExec.cmd_exec(self, "postconf -e \"virtual_gid_maps " "= static:5000\"") - EEShellExec.cmd_exec("postconf -e \"virtual_mailbox_domains = " - "mysql:/etc/postfix/mysql/virtual_" - "domains_maps.cf\"") - EEShellExec.cmd_exec("postconf -e \"virtual_mailbox_maps = " - "mysql:/etc/postfix/mysql/virtual_" + EEShellExec.cmd_exec(self, "postconf -e \"" + " virtual_mailbox_domains = " + " mysql:/etc/postfix/mysql/virtual_" + " domains_maps.cf\"") + EEShellExec.cmd_exec(self, "postconf -e \"virtual_mailbox_maps" + " = mysql:/etc/postfix/mysql/virtual_" "mailbox_maps.cf\"") - EEShellExec.cmd_exec("postconf -e \"virtual_alias_maps = " - "mysql:/etc/postfix/mysql/virtual_" - "alias_maps.cf\"") - EEShellExec.cmd_exec("openssl req -new -x509 -days 3650 -nodes" - " -subj /commonName={HOSTNAME}/emailAddre" + EEShellExec.cmd_exec(self, "postconf -e \"virtual_alias_maps " + "= mysql:/etc/postfix/mysql/virtual_" + " alias_maps.cf\"") + EEShellExec.cmd_exec(self, "openssl req -new -x509 -days " + " 3650 -nodes-subj /commonName={HOSTNAME}" + "/emailAddre" "ss={EMAIL} -out /etc/ssl/certs/postfix." "pem -keyout /etc/ssl/private/postfix.pem" .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) - EEShellExec.cmd_exec("chmod 0600 /etc/ssl/private/postfix.pem") - EEShellExec.cmd_exec("postconf -e \"smtpd_tls_cert_file = " - "/etc/ssl/certs/postfix.pem\"") - EEShellExec.cmd_exec("postconf -e \"smtpd_tls_key_file = " - "/etc/ssl/private/postfix.pem\"") + EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private" + "/postfix.pem") + EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_cert_file " + "= /etc/ssl/certs/postfix.pem\"") + EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_key_file " + " = /etc/ssl/private/postfix.pem\"") # Sieve configuration if not os.path.exists('/var/lib/dovecot/sieve/'): @@ -318,8 +321,9 @@ class EEStackController(CementBaseController): # Compile sieve rules self.app.log.debug("Privillages to dovecot ") - EEShellExec.cmd_exec("chown -R vmail:vmail /var/lib/dovecot") - EEShellExec.cmd_exec("sievec /var/lib/dovecot/sieve/" + EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" + "/dovecot") + EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/" "default.sieve") if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): @@ -334,31 +338,32 @@ class EEStackController(CementBaseController): ee_amavis.close() # Amavis postfix configuration - EEShellExec.cmd_exec("postconf -e \"content_filter = " + EEShellExec.cmd_exec(self, "postconf -e \"content_filter = " "smtp-amavis:[127.0.0.1]:10024\"") - EEShellExec.cmd_exec("sed -i \"s/1 pickup/1 pickup" + EEShellExec.cmd_exec(self, "sed -i \"s/1 pickup/1 " + "pickup" "\n -o content_filter=\n -o" " receive_override_options=no_header_body" "_checks/\" /etc/postfix/master.cf") # Amavis ClamAV configuration self.app.log.debug("Adding new user clamav amavis") - EEShellExec.cmd_exec("adduser clamav amavis") + EEShellExec.cmd_exec(self, "adduser clamav amavis") self.app.log.debug("Adding new user amavis clamav") - EEShellExec.cmd_exec("adduser amavis clamav") + EEShellExec.cmd_exec(self, "adduser amavis clamav") self.app.log.debug("Privillages to file /var/lib/amavis/tmp ") - EEShellExec.cmd_exec("chmod -R 775 /var/lib/amavis/tmp") + EEShellExec.cmd_exec(self, "chmod -R 775 /var/lib/amavis/tmp") # Update ClamAV database self.app.log.debug("Updating database") - EEShellExec.cmd_exec("freshclam") + EEShellExec.cmd_exec(self, "freshclam") self.app.log.debug("Restarting service clamav-daemon") - EEShellExec.cmd_exec("service clamav-daemon restart") + EEShellExec.cmd_exec(self, "service clamav-daemon restart") if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): self.app.log.debug("Privillages to /usr/bin/wp ") - EEShellExec.cmd_exec("chmod +x /usr/bin/wp") + EEShellExec.cmd_exec(self, "chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] for x in packages): EEExtract.extract(self, '/tmp/pma.tar.gz', '/tmp/') @@ -372,7 +377,7 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/db/pma/') self.app.log.debug('Privillages to www-data:www-data ' '/var/www/22222/htdocs/db/pma ') - EEShellExec.cmd_exec('chown -R www-data:www-data ' + EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' '/var/www/22222/htdocs/db/pma') if any('/tmp/memcache.tar.gz' == x[1] for x in packages): @@ -382,7 +387,7 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/cache/memcache') self.app.log.debug("Privillages to" " /var/www/22222/htdocs/cache/memcache") - EEShellExec.cmd_exec('chown -R www-data:www-data ' + EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' '/var/www/22222/htdocs/cache/memcache') if any('/tmp/webgrind.tar.gz' == x[1] @@ -398,7 +403,7 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/php/webgrind') self.app.log.debug("Privillages www-data:www-data " "/var/www/22222/htdocs/php/webgrind/ ") - EEShellExec.cmd_exec('chown -R www-data:www-data ' + EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' '/var/www/22222/htdocs/php/webgrind/') if any('/tmp/anemometer.tar.gz' == x[1] @@ -412,7 +417,7 @@ class EEStackController(CementBaseController): shutil.move('/tmp/Anemometer-master', '/var/www/22222/htdocs/db/anemometer') chars = ''.join(random.sample(string.ascii_letters, 8)) - EEShellExec.cmd_exec('mysql < /var/www/22222/htdocs/db' + EEShellExec.cmd_exec(self, 'mysql < /var/www/22222/htdocs/db' '/anemometer/install.sql') EEMysql.execute(self, 'grant select on *.* to \'anemometer\'' '@\'localhost\'') @@ -432,7 +437,8 @@ class EEStackController(CementBaseController): if any('/usr/bin/pt-query-advisor' == x[1] for x in packages): - EEShellExec.cmd_exec("chmod +x /usr/bin/pt-query-advisor") + EEShellExec.cmd_exec(self, "chmod +x /usr/bin/pt-query" + "-advisor") if any('/tmp/vimbadmin.tar.gz' == x[1] for x in packages): # Extract ViMbAdmin @@ -449,11 +455,13 @@ class EEStackController(CementBaseController): # Donwload composer and install ViMbAdmin self.app.log.debug("Downloading composer " "https://getcomposer.org/installer | php ") - EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin; curl" + EEShellExec.cmd_exec(self, "cd /var/www/22222/htdocs" + "/vimbadmin; curl" " -sS https://getcomposer.org/installer |" " php") self.app.log.debug("installation of composer") - EEShellExec.cmd_exec("cd /var/www/22222/htdocs/vimbadmin && " + EEShellExec.cmd_exec(self, "cd /var/www/22222/htdocs" + "/vimbadmin && " "php composer.phar install --prefer-dist" " --no-dev && rm -f /var/www/22222/htdocs" "/vimbadmin/composer.phar") diff --git a/ee/core/variables.py b/ee/core/variables.py index 1cbd96c6..f6fe0d05 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -25,7 +25,6 @@ class EEVariables(): ee_user = config['user']['name'] ee_email = config['user']['email'] except KeyError as e: - self.app.log.error('Unable to find GIT user name and Email', e) print("Unable to find GIT user name and Email") sys.exit(1) From 12180287a20910a010ceed5cc84b76369af0a4cf Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 31 Dec 2014 11:29:38 +0530 Subject: [PATCH 578/829] fixed various typo --- ee/cli/plugins/stack.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 187c0040..120f7c87 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -72,7 +72,7 @@ class EEStackController(CementBaseController): def pre_pref(self, apt_packages): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): print("Pre-seeding postfix variables ... ") - EEShellExec.cmd_exec(self, "echo \"postfix postfix " + EEShellExec.cmd_exec(self, "echo \"postfix postfix" "/main_mailer_typestring 'Internet Site'\" | " "debconf-set-selections") EEShellExec.cmd_exec(self, "echo \"postfix postfix/mailname string" @@ -106,8 +106,7 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_nginx).issubset(set(apt_packages)): print("Adding repository for Nginx ... ") if EEVariables.ee_platform_distro == 'Debian': - s - elf.app.log.debug('Adding Dotdeb/nginx GPG key') + self.app.log.debug('Adding Dotdeb/nginx GPG key') EERepo.add(repo_url=EEVariables.ee_nginx_repo) else: self.app.log.debug('Adding ppa of Nginx') @@ -302,11 +301,11 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_mail).issubset(set(apt_packages)): self.app.log.debug("Executing mail commands") EEShellExec.cmd_exec(self, "adduser --uid 5000 --home /var" - "/vmail--disabled-password --gecos ''" + "/vmail --disabled-password --gecos ''" " vmail") EEShellExec.cmd_exec(self, "openssl req -new -x509 -days 3650 " "-nodes -subj /commonName={HOSTNAME}" - "/emailAddre ss={EMAIL} -out /etc/ssl" + " /emailAddress={EMAIL} -out /etc/ssl" "/certs/dovecot." "pem -keyout /etc/ssl/private/dovecot.pem" .format(HOSTNAME=EEVariables.ee_fqdn, @@ -344,12 +343,13 @@ class EEStackController(CementBaseController): " smtpd_relay_restrictions =" " permit_sasl_authenticated, " " permit_mynetworks, " - " reject_unauth_destination\"" - " protocols = !SSLv2,!SSLv3\"") + " reject_unauth_destination\"") + EEShellExec.cmd_exec(self, "postconf -e \"" - "smtpd_tls_mandatory_") + "smtpd_tls_mandatory_" + "protocols = !SSLv2,!SSLv3\"") EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls_mandatory_" - " protocols = !SSLv2,!SSLv3\"") + "protocols = !SSLv2,!SSLv3\"") EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_protocols " " = !SSLv2,!SSLv3\"") EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls_protocols " From 11f5b1e4602c79a73a622437b88aa1e250917e0d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 31 Dec 2014 11:57:56 +0530 Subject: [PATCH 579/829] Fixed various bugs --- ee/cli/plugins/debug.py | 18 +++++++++--------- ee/cli/plugins/stack.py | 16 ++++++++-------- ee/core/apt_repo.py | 12 +++++++----- ee/core/aptget.py | 8 ++++---- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index bcdaf710..23f26c24 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -17,23 +17,23 @@ class EEDebugController(CementBaseController): stacked_type = 'nested' arguments = [ (['--stop'], - dict(help='Install web stack', action='store_true')), + dict(help='Stop debug', action='store_true')), (['--start'], - dict(help='Install admin tools stack', action='store_true')), + dict(help='Start debug', action='store_true')), (['--nginx'], - dict(help='Install mail server stack', action='store_true')), + dict(help='Debug Nginx', action='store_true')), (['--php'], - dict(help='Install Nginx stack', action='store_true')), + dict(help='Debug PHP', action='store_true')), (['--fpm'], - dict(help='Install PHP stack', action='store_true')), + dict(help='Debug FastCGI', action='store_true')), (['--mysql'], - dict(help='Install MySQL stack', action='store_true')), + dict(help='Debug MySQL', action='store_true')), (['--wp'], - dict(help='Install Postfix stack', action='store_true')), + dict(help='Debug WordPress sites', action='store_true')), (['--rewrite'], - dict(help='Install WPCLI stack', action='store_true')), + dict(help='Debug Nginx rewrite rules', action='store_true')), (['-i', '--interactive'], - dict(help='Install WPCLI stack', action='store_true')), + dict(help='Interactive debug', action='store_true')), ] @expose(hide=True) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 120f7c87..15f33391 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -79,9 +79,9 @@ class EEStackController(CementBaseController): "$(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): print("Adding repository for MySQL ... ") - EERepo.add(repo_url=EEVariables.ee_mysql_repo) + EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) self.app.log.debug('Adding key of MySQL.') - EERepo.add_key('1C4CBDCDCD2EFD2A') + EERepo.add_key(self, '1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) print("Pre-seeding MySQL variables ... ") EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " @@ -107,26 +107,26 @@ class EEStackController(CementBaseController): print("Adding repository for Nginx ... ") if EEVariables.ee_platform_distro == 'Debian': self.app.log.debug('Adding Dotdeb/nginx GPG key') - EERepo.add(repo_url=EEVariables.ee_nginx_repo) + EERepo.add(self, repo_url=EEVariables.ee_nginx_repo) else: self.app.log.debug('Adding ppa of Nginx') - EERepo.add(ppa=EEVariables.ee_nginx_repo) + EERepo.add(self, ppa=EEVariables.ee_nginx_repo) if set(EEVariables.ee_php).issubset(set(apt_packages)): print("Adding repository for PHP ... ") if EEVariables.ee_platform_distro == 'Debian': self.app.log.debug('Adding repo_url of php for Debian') - EERepo.add(repo_url=EEVariables.ee_php_repo) + EERepo.add(self, repo_url=EEVariables.ee_php_repo) self.app.log.debug('Adding Dotdeb/php GPG key') - EERepo.add_key('89DF5277') + EERepo.add_key(self, '89DF5277') else: self.app.log.debug('Adding ppa for PHP') - EERepo.add(ppa=EEVariables.ee_php_repo) + EERepo.add(self, ppa=EEVariables.ee_php_repo) if set(EEVariables.ee_mail).issubset(set(apt_packages)): if EEVariables.ee_platform_codename == 'squeeze': print("Adding repository for dovecot ... ") - EERepo.add(repo_url=EEVariables.ee_dovecot_repo) + EERepo.add(self, repo_url=EEVariables.ee_dovecot_repo) self.app.log.debug('Executing the command debconf-set-selections.') EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/" "create-ssl-cert boolean yes\" " diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 0ed5c554..8ad22f34 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -10,7 +10,7 @@ class EERepo(): """Initialize """ pass - def add(repo_url=None, ppa=None): + def add(self, repo_url=None, ppa=None): # TODO add repository code if repo_url is not None: @@ -31,13 +31,15 @@ class EERepo(): print("Cannot add repo for {distro}" .format(distro=EEVariables.ee_platform_distro)) else: - EEShellExec.cmd_exec("add-apt-repository -y '{ppa_name}'" + EEShellExec.cmd_exec(self, "add-apt-repository -y " + "'{ppa_name}'" .format(ppa_name=ppa)) - def remove(repo_url=None): + def remove(self, repo_url=None): # TODO remove repository - EEShellExec.cmd_exec("add-apt-repository -y " - "--remove '{ppa_name}'".format(ppa_name=repo_url)) + EEShellExec.cmd_exec(self, "add-apt-repository -y " + "--remove '{ppa_name}'" + .format(ppa_name=repo_url)) pass def add_key(keyids, keyserver=None): diff --git a/ee/core/aptget.py b/ee/core/aptget.py index f7fc1776..645a40c8 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -13,7 +13,7 @@ class EEAptGet: def update(self): """Similar to apt-get update""" - self.app.log.debug("Update cache") + # self.app.log.debug("Update cache") self.cache.update(self.fprogress) self.cache.open() @@ -202,19 +202,19 @@ class EEAptGet: # Check if packages available for remove/update. if self.cache.delete_count > 0: - self.app.log.debug('packages will be REMOVED ') + # self.app.log.debug('packages will be REMOVED ') print("The following packages will be REMOVED:" "\n {pkg_name}" .format(pkg_name=my_selected_packages)) print("{pkg_remove_count} to remove." .format(pkg_remove_count=self.cache.delete_count)) - self.app.log.debug('bytes disk space will be freed') + # self.app.log.debug('bytes disk space will be freed') print("After this operation, {space} bytes disk spac" "e will be freed.".format(space=self.cache.required_space)) try: self.cache.commit(self.fprogress, self.iprogress) except Exception as e: - self.app.log.error('Sorry, package installation failed ') + # self.app.log.error('Sorry, package installation failed ') print("Sorry, package installation failed [{err}]" .format(err=str(e))) return(False) From 45ec223e3f2b7611d711ca6b4219bf14d99d71a2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 31 Dec 2014 12:04:28 +0530 Subject: [PATCH 580/829] Fixed travis --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 15f33391..d83a5073 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -305,7 +305,7 @@ class EEStackController(CementBaseController): " vmail") EEShellExec.cmd_exec(self, "openssl req -new -x509 -days 3650 " "-nodes -subj /commonName={HOSTNAME}" - " /emailAddress={EMAIL} -out /etc/ssl" + "/emailAddress={EMAIL} -out /etc/ssl" "/certs/dovecot." "pem -keyout /etc/ssl/private/dovecot.pem" .format(HOSTNAME=EEVariables.ee_fqdn, From d71f8495b42b3f85834e46af4ee08a6ef0cd3c7f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 31 Dec 2014 12:17:58 +0530 Subject: [PATCH 581/829] Fixed Travis --- ee/cli/plugins/stack.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index d83a5073..5a951733 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -373,10 +373,10 @@ class EEStackController(CementBaseController): "= mysql:/etc/postfix/mysql/virtual_" " alias_maps.cf\"") EEShellExec.cmd_exec(self, "openssl req -new -x509 -days " - " 3650 -nodes-subj /commonName={HOSTNAME}" - "/emailAddre" - "ss={EMAIL} -out /etc/ssl/certs/postfix." - "pem -keyout /etc/ssl/private/postfix.pem" + " 3650 -nodes -subj /commonName=" + "{HOSTNAME}/emailAddress={EMAIL}" + " -out /etc/ssl/certs/postfix.pem" + " -keyout /etc/ssl/private/postfix.pem" .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private" From ebc087344b2b093dac167dacc79bf64ce4c113ba Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 31 Dec 2014 12:36:23 +0530 Subject: [PATCH 582/829] Fixed purging not working --- ee/cli/plugins/debug.py | 18 +++++++++++++++++- ee/cli/plugins/stack.py | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 23f26c24..4ac9725a 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -38,7 +38,23 @@ class EEDebugController(CementBaseController): @expose(hide=True) def default(self): - print("Inside Debug") + self.start = True + if self.app.pargs.stop: + self.start = False + if self.app.pargs.nginx: + pass + if self.app.pargs.php: + pass + if self.app.pargs.fpm: + pass + if self.app.pargs.mysql: + pass + if self.app.pargs.wp: + pass + if self.app.pargs.rewrite: + pass + if self.app.pargs.interactive: + pass def load(app): diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 5a951733..7e0f5d63 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -910,7 +910,7 @@ class EEStackController(CementBaseController): ] if len(apt_packages): - pkg.remove(self, apt_packages, purge=True) + pkg.remove(apt_packages, purge=True) if len(packages): EEFileUtils.remove(self, packages) From 5943b38a4052c94a6686ae8b5ecca7384f3a0e74 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 31 Dec 2014 15:01:09 +0530 Subject: [PATCH 583/829] ee mod setup database completed --- config/ee.conf | 6 +-- ee/cli/plugins/site.py | 3 +- ee/cli/plugins/site_functions.py | 87 +++++++++++++++++++++++++++----- ee/core/fileutils.py | 25 ++++----- 4 files changed, 91 insertions(+), 30 deletions(-) diff --git a/config/ee.conf b/config/ee.conf index dddf28f1..1f4c6727 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -46,13 +46,13 @@ grant-host = localhost -db-name = false +db-name = False -db-user = false +db-user = False [wordpress] -prefix = false +prefix = False user = diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index fd9d5bab..0487b720 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -4,7 +4,7 @@ from cement.core import handler, hook from ee.core.variables import EEVariables from ee.core.domainvalidate import validate_domain from ee.core.fileutils import EEFileUtils -from ee.cli.plugins.site_functions import setup_domain +from ee.cli.plugins.site_functions import setup_domain, setup_database import sys import os @@ -237,6 +237,7 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot) setup_domain(self, data) + setup_database(self, data) class EESiteUpdateController(CementBaseController): diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 11a12a28..881b488c 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -1,5 +1,10 @@ import os +import random +import string +import sys +import getpass from ee.core.fileutils import EEFileUtils +from ee.core.mysql import EEMysql def setup_domain(self, data): @@ -17,15 +22,17 @@ def setup_domain(self, data): ee_site_nginx_conf.close() except IOError as e: print("Unable to create nginx conf for {2} ({0}): {1}" - .format(e.errno, e.strerror)) + .format(e.errno, e.strerror, ee_domain_name)) + sys.exit(1) except Exception as e: print("{0}".format(e)) + sys.exit(1) # create symbolic link for - EEFileUtils.create_symlink(['/etc/nginx/sites-available/{0}.conf' - .format(ee_domain_name), - '/etc/nginx/sites-enabled/{0}.conf' - .format(ee_domain_name)]) + EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}.conf' + .format(ee_domain_name), + '/etc/nginx/sites-enabled/{0}.conf' + .format(ee_domain_name)]) # Creating htdocs & logs directory try: @@ -35,19 +42,71 @@ def setup_domain(self, data): os.makedirs('{0}/logs'.format(ee_site_webroot)) except Exception as e: print("{0}".format(e)) + sys.exit(1) - EEFileUtils.create_symlink(['/var/log/nginx/{0}.access.log' - .format(ee_domain_name), - '{0}/logs/access.log' - .format(ee_site_webroot)]) - EEFileUtils.create_symlink(['/var/log/nginx/{0}.error.log' - .format(ee_domain_name), - '{0}/logs/error.log' - .format(ee_site_webroot)]) + EEFileUtils.create_symlink(self, ['/var/log/nginx/{0}.access.log' + .format(ee_domain_name), + '{0}/logs/access.log' + .format(ee_site_webroot)]) + EEFileUtils.create_symlink(self, ['/var/log/nginx/{0}.error.log' + .format(ee_domain_name), + '{0}/logs/error.log' + .format(ee_site_webroot)]) def setup_database(self, data): ee_domain_name = data['site_name'] ee_random = (''.join(random.sample(string.ascii_uppercase + - string.ascii_lowercase + string.digits, 64))) + string.ascii_lowercase + string.digits, 15))) ee_replace_dot = ee_domain_name.replace('.', '_') + prompt_dbname = self.app.config.get('mysql', 'db-name') + prompt_dbuser = self.app.config.get('mysql', 'db-user') + ee_mysql_host = self.app.config.get('mysql', 'grant-host') + print(ee_random) + + if prompt_dbname == 'True': + try: + ee_db_name = input('Enter the MySQL database name [{0}]:' + .format(ee_replace_dot)) + except EOFError as e: + print("{0} {1}".format(e.errorno, e.strerror)) + sys.exit(0) + + if not ee_db_name: + ee_db_name = ee_replace_dot + + if prompt_dbuser: + try: + ee_db_username = input('Enter the MySQL database user name [{0}]: ' + .format(ee_replace_dot)) + ee_db_password = input('Enter the MySQL database password [{0}]: ' + .format(ee_random)) + except EOFError as e: + print("{0} {1}".format(e.errorno, e.strerror)) + sys.exit(1) + + if not ee_db_username: + ee_db_username = ee_replace_dot + if not ee_db_password: + ee_db_password = ee_random + + if len(ee_db_name) > 16: + print('Autofix MySQL username (ERROR 1470 (HY000)), please wait...' + ) + ee_random10 = (''.join(random.sample(string.ascii_uppercase + + string.ascii_lowercase + string.digits, 10))) + ee_db_name = (ee_db_name[0:6] + ee_random10) + + # create MySQL database + EEMysql.execute(self, "create database \'{0}\'" + .format(ee_db_name)) + + # Create MySQL User + EEMysql.execute(self, + "create user \'{0}\'@\'{1}\' identified by \'{2}\'" + .format(ee_db_username, ee_mysql_host, ee_db_password)) + + # Grant permission + EEMysql.execute(self, + "grant all privileges on \'{0}\'.* to \'{1}\'@\'{2}\'" + .format(ee_db_name, ee_db_username, ee_db_password)) diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index f9f9e698..c93edab2 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -1,6 +1,7 @@ """EasyEngine file utils core classes.""" import shutil import os +import sys import glob @@ -24,24 +25,24 @@ class EEFileUtils(): shutil.rmtree(file) self.app.log.info("Done") except shutil.Error as e: - self.app.log.error('Unable to Remove file' - + os.path.basename(file)+e.reason()) - self.app.log.info("Unable to remove file, [{err}]" - .format(err=str(e.reason))) - return False + self.app.log.error('Unable to Remove file {err}' + .format(err=str(e.reason))) + sys.exit(1) - def create_symlink(paths): + def create_symlink(self, paths): src = paths[0] dst = paths[1] try: os.symlink(src, dst) except Exception as e: - print("Unable to create symbolic link ...\n {0} " - .format(e.reason)) + self.app.log.error("Unable to create symbolic link ...\n {0} {1}" + .format(e.errno, e.strerror)) + sys.exit(1) - def remove_symlink(filepath): + def remove_symlink(self, filepath): try: - os.unlink(path) + os.unlink(filepath) except Exception as e: - print("Unable to reomove symbolic link ...\n {0} " - .format(e.reason)) + self.app.log.error("Unable to reomove symbolic link ...\n {0} {1}" + .format(e.errno, e.strerror)) + sys.exit(1) From 1a1a57225ae8dfe8504f1bd5851691af96757b5f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 31 Dec 2014 15:03:08 +0530 Subject: [PATCH 584/829] ee debug paramter done --- config/ee.conf | 2 +- ee/cli/plugins/debug.py | 73 +++++++++++++++++++++++++++++++++++++---- ee/cli/plugins/stack.py | 1 - 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/config/ee.conf b/config/ee.conf index dddf28f1..19994a86 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -40,7 +40,7 @@ [stack] - # ip-address = +ip-address = 1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4 [mysql] diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 4ac9725a..5b97674a 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -36,25 +36,84 @@ class EEDebugController(CementBaseController): dict(help='Interactive debug', action='store_true')), ] + @expose(hide=True) + def debug_nginx(self): + if self.start: + print("Start Nginx debug") + debug_address = (self.app.config.get('stack', 'ip-address') + .split()) + print(debug_address) + else: + print("Stop Nginx debug") + + @expose(hide=True) + def debug_php(self): + if self.start: + print("Start PHP debug") + else: + print("Stop PHP debug") + + @expose(hide=True) + def debug_fpm(self): + if self.start: + print("Start FPM debug") + else: + print("Stop FPM debug") + + @expose(hide=True) + def debug_mysql(self): + if self.start: + print("Start MySQL debug") + else: + print("Stop MySQL debug") + + @expose(hide=True) + def debug_wp(self): + if self.start: + print("Start WP debug") + else: + print("Stop WP debug") + + @expose(hide=True) + def debug_rewrite(self): + if self.start: + print("Start WP-Rewrite debug") + else: + print("Stop WP-Rewrite debug") + @expose(hide=True) def default(self): self.start = True + self.interactive = False + if self.app.pargs.stop: self.start = False + + if ((not self.app.pargs.nginx) and (not self.app.pargs.php) + and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) + and (not self.app.pargs.wp) and (not self.app.pargs.rewrite)): + self.debug_nginx() + self.debug_php() + self.debug_fpm() + self.debug_mysql() + self.debug_wp() + self.debug_rewrite() + if self.app.pargs.nginx: - pass + self.debug_nginx() if self.app.pargs.php: - pass + self.debug_php() if self.app.pargs.fpm: - pass + self.debug_fpm() if self.app.pargs.mysql: - pass + self.debug_mysql() if self.app.pargs.wp: - pass + self.debug_wp() if self.app.pargs.rewrite: - pass + self.debug_rewrite() + if self.app.pargs.interactive: - pass + self.interactive = True def load(app): diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 7e0f5d63..cafe9a42 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -143,7 +143,6 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_nginx).issubset(set(apt_packages)): # Nginx core configuration change using configparser nc = NginxConfig() - print('in nginx') self.app.log.debug('Loading file /etc/nginx/nginx.conf ') nc.loadf('/etc/nginx/nginx.conf') nc.set('worker_processes', 'auto') From 1220d7a4eed6623bead692cbcc78599fb5a87d2d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 31 Dec 2014 16:54:23 +0530 Subject: [PATCH 585/829] Nginx debug done --- config/ee.conf | 2 +- ee/cli/plugins/debug.py | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/config/ee.conf b/config/ee.conf index 355a538a..f2bc141e 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -40,7 +40,7 @@ [stack] -ip-address = 1.1.1.1 2.2.2.2 3.3.3.3 4.4.4.4 +# ip-address = 0.0.0.0/0 [mysql] diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 5b97674a..cf8dca40 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -2,6 +2,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook +from ee.core.shellexec import EEShellExec def debug_plugin_hook(app): @@ -38,13 +39,36 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_nginx(self): + self.trigger_nginx = False if self.start: - print("Start Nginx debug") - debug_address = (self.app.config.get('stack', 'ip-address') - .split()) - print(debug_address) + try: + debug_address = (self.app.config.get('stack', 'ip-address') + .split()) + except Exception as e: + debug_address = ['0.0.0.0/0'] + for ip_addr in debug_address: + if not ("debug_connection "+ip_addr in open('/etc/nginx/' + 'nginx.conf').read()): + print("Setting up NGINX debug connection for "+ip_addr) + EEShellExec.cmd_exec(self, "sed -i \"/events {{/a\\ \\ \\ " + "\\ $(echo debug_connection " + "{ip}\;)\" /etc/nginx/" + "nginx.conf".format(ip=ip_addr)) + self.trigger_nginx = True + + if not self.trigger_nginx: + print("NGINX debug connection already enabled") + + self.msg = self.msg + " /var/log/nginx/*.error.log" + else: - print("Stop Nginx debug") + if "debug_connection " in open('/etc/nginx/nginx.conf').read(): + print("Disabling Nginx debug connections") + EEShellExec.cmd_exec(self, "sed -i \"/debug_connection.*/d\"" + " /etc/nginx/nginx.conf") + self.trigger_nginx = True + else: + print("Nginx debug connection already disbaled") @expose(hide=True) def debug_php(self): @@ -85,6 +109,7 @@ class EEDebugController(CementBaseController): def default(self): self.start = True self.interactive = False + self.msg = "" if self.app.pargs.stop: self.start = False From f977bec127c7a1f13a396fa36d2de53611c08604 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 31 Dec 2014 18:48:04 +0530 Subject: [PATCH 586/829] PHP debug done --- ee/cli/plugins/debug.py | 28 ++++++++++++++++++++++++++-- ee/cli/plugins/stack.py | 1 + ee/cli/templates/upstream.mustache | 4 ++-- ee/core/shellexec.py | 2 +- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index cf8dca40..3572501d 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -73,9 +73,33 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_php(self): if self.start: - print("Start PHP debug") + if not (EEShellExec.cmd_exec(self, "sed -n \"/upstream php" + "{/,/}/p \" /etc/nginx/" + "conf.d/upstream.conf " + "| grep 9001")): + print("Enabling PHP debug") + data = dict(php="9001", debug="9001") + self.app.log.debug('writting the nginx configration to file' + '/etc/nginx/conf.d/upstream.conf ') + ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') + self.app.render((data), 'upstream.mustache', out=ee_nginx) + ee_nginx.close() + + else: + print("PHP debug is allready enabled") else: - print("Stop PHP debug") + if EEShellExec.cmd_exec(self, "sed -n \"/upstream php {/,/}/p\" " + "/etc/nginx/conf.d/upstream.conf " + "| grep 9001"): + print("Disabling PHP debug") + data = dict(php="9000", debug="9001") + self.app.log.debug('writting the nginx configration to file' + '/etc/nginx/conf.d/upstream.conf ') + ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') + self.app.render((data), 'upstream.mustache', out=ee_nginx) + ee_nginx.close() + else: + print("PHP debug is allready disbaled") @expose(hide=True) def debug_fpm(self): diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index cafe9a42..9cabdb4d 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -177,6 +177,7 @@ class EEStackController(CementBaseController): self.app.render((data), 'fastcgi.mustache', out=ee_nginx) ee_nginx.close() + data = dict(php="9000", debug="9001") self.app.log.debug('writting the nginx configration to file' '/etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') diff --git a/ee/cli/templates/upstream.mustache b/ee/cli/templates/upstream.mustache index d147724e..8a265179 100644 --- a/ee/cli/templates/upstream.mustache +++ b/ee/cli/templates/upstream.mustache @@ -1,9 +1,9 @@ # Common upstream settings upstream php { # server unix:/run/php5-fpm.sock; -server 127.0.0.1:9000; +server 127.0.0.1:{{php}}; } upstream debug { # Debug Pool -server 127.0.0.1:9001; +server 127.0.0.1:{{debug}}; } diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 1b9f6e98..2941fdf3 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -16,7 +16,7 @@ class EEShellExec(): if retcode[0] == 0: return True else: - self.app.log.info(retcode[1]) + self.app.log.warn(retcode[1]) return False except OSError as e: self.app.log.info(e) From 9870f0085c3813ca80a03242da06cf7702b29867 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 31 Dec 2014 19:24:39 +0530 Subject: [PATCH 587/829] completed ee clean command --- ee/cli/bootstrap.py | 2 -- ee/cli/controllers/clean.py | 41 ------------------------------------- ee/core/services.py | 4 ++-- 3 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 ee/cli/controllers/clean.py diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index 07250f46..8fee5c47 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -5,7 +5,6 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController -from ee.cli.controllers.clean import EECleanController from ee.cli.controllers.secure import EESecureController from ee.cli.controllers.isl import EEImportslowlogController from ee.cli.controllers.info import EEInfoController @@ -13,7 +12,6 @@ from ee.cli.controllers.info import EEInfoController def load(app): handler.register(EEBaseController) - handler.register(EECleanController) handler.register(EEInfoController) handler.register(EEImportslowlogController) handler.register(EESecureController) diff --git a/ee/cli/controllers/clean.py b/ee/cli/controllers/clean.py deleted file mode 100644 index 52b9afdf..00000000 --- a/ee/cli/controllers/clean.py +++ /dev/null @@ -1,41 +0,0 @@ -"""EasyEngine site controller.""" - -from cement.core.controller import CementBaseController, expose - - -class EECleanController(CementBaseController): - class Meta: - label = 'clean' - stacked_on = 'base' - stacked_type = 'nested' - description = 'clean command cleans different cache with following \ - options' - arguments = [ - (['--all'], - dict(help='clean all cache', action='store_true')), - (['--fastcgi'], - dict(help='clean fastcgi cache', action='store_true')), - (['--memcache'], - dict(help='clean memcache', action='store_true')), - (['--opcache'], - dict(help='clean opcode cache cache', action='store_true')) - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee clean command here - print("Inside EECleanController.default().") - - # clean command Options and subcommand calls and definations to - # mention here - - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. - # diff --git a/ee/core/services.py b/ee/core/services.py index e6b8de58..615e65fe 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -38,8 +38,8 @@ class EEService(): def restart_service(self, service_name): try: - EEService.stop_service(service_name) - EEService.start_service(service_name) + EEService.stop_service(self, service_name) + EEService.start_service(self, service_name) except OSError as e: self.app.log.error("Execution failed:", e) From fafecd8c11be27ef6494e783cac8f1000f18b5bb Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 31 Dec 2014 19:25:05 +0530 Subject: [PATCH 588/829] completed ee clean command --- config/plugins.d/clean.conf | 8 ++++ ee/cli/plugins/clean.py | 83 +++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 config/plugins.d/clean.conf create mode 100644 ee/cli/plugins/clean.py diff --git a/config/plugins.d/clean.conf b/config/plugins.d/clean.conf new file mode 100644 index 00000000..be834348 --- /dev/null +++ b/config/plugins.d/clean.conf @@ -0,0 +1,8 @@ +### Example Plugin Configuration for EasyEngine + +[clean] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py new file mode 100644 index 00000000..02444987 --- /dev/null +++ b/ee/cli/plugins/clean.py @@ -0,0 +1,83 @@ +from ee.core.shellexec import EEShellExec +from ee.core.aptget import EEAptGet +from ee.core.services import EEService +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +import os + + +def clean_plugin_hook(app): + # do something with the ``app`` object here. + pass + + +class EECleanController(CementBaseController): + class Meta: + label = 'clean' + stacked_on = 'base' + stacked_type = 'nested' + description = 'clean command cleans different cache with following \ + options' + arguments = [ + (['--all'], + dict(help='clean all cache', action='store_true')), + (['--fastcgi'], + dict(help='clean fastcgi cache', action='store_true')), + (['--memcache'], + dict(help='clean memcache', action='store_true')), + (['--opcache'], + dict(help='clean opcode cache cache', action='store_true')) + ] + + @expose(hide=True) + def default(self): + # TODO Default action for ee clean command here + if (not (self.app.pargs.all or self.app.pargs.fastcgi or + self.app.pargs.memcache or self.app.pargs.opcache)): + self.clean_fastcgi() + if self.app.pargs.all: + self.clean_memcache() + self.clean_fastcgi() + self.clean_opcache() + if self.app.pargs.fastcgi: + self.clean_fastcgi() + if self.app.pargs.memcache: + self.clean_memcache() + if self.app.pargs.opcache: + self.clean_opcache() + + @expose(hide=True) + def clean_memcache(self): + print("in memcache..") + pkg = EEAptGet() + if(pkg.is_installed("memcached")): + print("memcache is installed...") + EEService.restart_service(self, "memcached") + print("Cleaning memcache..") + else: + print("memcache is not installed..") + + @expose(hide=True) + def clean_fastcgi(self): + if(os.path.isdir("/var/run/nginx-cache")): + print("Cleaning fastcgi...") + EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") + else: + print("Error occur while Cleaning fastcgi..") + + @expose(hide=True) + def clean_opcache(self): + try: + print("Cleaning opcache.... ") + EEShellExec.cmd_exec(self, "wget --no-check-certificate --spider" + " -q https://127.0.0.1:22222/cache/opcache" + "/opgui.php?page=reset") + except OSError: + print("Unable to clean opache..") + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EECleanController) + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', clean_plugin_hook) From 5e65ee6d1b9fbaebd8de69e20993238e1c166c34 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 31 Dec 2014 19:25:20 +0530 Subject: [PATCH 589/829] Added FPM debug --- ee/cli/plugins/debug.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 3572501d..231ace39 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -84,7 +84,7 @@ class EEDebugController(CementBaseController): ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() - + self.trigger_php = True else: print("PHP debug is allready enabled") else: @@ -98,15 +98,32 @@ class EEDebugController(CementBaseController): ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() + self.trigger_php = True else: print("PHP debug is allready disbaled") @expose(hide=True) def debug_fpm(self): if self.start: - print("Start FPM debug") + if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " + "/etc/php5/fpm/php-fpm.conf"): + print("Setting up PHP5-FPM log_level = debug") + EEShellExec.cmd_exec(self, "sed -i \"s\';log_level.*\'log_" + "level = debug\'\" /etc/php5/fpm" + "/php-fpm.conf") + self.trigger_php = True + else: + print("PHP5-FPM log_level = debug already setup") else: - print("Stop FPM debug") + if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " + "/etc/php5/fpm/php-fpm.conf"): + print("Disabling PHP5-FPM log_level = debug") + EEShellExec.cmd_exec(self, "sed -i \"s\'log_level.*\';log_" + "level = notice\'\" /etc/php5/fpm" + "/php-fpm.conf") + self.trigger_php = True + else: + print("PHP5-FPM log_level = debug already disabled") @expose(hide=True) def debug_mysql(self): From de8d0f6c16b4e7f4b9ef417fc23b1de086c55c79 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 2 Jan 2015 16:55:57 +0530 Subject: [PATCH 590/829] Added MySQL debug --- ee/cli/plugins/debug.py | 44 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 231ace39..2a9d988e 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -3,6 +3,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.shellexec import EEShellExec +from ee.core.mysql import EEMysql def debug_plugin_hook(app): @@ -35,6 +36,9 @@ class EEDebugController(CementBaseController): dict(help='Debug Nginx rewrite rules', action='store_true')), (['-i', '--interactive'], dict(help='Interactive debug', action='store_true')), + (['--import-slow-log-interval'], + dict(help='Import MySQL slow log to Anemometer', + action='store', dest='interval')), ] @expose(hide=True) @@ -128,9 +132,45 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_mysql(self): if self.start: - print("Start MySQL debug") + if not EEShellExec.cmd_exec(self, "mysql -e \"show variables like" + " \'slow_query_log\';\" | " + "grep ON"): + print("Setting up MySQL slow log") + EEMysql.execute(self, "set global slow_query_log = " + "\'ON\';") + EEMysql.execute(self, "set global slow_query_log_file = " + "\'/var/log/mysql/mysql-slow.log\';") + EEMysql.execute(self, "set global long_query_time = 2;") + EEMysql.execute(self, "set global log_queries_not_using" + "_indexes = \'ON\';") + if self.app.pargs.interval: + try: + cron_time = int(self.app.pargs.interval) + except Exception as e: + cron_time = 5 + EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l 2> " + "/dev/null | {{ cat; echo -e" + " \\\"#EasyEngine start MySQL slow" + " log \\n*/{0} * * * * " + "/usr/local/sbin/ee import-slow-log\\" + "n#EasyEngine end MySQL slow log\\\";" + " }} | crontab -\"".format(cron_time)) + else: + print("MySQL slow log is allready enabled") else: - print("Stop MySQL debug") + if EEShellExec.cmd_exec(self, "mysql -e \"show variables like \'" + "slow_query_log\';\" | grep ON"): + print("Disabling MySQL slow log") + EEMysql.execute(self, "set global slow_query_log = \'OFF\';") + EEMysql.execute(self, "set global slow_query_log_file = \'" + "/var/log/mysql/mysql-slow.log\';") + EEMysql.execute(self, "set global long_query_time = 10;") + EEMysql.execute(self, "set global log_queries_not_using_index" + "es = \'OFF\';") + EEShellExec.cmd_exec(self, "crontab -l | sed \'/#EasyEngine " + "start/,/#EasyEngine end/d\' | crontab -") + else: + print("MySQL slow log already disabled") @expose(hide=True) def debug_wp(self): From 0ec933e37ddbc4b25ff5a6934273c56e655fa93a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 2 Jan 2015 18:40:27 +0530 Subject: [PATCH 591/829] Added optional site name is argument and completed all ee debug arguments --- ee/cli/plugins/debug.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 2a9d988e..5e824ea6 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -39,12 +39,14 @@ class EEDebugController(CementBaseController): (['--import-slow-log-interval'], dict(help='Import MySQL slow log to Anemometer', action='store', dest='interval')), + (['site_name'], + dict(help='Website Name', nargs='?', default=None)) ] @expose(hide=True) def debug_nginx(self): self.trigger_nginx = False - if self.start: + if self.start and not self.app.pargs.site_name: try: debug_address = (self.app.config.get('stack', 'ip-address') .split()) @@ -65,7 +67,7 @@ class EEDebugController(CementBaseController): self.msg = self.msg + " /var/log/nginx/*.error.log" - else: + elif not self.start and not self.app.pargs.site_name: if "debug_connection " in open('/etc/nginx/nginx.conf').read(): print("Disabling Nginx debug connections") EEShellExec.cmd_exec(self, "sed -i \"/debug_connection.*/d\"" @@ -74,6 +76,12 @@ class EEDebugController(CementBaseController): else: print("Nginx debug connection already disbaled") + elif self.start and self.app.pargs.site_name: + print("Enabling debug for "+self.app.pargs.site_name) + + elif not self.start and self.app.pargs.site_name: + print("Disabling debug for "+self.app.pargs.site_name) + @expose(hide=True) def debug_php(self): if self.start: @@ -174,23 +182,30 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_wp(self): - if self.start: - print("Start WP debug") + if self.start and self.app.pargs.site_name: + print("Start WP debug for site") + elif not self.start and not self.app.pargs.site_name: + print("Stop WP debug for site") else: - print("Stop WP debug") + print("Missing argument site_name") @expose(hide=True) def debug_rewrite(self): - if self.start: - print("Start WP-Rewrite debug") - else: - print("Stop WP-Rewrite debug") + if self.start and not self.app.pargs.site_name: + print("Start WP-Rewrite debug globally") + elif self.start and not self.app.pargs.site_name: + print("Stop WP-Rewrite debug globally") + elif self.start and self.app.pargs.site_name: + print("Start WP-Rewrite for site") + elif not self.start and not self.app.pargs.site_name: + print("Stop WP-Rewrite for site") @expose(hide=True) def default(self): self.start = True self.interactive = False self.msg = "" + print(self.app.pargs.site_name) if self.app.pargs.stop: self.start = False From fdc5efbc818e045a22c410527c702132e414774d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 2 Jan 2015 19:40:04 +0530 Subject: [PATCH 592/829] ee woordpress setup module done --- ee/cli/plugins/site.py | 45 ++++++++++++------ ee/cli/plugins/site_functions.py | 81 ++++++++++++++++++++++++++++++++ ee/core/fileutils.py | 25 ++++++++++ 3 files changed, 136 insertions(+), 15 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 0487b720..baa6fa33 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -131,7 +131,8 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=True, basic=False, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.php and not (self.app.pargs.html or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc @@ -140,7 +141,8 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.mysql and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc @@ -149,7 +151,8 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc) and not (self.app.pargs.html or @@ -160,25 +163,29 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=False, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=False, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.wpsubdir and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or @@ -188,25 +195,29 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=True, - wpsubdir=True, webroot=ee_site_webroot) + wpsubdir=True, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, - wpsubdir=True, webroot=ee_site_webroot) + wpsubdir=True, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, - wpsubdir=True, webroot=ee_site_webroot) + wpsubdir=True, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, - wpsubdir=True, webroot=ee_site_webroot) + wpsubdir=True, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or @@ -216,25 +227,29 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=True, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain_name, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, - wpsubdir=False, webroot=ee_site_webroot) + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='') setup_domain(self, data) setup_database(self, data) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 881b488c..9a5573ca 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -5,6 +5,7 @@ import sys import getpass from ee.core.fileutils import EEFileUtils from ee.core.mysql import EEMysql +from ee.core.shellexec import EEShellExec def setup_domain(self, data): @@ -110,3 +111,83 @@ def setup_database(self, data): EEMysql.execute(self, "grant all privileges on \'{0}\'.* to \'{1}\'@\'{2}\'" .format(ee_db_name, ee_db_username, ee_db_password)) + + +def setup_wordpress(data): + ee_domain_name = data['site_name'] + ee_site_webroot = data['webroot'] + prompt_wpprefix = self.app.config.get('wordpress', 'prefix') + ee_wp_user = self.app.config.get('wordpress', 'user') + ee_wp_pass = self.app.config.get('wordpress', 'password') + ee_wp_email = self.app.config.get('wordpress', 'email') + # Random characters + ee_random = (''.join(random.sample(string.ascii_uppercase + + string.ascii_lowercase + string.digits, 15))) + print("Downloading Wordpress, please wait...") + EEShellExec.cmd_exec(self, "wp --allow-root core download" + "--path={0}/htdocs/".format(ee_site_webroot)) + + setup_database(self, data) + if prompt_wpprefix == 'True': + ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' + .format(ee_replace_dot)) + while re.match('^[A-Za-z0-9_]*$', ee_wp_prefix): + print("Warning: table prefix can only contain numbers, letters," + "and underscores") + ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ') + if not ee_wp_prefix: + ee_wp_prefix = 'wp_' + + # Modify wp-config.php & move outside the webroot + '''EEFileUtils.copyfile(self, + '{0}/htdocs/wp-config-sample.php' + .format(ee_site_webroot), + '{0}/wp-config.php'.format(ee_site_webroot)) + EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), + 'database_name_here', '') + EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), + 'database_name_here', '') + EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), + 'username_here', '') + EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), + 'password_here', '') + EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), + 'localhost', '') + EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), + 'wp_', '')''' + + EEShellExec.cmd_exec(self, "wp --allow-root core config" + "--dbname={0} --dbprefix={1}" + .format(ee_db_name, ee_wp_prefix) + "--dbuser={2} --dbprefix={3}" + .format(ee_db_user, ee_db_password)) + + EEFileUtils.mvfile('./wp-config.php', '../') + + # TODO code for salts here + if not ee_wp_user: + ee_wp_user = EEVariables.ee_user + while not ee_wp_user: + print("Warning: Usernames can have only alphanumeric" + "characters, spaces, underscores, hyphens," + "periods and the @ symbol.") + ee_wp_user = input('Enter WordPress username: ') + + if not ee_wp_pass: + ee_wp_pass = ee_random + + if not ee_wp_email: + ee_wp_email = EEVariables.ee_email + while not ee_wp_email: + ee_wp_email = input('Enter WordPress email: ') + + print("Setting up WordPress, please wait...") + EEShellExec.cmd_exec(self, "wp --allow-root core install" + "--url=www.{0} --title=www.{0} --admin_name={1}" + .format(ee_domain_name, ee_wp_user) + "--admin_password={0} --admin_email={1}" + .format(ee_wp_pass, ee_wp_email)) + + print("Updating WordPress permalink, please wait...") + EEShellExec.cmd_exec("wp rewrite structure --allow-root" + "/%year%/%monthnum%/%day%/%postname%/") diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index c93edab2..8b0c9aaf 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -3,6 +3,8 @@ import shutil import os import sys import glob +import shutil +import fileinput class EEFileUtils(): @@ -46,3 +48,26 @@ class EEFileUtils(): self.app.log.error("Unable to reomove symbolic link ...\n {0} {1}" .format(e.errno, e.strerror)) sys.exit(1) + + def copyfile(self, src, dst): + try: + shutil.copy2(src, dest) + except shutil.Error as e: + print('Error: {0}'.format(e)) + except IOError as e: + print('Error: {e}'.format(e.strerror)) + + def searchreplace(self, fnm, sstr, rstr): + try: + for line in fileinput.input(fnm, inplace=True): + print(line.replace(textToSearch, textToReplace), end='') + except Exception as e: + print('Error : {0}'.format(e)) + + def mvfile(self, src, dst): + try: + shutil.move(src, dst) + except shutil.Error as e: + self.app.log.error('Unable to move file {err}' + .format(err=str(e.reason))) + sys.exit(1) From 2c5e602b92cad4b91e2addf37626145cf56906e1 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 5 Jan 2015 15:28:39 +0530 Subject: [PATCH 593/829] Addded WordPress debug --- ee/cli/plugins/debug.py | 103 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 5e824ea6..96670267 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -4,6 +4,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.shellexec import EEShellExec from ee.core.mysql import EEMysql +import os def debug_plugin_hook(app): @@ -46,6 +47,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_nginx(self): self.trigger_nginx = False + # start global debug if self.start and not self.app.pargs.site_name: try: debug_address = (self.app.config.get('stack', 'ip-address') @@ -67,6 +69,7 @@ class EEDebugController(CementBaseController): self.msg = self.msg + " /var/log/nginx/*.error.log" + # stop global debug elif not self.start and not self.app.pargs.site_name: if "debug_connection " in open('/etc/nginx/nginx.conf').read(): print("Disabling Nginx debug connections") @@ -76,14 +79,48 @@ class EEDebugController(CementBaseController): else: print("Nginx debug connection already disbaled") + # start site specific debug elif self.start and self.app.pargs.site_name: - print("Enabling debug for "+self.app.pargs.site_name) + config_path = ("/etc/nginx/sites-available/{0}" + .format(self.app.pargs.site_name)) + if os.path.isfile(config_path): + if not EEShellExec.cmd_exec("grep \"error.log debug\" {0}" + .format(config_path)): + print("Starting NGINX debug connection for {0}" + .format(self.app.pargs.site_name)) + EEShellExec.cmd_exec("sed -i \"s/error.log;/error.log " + "debug;/\" {0}".format(config_path)) + self.trigger_nginx = True + + else: + print("Debug for site allready enabled") + + else: + print("{0} domain not valid".format(self.app.pargs.site_name)) + # stop site specific debug elif not self.start and self.app.pargs.site_name: - print("Disabling debug for "+self.app.pargs.site_name) + config_path = ("/etc/nginx/sites-available/{0}" + .format(self.app.pargs.site_name)) + if os.path.isfile(config_path): + if EEShellExec.cmd_exec("grep \"error.log debug\" {0}" + .format(config_path)): + print("Stoping NGINX debug connection for {0}" + .format(self.app.pargs.site_name)) + EEShellExec.cmd_exec("sed -i \"s/error.log debug;/" + "error.log;/\" {0}" + .format(config_path)) + self.trigger_nginx = True + + else: + print("Debug for site allready disbaled") + + else: + print("{0} domain not valid".format(self.app.pargs.site_name)) @expose(hide=True) def debug_php(self): + # PHP global debug start if self.start: if not (EEShellExec.cmd_exec(self, "sed -n \"/upstream php" "{/,/}/p \" /etc/nginx/" @@ -99,6 +136,8 @@ class EEDebugController(CementBaseController): self.trigger_php = True else: print("PHP debug is allready enabled") + + # PHP global debug stop else: if EEShellExec.cmd_exec(self, "sed -n \"/upstream php {/,/}/p\" " "/etc/nginx/conf.d/upstream.conf " @@ -116,6 +155,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_fpm(self): + # PHP5-FPM start global debug if self.start: if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): @@ -126,6 +166,7 @@ class EEDebugController(CementBaseController): self.trigger_php = True else: print("PHP5-FPM log_level = debug already setup") + # PHP5-FPM stop global debug else: if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): @@ -139,6 +180,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_mysql(self): + # MySQL start global debug if self.start: if not EEShellExec.cmd_exec(self, "mysql -e \"show variables like" " \'slow_query_log\';\" | " @@ -165,6 +207,7 @@ class EEDebugController(CementBaseController): " }} | crontab -\"".format(cron_time)) else: print("MySQL slow log is allready enabled") + # MySQL stop global debug else: if EEShellExec.cmd_exec(self, "mysql -e \"show variables like \'" "slow_query_log\';\" | grep ON"): @@ -183,9 +226,58 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_wp(self): if self.start and self.app.pargs.site_name: - print("Start WP debug for site") - elif not self.start and not self.app.pargs.site_name: - print("Stop WP debug for site") + wp_config = ("/var/www/{0}/wp-config.php" + .format(self.app.pargs.site_name)) + webroot = "/var/www/{0}".format(self.app.pargs.site_name) + if os.path.isfile(wp_config): + if not EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |" + " grep true".format(wp_config)): + print("Starting WordPress debug") + open("{0}/htdocs/wp-content/debug.log".format(webroot), + 'a').close() + EEShellExec.cmd_exec(self, "chown www-data: {0}/htdocs/wp-" + "content/debug.log".format(webroot)) + EEShellExec.cmd_exec(self, "sed -i \"s/define(\'WP_DEBUG\'" + ".*/define(\'WP_DEBUG\', true);\\n" + "define(\'WP_DEBUG_DISPLAY\', false);" + "\\ndefine(\'WP_DEBUG_LOG\', true);" + "\\ndefine(\'SAVEQUERIES\', true);/\"" + " {0}".format(wp_config)) + EEShellExec.cmd_exec(self, "cd {0}/htdocs/ && wp" + " plugin --allow-root install " + "developer".format(webroot)) + EEShellExec.cmd_exec(self, "chown -R www-data: {0}/htdocs/" + "wp-content/plugins" + .format(webroot)) + else: + print("WordPress debug log already enabled") + else: + print("{0} domain not valid".format(self.app.pargs.site_name)) + + elif not self.start and self.app.pargs.site_name: + wp_config = ("/var/www/{0}/wp-config.php" + .format(self.app.pargs.site_name)) + webroot = "/var/www/{0}".format(self.app.pargs.site_name) + if os.path.isfile(wp_config): + if EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | " + "grep true".format(wp_config)): + print("Disabling WordPress debug") + EEShellExec.cmd_exec(self, "sed -i \"s/define(\'WP_DEBUG\'" + ", true);/define(\'WP_DEBUG\', " + "false);/\" {0}".format(wp_config)) + EEShellExec.cmd_exec(self, "sed -i \"/define(\'" + "WP_DEBUG_DISPLAY\', false);/d\" {0}" + .format(wp_config)) + EEShellExec.cmd_exec(self, "sed -i \"/define(\'" + "WP_DEBUG_LOG\', true);/d\" {0}" + .format(wp_config)) + EEShellExec.cmd_exec("sed -i \"/define(\'" + "SAVEQUERIES\', " + "true);/d\" {0}".format(wp_config)) + else: + print("WordPress debug all already disbaled") + else: + print("{0} domain not valid".format(self.app.pargs.site_name)) else: print("Missing argument site_name") @@ -205,7 +297,6 @@ class EEDebugController(CementBaseController): self.start = True self.interactive = False self.msg = "" - print(self.app.pargs.site_name) if self.app.pargs.stop: self.start = False From 04583f1697626dc37189865a798651cc1930ee68 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 5 Jan 2015 16:17:57 +0530 Subject: [PATCH 594/829] ee wordpress plugin install added --- ee/cli/plugins/site.py | 13 +++--- ee/cli/plugins/site_functions.py | 77 +++++++++++++++++++++++++++----- ee/core/fileutils.py | 8 ++++ ee/core/services.py | 13 ++++++ 4 files changed, 93 insertions(+), 18 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index baa6fa33..9c3dfaec 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -4,7 +4,7 @@ from cement.core import handler, hook from ee.core.variables import EEVariables from ee.core.domainvalidate import validate_domain from ee.core.fileutils import EEFileUtils -from ee.cli.plugins.site_functions import setup_domain, setup_database +from ee.cli.plugins.site_functions import * import sys import os @@ -131,8 +131,7 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=True, basic=False, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.php and not (self.app.pargs.html or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc @@ -141,8 +140,7 @@ class EESiteCreateController(CementBaseController): data = dict(site_name=ee_domain_name, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, - wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + wpsubdir=False, webroot=ee_site_webroot) if (self.app.pargs.mysql and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc @@ -252,7 +250,10 @@ class EESiteCreateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='') setup_domain(self, data) - setup_database(self, data) + if 'ee_db_name' in data.keys(): + data = setup_database(self, data) + if data['wp']: + setup_wordpress(self, data) class EESiteUpdateController(CementBaseController): diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 9a5573ca..ec9ead53 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -63,7 +63,6 @@ def setup_database(self, data): prompt_dbname = self.app.config.get('mysql', 'db-name') prompt_dbuser = self.app.config.get('mysql', 'db-user') ee_mysql_host = self.app.config.get('mysql', 'grant-host') - print(ee_random) if prompt_dbname == 'True': try: @@ -111,9 +110,13 @@ def setup_database(self, data): EEMysql.execute(self, "grant all privileges on \'{0}\'.* to \'{1}\'@\'{2}\'" .format(ee_db_name, ee_db_username, ee_db_password)) + data['ee_db_name'] = ee_db_name + data['ee_db_user'] = ee_db_username + data['ee_db_pass'] = ee_db_password + return data -def setup_wordpress(data): +def setup_wordpress(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] prompt_wpprefix = self.app.config.get('wordpress', 'prefix') @@ -156,11 +159,22 @@ def setup_wordpress(data): EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), 'wp_', '')''' - EEShellExec.cmd_exec(self, "wp --allow-root core config" - "--dbname={0} --dbprefix={1}" - .format(ee_db_name, ee_wp_prefix) - "--dbuser={2} --dbprefix={3}" - .format(ee_db_user, ee_db_password)) + EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) + if not data['multisite']: + EEShellExec.cmd_exec(self, "wp --allow-root core config" + "--dbname={0} --dbprefix={1} --dbuser={2}" + .format(ee_db_name, ee_wp_prefix, ee_db_user) + + "--dbpass={0}".format(ee_db_password)) + + else: + EEShellExec.cmd_exec(self, "wp --allow-root core config" + "--dbname={0} --dbprefix={1}" + .format(ee_db_name, ee_wp_prefix) + + "--dbuser={0} --dbpass={1} --extra-php< Date: Mon, 5 Jan 2015 16:59:23 +0530 Subject: [PATCH 595/829] fixed "ProgrammingError" object has no attribute "reason" --- ee/cli/plugins/site_functions.py | 62 ++++++++++++++++---------------- ee/core/mysql.py | 7 ++-- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index ec9ead53..f001ca8f 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -63,6 +63,7 @@ def setup_database(self, data): prompt_dbname = self.app.config.get('mysql', 'db-name') prompt_dbuser = self.app.config.get('mysql', 'db-user') ee_mysql_host = self.app.config.get('mysql', 'grant-host') + ee_db_name = '' if prompt_dbname == 'True': try: @@ -72,8 +73,8 @@ def setup_database(self, data): print("{0} {1}".format(e.errorno, e.strerror)) sys.exit(0) - if not ee_db_name: - ee_db_name = ee_replace_dot + if not ee_db_name: + ee_db_name = ee_replace_dot if prompt_dbuser: try: @@ -85,35 +86,34 @@ def setup_database(self, data): print("{0} {1}".format(e.errorno, e.strerror)) sys.exit(1) - if not ee_db_username: - ee_db_username = ee_replace_dot - if not ee_db_password: - ee_db_password = ee_random - - if len(ee_db_name) > 16: - print('Autofix MySQL username (ERROR 1470 (HY000)), please wait...' - ) - ee_random10 = (''.join(random.sample(string.ascii_uppercase + - string.ascii_lowercase + string.digits, 10))) - ee_db_name = (ee_db_name[0:6] + ee_random10) - - # create MySQL database - EEMysql.execute(self, "create database \'{0}\'" - .format(ee_db_name)) - - # Create MySQL User - EEMysql.execute(self, - "create user \'{0}\'@\'{1}\' identified by \'{2}\'" - .format(ee_db_username, ee_mysql_host, ee_db_password)) - - # Grant permission - EEMysql.execute(self, - "grant all privileges on \'{0}\'.* to \'{1}\'@\'{2}\'" - .format(ee_db_name, ee_db_username, ee_db_password)) - data['ee_db_name'] = ee_db_name - data['ee_db_user'] = ee_db_username - data['ee_db_pass'] = ee_db_password - return data + if not ee_db_username: + ee_db_username = ee_replace_dot + if not ee_db_password: + ee_db_password = ee_random + + if len(ee_db_username) > 16: + print('Autofix MySQL username (ERROR 1470 (HY000)), please wait...') + ee_random10 = (''.join(random.sample(string.ascii_uppercase + + string.ascii_lowercase + string.digits, 10))) + ee_db_name = (ee_db_name[0:6] + ee_random10) + + # create MySQL database + EEMysql.execute(self, "create database \'{0}\'" + .format(ee_db_name)) + + # Create MySQL User + EEMysql.execute(self, + "create user \'{0}\'@\'{1}\' identified by \'{2}\'" + .format(ee_db_username, ee_mysql_host, ee_db_password)) + + # Grant permission + EEMysql.execute(self, + "grant all privileges on \'{0}\'.* to \'{1}\'@\'{2}\'" + .format(ee_db_name, ee_db_username, ee_db_password)) + data['ee_db_name'] = ee_db_name + data['ee_db_user'] = ee_db_username + data['ee_db_pass'] = ee_db_password + return data def setup_wordpress(self, data): diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 19381f4b..dbc58421 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -28,14 +28,15 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() except Exception as e: - self.app.log.error('Unable to connect to database', e.reason()) - self.app.log.info("Unable to connect to database") + self.app.log.error('Unable to connect to database: {0}' + .format(e.strerror)) return False try: cur.execute(statement) except Exception as e: - self.app.log.error('Error occured while executing', e.reason()) + self.app.log.error('Error occured while executing: {0}' + .format(e.strerror)) self.app.log.info("Error occured while executing "+statement) cur.close() conn.close() From d33ebe194f538540cd1b654e48e700f4307598eb Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 5 Jan 2015 17:30:24 +0530 Subject: [PATCH 596/829] updated log messages --- config/ee.conf | 2 +- ee/cli/bootstrap.py | 2 -- ee/cli/controllers/secure.py | 27 --------------------------- ee/core/download.py | 13 ++++--------- ee/core/extract.py | 4 ++-- ee/core/mysql.py | 4 ++-- ee/core/services.py | 11 ++++++++--- ee/core/shellexec.py | 3 ++- 8 files changed, 19 insertions(+), 47 deletions(-) delete mode 100644 ee/cli/controllers/secure.py diff --git a/config/ee.conf b/config/ee.conf index f2bc141e..1f89eeee 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -40,7 +40,7 @@ [stack] -# ip-address = 0.0.0.0/0 +ip-address = 0.0.0.0/0 1.1.1.1 2.2.2.2 [mysql] diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index 8fee5c47..48b62d3b 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -5,7 +5,6 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController -from ee.cli.controllers.secure import EESecureController from ee.cli.controllers.isl import EEImportslowlogController from ee.cli.controllers.info import EEInfoController @@ -14,4 +13,3 @@ def load(app): handler.register(EEBaseController) handler.register(EEInfoController) handler.register(EEImportslowlogController) - handler.register(EESecureController) diff --git a/ee/cli/controllers/secure.py b/ee/cli/controllers/secure.py deleted file mode 100644 index 17688636..00000000 --- a/ee/cli/controllers/secure.py +++ /dev/null @@ -1,27 +0,0 @@ -from cement.core.controller import CementBaseController, expose - - -class EESecureController(CementBaseController): - class Meta: - label = 'secure' - stacked_on = 'base' - stacked_type = 'nested' - description = 'secure command used for debugging issued with stack or \ - site specific configuration' - arguments = [ - (['--ip'], - dict(help='whitelist ip addresses to access admin tools without \ - authentication', - action='store_true')), - (['--auth'], - dict(help='change http auth credentials', - action='store_true')), - (['--port'], - dict(help='change port for admin tools default is 22222', - action='store_true')), - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee debug command - print("Inside EESecureController.default().") diff --git a/ee/core/download.py b/ee/core/download.py index 2ab6375b..81cf0f46 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -21,21 +21,16 @@ class EEDownload(): urllib.request.urlretrieve(url, filename) self.app.log.info("Done") except urllib.error.URLError as e: - self.app.log.error("Error is :" - + os.path.basename(url)+e.reason()) self.app.log.info("Unable to donwload file, [{err}]" .format(err=str(e.reason))) return False except urllib.error.HTTPError as e: - self.app.log.error("Package download failed", e.reason()) - self.app.log.info("Package download failed. [{err}]" - .format(err=str(e.reason))) + self.app.log.error("Package download failed. [{err}]" + .format(err=str(e.reason))) return False except urllib.error.ContentTooShortError as e: self.app.log.error("Package download failed. The amount of the" " downloaded data is less than " - "the expected amount"+e.reason()) - self.app.log.info("Package download failed. The amount of the" - "downloaded data is less than" - " the expected amount") + "the expected amount \{0} {1}" + .format(e.errno, e.strerror)) return False diff --git a/ee/core/extract.py b/ee/core/extract.py index ab5d9169..fcb8a2d8 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -14,6 +14,6 @@ class EEExtract(): os.remove(file) return True except tarfile.TarError as e: - self.app.log.error('Unable to extract file', e.reason()) - self.app.log.info("Unable to extract file "+file) + self.app.log.error('Unable to extract file \{0} {1}' + .format(e.errno, e.strerror)) return False diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 19381f4b..86ce093e 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -28,8 +28,8 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() except Exception as e: - self.app.log.error('Unable to connect to database', e.reason()) - self.app.log.info("Unable to connect to database") + self.app.log.error('Unable to connect to database\{0} {1}' + .format(e.errno, e.strerror)) return False try: diff --git a/ee/core/services.py b/ee/core/services.py index 615e65fe..790a00ff 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -20,7 +20,8 @@ class EEService(): else: self.app.log.error(retcode[1]) except OSError as e: - self.app.log.error("Execution failed:", e) + self.app.log.error("Unable to start service \ {0} {1}" + .format(e.errno, e.strerror)) return False def stop_service(self, service_name): @@ -33,7 +34,8 @@ class EEService(): else: return False except OSError as e: - self.app.log.error("Execution failed:", e) + self.app.log.error("Unable to stop services \ {0}{1}" + .format(e.errno, e.strerror)) return False def restart_service(self, service_name): @@ -41,7 +43,8 @@ class EEService(): EEService.stop_service(self, service_name) EEService.start_service(self, service_name) except OSError as e: - self.app.log.error("Execution failed:", e) + self.app.log.error("Unable to restart services \{0} {1}" + .format(e.errno, e.strerror)) def get_service_status(self, service_name): try: @@ -57,4 +60,6 @@ class EEService(): else: return False except OSError as e: + self.app.log.error("Unable to get services status \ {0}{1}" + .format(e.errno, e.strerror)) return False diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 2941fdf3..5ce9d5dd 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -19,5 +19,6 @@ class EEShellExec(): self.app.log.warn(retcode[1]) return False except OSError as e: - self.app.log.info(e) + self.app.log.error("Unable to execute command \ {0}{1}" + .format(e.errno, e.strerror)) return False From a1d897dcec87c9a70032ee540f545a0f75fe5834 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 5 Jan 2015 17:31:48 +0530 Subject: [PATCH 597/829] fixed error status --- ee/cli/plugins/site.py | 2 +- ee/cli/plugins/site_functions.py | 4 ++-- ee/core/mysql.py | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 9c3dfaec..8aa160d1 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -250,7 +250,7 @@ class EESiteCreateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='') setup_domain(self, data) - if 'ee_db_name' in data.keys(): + if 'ee_db_name' in data.keys() and not data['wp']: data = setup_database(self, data) if data['wp']: setup_wordpress(self, data) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index f001ca8f..ba1c42f6 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -127,8 +127,8 @@ def setup_wordpress(self, data): ee_random = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 15))) print("Downloading Wordpress, please wait...") - EEShellExec.cmd_exec(self, "wp --allow-root core download" - "--path={0}/htdocs/".format(ee_site_webroot)) + EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) + EEShellExec.cmd_exec(self, "wp --allow-root core download") setup_database(self, data) if prompt_wpprefix == 'True': diff --git a/ee/core/mysql.py b/ee/core/mysql.py index dbc58421..5b19661f 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -2,6 +2,7 @@ import pymysql import configparser from os.path import expanduser +import sys class EEMysql(): @@ -29,18 +30,17 @@ class EEMysql(): cur = conn.cursor() except Exception as e: self.app.log.error('Unable to connect to database: {0}' - .format(e.strerror)) - return False + .format(e)) + sys.exit(1) try: cur.execute(statement) except Exception as e: self.app.log.error('Error occured while executing: {0}' - .format(e.strerror)) - self.app.log.info("Error occured while executing "+statement) + .format(e)) cur.close() conn.close() - return False + sys.exit(1) cur.close() conn.close() From 298049aaed576fb9fa07a572b38d98c2b1616309 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 5 Jan 2015 17:45:14 +0530 Subject: [PATCH 598/829] ee debug done --- ee/cli/plugins/debug.py | 92 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 9 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 96670267..63397c3e 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -4,6 +4,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.shellexec import EEShellExec from ee.core.mysql import EEMysql +from ee.core.services import EEService import os @@ -46,7 +47,6 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_nginx(self): - self.trigger_nginx = False # start global debug if self.start and not self.app.pargs.site_name: try: @@ -67,7 +67,7 @@ class EEDebugController(CementBaseController): if not self.trigger_nginx: print("NGINX debug connection already enabled") - self.msg = self.msg + " /var/log/nginx/*.error.log" + self.msg = self.msg + [" /var/log/nginx/*.error.log"] # stop global debug elif not self.start and not self.app.pargs.site_name: @@ -95,6 +95,9 @@ class EEDebugController(CementBaseController): else: print("Debug for site allready enabled") + self.msg = self.msg + ['/var/www//logs/error.log' + .format(self.app.pargs.site_name)] + else: print("{0} domain not valid".format(self.app.pargs.site_name)) @@ -137,6 +140,8 @@ class EEDebugController(CementBaseController): else: print("PHP debug is allready enabled") + self.msg = self.msg + ['/var/log/php5/slow.log'] + # PHP global debug stop else: if EEShellExec.cmd_exec(self, "sed -n \"/upstream php {/,/}/p\" " @@ -166,6 +171,8 @@ class EEDebugController(CementBaseController): self.trigger_php = True else: print("PHP5-FPM log_level = debug already setup") + + self.msg = self.msg + ['/var/log/php5/fpm.log'] # PHP5-FPM stop global debug else: if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " @@ -207,6 +214,9 @@ class EEDebugController(CementBaseController): " }} | crontab -\"".format(cron_time)) else: print("MySQL slow log is allready enabled") + + self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] + # MySQL stop global debug else: if EEShellExec.cmd_exec(self, "mysql -e \"show variables like \'" @@ -283,20 +293,73 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_rewrite(self): + # Start Nginx rewrite debug globally if self.start and not self.app.pargs.site_name: - print("Start WP-Rewrite debug globally") - elif self.start and not self.app.pargs.site_name: - print("Stop WP-Rewrite debug globally") - elif self.start and self.app.pargs.site_name: - print("Start WP-Rewrite for site") + if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " + "/etc/nginx/nginx.conf"): + print("Setting up Nginx rewrite logs") + EEShellExec.cmd_exec(self, "sed -i \'/http {/a \\\\t" + "rewrite_log on;\' /etc/nginx/nginx.conf") + self.trigger_nginx = True + else: + print("NGINX rewrite logs already enabled") + + if '/var/log/nginx/*.error.log' not in self.msg: + self.msg = self.msg + ['/var/log/nginx/*.error.log'] + + # Stop Nginx rewrite debug globally elif not self.start and not self.app.pargs.site_name: - print("Stop WP-Rewrite for site") + if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " + "/etc/nginx/nginx.conf"): + print("Disabling Nginx rewrite logs") + EEShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\"" + " /etc/nginx/nginx.conf") + self.trigger_nginx = True + else: + print("NGINX rewrite logs already disbaled") + # Start Nginx rewrite for site + elif self.start and self.app.pargs.site_name: + config_path = ("/etc/nginx/sites-available/{0}.conf" + .format(self.app.pargs.site_name)) + if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" + .format(config_path)): + print("Setting up NGINX rewrite logs for {0}" + .format(self.app.pargs.site_name)) + EEShellExec.cmd_exec(self, "sed -i \"/access_log/i \\\\\\t" + "rewrite_log on;\" {0}" + .format(config_path)) + self.trigger_nginx = True + else: + print("Nginx rewrite logs for {0} allready setup" + .format(self.app.pargs.site_name)) + + if ('/var/www/{0}/logs/error.log'.format(self.app.pargs.site_name) + not in self.msg): + self.msg = self.msg + ['/var/www/{0}/logs/error.log' + .format(self.app.pargs.site_name)] + + # Stop Nginx rewrite for site + elif not self.start and self.app.pargs.site_name: + config_path = ("/etc/nginx/sites-available/{0}.conf" + .format(self.app.pargs.site_name)) + if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" + .format(config_path)): + print("Disabling NGINX rewrite logs for {0}" + .format(self.app.pargs.site_name)) + EEShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\" {0}" + .format(config_path)) + self.trigger_nginx = True + else: + print("Nginx rewrite logs for {0} allready disbaled" + .format(self.app.pargs.site_name)) @expose(hide=True) def default(self): self.start = True self.interactive = False - self.msg = "" + self.msg = [] + self.trigger_nginx = False + self.trigger_php = False if self.app.pargs.stop: self.start = False @@ -327,6 +390,17 @@ class EEDebugController(CementBaseController): if self.app.pargs.interactive: self.interactive = True + # Reload Nginx + if self.trigger_nginx: + EEService.reload_service(self, ['nginx']) + # Reload PHP + if self.trigger_php: + EEService.reload_service(self, ['php5-fpm']) + + if len(self.msg) > 0: + print("Use following command to check debug logs:\n{0}" + .format(self.msg.join())) + def load(app): # register the plugin class.. this only happens if the plugin is enabled From 3578971c401fedef66b96aa5ac7ed57cad676ce5 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 5 Jan 2015 19:22:44 +0530 Subject: [PATCH 599/829] added log messages in debug.py --- ee/cli/plugins/debug.py | 100 ++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 63397c3e..b181dc29 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -57,7 +57,8 @@ class EEDebugController(CementBaseController): for ip_addr in debug_address: if not ("debug_connection "+ip_addr in open('/etc/nginx/' 'nginx.conf').read()): - print("Setting up NGINX debug connection for "+ip_addr) + self.app.log.info("Setting up NGINX debug connection" + " for "+ip_addr) EEShellExec.cmd_exec(self, "sed -i \"/events {{/a\\ \\ \\ " "\\ $(echo debug_connection " "{ip}\;)\" /etc/nginx/" @@ -65,19 +66,19 @@ class EEDebugController(CementBaseController): self.trigger_nginx = True if not self.trigger_nginx: - print("NGINX debug connection already enabled") + self.app.log.info("NGINX debug connection already enabled") self.msg = self.msg + [" /var/log/nginx/*.error.log"] # stop global debug elif not self.start and not self.app.pargs.site_name: if "debug_connection " in open('/etc/nginx/nginx.conf').read(): - print("Disabling Nginx debug connections") + self.app.log.info("Disabling Nginx debug connections") EEShellExec.cmd_exec(self, "sed -i \"/debug_connection.*/d\"" " /etc/nginx/nginx.conf") self.trigger_nginx = True else: - print("Nginx debug connection already disbaled") + self.app.log.info("Nginx debug connection already disbaled") # start site specific debug elif self.start and self.app.pargs.site_name: @@ -86,20 +87,22 @@ class EEDebugController(CementBaseController): if os.path.isfile(config_path): if not EEShellExec.cmd_exec("grep \"error.log debug\" {0}" .format(config_path)): - print("Starting NGINX debug connection for {0}" - .format(self.app.pargs.site_name)) + self.app.log.info("Starting NGINX debug connection for " + "{0}" + .format(self.app.pargs.site_name)) EEShellExec.cmd_exec("sed -i \"s/error.log;/error.log " "debug;/\" {0}".format(config_path)) self.trigger_nginx = True else: - print("Debug for site allready enabled") + self.app.log.info("Debug for site allready enabled") self.msg = self.msg + ['/var/www//logs/error.log' .format(self.app.pargs.site_name)] else: - print("{0} domain not valid".format(self.app.pargs.site_name)) + self.app.log.info("{0} domain not valid" + .format(self.app.pargs.site_name)) # stop site specific debug elif not self.start and self.app.pargs.site_name: @@ -108,18 +111,19 @@ class EEDebugController(CementBaseController): if os.path.isfile(config_path): if EEShellExec.cmd_exec("grep \"error.log debug\" {0}" .format(config_path)): - print("Stoping NGINX debug connection for {0}" - .format(self.app.pargs.site_name)) + self.app.log.info("Stoping NGINX debug connection for {0}" + .format(self.app.pargs.site_name)) EEShellExec.cmd_exec("sed -i \"s/error.log debug;/" "error.log;/\" {0}" .format(config_path)) self.trigger_nginx = True else: - print("Debug for site allready disbaled") + self.app.log.info("Debug for site allready disbaled") else: - print("{0} domain not valid".format(self.app.pargs.site_name)) + self.app.log.info("{0} domain not valid" + .format(self.app.pargs.site_name)) @expose(hide=True) def debug_php(self): @@ -129,16 +133,16 @@ class EEDebugController(CementBaseController): "{/,/}/p \" /etc/nginx/" "conf.d/upstream.conf " "| grep 9001")): - print("Enabling PHP debug") + self.app.log.info("Enabling PHP debug") data = dict(php="9001", debug="9001") - self.app.log.debug('writting the nginx configration to file' - '/etc/nginx/conf.d/upstream.conf ') + self.app.log.info('writting the nginx configration to file' + '/etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() self.trigger_php = True else: - print("PHP debug is allready enabled") + self.app.log.info("PHP debug is allready enabled") self.msg = self.msg + ['/var/log/php5/slow.log'] @@ -147,16 +151,16 @@ class EEDebugController(CementBaseController): if EEShellExec.cmd_exec(self, "sed -n \"/upstream php {/,/}/p\" " "/etc/nginx/conf.d/upstream.conf " "| grep 9001"): - print("Disabling PHP debug") + self.app.log.info("Disabling PHP debug") data = dict(php="9000", debug="9001") - self.app.log.debug('writting the nginx configration to file' - '/etc/nginx/conf.d/upstream.conf ') + self.app.log.info('writting the nginx configration to file' + '/etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() self.trigger_php = True else: - print("PHP debug is allready disbaled") + self.app.log.info("PHP debug is allready disbaled") @expose(hide=True) def debug_fpm(self): @@ -164,26 +168,27 @@ class EEDebugController(CementBaseController): if self.start: if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): - print("Setting up PHP5-FPM log_level = debug") + self.app.log.info("Setting up PHP5-FPM log_level = debug") EEShellExec.cmd_exec(self, "sed -i \"s\';log_level.*\'log_" "level = debug\'\" /etc/php5/fpm" "/php-fpm.conf") self.trigger_php = True else: - print("PHP5-FPM log_level = debug already setup") + self.app.log.info("PHP5-FPM log_level = debug already setup") self.msg = self.msg + ['/var/log/php5/fpm.log'] # PHP5-FPM stop global debug else: if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): - print("Disabling PHP5-FPM log_level = debug") + self.app.log.info("Disabling PHP5-FPM log_level = debug") EEShellExec.cmd_exec(self, "sed -i \"s\'log_level.*\';log_" "level = notice\'\" /etc/php5/fpm" "/php-fpm.conf") self.trigger_php = True else: - print("PHP5-FPM log_level = debug already disabled") + self.app.log.info("PHP5-FPM log_level = debug " + " already disabled") @expose(hide=True) def debug_mysql(self): @@ -213,7 +218,7 @@ class EEDebugController(CementBaseController): "n#EasyEngine end MySQL slow log\\\";" " }} | crontab -\"".format(cron_time)) else: - print("MySQL slow log is allready enabled") + self.app.log.info("MySQL slow log is allready enabled") self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] @@ -231,7 +236,7 @@ class EEDebugController(CementBaseController): EEShellExec.cmd_exec(self, "crontab -l | sed \'/#EasyEngine " "start/,/#EasyEngine end/d\' | crontab -") else: - print("MySQL slow log already disabled") + self.app.log.info("MySQL slow log already disabled") @expose(hide=True) def debug_wp(self): @@ -242,7 +247,7 @@ class EEDebugController(CementBaseController): if os.path.isfile(wp_config): if not EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |" " grep true".format(wp_config)): - print("Starting WordPress debug") + self.app.log.info("Starting WordPress debug") open("{0}/htdocs/wp-content/debug.log".format(webroot), 'a').close() EEShellExec.cmd_exec(self, "chown www-data: {0}/htdocs/wp-" @@ -260,9 +265,10 @@ class EEDebugController(CementBaseController): "wp-content/plugins" .format(webroot)) else: - print("WordPress debug log already enabled") + self.app.log.info("WordPress debug log already enabled") else: - print("{0} domain not valid".format(self.app.pargs.site_name)) + self.app.log.info("{0} domain not valid" + .format(self.app.pargs.site_name)) elif not self.start and self.app.pargs.site_name: wp_config = ("/var/www/{0}/wp-config.php" @@ -271,7 +277,7 @@ class EEDebugController(CementBaseController): if os.path.isfile(wp_config): if EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | " "grep true".format(wp_config)): - print("Disabling WordPress debug") + self.app.log.info("Disabling WordPress debug") EEShellExec.cmd_exec(self, "sed -i \"s/define(\'WP_DEBUG\'" ", true);/define(\'WP_DEBUG\', " "false);/\" {0}".format(wp_config)) @@ -287,9 +293,10 @@ class EEDebugController(CementBaseController): else: print("WordPress debug all already disbaled") else: - print("{0} domain not valid".format(self.app.pargs.site_name)) + self.app.log.info("{0} domain not valid" + .format(self.app.pargs.site_name)) else: - print("Missing argument site_name") + self.app.log.info("Missing argument site_name") @expose(hide=True) def debug_rewrite(self): @@ -297,12 +304,12 @@ class EEDebugController(CementBaseController): if self.start and not self.app.pargs.site_name: if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " "/etc/nginx/nginx.conf"): - print("Setting up Nginx rewrite logs") + self.app.log.info("Setting up Nginx rewrite logs") EEShellExec.cmd_exec(self, "sed -i \'/http {/a \\\\t" "rewrite_log on;\' /etc/nginx/nginx.conf") self.trigger_nginx = True else: - print("NGINX rewrite logs already enabled") + self.app.log.info("NGINX rewrite logs already enabled") if '/var/log/nginx/*.error.log' not in self.msg: self.msg = self.msg + ['/var/log/nginx/*.error.log'] @@ -311,27 +318,27 @@ class EEDebugController(CementBaseController): elif not self.start and not self.app.pargs.site_name: if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " "/etc/nginx/nginx.conf"): - print("Disabling Nginx rewrite logs") + self.app.log.info("Disabling Nginx rewrite logs") EEShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\"" " /etc/nginx/nginx.conf") self.trigger_nginx = True else: - print("NGINX rewrite logs already disbaled") + self.app.log.info("NGINX rewrite logs already disbaled") # Start Nginx rewrite for site elif self.start and self.app.pargs.site_name: config_path = ("/etc/nginx/sites-available/{0}.conf" .format(self.app.pargs.site_name)) if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" .format(config_path)): - print("Setting up NGINX rewrite logs for {0}" - .format(self.app.pargs.site_name)) + self.app.log.info("Setting up NGINX rewrite logs for {0}" + .format(self.app.pargs.site_name)) EEShellExec.cmd_exec(self, "sed -i \"/access_log/i \\\\\\t" "rewrite_log on;\" {0}" .format(config_path)) self.trigger_nginx = True else: - print("Nginx rewrite logs for {0} allready setup" - .format(self.app.pargs.site_name)) + self.app.log.info("Nginx rewrite logs for {0} allready setup" + .format(self.app.pargs.site_name)) if ('/var/www/{0}/logs/error.log'.format(self.app.pargs.site_name) not in self.msg): @@ -344,14 +351,15 @@ class EEDebugController(CementBaseController): .format(self.app.pargs.site_name)) if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" .format(config_path)): - print("Disabling NGINX rewrite logs for {0}" - .format(self.app.pargs.site_name)) + self.app.log.info("Disabling NGINX rewrite logs for {0}" + .format(self.app.pargs.site_name)) EEShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\" {0}" .format(config_path)) self.trigger_nginx = True else: - print("Nginx rewrite logs for {0} allready disbaled" - .format(self.app.pargs.site_name)) + self.app.log.info("Nginx rewrite logs for {0} allready " + " disbaled" + .format(self.app.pargs.site_name)) @expose(hide=True) def default(self): @@ -398,8 +406,8 @@ class EEDebugController(CementBaseController): EEService.reload_service(self, ['php5-fpm']) if len(self.msg) > 0: - print("Use following command to check debug logs:\n{0}" - .format(self.msg.join())) + self.app.log.info("Use following command to check debug logs:" + "\n{0}".format(self.msg.join())) def load(app): From 5804eb8edc8adf25da6f077a8812a25b010a269c Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 5 Jan 2015 19:32:21 +0530 Subject: [PATCH 600/829] ee secure command --- config/plugins.d/secure.conf | 8 +++ ee/cli/plugins/secure.py | 116 +++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 config/plugins.d/secure.conf create mode 100644 ee/cli/plugins/secure.py diff --git a/config/plugins.d/secure.conf b/config/plugins.d/secure.conf new file mode 100644 index 00000000..b70f167b --- /dev/null +++ b/config/plugins.d/secure.conf @@ -0,0 +1,8 @@ +### Example Plugin Configuration for EasyEngine + +[secure] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py new file mode 100644 index 00000000..82dbdd01 --- /dev/null +++ b/ee/cli/plugins/secure.py @@ -0,0 +1,116 @@ +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +from ee.core.shellexec import EEShellExec +from ee.core.variables import EEVariables +import string +import random +import sys +import hashlib +import getpass + + +def secure_plugin_hook(app): + # do something with the ``app`` object here. + pass + + +class EEsecureController(CementBaseController): + class Meta: + label = 'secure' + stacked_on = 'base' + stacked_type = 'nested' + description = 'clean command cleans different cache with following \ + options' + arguments = [ + (['--auth'], + dict(help='secure auth', action='store_true')), + (['--port'], + dict(help='secure port', action='store_true')), + (['--ip'], + dict(help='secure ip', action='store_true')) + ] + + @expose(hide=True) + def default(self): + # TODO Default action for ee clean command here + if self.app.pargs.auth: + self.secure_auth() + if self.app.pargs.port: + self.secure_port() + if self.app.pargs.ip: + self.secure_ip() + + @expose(hide=True) + def secure_auth(self): + print("Securing auth.....") + passwd = ''.join([random.choice + (string.ascii_letters + string.digits) + for n in range(6)]) + username = input("Provide HTTP authentication user " + "name [{0}] :".format(EEVariables.ee_user)) + password = input("Provide HTTP authentication " + "password [{0}]".format(passwd)) + if password == "": + password = passwd + print(password) + if username == "": + username = EEVariables.ee_user + print(username) + EEShellExec.cmd_exec(self, "printf \"{username}:" + "$(openssl passwd -crypt " + "{password} 2> /dev/null)\n\"" + "> /etc/nginx/htpasswd-ee 2>/dev/null" + .format(username=username, + password=password)) + + @expose(hide=True) + def secure_port(self): + #TODO:remaining with ee.conf updation in file + port = input("EasyEngine admin port [22222]:") + if port == "": + port = 22222 + if EEVariables.ee_platform_distro == 'Ubuntu': + EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " + "{port} default_server ssl spdy;/\" " + "/etc/nginx/sites-available/22222" + .format(port=port)) + elif EEVariables.ee_platform_distro == 'Debian': + EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " + "{port} default_server ssl;/\" " + "/etc/nginx/sites-available/22222" + .format(port=port)) + + @expose(hide=True) + def secure_ip(self): + newlist = [] + ip = input("Enter the comma separated IP addresses " + "to white list [127.0.0.1]:") + ip_found = False + try: + user_list_ip = ip.split(',') + except Exception as e: + ip = ['127.0.0.1'] + self.app.config.set('mysql', 'grant-host', "hello") + exist_ip_list = self.app.config.get('stack', 'ip-address').split() + print(exist_ip_list) + for check_ip in user_list_ip: + if check_ip not in exist_ip_list: + newlist.extend(exist_ip_list) + else: + print("IP found") + # changes in acl.conf file + if len(newlist) != 0: + EEShellExec.cmd_exec(self, "sed -i \"/allow.*/d\" /etc/nginx" + "/common/acl.conf") + for whitelist_adre in newlist: + EEShellExec.cmd_exec(self, "sed -i \"/deny/i " + "echo allow {whitelist_adre}\\;\" " + "/etc/nginx/common/acl.conf" + .format(whitelist_adre=whitelist_adre)) + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EEsecureController) + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', secure_plugin_hook) From bbefe502b7a0493ce8d10d3ddb079ac7f09d6af7 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 5 Jan 2015 19:47:46 +0530 Subject: [PATCH 601/829] added log message in secure.py --- ee/cli/plugins/secure.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 82dbdd01..79bcc4cf 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -32,7 +32,6 @@ class EEsecureController(CementBaseController): @expose(hide=True) def default(self): - # TODO Default action for ee clean command here if self.app.pargs.auth: self.secure_auth() if self.app.pargs.port: @@ -42,7 +41,6 @@ class EEsecureController(CementBaseController): @expose(hide=True) def secure_auth(self): - print("Securing auth.....") passwd = ''.join([random.choice (string.ascii_letters + string.digits) for n in range(6)]) @@ -50,12 +48,14 @@ class EEsecureController(CementBaseController): "name [{0}] :".format(EEVariables.ee_user)) password = input("Provide HTTP authentication " "password [{0}]".format(passwd)) - if password == "": - password = passwd - print(password) if username == "": username = EEVariables.ee_user - print(username) + self.app.log.info("HTTP authentication username:{username}" + .format(username=username)) + if password == "": + password = passwd + self.app.log.info("HTTP authentication password:{password}" + .format(password=password)) EEShellExec.cmd_exec(self, "printf \"{username}:" "$(openssl passwd -crypt " "{password} 2> /dev/null)\n\"" @@ -65,7 +65,6 @@ class EEsecureController(CementBaseController): @expose(hide=True) def secure_port(self): - #TODO:remaining with ee.conf updation in file port = input("EasyEngine admin port [22222]:") if port == "": port = 22222 @@ -82,10 +81,10 @@ class EEsecureController(CementBaseController): @expose(hide=True) def secure_ip(self): + #TODO:remaining with ee.conf updation in file newlist = [] ip = input("Enter the comma separated IP addresses " "to white list [127.0.0.1]:") - ip_found = False try: user_list_ip = ip.split(',') except Exception as e: @@ -96,8 +95,6 @@ class EEsecureController(CementBaseController): for check_ip in user_list_ip: if check_ip not in exist_ip_list: newlist.extend(exist_ip_list) - else: - print("IP found") # changes in acl.conf file if len(newlist) != 0: EEShellExec.cmd_exec(self, "sed -i \"/allow.*/d\" /etc/nginx" From 1a1e95d8884e71c5eddd22547f7b88ce918e0e49 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 5 Jan 2015 20:17:04 +0530 Subject: [PATCH 602/829] minor fix --- ee/cli/plugins/site_functions.py | 99 ++++++++++++++++---------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index ba1c42f6..9377e712 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -6,6 +6,7 @@ import getpass from ee.core.fileutils import EEFileUtils from ee.core.mysql import EEMysql from ee.core.shellexec import EEShellExec +from ee.core.variables import EEVariables def setup_domain(self, data): @@ -64,8 +65,10 @@ def setup_database(self, data): prompt_dbuser = self.app.config.get('mysql', 'db-user') ee_mysql_host = self.app.config.get('mysql', 'grant-host') ee_db_name = '' + ee_db_username = '' + ee_db_password = '' - if prompt_dbname == 'True': + if prompt_dbname == 'True' or prompt_dbname == 'true': try: ee_db_name = input('Enter the MySQL database name [{0}]:' .format(ee_replace_dot)) @@ -76,7 +79,7 @@ def setup_database(self, data): if not ee_db_name: ee_db_name = ee_replace_dot - if prompt_dbuser: + if prompt_dbuser == 'True' or prompt_dbuser == 'true': try: ee_db_username = input('Enter the MySQL database user name [{0}]: ' .format(ee_replace_dot)) @@ -98,17 +101,19 @@ def setup_database(self, data): ee_db_name = (ee_db_name[0:6] + ee_random10) # create MySQL database - EEMysql.execute(self, "create database \'{0}\'" + EEMysql.execute(self, "create database {0}" .format(ee_db_name)) + print("create user {0}@{1} identified by '{2}'" + .format(ee_db_username, ee_mysql_host, ee_db_password)) # Create MySQL User EEMysql.execute(self, - "create user \'{0}\'@\'{1}\' identified by \'{2}\'" + "create user {0}@{1} identified by '{2}'" .format(ee_db_username, ee_mysql_host, ee_db_password)) # Grant permission 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_db_password)) data['ee_db_name'] = ee_db_name data['ee_db_user'] = ee_db_username @@ -126,59 +131,55 @@ def setup_wordpress(self, data): # Random characters ee_random = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 15))) + ee_wp_prefix = '' + ee_wp_user = '' + ee_wp_pass = '' + print("Downloading Wordpress, please wait...") EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") - setup_database(self, data) - if prompt_wpprefix == 'True': - ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' - .format(ee_replace_dot)) - while re.match('^[A-Za-z0-9_]*$', ee_wp_prefix): - print("Warning: table prefix can only contain numbers, letters," - "and underscores") - ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ') + data = setup_database(self, data) + if prompt_wpprefix == 'True' or prompt_wpprefix == 'true': + try: + ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' + .format(ee_replace_dot)) + while re.match('^[A-Za-z0-9_]*$', ee_wp_prefix): + print("Warning: table prefix can only contain numbers, " + "letters, and underscores") + ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' + ) + except EOFError as e: + print("{0} {1}".format(e.errorno, e.strerror)) + sys.exit(1) + if not ee_wp_prefix: ee_wp_prefix = 'wp_' # Modify wp-config.php & move outside the webroot - '''EEFileUtils.copyfile(self, - '{0}/htdocs/wp-config-sample.php' - .format(ee_site_webroot), - '{0}/wp-config.php'.format(ee_site_webroot)) - EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), - 'database_name_here', '') - EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), - 'database_name_here', '') - EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), - 'username_here', '') - EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), - 'password_here', '') - EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), - 'localhost', '') - EEFileUtils.searchreplace('{0}/wp-config.php'.format(ee_site_webroot), - 'wp_', '')''' EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) if not data['multisite']: - EEShellExec.cmd_exec(self, "wp --allow-root core config" - "--dbname={0} --dbprefix={1} --dbuser={2}" - .format(ee_db_name, ee_wp_prefix, ee_db_user) - + "--dbpass={0}".format(ee_db_password)) + print("Generating wp-config") + + EEShellExec.cmd_exec(self, "wp --allow-root core config " + + "--dbname={0} --dbprefix={1} --dbuser={2} " + .format(data['ee_db_name'], ee_wp_prefix, + data['ee_db_user']) + + "--dbpass={0}".format(data['ee_db_pass'])) else: - EEShellExec.cmd_exec(self, "wp --allow-root core config" - "--dbname={0} --dbprefix={1}" - .format(ee_db_name, ee_wp_prefix) + EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core config " + + "--dbname={0} --dbprefix={1} " + .format(data['ee_db_name'], ee_wp_prefix) + "--dbuser={0} --dbpass={1} --extra-php< Date: Tue, 6 Jan 2015 13:16:50 +0530 Subject: [PATCH 603/829] added urllib in clean_opcache --- ee/cli/plugins/clean.py | 24 +++++++++++++----------- ee/core/fileutils.py | 4 +--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 02444987..2971d942 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -4,6 +4,7 @@ from ee.core.services import EEService from cement.core.controller import CementBaseController, expose from cement.core import handler, hook import os +import urllib.request def clean_plugin_hook(app): @@ -51,29 +52,30 @@ class EECleanController(CementBaseController): print("in memcache..") pkg = EEAptGet() if(pkg.is_installed("memcached")): - print("memcache is installed...") + self.app.log.info("memcache is installed...") EEService.restart_service(self, "memcached") - print("Cleaning memcache..") + self.app.log.info("Cleaning memcache..") else: - print("memcache is not installed..") + self.app.log.info("memcache is not installed..") @expose(hide=True) def clean_fastcgi(self): if(os.path.isdir("/var/run/nginx-cache")): - print("Cleaning fastcgi...") + self.app.log.info("Cleaning fastcgi...") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") else: - print("Error occur while Cleaning fastcgi..") + self.app.log.info("Error occur while Cleaning fastcgi..") @expose(hide=True) def clean_opcache(self): + #try: try: - print("Cleaning opcache.... ") - EEShellExec.cmd_exec(self, "wget --no-check-certificate --spider" - " -q https://127.0.0.1:22222/cache/opcache" - "/opgui.php?page=reset") - except OSError: - print("Unable to clean opache..") + self.app.log.info("Cleaning opcache.... ") + wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" + "/opcache/opgui.php?page=reset").read() + except Exception as e: + self.app.log.info("Unable to clean opacache\n {0}{1}" + .format(e.errno, e.strerror)) def load(app): diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 9740ca42..c74ab885 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -15,15 +15,13 @@ class EEFileUtils(): def remove(self, filelist): for file in filelist: if os.path.isfile(file): - self.app.log.debug('Removing file') self.app.log.info("Removing "+os.path.basename(file)+" ...") os.remove(file) self.app.log.debug('file Removed') self.app.log.info("Done") if os.path.isdir(file): try: - self.app.log.debug('Removing file') - print("Removing "+os.path.basename(file)+" ...") + print("Removing "+os.path.basename(file)+"...") shutil.rmtree(file) self.app.log.info("Done") except shutil.Error as e: From ef0c3b8b27f8bc4d0adad74930a36d2fae8b99a8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 6 Jan 2015 14:57:26 +0530 Subject: [PATCH 604/829] Fixed Packages installation bug :) --- ee/cli/plugins/clean.py | 3 +- ee/cli/plugins/stack.py | 11 ++- ee/core/aptget.py | 155 ++++++++++++++++++++++------------------ 3 files changed, 91 insertions(+), 78 deletions(-) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 02444987..1cf8575c 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -49,8 +49,7 @@ class EECleanController(CementBaseController): @expose(hide=True) def clean_memcache(self): print("in memcache..") - pkg = EEAptGet() - if(pkg.is_installed("memcached")): + if(EEAptGet.is_installed("memcached")): print("memcache is installed...") EEService.restart_service(self, "memcached") print("Cleaning memcache..") diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9cabdb4d..2baed8fd 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -707,7 +707,6 @@ class EEStackController(CementBaseController): @expose() def install(self, packages=[], apt_packages=[]): - pkg = EEAptGet() if self.app.pargs.web: self.app.log.debug("Setting apt_packages variable for Nginx ,PHP" " ,MySQL ") @@ -798,9 +797,9 @@ class EEStackController(CementBaseController): self.pre_pref(apt_packages) if len(apt_packages): self.app.log.debug("Updating apt-cache") - pkg.update() + EEAptGet.update() self.app.log.debug("Installing all apt_packages") - pkg.install(apt_packages) + EEAptGet.install(apt_packages) if len(packages): self.app.log.debug("Downloading all packages") EEDownload.download(self, packages) @@ -809,7 +808,6 @@ class EEStackController(CementBaseController): @expose() def remove(self): - pkg = EEAptGet() apt_packages = [] packages = [] @@ -857,13 +855,12 @@ class EEStackController(CementBaseController): if len(apt_packages): self.app.log.debug("Removing apt_packages") - pkg.remove(self, apt_packages) + EEAptGet.remove(apt_packages) if len(packages): EEFileUtils.remove(self, packages) @expose() def purge(self): - pkg = EEAptGet() apt_packages = [] packages = [] @@ -910,7 +907,7 @@ class EEStackController(CementBaseController): ] if len(apt_packages): - pkg.remove(apt_packages, purge=True) + EEAptGet.remove(apt_packages, purge=True) if len(packages): EEFileUtils.remove(self, packages) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 645a40c8..069b8303 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -3,35 +3,36 @@ import apt import sys -class EEAptGet: +class EEAptGet(): """Generic apt-get intialisation""" - def __init__(self): - self.cache = apt.Cache() - self.fprogress = apt.progress.text.AcquireProgress() - self.iprogress = apt.progress.base.InstallProgress() - - def update(self): + def update(): """Similar to apt-get update""" - # self.app.log.debug("Update cache") - self.cache.update(self.fprogress) - self.cache.open() + # app.log.debug("Update cache") + cache = apt.Cache() + fprogress = apt.progress.text.AcquireProgress() + iprogress = apt.progress.base.InstallProgress() + cache.update(fprogress) + cache.close() - def upgrade(self, packages): + def upgrade(packages): """Similar to apt-get update""" + cache = apt.Cache() + fprogress = apt.progress.text.AcquireProgress() + iprogress = apt.progress.base.InstallProgress() my_selected_packages = [] # Cache Initialization - if not self.cache: - self.cache = apt.Cache() + if not cache: + cache = apt.Cache() # Cache Read - self.cache.open() + cache.open() for package in packages: - pkg = self.cache[package] + pkg = cache[package] # Check Package Installed if pkg.is_installed: # Check Package is Upgradeble if pkg.is_upgradable: - with self.cache.actiongroup(): + with cache.actiongroup(): # Mark Package for Upgrade pkg.mark_upgrade() my_selected_packages.append(pkg.installed) @@ -49,31 +50,34 @@ class EEAptGet: print("{pkg_install_count} newly installed." .format(pkg_upgrade_count=len(my_selected_packages))) print("Need to get {req_download} bytes of archives" - .format(req_download=self.cache.required_download)) + .format(req_download=cache.required_download)) print("After this operation, {space} bytes of" "additional disk space will be used." - .format(space=self.cache.required_space)) + .format(space=cache.required_space)) try: # Commit changes in cache (actually install) - self.cache.commit(self.fprogress, self.iprogress) + cache.commit(fprogress, iprogress) except Exception as e: print("package installation failed. [{err}]" .format(err=str(e))) return(False) return(True) - def install(self, packages): + def install(packages): """Installation of packages""" + cache = apt.Cache() + fprogress = apt.progress.text.AcquireProgress() + iprogress = apt.progress.base.InstallProgress() my_selected_packages = [] # Cache Initialization - if not self.cache: - self.cache = apt.Cache() + if not cache: + cache = apt.Cache() # Cache Read - self.cache.open() + cache.open() for package in packages: try: - pkg = self.cache[package] + pkg = cache[package] except KeyError as e: continue # Check Package Installed @@ -90,63 +94,68 @@ class EEAptGet: .format(package_name=pkg.shortname, package_ver=pkg.installed)) else: - with self.cache.actiongroup(): + with cache.actiongroup(): # Mark Package for Installation pkg.mark_install() my_selected_packages.append(pkg.name) # Check if packages available for install. - if self.cache.install_count > 0: + if cache.install_count > 0: print("The following NEW packages will be installed:" "\n {pkg_name}" .format(pkg_name=my_selected_packages)) print("{pkg_install_count} newly installed." - .format(pkg_install_count=self.cache.install_count)) + .format(pkg_install_count=cache.install_count)) print("Need to get {req_download} bytes of archives" - .format(req_download=self.cache.required_download)) + .format(req_download=cache.required_download)) print("After this operation, {space} bytes of" "additional disk space will be used." - .format(space=self.cache.required_space)) + .format(space=cache.required_space)) try: # Commit changes in cache (actually install) - self.cache.commit(self.fprogress, self.iprogress) + cache.commit(fprogress, iprogress) except Exception as e: print("package installation failed. [{err}]" .format(err=str(e))) return(False) + cache.close() + cache.close() return(True) - def __dependencies_loop(self, deplist, pkg, onelevel=False): - """ Loops through pkg's dependencies. - Returns a list with every package found. """ - if not self.cache: - self.cache = apt.Cache() - if onelevel: - onelevellist = [] - if not pkg.is_installed: - return - for depf in pkg.installed.dependencies: - for dep in depf: - if (dep.name in self.cache and not self.cache[dep.name] - in deplist): - deplist.append(self.cache[dep.name]) - self.__dependencies_loop(deplist, self.cache[dep.name]) - if onelevel: - if dep.name in self.cache: - onelevellist.append(self.cache[dep.name]) - if onelevel: - return onelevellist + def remove(packages, auto=True, purge=False): + def __dependencies_loop(cache, deplist, pkg, onelevel=True): + """ Loops through pkg's dependencies. + Returns a list with every package found. """ + print("Inside") + if onelevel: + onelevellist = [] + if not pkg.is_installed: + return + for depf in pkg.installed.dependencies: + for dep in depf: + if (dep.name in cache and not cache[dep.name] + in deplist): + deplist.append(cache[dep.name]) + __dependencies_loop(cache, deplist, cache[dep.name]) + if onelevel: + if dep.name in cache: + onelevellist.append(cache[dep.name]) + if onelevel: + return onelevellist + + cache = apt.Cache() + fprogress = apt.progress.text.AcquireProgress() + iprogress = apt.progress.base.InstallProgress() - def remove(self, packages, auto=True, purge=False): my_selected_packages = [] # Cache Initialization - if not self.cache: - self.cache = apt.Cache() + if not cache: + cache = apt.Cache() # Cache Read - self.cache.open() + cache.open() for package in packages: print("processing", package) - package = self.cache[package] + package = cache[package] if not package.is_installed: print("Package '{package_name}' is not installed," " so not removed." @@ -162,8 +171,8 @@ class EEAptGet: # 2) We sequentially remove every package in list # - via is_auto_installed we check if we can safely remove it deplist = [] - onelevel = self.__dependencies_loop(deplist, package, - onelevel=True) + onelevel = __dependencies_loop(cache, deplist, package, + onelevel=True) # Mark for deletion the first package, to fire up auto_removable # Purge? if purge: @@ -201,34 +210,42 @@ class EEAptGet: pkg.mark_auto(auto=False) # Check if packages available for remove/update. - if self.cache.delete_count > 0: - # self.app.log.debug('packages will be REMOVED ') + if cache.delete_count > 0: + # app.log.debug('packages will be REMOVED ') print("The following packages will be REMOVED:" "\n {pkg_name}" .format(pkg_name=my_selected_packages)) print("{pkg_remove_count} to remove." - .format(pkg_remove_count=self.cache.delete_count)) - # self.app.log.debug('bytes disk space will be freed') + .format(pkg_remove_count=cache.delete_count)) + # app.log.debug('bytes disk space will be freed') print("After this operation, {space} bytes disk spac" - "e will be freed.".format(space=self.cache.required_space)) + "e will be freed.".format(space=cache.required_space)) try: - self.cache.commit(self.fprogress, self.iprogress) + cache.commit(fprogress, iprogress) except Exception as e: - # self.app.log.error('Sorry, package installation failed ') + # app.log.error('Sorry, package installation failed ') print("Sorry, package installation failed [{err}]" .format(err=str(e))) + cache.close() return(False) + cache.close() return(True) - def is_installed(self, package): + def is_installed(package): + cache = apt.Cache() + fprogress = apt.progress.text.AcquireProgress() + iprogress = apt.progress.base.InstallProgress() + # Cache Initialization - if not self.cache: - self.cache = apt.Cache() + if not cache: + cache = apt.Cache() # Cache Read - self.cache.open() - pkg = self.cache[package] + cache.open() + pkg = cache[package] # Check Package Installed if pkg.is_installed: + cache.close() return True else: + cache.close() return False From a1c31cd3db2fa721ed0414aa2339f4128e9fe314 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 6 Jan 2015 15:02:05 +0530 Subject: [PATCH 605/829] added permission methods --- ee/cli/plugins/site.py | 11 ++++++++--- ee/cli/plugins/site_functions.py | 22 +++++++++++++--------- ee/core/fileutils.py | 30 ++++++++++++++++++++++++++++++ ee/core/permissions.py | 3 +++ 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 8aa160d1..5303091c 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -249,11 +249,16 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='') - setup_domain(self, data) + # setup NGINX configuration, and webroot + SetupDomain(self, data) + # Setup database for MySQL site if 'ee_db_name' in data.keys() and not data['wp']: - data = setup_database(self, data) + data = SetupDatabase(self, data) + # Setup WordPress if Wordpress site if data['wp']: - setup_wordpress(self, data) + ee_wp_creds = SetupWordpress(self, data) + + # TODO setup Perissions for webroot class EESiteUpdateController(CementBaseController): diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 9377e712..c0262688 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -9,7 +9,7 @@ from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables -def setup_domain(self, data): +def SetupDomain(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] @@ -56,7 +56,7 @@ def setup_domain(self, data): .format(ee_site_webroot)]) -def setup_database(self, data): +def SetupDatabase(self, data): ee_domain_name = data['site_name'] ee_random = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 15))) @@ -121,7 +121,7 @@ def setup_database(self, data): return data -def setup_wordpress(self, data): +def SetupWordpress(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] prompt_wpprefix = self.app.config.get('wordpress', 'prefix') @@ -139,7 +139,7 @@ def setup_wordpress(self, data): EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") - data = setup_database(self, data) + data = SetupDatabase(self, data) if prompt_wpprefix == 'True' or prompt_wpprefix == 'true': try: ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' @@ -219,25 +219,29 @@ def setup_wordpress(self, data): "/%year%/%monthnum%/%day%/%postname%/") """Install nginx-helper plugin """ - install_wp_plugin(self, 'nginx-helper', data) + InstallWP_Plugin(self, 'nginx-helper', data) """Install Wp Super Cache""" if data['wpsc']: - install_wp_plugin(self, 'wp-super-cache', data) + InstallWP_Plugin(self, 'wp-super-cache', data) """Install W3 Total Cache""" if data['w3tc'] or data['wpfc']: - install_wp_plugin(self, 'w3-total-cache', data) + InstallWP_Plugin(self, 'w3-total-cache', data) + wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass, + wp_email=ee_wp_email) + return wp_creds -def setup_wordpress_network(self, data): + +def SetupWordpressNetwork(self, data): ee_site_webroot = data['webroot'] EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert' '--title=') -def install_wp_plugin(self, plugin_name, data): +def InstallWP_Plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] print("Installing plugin {0}".format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 9740ca42..c220f3a9 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -79,3 +79,33 @@ class EEFileUtils(): self.app.log.error('Unable to Change Directory {err}' .format(err=e.strerror)) sys.exit(1) + + def chown(self, path, user, group, recursive=False): + try: + if recursive: + for root, dirs, files in os.walk(path): + for d in dirs: + shutil.chown(os.path.join(root, d), user=user, + group=group) + for f in files: + shutil.chown(os.path.join(root, f), user=user, + group=group) + else: + shutil.chown(path, user=user, group=group) + except shutil.Error as e: + self.log.error("Unable to change owner {0}".format(e.strerror)) + sys.exit(1) + + def chmod(self, path, perm, recursive=False): + try: + if recursive: + for root, dirs, files in os.walk(path): + for d in dirs: + os.chmod(os.path.join(root, d), perm) + for f in files: + os.chmod(os.path.join(root, f), perm) + else: + os.chmod(path, perm) + except OSError as e: + self.log.error("Unable to change owner {0}".format(e.strerror)) + sys.exit(1) diff --git a/ee/core/permissions.py b/ee/core/permissions.py index d0f93623..9de98330 100644 --- a/ee/core/permissions.py +++ b/ee/core/permissions.py @@ -6,3 +6,6 @@ class EESetPermission(): def ___init__(): # TODO method for set permission pass + + def setPermissions(self, user, group, path, recursive=False): + pass From c2cab4f6432dcd0033b618df79b02be12c70bc35 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 6 Jan 2015 18:08:03 +0530 Subject: [PATCH 606/829] Fixed MySQL installation --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 2baed8fd..c0f4cdb8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -93,7 +93,7 @@ class EEStackController(CementBaseController): "password {chars}\" | " "debconf-set-selections".format(chars=chars)) mysql_config = """ - [mysqld] + [client] user = root password = {chars} """.format(chars=chars) From 0b280562221331fec682f0bad6b0d1a6a2f0ad20 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 6 Jan 2015 18:57:06 +0530 Subject: [PATCH 607/829] Fixed Nginx configuration bug --- ee/cli/plugins/stack.py | 212 ++++++++++++++++++++-------------------- ee/core/aptget.py | 1 - 2 files changed, 107 insertions(+), 106 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c0f4cdb8..376a8924 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -141,111 +141,113 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): pass if set(EEVariables.ee_nginx).issubset(set(apt_packages)): - # Nginx core configuration change using configparser - nc = NginxConfig() - self.app.log.debug('Loading file /etc/nginx/nginx.conf ') - nc.loadf('/etc/nginx/nginx.conf') - nc.set('worker_processes', 'auto') - nc.append(('worker_rlimit_nofile', '100000'), position=2) - nc.remove(('events', '')) - nc.append({'name': 'events', 'param': '', 'value': - [('worker_connections', '4096'), - ('multi_accept', 'on')]}, position=4) - nc.set([('http',), 'keepalive_timeout'], '30') - self.app.log.debug("Writting nginx configration to " - "file /etc/nginx/nginx.conf ") - nc.savef('/etc/nginx/nginx.conf') - - # Custom Nginx configuration by EasyEngine - data = dict(version='EasyEngine 3.0.1') - self.app.log.debug('writting the nginx configration to file' - '/etc/nginx/conf.d/ee-nginx.conf ') - ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') - self.app.render((data), 'nginx-core.mustache', out=ee_nginx) - ee_nginx.close() - - data = dict() - self.app.log.debug('writting the nginx configration to file' - '/etc/nginx/conf.d/blockips.conf ') - ee_nginx = open('/etc/nginx/conf.d/blockips.conf', 'w') - self.app.render((data), 'blockips.mustache', out=ee_nginx) - ee_nginx.close() - - self.app.log.debug('writting the nginx configration to file' - '/etc/nginx/conf.d/fastcgi.conf ') - ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf', 'w') - self.app.render((data), 'fastcgi.mustache', out=ee_nginx) - ee_nginx.close() - - data = dict(php="9000", debug="9001") - self.app.log.debug('writting the nginx configration to file' - '/etc/nginx/conf.d/upstream.conf ') - ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') - self.app.render((data), 'upstream.mustache', out=ee_nginx) - ee_nginx.close() - - # Setup Nginx common directory - if not os.path.exists('/etc/nginx/common'): - self.app.log.debug('Creating directory' - '/etc/nginx/common') - os.makedirs('/etc/nginx/common') - - data = dict() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/acl.conf') - ee_nginx = open('/etc/nginx/common/acl.conf', 'w') - self.app.render((data), 'acl.mustache', - out=ee_nginx) - ee_nginx.close() - - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/locations.conf') - ee_nginx = open('/etc/nginx/common/locations.conf', 'w') - self.app.render((data), 'locations.mustache', - out=ee_nginx) - ee_nginx.close() - - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/ php.conf') - ee_nginx = open('/etc/nginx/common/php.conf', 'w') - self.app.render((data), 'php.mustache', - out=ee_nginx) - ee_nginx.close() - - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/w3tc.conf') - ee_nginx = open('/etc/nginx/common/w3tc.conf', 'w') - self.app.render((data), 'w3tc.mustache', - out=ee_nginx) - ee_nginx.close() - - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/wpcommon.conf') - ee_nginx = open('/etc/nginx/common/wpcommon.conf', 'w') - self.app.render((data), 'wpcommon.mustache', - out=ee_nginx) - ee_nginx.close() - - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/wpfc.conf') - ee_nginx = open('/etc/nginx/common/wpfc.conf', 'w') - self.app.render((data), 'wpfc.mustache', - out=ee_nginx) - ee_nginx.close() - - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/wpsc.conf') - ee_nginx = open('/etc/nginx/common/wpsc.conf', 'w') - self.app.render((data), 'wpsc.mustache', - out=ee_nginx) - ee_nginx.close() - - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/wpsubdir.conf') - ee_nginx = open('/etc/nginx/common/wpsubdir.conf', 'w') - self.app.render((data), 'wpsubdir.mustache', - out=ee_nginx) - ee_nginx.close() + if ((not os.path.isfile('/etc/nginx/conf.d/ee-nginx.conf')) and + os.path.isfile('/etc/nginx/nginx.conf')): + nc = NginxConfig() + self.app.log.debug('Loading file /etc/nginx/nginx.conf ') + nc.loadf('/etc/nginx/nginx.conf') + nc.set('worker_processes', 'auto') + nc.append(('worker_rlimit_nofile', '100000'), position=2) + nc.remove(('events', '')) + nc.append({'name': 'events', 'param': '', 'value': + [('worker_connections', '4096'), + ('multi_accept', 'on')]}, position=4) + nc.set([('http',), 'keepalive_timeout'], '30') + self.app.log.debug("Writting nginx configration to " + "file /etc/nginx/nginx.conf ") + nc.savef('/etc/nginx/nginx.conf') + + # Custom Nginx configuration by EasyEngine + data = dict(version='EasyEngine 3.0.1') + self.app.log.debug('writting the nginx configration to ' + 'file /etc/nginx/conf.d/ee-nginx.conf ') + ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') + self.app.render((data), 'nginx-core.mustache', + out=ee_nginx) + ee_nginx.close() + + data = dict() + self.app.log.debug('writting the nginx configration to' + 'file /etc/nginx/conf.d/blockips.conf') + ee_nginx = open('/etc/nginx/conf.d/blockips.conf', 'w') + self.app.render((data), 'blockips.mustache', out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('writting the nginx configration to' + ' file /etc/nginx/conf.d/fastcgi.conf') + ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf', 'w') + self.app.render((data), 'fastcgi.mustache', out=ee_nginx) + ee_nginx.close() + + data = dict(php="9000", debug="9001") + self.app.log.debug('writting the nginx configration to' + 'file /etc/nginx/conf.d/upstream.conf ') + ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') + self.app.render((data), 'upstream.mustache', out=ee_nginx) + ee_nginx.close() + + # Setup Nginx common directory + if not os.path.exists('/etc/nginx/common'): + self.app.log.debug('Creating directory' + '/etc/nginx/common') + os.makedirs('/etc/nginx/common') + + data = dict() + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/acl.conf') + ee_nginx = open('/etc/nginx/common/acl.conf', 'w') + self.app.render((data), 'acl.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/locations.conf') + ee_nginx = open('/etc/nginx/common/locations.conf', 'w') + self.app.render((data), 'locations.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/ php.conf') + ee_nginx = open('/etc/nginx/common/php.conf', 'w') + self.app.render((data), 'php.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/w3tc.conf') + ee_nginx = open('/etc/nginx/common/w3tc.conf', 'w') + self.app.render((data), 'w3tc.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/wpcommon.conf') + ee_nginx = open('/etc/nginx/common/wpcommon.conf', 'w') + self.app.render((data), 'wpcommon.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/wpfc.conf') + ee_nginx = open('/etc/nginx/common/wpfc.conf', 'w') + self.app.render((data), 'wpfc.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/wpsc.conf') + ee_nginx = open('/etc/nginx/common/wpsc.conf', 'w') + self.app.render((data), 'wpsc.mustache', + out=ee_nginx) + ee_nginx.close() + + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/wpsubdir.conf') + ee_nginx = open('/etc/nginx/common/wpsubdir.conf', 'w') + self.app.render((data), 'wpsubdir.mustache', + out=ee_nginx) + ee_nginx.close() if set(EEVariables.ee_php).issubset(set(apt_packages)): # Parse etc/php5/fpm/php.ini diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 069b8303..29a78833 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -126,7 +126,6 @@ class EEAptGet(): def __dependencies_loop(cache, deplist, pkg, onelevel=True): """ Loops through pkg's dependencies. Returns a list with every package found. """ - print("Inside") if onelevel: onelevellist = [] if not pkg.is_installed: From 5a12ab70c7efd74b52e8029c0f92b532fb03b1c7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 6 Jan 2015 19:03:38 +0530 Subject: [PATCH 608/829] Tweaked repo adding --- ee/core/apt_repo.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 8ad22f34..3b3372b8 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -17,9 +17,10 @@ class EERepo(): repo_file_path = ("/etc/apt/sources.list.d/" + EEVariables().ee_repo_file) try: - with open(repo_file_path, "a") as repofile: - repofile.write(repo_url) - repofile.close() + if repo_url not in open(repo_file_path).read(): + with open(repo_file_path, "a") as repofile: + repofile.write(repo_url) + repofile.close() return True except IOError as e: print("File I/O error({0}): {1}".format(e.errno, e.strerror)) From 2950436dd580020f0b093dc054a50861d4385e77 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 7 Jan 2015 13:24:48 +0530 Subject: [PATCH 609/829] Added Swap creation --- ee/cli/plugins/stack.py | 2 ++ ee/core/addswap.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 ee/core/addswap.py diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 376a8924..7bc0bac1 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -10,6 +10,7 @@ from ee.core.fileutils import EEFileUtils from ee.core.apt_repo import EERepo from ee.core.extract import EEExtract from ee.core.mysql import EEMysql +from ee.core.addswap import EESwap from pynginxconfig import NginxConfig import random import string @@ -798,6 +799,7 @@ class EEStackController(CementBaseController): self.app.log.debug("Calling pre_pref ") self.pre_pref(apt_packages) if len(apt_packages): + EESwap.add(self) self.app.log.debug("Updating apt-cache") EEAptGet.update() self.app.log.debug("Installing all apt_packages") diff --git a/ee/core/addswap.py b/ee/core/addswap.py new file mode 100644 index 00000000..6ae7d009 --- /dev/null +++ b/ee/core/addswap.py @@ -0,0 +1,24 @@ +from ee.core.variables import EEVariables +from ee.core.shellexec import EEShellExec +from ee.core.fileutils import EEFileUtils + + +class EESwap(): + """Manage Swap""" + + def __init__(): + """Initialize """ + pass + + def add(self): + if EEVariables.ee_ram < 512: + if EEVariables.ee_swap < 1000: + self.app.log.info("Adding SWAP") + EEShellExec.cmd_exec(self, "dd if=/dev/zero of=/ee-swapfile " + "bs=1024 count=1048k") + EEShellExec.cmd_exec(self, "mkswap /ee-swapfile") + EEFileUtils.chown(self, "/ee-swapfile", "root", "root") + EEFileUtils.chmod(self, "/ee-swapfile", 0o600) + EEShellExec.cmd_exec(self, "swapon /ee-swapfile") + with open("/etc/fstab", "a") as swap_file: + myfile.write("/ee-swapfile\tnone\tswap\tsw\t0 0") From 0e9a1ed7409fd7076995c302476d7bd80161deb4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 7 Jan 2015 13:41:34 +0530 Subject: [PATCH 610/829] Fixed some PHP bugs --- ee/cli/plugins/stack.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 7bc0bac1..793d8fe1 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -251,6 +251,11 @@ class EEStackController(CementBaseController): ee_nginx.close() if set(EEVariables.ee_php).issubset(set(apt_packages)): + # Create log directories + if not os.path.exists('/var/log/php5/'): + self.app.log.debug('Creating directory /var/log/php5/') + os.makedirs('/var/log/php5/') + # Parse etc/php5/fpm/php.ini config = configparser.ConfigParser() self.app.log.debug("configring php file /etc/php5/fpm/php.ini") @@ -280,7 +285,7 @@ class EEStackController(CementBaseController): config['www']['ping.path'] = '/ping' config['www']['pm.status_path'] = '/status' config['www']['pm.max_requests'] = '500' - config['www']['pm.max_children'] = '' + config['www']['pm.max_children'] = '100' config['www']['pm.start_servers'] = '20' config['www']['pm.min_spare_servers'] = '10' config['www']['pm.max_spare_servers'] = '30' From 48444c2102d2f8021b9802843a1a59daf5b7d545 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 7 Jan 2015 17:44:08 +0530 Subject: [PATCH 611/829] working ee site create --- ee/cli/plugins/site.py | 163 +++++++++++++++++++------------ ee/cli/plugins/site_functions.py | 70 ++++++++----- ee/core/domainvalidate.py | 5 +- ee/core/fileutils.py | 5 +- ee/core/services.py | 8 +- ee/core/shellexec.py | 11 ++- ee/core/variables.py | 2 + 7 files changed, 162 insertions(+), 102 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 5303091c..eeb39b13 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -2,9 +2,10 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.variables import EEVariables -from ee.core.domainvalidate import validate_domain +from ee.core.domainvalidate import ValidateDomain from ee.core.fileutils import EEFileUtils from ee.cli.plugins.site_functions import * +from ee.core.services import EEService import sys import os @@ -113,152 +114,184 @@ class EESiteCreateController(CementBaseController): # data = dict(foo='EESiteCreateController.default().') # self.app.render((data), 'default.mustache') # Check domain name validation - ee_domain_name = validate_domain(self.app.pargs.site_name) - ee_site_webroot = EEVariables.ee_webroot + ee_domain_name + (ee_domain, + ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + ee_site_webroot = EEVariables.ee_webroot + ee_domain # Check if doain previously exists or not if os.path.isfile('/etc/nginx/sites-available/{0}.conf' - .format(ee_domain_name)): + .format(ee_domain)): self.app.log.error("site {0} already exists" - .format(ee_domain_name)) - return False + .format(ee_domain)) + sys.exit(1) # setup nginx configuration for site + # HTmL if (self.app.pargs.html and not (self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=True, basic=False, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot) + #PHP if (self.app.pargs.php and not (self.app.pargs.html or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or - self.app.pargs.wsubdir or self.app.pargs.wsubdomain)): - data = dict(site_name=ee_domain_name, + self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot) - + #ySQL if (self.app.pargs.mysql and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or - self.app.pargs.wsubdir or self.app.pargs.wsubdomain)): - data = dict(site_name=ee_domain_name, + self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') - + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') + #WP if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc) and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): if (self.app.pargs.wp and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=False, wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') - + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') + #WPSUBDIR if (self.app.pargs.wpsubdir and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdomain or self.app.pargs.wp)): + print("Inside wpsubdir") if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=True, wpsubdir=True, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, wpsubdir=True, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, wpsubdir=True, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - data = dict(site_name=ee_domain_name, + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, wpsubdir=True, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') - - if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or - self.app.pargs.php or self.app.pargs.mysql or - self.app.pargs.wpsubdir or self.app.pargs.wp)): - if (self.app.pargs.wpsubdomain and not (self.app.pargs.w3tc - or self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=ee_domain_name, - static=False, basic=True, wp=True, w3tc=False, - wpfc=False, wpsc=False, multisite=True, - wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') - if (self.app.pargs.w3tc and not - (self.app.pargs.wpfc or self.app.pargs.wpsc)): - data = dict(site_name=ee_domain_name, - static=False, basic=False, wp=True, w3tc=True, - wpfc=False, wpsc=False, multisite=True, - wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') - if (self.app.pargs.wpfc and not - (self.app.pargs.wpsc or self.app.pargs.w3tc)): - data = dict(site_name=ee_domain_name, - static=False, basic=False, wp=True, w3tc=False, - wpfc=True, wpsc=False, multisite=True, - wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') - if (self.app.pargs.wpsc and not - (self.app.pargs.w3tc or self.app.pargs.wpfc)): - data = dict(site_name=ee_domain_name, - static=False, basic=False, wp=True, w3tc=False, - wpfc=False, wpsc=True, multisite=True, - wpsubdir=False, webroot=ee_site_webroot, - ee_db_name='', ee_db_user='', ee_db_pass='') + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') + #WPSUBDOAIN + if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.mysql or + self.app.pargs.wpsubdir or self.app.pargs.wp)): + if (self.app.pargs.wpsubdomain and not (self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') + if (self.app.pargs.w3tc and not + (self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=True, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') + if (self.app.pargs.wpfc and not + (self.app.pargs.wpsc or self.app.pargs.w3tc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=False, + wpfc=True, wpsc=False, multisite=True, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') + if (self.app.pargs.wpsc and not + (self.app.pargs.w3tc or self.app.pargs.wpfc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=False, + wpfc=False, wpsc=True, multisite=True, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='') # setup NGINX configuration, and webroot SetupDomain(self, data) # Setup database for MySQL site if 'ee_db_name' in data.keys() and not data['wp']: data = SetupDatabase(self, data) + eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), 'w') + eedbconfig.write("" + .format(data['ee_db_name'], data['ee_db_user'], + data['ee_db_pass'], data['ee_db_host'])) + eedbconfig.close() # Setup WordPress if Wordpress site if data['wp']: ee_wp_creds = SetupWordpress(self, data) - - # TODO setup Perissions for webroot + # Service Nginx Reload + EEService.reload_service(self, 'nginx') + # Setup Permissions for webroot + SetWebrootPermissions(self, data['webroot']) + if data['wp']: + print("WordPress Admin User : {0}".format(ee_wp_creds['wp_user'])) + print("WordPress Admin User Password : {0}" + .format(ee_wp_creds['wp_pass'])) + print("Successfully created site http://{0}".format(ee_www_domain)) class EESiteUpdateController(CementBaseController): diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index c0262688..e1927de5 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -101,11 +101,10 @@ def SetupDatabase(self, data): ee_db_name = (ee_db_name[0:6] + ee_random10) # create MySQL database + print("Setting Up Database for {0}...".format(ee_domain_name)) EEMysql.execute(self, "create database {0}" .format(ee_db_name)) - print("create user {0}@{1} identified by '{2}'" - .format(ee_db_username, ee_mysql_host, ee_db_password)) # Create MySQL User EEMysql.execute(self, "create user {0}@{1} identified by '{2}'" @@ -114,11 +113,12 @@ def SetupDatabase(self, data): # Grant permission EEMysql.execute(self, "grant all privileges on {0}.* to {1}@{2}" - .format(ee_db_name, ee_db_username, ee_db_password)) + .format(ee_db_name, ee_db_username, ee_mysql_host)) data['ee_db_name'] = ee_db_name data['ee_db_user'] = ee_db_username data['ee_db_pass'] = ee_db_password - return data + data['ee_db_host'] = ee_mysql_host + return(data) def SetupWordpress(self, data): @@ -159,24 +159,25 @@ def SetupWordpress(self, data): # Modify wp-config.php & move outside the webroot EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) + print("Setting up WordPress Configuration...") if not data['multisite']: - print("Generating wp-config") - EEShellExec.cmd_exec(self, "wp --allow-root core config " + "--dbname={0} --dbprefix={1} --dbuser={2} " .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_user']) + "--dbpass={0}".format(data['ee_db_pass'])) - else: EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core config " + "--dbname={0} --dbprefix={1} " .format(data['ee_db_name'], ee_wp_prefix) - + "--dbuser={0} --dbpass={1} --extra-php< Date: Wed, 7 Jan 2015 17:44:50 +0530 Subject: [PATCH 612/829] Fixed issue in PHP, Added Swap creation --- ee/cli/plugins/stack.py | 13 ++++++ ee/core/addswap.py | 2 +- ee/core/aptget.py | 95 ++++++++++++++++++++++------------------- ee/core/fileutils.py | 5 ++- ee/core/variables.py | 5 ++- 5 files changed, 72 insertions(+), 48 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 793d8fe1..f15bdbb7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -297,6 +297,19 @@ class EEStackController(CementBaseController): " /etc/php5/fpm/pool.d/www.conf") config.write(configfile) + # Generate /etc/php5/fpm/pool.d/debug.conf + EEFileUtils.copyfile(self, "/etc/php5/fpm/pool.d/www.conf", + "/etc/php5/fpm/pool.d/debug.conf") + EEFileUtils.searchreplace(self, "/etc/php5/fpm/pool.d/" + "debug.conf", "[www]", "[debug]") + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/pool.d/debug.conf') + config['debug']['listen'] = '127.0.0.1:9001' + with open('/etc/php5/fpm/pool.d/debug.conf', 'w') as confifile: + self.app.log.debug("writting PHP5 configartion into " + " /etc/php5/fpm/pool.d/debug.conf") + config.write(confifile) + if set(EEVariables.ee_mysql).issubset(set(apt_packages)): config = configparser.ConfigParser() config.read('/etc/mysql/my.cnf') diff --git a/ee/core/addswap.py b/ee/core/addswap.py index 6ae7d009..192ba79d 100644 --- a/ee/core/addswap.py +++ b/ee/core/addswap.py @@ -21,4 +21,4 @@ class EESwap(): EEFileUtils.chmod(self, "/ee-swapfile", 0o600) EEShellExec.cmd_exec(self, "swapon /ee-swapfile") with open("/etc/fstab", "a") as swap_file: - myfile.write("/ee-swapfile\tnone\tswap\tsw\t0 0") + swap_file.write("/ee-swapfile\tnone\tswap\tsw\t0 0") diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 29a78833..2ab468c3 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -161,52 +161,61 @@ class EEAptGet(): .format(package_name=package.name)) continue if package.marked_delete: + my_selected_packages.append(package.name) + # Mark for deletion the first package, to fire up + # auto_removable Purge? + if purge: + package.mark_delete(purge=True) + else: + package.mark_delete(purge=False) continue else: my_selected_packages.append(package.name) - # How logic works: - # 1) We loop trough dependencies's dependencies and add them to - # the list. - # 2) We sequentially remove every package in list - # - via is_auto_installed we check if we can safely remove it - deplist = [] - onelevel = __dependencies_loop(cache, deplist, package, - onelevel=True) - # Mark for deletion the first package, to fire up auto_removable - # Purge? - if purge: - package.mark_delete(purge=True) - else: - package.mark_delete(purge=False) - # Also ensure we remove AT LEAST the first level of dependencies - # (that is, the actual package's dependencies). - if auto: - markedauto = [] - for pkg in onelevel: - if (not pkg.marked_install and pkg.is_installed - and not pkg.is_auto_installed): - pkg.mark_auto() - markedauto.append(pkg) - - for pkg in deplist: - if (not pkg.marked_install and pkg.is_installed and - pkg.is_auto_removable): - # Purge? - if purge: - pkg.mark_delete(purge=True) - else: - pkg.mark_delete(purge=False) - # Restore auted items - for pkg in markedauto: - if not pkg.marked_delete: - pkg.mark_auto(False) - else: - # We need to ensure that the onelevel packages are not marked - # as automatically installed, otherwise the user may drop - # them via autoremove or aptitude. - for pkg in onelevel: - if pkg.is_installed and pkg.is_auto_installed: - pkg.mark_auto(auto=False) + print(my_selected_packages) + # How logic works: + # 1) We loop trough dependencies's dependencies and add them to + # the list. + # 2) We sequentially remove every package in list + # - via is_auto_installed we check if we can safely remove it + deplist = [] + onelevel = __dependencies_loop(cache, deplist, package, + onelevel=True) + # Mark for deletion the first package, to fire up + # auto_removable Purge? + if purge: + package.mark_delete(purge=True) + else: + package.mark_delete(purge=False) + + # Also ensure we remove AT LEAST the first level of + # dependencies (that is, the actual package's dependencies). + if auto: + markedauto = [] + for pkg in onelevel: + if (not pkg.marked_install and pkg.is_installed + and not pkg.is_auto_installed): + pkg.mark_auto() + markedauto.append(pkg) + + for pkg in deplist: + if (not pkg.marked_install and pkg.is_installed and + pkg.is_auto_removable): + # Purge? + if purge: + pkg.mark_delete(purge=True) + else: + pkg.mark_delete(purge=False) + # Restore auted items + for pkg in markedauto: + if not pkg.marked_delete: + pkg.mark_auto(False) + else: + # We need to ensure that the onelevel packages are not + # marked as automatically installed, otherwise the user may + # drop them via autoremove or aptitude. + for pkg in onelevel: + if pkg.is_installed and pkg.is_auto_installed: + pkg.mark_auto(auto=False) # Check if packages available for remove/update. if cache.delete_count > 0: diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 7250adcc..0199a463 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -47,7 +47,7 @@ class EEFileUtils(): .format(e.errno, e.strerror)) sys.exit(1) - def copyfile(self, src, dst): + def copyfile(self, src, dest): try: shutil.copy2(src, dest) except shutil.Error as e: @@ -58,7 +58,8 @@ class EEFileUtils(): def searchreplace(self, fnm, sstr, rstr): try: for line in fileinput.input(fnm, inplace=True): - print(line.replace(textToSearch, textToReplace), end='') + print(line.replace(sstr, rstr), end='') + fileinput.close() except Exception as e: print('Error : {0}'.format(e)) diff --git a/ee/core/variables.py b/ee/core/variables.py index 043e69f9..e8dc451c 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -52,8 +52,9 @@ class EEVariables(): elif ee_platform_codename == 'wheezy': ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all" .format(codename=ee_platform_codename)) - ee_php = ["php5-curl", "php5-gd", "php5-cli", "php5-fpm", "php5-imap", - "php5-mcrypt", "php5-xdebug"] + ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-cli", "php5-imap", + "php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", + "php5-mysql"] # MySQL repo and packages ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main" From 041885901809848bdb2aecba90f1fe954f590c10 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 7 Jan 2015 19:54:12 +0530 Subject: [PATCH 613/829] Optimized installation, Fixed various installation bugs --- ee/cli/plugins/stack.py | 70 +++++++++++++++++++++++++++-------------- ee/core/aptget.py | 17 ++++++---- 2 files changed, 57 insertions(+), 30 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index f15bdbb7..25639ee7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -74,10 +74,11 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): print("Pre-seeding postfix variables ... ") EEShellExec.cmd_exec(self, "echo \"postfix postfix" - "/main_mailer_typestring 'Internet Site'\" | " - "debconf-set-selections") + "/main_mailer_type string \'Internet Site\'\"" + " | debconf-set-selections") EEShellExec.cmd_exec(self, "echo \"postfix postfix/mailname string" - "$(hostname -f)\" | debconf-set-selections") + " $(hostname -f)\" | debconf-set-selections") + if set(EEVariables.ee_mysql).issubset(set(apt_packages)): print("Adding repository for MySQL ... ") EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) @@ -731,43 +732,64 @@ class EEStackController(CementBaseController): if self.app.pargs.web: self.app.log.debug("Setting apt_packages variable for Nginx ,PHP" " ,MySQL ") - apt_packages = (apt_packages + EEVariables.ee_nginx + - EEVariables.ee_php + EEVariables.ee_mysql) + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.wpcli = True + self.app.pargs.postfix = True if self.app.pargs.admin: pass # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: - apt_packages = apt_packages + EEVariables.ee_mail - self.app.log.debug("Setting apt_packages variable for mail") - packages = packages + [["https://github.com/opensolutions/ViMbAdmi" - "n/archive/3.0.10.tar.gz", "/tmp/vimbadmin" - ".tar.gz"], - ["https://github.com/roundcube/" - "roundcubemail/releases/download/" - "1.0.4/roundcubemail-1.0.4.tar.gz", - "/tmp/roundcube.tar.gz"] - ] - if EEVariables.ee_ram > 1024: - apt_packages = apt_packages + EEVariables.ee_mailscanner + if not EEAptGet.is_installed('dovecot'): + self.app.log.debug("Setting apt_packages variable for mail") + apt_packages = apt_packages + EEVariables.ee_mail + packages = packages + [["https://github.com/opensolutions/" + "ViMbAdmin/archive/3.0.10.tar.gz", + "/tmp/vimbadmin.tar.gz"], + ["https://github.com/roundcube/" + "roundcubemail/releases/download/" + "1.0.4/roundcubemail-1.0.4.tar.gz", + "/tmp/roundcube.tar.gz"]] + + if EEVariables.ee_ram > 1024: + apt_packages = apt_packages + EEVariables.ee_mailscanner + else: + self.app.log.info("Mail server is allready installed") if self.app.pargs.nginx: self.app.log.debug("Setting apt_packages variable for Nginx") - apt_packages = apt_packages + EEVariables.ee_nginx + if not EEAptGet.is_installed('nginx-common'): + apt_packages = apt_packages + EEVariables.ee_nginx + else: + self.app.log.info("Nginx allready installed") if self.app.pargs.php: self.app.log.debug("Setting apt_packages variable for PHP") - apt_packages = apt_packages + EEVariables.ee_php + if not EEAptGet.is_installed('php5-common'): + apt_packages = apt_packages + EEVariables.ee_php + else: + self.app.log.info("PHP allready installed") if self.app.pargs.mysql: self.app.log.debug("Setting apt_packages variable for MySQL") - apt_packages = apt_packages + EEVariables.ee_mysql + if not EEShellExec.cmd_exec(self, "mysqladmin ping"): + apt_packages = apt_packages + EEVariables.ee_mysql + else: + self.app.log.info("MySQL connection is allready alive") if self.app.pargs.postfix: self.app.log.debug("Setting apt_packages variable for PostFix") - apt_packages = apt_packages + EEVariables.ee_postfix + if not EEAptGet.is_installed('postfix'): + apt_packages = apt_packages + EEVariables.ee_postfix + else: + self.app.log.info("Postfix is allready installed") if self.app.pargs.wpcli: self.app.log.debug("Setting packages variable for WPCLI") - packages = packages + [["https://github.com/wp-cli/wp-cli/releases" - "/download/v0.17.1/wp-cli.phar", - "/usr/bin/wp"]] + 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"]] + else: + self.app.log.info("WP-CLI is allready installed") if self.app.pargs.phpmyadmin: self.app.log.debug("Setting packages varible for phpMyAdmin ") packages = packages + [["https://github.com/phpmyadmin/phpmyadmin" diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 2ab468c3..bba60353 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -249,11 +249,16 @@ class EEAptGet(): cache = apt.Cache() # Cache Read cache.open() - pkg = cache[package] - # Check Package Installed - if pkg.is_installed: - cache.close() - return True - else: + try: + pkg = cache[package] + # Check Package Installed + if pkg.is_installed: + cache.close() + return True + else: + cache.close() + return False + except Exception as e: cache.close() return False + From 9b1b3270e0ed1addd95d75b5011c74f7ab09d544 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 7 Jan 2015 20:08:10 +0530 Subject: [PATCH 614/829] formatting output ee site create --- ee/cli/plugins/site.py | 36 ++++++++++++++++---------- ee/cli/plugins/site_functions.py | 44 +++++++++++++++++--------------- ee/core/logging.py | 23 +++++++++++++++++ 3 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 ee/core/logging.py diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index eeb39b13..11f590a5 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -197,7 +197,6 @@ class EESiteCreateController(CementBaseController): if (self.app.pargs.wpsubdir and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdomain or self.app.pargs.wp)): - print("Inside wpsubdir") if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -272,14 +271,23 @@ class EESiteCreateController(CementBaseController): # Setup database for MySQL site if 'ee_db_name' in data.keys() and not data['wp']: data = SetupDatabase(self, data) - eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), 'w') - eedbconfig.write("" - .format(data['ee_db_name'], data['ee_db_user'], - data['ee_db_pass'], data['ee_db_host'])) - eedbconfig.close() + try: + eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), + 'w') + eedbconfig.write("" + .format(data['ee_db_name'], + data['ee_db_user'], + data['ee_db_pass'], + data['ee_db_host'])) + eedbconfig.close() + except IOError as e: + self.app.log.error("Unable to create ee-config.php for " + "{2} ({0}): {1}" + .format(e.errno, e.strerror, ee_domain)) + sys.exit(1) # Setup WordPress if Wordpress site if data['wp']: ee_wp_creds = SetupWordpress(self, data) @@ -288,10 +296,12 @@ class EESiteCreateController(CementBaseController): # Setup Permissions for webroot SetWebrootPermissions(self, data['webroot']) if data['wp']: - print("WordPress Admin User : {0}".format(ee_wp_creds['wp_user'])) - print("WordPress Admin User Password : {0}" - .format(ee_wp_creds['wp_pass'])) - print("Successfully created site http://{0}".format(ee_www_domain)) + Log.info(self, '\033[94m'+"WordPress Admin User :" + " {0}".format(ee_wp_creds['wp_user'])+'\033[0m') + Log.info(self, "WordPress Admin User Password : {0}" + .format(ee_wp_creds['wp_pass'])) + Log.info(self, "Successfully created site" + " http://{0}".format(ee_www_domain)) class EESiteUpdateController(CementBaseController): diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index e1927de5..3ec10f92 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -7,13 +7,14 @@ from ee.core.fileutils import EEFileUtils from ee.core.mysql import EEMysql from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables +from ee.core.logging import Log def SetupDomain(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] - print("Creating {0}, please wait...".format(ee_domain_name)) + self.app.log.info("Creating {0} ...".format(ee_domain_name)) # write nginx config for file try: ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}.conf' @@ -23,11 +24,11 @@ def SetupDomain(self, data): out=ee_site_nginx_conf) ee_site_nginx_conf.close() except IOError as e: - print("Unable to create nginx conf for {2} ({0}): {1}" - .format(e.errno, e.strerror, ee_domain_name)) + Log.error(self, "Unable to create nginx conf for {2} ({0}): {1}" + .format(e.errno, e.strerror, ee_domain_name)) sys.exit(1) except Exception as e: - print("{0}".format(e)) + Log.error(self, "{0}".format(e)) sys.exit(1) # create symbolic link for @@ -43,7 +44,7 @@ def SetupDomain(self, data): if not os.path.exists('{0}/logs'.format(ee_site_webroot)): os.makedirs('{0}/logs'.format(ee_site_webroot)) except Exception as e: - print("{0}".format(e)) + Log.error(self, "{0}".format(e)) sys.exit(1) EEFileUtils.create_symlink(self, ['/var/log/nginx/{0}.access.log' @@ -73,7 +74,7 @@ def SetupDatabase(self, data): ee_db_name = input('Enter the MySQL database name [{0}]:' .format(ee_replace_dot)) except EOFError as e: - print("{0} {1}".format(e.errorno, e.strerror)) + Log.error(self, "{0} {1}".format(e.errorno, e.strerror)) sys.exit(0) if not ee_db_name: @@ -86,7 +87,7 @@ def SetupDatabase(self, data): ee_db_password = input('Enter the MySQL database password [{0}]: ' .format(ee_random)) except EOFError as e: - print("{0} {1}".format(e.errorno, e.strerror)) + Log.error(self, "{0} {1}".format(e.errorno, e.strerror)) sys.exit(1) if not ee_db_username: @@ -95,13 +96,14 @@ def SetupDatabase(self, data): ee_db_password = ee_random if len(ee_db_username) > 16: - print('Autofix MySQL username (ERROR 1470 (HY000)), please wait...') + self.app.log.info('Autofix MySQL username (ERROR 1470 (HY000)),' + ' please wait...') ee_random10 = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 10))) ee_db_name = (ee_db_name[0:6] + ee_random10) # create MySQL database - print("Setting Up Database for {0}...".format(ee_domain_name)) + self.app.log.info("Setting Up Database ...") EEMysql.execute(self, "create database {0}" .format(ee_db_name)) @@ -135,7 +137,7 @@ def SetupWordpress(self, data): ee_wp_user = '' ee_wp_pass = '' - print("Downloading Wordpress, please wait...") + self.app.log.info("Downloading Wordpress...") EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") @@ -145,12 +147,12 @@ def SetupWordpress(self, data): ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' .format(ee_replace_dot)) while re.match('^[A-Za-z0-9_]*$', ee_wp_prefix): - print("Warning: table prefix can only contain numbers, " - "letters, and underscores") + self.app.log.warn("table prefix can only " + "contain numbers, letters, and underscores") ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' ) except EOFError as e: - print("{0} {1}".format(e.errorno, e.strerror)) + Log.error(self, "{0} {1}".format(e.errorno, e.strerror)) sys.exit(1) if not ee_wp_prefix: @@ -159,7 +161,7 @@ def SetupWordpress(self, data): # Modify wp-config.php & move outside the webroot EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) - print("Setting up WordPress Configuration...") + self.app.log.debug("Setting Up WordPress Configuration...") if not data['multisite']: EEShellExec.cmd_exec(self, "wp --allow-root core config " + "--dbname={0} --dbprefix={1} --dbuser={2} " @@ -184,9 +186,9 @@ def SetupWordpress(self, data): if not ee_wp_user: ee_wp_user = EEVariables.ee_user while not ee_wp_user: - print("Warning: Usernames can have only alphanumeric" - "characters, spaces, underscores, hyphens," - "periods and the @ symbol.") + self.app.log.warn("Usernames can have only alphanumeric" + "characters, spaces, underscores, hyphens," + "periods and the @ symbol.") ee_wp_user = input('Enter WordPress username: ') if not ee_wp_pass: @@ -197,7 +199,7 @@ def SetupWordpress(self, data): while not ee_wp_email: ee_wp_email = input('Enter WordPress email: ') - print("Setting up WordPress, please wait...") + self.app.log.debug("Setting up WordPress Tables, please wait...") if not data['multisite']: EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install " @@ -218,7 +220,7 @@ def SetupWordpress(self, data): if not data['wpsubdir'] else ''), errormsg="Unable to setup WordPress Tables") - print("Updating WordPress permalink, please wait...") + self.app.log.debug("Updating WordPress permalink, please wait...") EEShellExec.cmd_exec(self, " php /usr/bin/wp --allow-root " "rewrite structure " "/%year%/%monthnum%/%day%/%postname%/", @@ -250,7 +252,7 @@ def SetupWordpressNetwork(self, data): def InstallWP_Plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] - print("Installing plugin {0}".format(plugin_name)) + self.app.log.debug("Installing plugin {0}".format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root install " "{0}".format(plugin_name), @@ -266,6 +268,6 @@ def InstallWP_Plugin(self, plugin_name, data): def SetWebrootPermissions(self, webroot): - print("Setting up Webroot Permissions...") + self.app.log.debug("Setting Up Permissions...") EEFileUtils.chown(self, webroot, EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) diff --git a/ee/core/logging.py b/ee/core/logging.py new file mode 100644 index 00000000..86c72278 --- /dev/null +++ b/ee/core/logging.py @@ -0,0 +1,23 @@ + + +class Log: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + + def error(self, msg): + self.app.log.error(Log.FAIL + msg + Log.ENDC) + + def info(self, msg): + self.app.log.info(Log.OKBLUE + msg + Log.ENDC) + + def warn(self, msg): + self.app.log.warn(Log.BOLD + msg + Log.ENDC) + + def debug(self, msg): + self.app.log.debug(Log.HEADER + msg + Log.ENDC) From d7365dd774fb089b53e5d9518f810971c577a06a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 07:29:30 +0000 Subject: [PATCH 615/829] Git function --- ee/core/git.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ee/core/git.py b/ee/core/git.py index 6a61cb91..7a97d15a 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -1,4 +1,5 @@ -"""EasyEngine GIT module""" +from sh import git, ErrorReturnCode +import os class EEGit(): @@ -6,3 +7,24 @@ class EEGit(): def ___init__(): # TODO method for core variables pass + + def add(paths, msg="Intializating"): + for path in paths: + agit = git.bake("--git-dir={0}/.git".format(path), + "--work-tree={0}".format(path)) + if os.path.isdir(path): + if not os.path.isdir(path+"/.git"): + try: + git.init(path) + except ErrorReturnCode as e: + print(e) + sys.exit(1) + status = git.status("-s") + if len(status.splitlines()) > 0: + try: + git.add("--all") + git.commit("-am {0}".format(msg)) + except ErrorReturnCode as e: + print(e) + sys.exit(1) + pass From c1b098d5b9241f90e84c48c0ae0fc052960db3e7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 13:32:43 +0530 Subject: [PATCH 616/829] Done EEGit --- ee/core/git.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ee/core/git.py b/ee/core/git.py index 7a97d15a..6ed576ae 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -2,29 +2,35 @@ from sh import git, ErrorReturnCode import os -class EEGit(): +class EEGit: """Intialization of core variables""" def ___init__(): # TODO method for core variables pass - def add(paths, msg="Intializating"): + def add(self, paths, msg="Intializating"): for path in paths: - agit = git.bake("--git-dir={0}/.git".format(path), - "--work-tree={0}".format(path)) + global git + git = git.bake("--git-dir={0}/.git".format(path), + "--work-tree={0}".format(path)) if os.path.isdir(path): if not os.path.isdir(path+"/.git"): try: + self.app.log.debug("EEGit: git init at {0}" + .format(path)) git.init(path) except ErrorReturnCode as e: - print(e) + self.app.log.error(e) sys.exit(1) status = git.status("-s") if len(status.splitlines()) > 0: try: + self.app.log.debug("EEGit: git commit at {0}" + .format(path)) git.add("--all") git.commit("-am {0}".format(msg)) except ErrorReturnCode as e: - print(e) + self.app.log.error(e) sys.exit(1) - pass + else: + self.app.log.debug("EEGit: Path {0} not present".format(path)) From 8408838ba278e6161119330bf9448af0db243dab Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 14:39:48 +0530 Subject: [PATCH 617/829] Addded all configurations into git --- ee/cli/plugins/stack.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 25639ee7..add58745 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -11,6 +11,7 @@ from ee.core.apt_repo import EERepo from ee.core.extract import EEExtract from ee.core.mysql import EEMysql from ee.core.addswap import EESwap +from ee.core.git import EEGit from pynginxconfig import NginxConfig import random import string @@ -141,6 +142,8 @@ class EEStackController(CementBaseController): def post_pref(self, apt_packages, packages): if len(apt_packages): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): + EEGit.add(self, ["/etc/postfix"], + msg="Adding Postfix into Git") pass if set(EEVariables.ee_nginx).issubset(set(apt_packages)): if ((not os.path.isfile('/etc/nginx/conf.d/ee-nginx.conf')) and @@ -250,6 +253,8 @@ class EEStackController(CementBaseController): self.app.render((data), 'wpsubdir.mustache', out=ee_nginx) ee_nginx.close() + EEGit.add(self, + ["/etc/nginx"], msg="Adding Nginx into Git") if set(EEVariables.ee_php).issubset(set(apt_packages)): # Create log directories @@ -310,6 +315,7 @@ class EEStackController(CementBaseController): self.app.log.debug("writting PHP5 configartion into " " /etc/php5/fpm/pool.d/debug.conf") config.write(confifile) + EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): config = configparser.ConfigParser() @@ -319,6 +325,7 @@ class EEStackController(CementBaseController): config['mysqld']['performance_schema'] = 0 with open('/etc/mysql/my.cnf', 'w') as configfile: config.write(configfile) + EEGit.add(self, ["/etc/mysql"], msg="Adding Nginx into Git") if set(EEVariables.ee_mail).issubset(set(apt_packages)): self.app.log.debug("Executing mail commands") @@ -429,6 +436,8 @@ class EEStackController(CementBaseController): "/dovecot") EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/" "default.sieve") + EEGit.add(self, ["/etc/postfix", "/etc/dovecot"], + msg="Installed mail server") if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): # Set up Custom amavis configuration @@ -463,6 +472,7 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec(self, "freshclam") self.app.log.debug("Restarting service clamav-daemon") EEShellExec.cmd_exec(self, "service clamav-daemon restart") + EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git") if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): @@ -742,6 +752,11 @@ class EEStackController(CementBaseController): pass # apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.mail: + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.postfix = True + if not EEAptGet.is_installed('dovecot'): self.app.log.debug("Setting apt_packages variable for mail") apt_packages = apt_packages + EEVariables.ee_mail From 9805c8c4090d7850e9525c09ba2ccaf01b9571fe Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 14:47:07 +0530 Subject: [PATCH 618/829] Fixed setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 013c9806..06100cb2 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ setup(name='ee', 'pynginxconfig', 'pymysql3', 'psutil', + 'sh', ], data_files=[('/etc/ee', ['config/ee.conf']), ('/etc/ee/plugins.d', conf), From 3b30792133ed9cec6e55219d387c97e6e65027da Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 14:53:32 +0530 Subject: [PATCH 619/829] Fixed FileIOError --- ee/core/apt_repo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 3b3372b8..bdf17cfd 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -1,4 +1,4 @@ -import os.path +import os from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables @@ -17,7 +17,11 @@ class EERepo(): repo_file_path = ("/etc/apt/sources.list.d/" + EEVariables().ee_repo_file) try: - if repo_url not in open(repo_file_path).read(): + if not os.path.isfile(repo_file_path): + with open(repo_file_path, "a") as repofile: + repofile.write(repo_url) + repofile.close() + elif repo_url not in open(repo_file_path).read(): with open(repo_file_path, "a") as repofile: repofile.write(repo_url) repofile.close() @@ -41,7 +45,6 @@ class EERepo(): EEShellExec.cmd_exec(self, "add-apt-repository -y " "--remove '{ppa_name}'" .format(ppa_name=repo_url)) - pass def add_key(keyids, keyserver=None): if keyserver is None: @@ -51,6 +54,3 @@ class EERepo(): + " --recv-keys {key}".format(key=keyids)) EEShellExec.cmd_exec("gpg -a --export --armor {0}".format(keyids) + " | apt-key add - ") - -# if __name__ == '__main__': -# EERepo().add(repo_url="http://ds.asf", codename="trusty", repo_type="main") From d6c890413cfdc7f1e828da08c5328464b62d2200 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 15:18:17 +0530 Subject: [PATCH 620/829] Fixed Percona configuration issues --- ee/cli/plugins/stack.py | 28 +++++++++++++++++++++------- ee/core/shellexec.py | 3 ++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index add58745..24b420a0 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -318,13 +318,27 @@ class EEStackController(CementBaseController): EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): - config = configparser.ConfigParser() - config.read('/etc/mysql/my.cnf') - config['mysqld']['wait_timeout'] = 30 - config['mysqld']['interactive_timeout'] = 60 - config['mysqld']['performance_schema'] = 0 - with open('/etc/mysql/my.cnf', 'w') as configfile: - config.write(configfile) + # TODO: Currently we are using, we need to remove it in future + # config = configparser.ConfigParser() + # config.read('/etc/mysql/my.cnf') + # config['mysqld']['wait_timeout'] = 30 + # config['mysqld']['interactive_timeout'] = 60 + # config['mysqld']['performance_schema'] = 0 + # with open('/etc/mysql/my.cnf', 'w') as configfile: + # config.write(configfile) + if not os.path.isfile("/etc/mysql/my.cnf"): + config = ("[mysqld]\nwait_timeout = 30\n" + "interactive_timeout=60\nperformance_schema = 0") + config_file = open("/etc/mysql/my.cnf", "w") + config_file.write(config) + config_file.close() + else: + EEShellExec.cmd_exec(self, "sed -i \"/#max_connections/a " + "wait_timeout = 30 \\n" + "interactive_timeout = 60 \\n" + "performance_schema = 0\" " + "/etc/mysql/my.cnf") + EEGit.add(self, ["/etc/mysql"], msg="Adding Nginx into Git") if set(EEVariables.ee_mail).issubset(set(apt_packages)): diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 67629697..fe09dedc 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -12,11 +12,12 @@ class EEShellExec(): def cmd_exec(self, command, errormsg=''): try: + self.app.log.debug("Running command: {0}".format(command)) retcode = subprocess.getstatusoutput(command) if retcode[0] == 0: return True else: - self.app.log.warn(retcode[1]) + self.app.log.debug(retcode[1]) return False except OSError as e: if errormsg: From 70ba7cbcc20085e18890e5950b8b1e8c6c5c6ae4 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 8 Jan 2015 16:25:59 +0530 Subject: [PATCH 621/829] sqlite db for site information --- config/plugins.d/site.conf | 1 + ee/cli/plugins/site.py | 35 ++++++++++++- ee/cli/plugins/sitedb.py | 71 +++++++++++++++++++++++++++ ee/cli/templates/virtualconf.mustache | 6 ++- 4 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 ee/cli/plugins/sitedb.py diff --git a/config/plugins.d/site.conf b/config/plugins.d/site.conf index 2fb468fe..0dad9ff0 100644 --- a/config/plugins.d/site.conf +++ b/config/plugins.d/site.conf @@ -6,3 +6,4 @@ ### `ee.cli.plugins.example` or from the file path ### `/var/lib/ee/plugins/example.py` enable_plugin = true +db_path = sqlite:////var/lib/ee/ee.sqlite diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 11f590a5..eb3fec4f 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -6,6 +6,7 @@ from ee.core.domainvalidate import ValidateDomain from ee.core.fileutils import EEFileUtils from ee.cli.plugins.site_functions import * from ee.core.services import EEService +from ee.cli.plugins.sitedb import * import sys import os @@ -115,7 +116,7 @@ class EESiteCreateController(CementBaseController): # self.app.render((data), 'default.mustache') # Check domain name validation (ee_domain, - ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = EEVariables.ee_webroot + ee_domain # Check if doain previously exists or not @@ -135,6 +136,8 @@ class EESiteCreateController(CementBaseController): static=True, basic=False, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot) + stype = 'html' + cache = 'basic' #PHP if (self.app.pargs.php and not (self.app.pargs.html or @@ -145,6 +148,8 @@ class EESiteCreateController(CementBaseController): static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot) + stype = 'php' + cache = 'basic' #ySQL if (self.app.pargs.mysql and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc @@ -156,6 +161,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'mysql' + cache = 'basic' #WP if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc) and not (self.app.pargs.html or @@ -169,6 +176,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wp' + cache = 'basic' if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -177,6 +186,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wp' + cache = 'w3tc' if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -185,6 +196,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wp' + cache = 'wpfc' if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -193,6 +206,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wp' + cache = 'wpsc' #WPSUBDIR if (self.app.pargs.wpsubdir and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or @@ -205,6 +220,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=True, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wpsubdir' + cache = 'basic' if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -213,6 +230,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=True, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wpsubdir' + cache = 'w3tc' if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -221,6 +240,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=True, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wpsubdir' + cache = 'wpfc' if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -229,6 +250,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=True, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wpsubdir' + cache = 'wpsc' #WPSUBDOAIN if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or @@ -241,6 +264,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wpsubdomain' + cache = 'basic' if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -249,6 +274,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wpsubdomain' + cache = 'w3tc' if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -257,6 +284,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wpsubdomain' + cache = 'wpfc' if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -265,6 +294,8 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='') + stype = 'wpsubdomain' + cache = 'wpsc' # setup NGINX configuration, and webroot SetupDomain(self, data) @@ -283,6 +314,7 @@ class EESiteCreateController(CementBaseController): data['ee_db_pass'], data['ee_db_host'])) eedbconfig.close() + stype = mysql except IOError as e: self.app.log.error("Unable to create ee-config.php for " "{2} ({0}): {1}" @@ -300,6 +332,7 @@ class EESiteCreateController(CementBaseController): " {0}".format(ee_wp_creds['wp_user'])+'\033[0m') Log.info(self, "WordPress Admin User Password : {0}" .format(ee_wp_creds['wp_pass'])) + addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot) Log.info(self, "Successfully created site" " http://{0}".format(ee_www_domain)) diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py new file mode 100644 index 00000000..4fd1a322 --- /dev/null +++ b/ee/cli/plugins/sitedb.py @@ -0,0 +1,71 @@ +from sqlalchemy import Column, DateTime, String, Integer, Boolean +from sqlalchemy import ForeignKey, func +from sqlalchemy.orm import relationship, backref +from sqlalchemy.ext.declarative import declarative_base +from ee.core.logging import Log +import sys + +Base = declarative_base() + + +class SiteDB(Base): + __tablename__ = 'Site' + id = Column(Integer, primary_key=True) + sitename = Column(String, unique=True) + + site_type = Column(String) + cache_type = Column(String) + site_path = Column(String) + + # Use default=func.now() to set the default created time + # of a site to be the current time when a + # Site record was created + + created_on = Column(DateTime, default=func.now()) + site_enabled = Column(Boolean, unique=False, default=True, nullable=False) + is_ssl = Column(Boolean, unique=False, default=False) + storage_fs = Column(String) + storage_db = Column(String) + + # def __init__(self): + # from sqlalchemy import create_engine + # self.engine = create_engine('sqlite:///orm_in_detail.sqlite') + +# if __name__ == "__main__": +# +# from sqlalchemy import create_engine +# engine = create_engine('sqlite:///orm_in_detail.sqlite') +# from sqlalchemy.orm import sessionmaker +# session = sessionmaker() +# session.configure(bind=engine) +# Base.metadata.create_all(engine) +# s = session() +# newRec = SiteDB(sitename='exa.in', site_type='wp', cache_type='basic', + # site_path='/var/www', site_enabled=True, is_ssl=False, storage_fs='ext4', + # storage_db='mysql') +# s.add(newRec) +# s.commit() +# s.flush() + + +def addNewSite(self, site, stype, cache, path, + enabled=True, ssl=False, fs='ext4', db='mysql'): + db_path = self.app.config.get('site', 'db_path') + try: + from sqlalchemy import create_engine + engine = create_engine(db_path) + from sqlalchemy.orm import sessionmaker + session = sessionmaker() + session.configure(bind=engine) + Base.metadata.create_all(engine) + s = session() + newRec = SiteDB(sitename=site, site_type=stype, cache_type=cache, + site_path=path, site_enabled=enabled, is_ssl=ssl, + storage_fs=fs, storage_db=db) + s.add(newRec) + s.commit() + s.flush() + except Exception as e: + Log.error(self, "Unable to add site to database : {0}" + .format(e)) + sys.exit(1) diff --git a/ee/cli/templates/virtualconf.mustache b/ee/cli/templates/virtualconf.mustache index 3f6790fc..fa29eb4a 100644 --- a/ee/cli/templates/virtualconf.mustache +++ b/ee/cli/templates/virtualconf.mustache @@ -6,7 +6,7 @@ server { # listen 80 default_server; {{/multisite}} - server_name {{site_name}} {{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{site_name}}; + server_name {{^vma}}{{^rc}}{{site_name}}{{/rc}}{{/vma}} {{#vma}}vma.*{{/vma}} {{#rc}}webmail.*{{/rc}} {{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{^vma}}{{^rc}}{{site_name}}{{/rc}}{{/vma}}; {{#multisite}} # Uncomment the following line for domain mapping @@ -15,7 +15,9 @@ server { access_log /var/log/nginx/{{site_name}}.access.log {{^static}}rt_cache{{/static}}; error_log /var/log/nginx/{{site_name}}.error.log; - root {{webroot}}/htdocs; + {{^vma}}{{^rc}}root {{webroot}}/htdocs;{{/rc}}{{/vma}} + {{#vma}}root /var/www/22222/htdocs/vimbadmin/public;{{/vma}} + {{#rc}}root /var/www/roundcubemail/htdocs/;{{/rc}} index {{^static}}index.php{{/static}} index.html index.htm; From f458f9f9822d0239d35779e46a8c2271b54370e0 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 16:50:00 +0530 Subject: [PATCH 622/829] Tweaked mail installation --- ee/cli/plugins/stack.py | 61 +++++++++++++++++++++++++++++------------ ee/core/variables.py | 4 +-- 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 24b420a0..dd5811b4 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -763,15 +763,17 @@ class EEStackController(CementBaseController): self.app.pargs.postfix = True if self.app.pargs.admin: - pass - # apt_packages = apt_packages + EEVariables.ee_nginx + self.app.parge.adminer = True + self.app.parge.phpmyadmin = True + self.app.parge.utils = True + if self.app.pargs.mail: self.app.pargs.nginx = True self.app.pargs.php = True self.app.pargs.mysql = True self.app.pargs.postfix = True - if not EEAptGet.is_installed('dovecot'): + if not EEAptGet.is_installed('dovecot-core'): self.app.log.debug("Setting apt_packages variable for mail") apt_packages = apt_packages + EEVariables.ee_mail packages = packages + [["https://github.com/opensolutions/" @@ -885,16 +887,27 @@ class EEStackController(CementBaseController): packages = [] if self.app.pargs.web: - self.app.log.debug("Removing apt_packages variable of Nginx " - ",PHP,MySQL") - apt_packages = (apt_packages + EEVariables.ee_nginx + - EEVariables.ee_php + EEVariables.ee_mysql) + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.wpcli = True + self.app.pargs.postfix = True + if self.app.pargs.admin: - pass - # apt_packages = apt_packages + EEVariables.ee_nginx + self.app.parge.adminer = True + self.app.parge.phpmyadmin = True + self.app.parge.utils = True + if self.app.pargs.mail: - pass - # apt_packages = apt_packages + EEVariables.ee_nginx + self.app.log.debug("Removing mail server packages") + apt_packages = apt_packages + EEVariables.ee_mail + apt_packages = apt_packages + EEVariables.ee_mailscanner + packages = packages + ["/var/www/22222/htdocs/vimbadmin", + "/var/www/roundcubemail"] + if EEShellExec.cmd_exec("mysqladmin ping"): + EEMysql.execute("drop database vimbadmin") + EEMysql.execute("drop database roundcubemail") + if self.app.pargs.nginx: self.app.log.debug("Removing apt_packages variable of Nginx") apt_packages = apt_packages + EEVariables.ee_nginx @@ -938,15 +951,27 @@ class EEStackController(CementBaseController): packages = [] if self.app.pargs.web: - self.app.log.debug("Purge Nginx,PHP,MySQL") - apt_packages = (apt_packages + EEVariables.ee_nginx - + EEVariables.ee_php + EEVariables.ee_mysql) + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.wpcli = True + self.app.pargs.postfix = True + if self.app.pargs.admin: - pass - # apt_packages = apt_packages + EEVariables.ee_nginx + self.app.parge.adminer = True + self.app.parge.phpmyadmin = True + self.app.parge.utils = True + if self.app.pargs.mail: - pass - # apt_packages = apt_packages + EEVariables.ee_nginx + self.app.log.debug("Removing mail server packages") + apt_packages = apt_packages + EEVariables.ee_mail + apt_packages = apt_packages + EEVariables.ee_mailscanner + packages = packages + ["/var/www/22222/htdocs/vimbadmin", + "/var/www/roundcubemail"] + if EEShellExec.cmd_exec("mysqladmin ping"): + EEMysql.execute("drop database vimbadmin") + EEMysql.execute("drop database roundcubemail") + if self.app.pargs.nginx: self.app.log.debug("Purge apt_packages variable of Nginx") apt_packages = apt_packages + EEVariables.ee_nginx diff --git a/ee/core/variables.py b/ee/core/variables.py index 63b3634b..f804ed03 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -79,8 +79,8 @@ class EEVariables(): # Mailscanner repo and packages ee_mailscanner_repo = () ee_mailscanner = ["amavisd-new", "spamassassin", "clamav", "clamav-daemon", - "arj", "zoo", "nomarch", "cpio", "lzop", - "cabextract", "p7zip", "rpm", "unrar-free"] + "arj", "zoo", "nomarch", "lzop", "cabextract", "p7zip", + "rpm", "unrar-free"] # Repo path ee_repo_file = "ee-repo.list" From 3b1a02c65a6c0b6980748e55f0995f87f5bfcff3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 17:17:22 +0530 Subject: [PATCH 623/829] Fixed Roundcube issue --- ee/cli/plugins/stack.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index dd5811b4..d42078a7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -742,11 +742,12 @@ class EEStackController(CementBaseController): "inc.php".format(password=rc_passwd)) # Sieve plugin configuration in roundcube - EEShellExec.cmd_exec(self, "sed -i \"s:\$config\['plugins'\] " + EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\[" + "\'plugins\'\] " "= array(:\$config\['plugins'\] = " - "array(\n'sieverules',:\" /var/www" + "array(\n\'sieverules\',:\\\" /var/www" "/roundcubemail/htdocs/config" - "/config.inc.php") + "/config.inc.php\"") EEShellExec.cmd_exec(self, "echo \"\$config['sieverules_port']" "=4190;\" >> /var/www/roundcubemail" "/htdocs/config/config.inc.php") From 1e18f68963ba8ffaf7c6343a9896a65c73955d38 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 17:52:01 +0530 Subject: [PATCH 624/829] Added SQLalchemy into setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 06100cb2..98d787a1 100644 --- a/setup.py +++ b/setup.py @@ -46,6 +46,7 @@ setup(name='ee', 'pymysql3', 'psutil', 'sh', + 'sqlalchemy', ], data_files=[('/etc/ee', ['config/ee.conf']), ('/etc/ee/plugins.d', conf), From d091116403a50f847049b314d16f208ff785ae3c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 17:54:27 +0530 Subject: [PATCH 625/829] Fixed typos --- ee/cli/plugins/stack.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index d42078a7..417d2bb3 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -969,9 +969,9 @@ class EEStackController(CementBaseController): apt_packages = apt_packages + EEVariables.ee_mailscanner packages = packages + ["/var/www/22222/htdocs/vimbadmin", "/var/www/roundcubemail"] - if EEShellExec.cmd_exec("mysqladmin ping"): - EEMysql.execute("drop database vimbadmin") - EEMysql.execute("drop database roundcubemail") + if EEShellExec.cmd_exec(self, "mysqladmin ping"): + EEMysql.execute(self, "drop database vimbadmin") + EEMysql.execute(self, "drop database roundcubemail") if self.app.pargs.nginx: self.app.log.debug("Purge apt_packages variable of Nginx") From 870eecd8eaac4f35b9f413145fad450d0902b281 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 18:14:07 +0530 Subject: [PATCH 626/829] Fixed typos --- ee/cli/plugins/stack.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 417d2bb3..a847c163 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -764,9 +764,9 @@ class EEStackController(CementBaseController): self.app.pargs.postfix = True if self.app.pargs.admin: - self.app.parge.adminer = True - self.app.parge.phpmyadmin = True - self.app.parge.utils = True + self.app.pargs.adminer = True + self.app.pargs.phpmyadmin = True + self.app.pargs.utils = True if self.app.pargs.mail: self.app.pargs.nginx = True @@ -895,9 +895,9 @@ class EEStackController(CementBaseController): self.app.pargs.postfix = True if self.app.pargs.admin: - self.app.parge.adminer = True - self.app.parge.phpmyadmin = True - self.app.parge.utils = True + self.app.pargs.adminer = True + self.app.pargs.phpmyadmin = True + self.app.pargs.utils = True if self.app.pargs.mail: self.app.log.debug("Removing mail server packages") @@ -959,9 +959,9 @@ class EEStackController(CementBaseController): self.app.pargs.postfix = True if self.app.pargs.admin: - self.app.parge.adminer = True - self.app.parge.phpmyadmin = True - self.app.parge.utils = True + self.app.pargs.adminer = True + self.app.pargs.phpmyadmin = True + self.app.pargs.utils = True if self.app.pargs.mail: self.app.log.debug("Removing mail server packages") From 54d08b1be4ef33f00b1c5255fd94fcb812d96fbc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 9 Jan 2015 15:38:01 +0530 Subject: [PATCH 627/829] Addded 22222 configuration --- ee/cli/controllers/base.py | 13 +++ ee/cli/plugins/stack.py | 112 +++++++++++++++++++++++++- ee/cli/templates/22222.mustache | 61 ++++++++++++++ ee/cli/templates/virtualconf.mustache | 2 +- ee/core/fileutils.py | 15 ++-- 5 files changed, 195 insertions(+), 8 deletions(-) create mode 100644 ee/cli/templates/22222.mustache diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index d0ec86f2..4ccc2869 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -32,3 +32,16 @@ class EEBaseController(CementBaseController): # The 'default.mustache' file would be loaded from # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. # + # ViMbAdmin Nginx configuration + data = dict(site_name='webmail', www_domain='webmail', static=False, + basic=True, wp=False, w3tc=False, wpfc=False, + wpsc=False, multisite=False, wpsubdir=False, + webroot='/var/www', ee_db_name='', + ee_db_user='', ee_db_pass='', ee_db_host='', + rc=True) + self.app.log.debug('Writting the nginx configration for' + ' ViMbAdmin') + ee_rc = open('/etc/nginx/sites-available/webmail.conf', 'w') + self.app.render((data), 'virtualconf.mustache', + out=ee_rc) + ee_rc.close() diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index a847c163..e8a4015c 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -13,6 +13,7 @@ from ee.core.mysql import EEMysql from ee.core.addswap import EESwap from ee.core.git import EEGit from pynginxconfig import NginxConfig +from ee.core.services import EEService import random import string import configparser @@ -144,7 +145,8 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): EEGit.add(self, ["/etc/postfix"], msg="Adding Postfix into Git") - pass + 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')): @@ -253,8 +255,74 @@ class EEStackController(CementBaseController): self.app.render((data), 'wpsubdir.mustache', out=ee_nginx) ee_nginx.close() + + # 22222 port settings + self.app.log.debug('Writting the nginx configration to' + 'file /etc/nginx/common/22222.conf') + ee_nginx = open('/etc/nginx/common/22222.conf', 'w') + self.app.render((data), '22222.mustache', + out=ee_nginx) + ee_nginx.close() + + passwd = ''.join([random.choice + (string.ascii_letters + string.digits) + for n in range(6)]) + EEShellExec.cmd_exec(self, "printf \"easyengine:" + "$(openssl passwd -crypt " + "{password} 2> /dev/null)\n\"" + "> /etc/nginx/htpasswd-ee 2>/dev/null" + .format(password=passwd)) + + # Create Symbolic link for 22222 + EEFileUtils.create_symlink(self, ['/etc/nginx/' + 'sites-available/' + '22222.conf', + '/etc/nginx/' + 'sites-enabled/' + '22222.conf']) + # Create log and cert folder and softlinks + if not os.path.exists('/var/www/22222/logs'): + os.makedirs('/var/www/22222/logs') + + if not os.path.exists('/var/www/22222/cert'): + os.makedirs('/var/www/22222/cert') + + EEFileUtils.create_symlink(self, ['/var/log/nginx/' + '22222.access.log', + '/var/www/22222/' + 'logs/access.log']) + + EEFileUtils.create_symlink(self, ['/var/log/nginx/' + '22222.error.log', + '/var/www/22222/' + 'logs/error.log']) + + EEShellExec.cmd_exec(self, "openssl genrsa -out " + "/var/www/22222/cert/22222.key 2048") + EEShellExec.cmd_exec(self, "openssl req -new -batch -subj " + "/commonName=127.0.0.1/ -key " + "/var/www/22222/cert/22222.key " + "-out /var/www/22222/cert/" + "22222.csr") + + EEFileUtils.mvfile(self, "/var/www/22222/cert/22222.key", + "/var/www/22222/cert/" + "22222.key.org") + + EEShellExec.cmd_exec(self, "openssl rsa -in " + "/var/www/22222/cert/" + "22222.key.org -out " + "/var/www/22222/cert/22222.key") + + EEShellExec.cmd_exec(self, "openssl x509 -req -days 3652 " + "-in /var/www/22222/cert/" + "22222.csr -signkey /var/www/" + "22222/cert/22222.key -out " + "/var/www/22222/cert/22222.crt") + # Nginx Configation into GIT EEGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git") + EEService.reload_service(self, ['nginx']) if set(EEVariables.ee_php).issubset(set(apt_packages)): # Create log directories @@ -316,6 +384,7 @@ class EEStackController(CementBaseController): " /etc/php5/fpm/pool.d/debug.conf") config.write(confifile) EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") + EEService.reload_service(self, ['php5-fpm']) if set(EEVariables.ee_mysql).issubset(set(apt_packages)): # TODO: Currently we are using, we need to remove it in future @@ -340,6 +409,7 @@ class EEStackController(CementBaseController): "/etc/mysql/my.cnf") EEGit.add(self, ["/etc/mysql"], msg="Adding Nginx into Git") + EEService.reload_service(self, ['mysql']) if set(EEVariables.ee_mail).issubset(set(apt_packages)): self.app.log.debug("Executing mail commands") @@ -452,6 +522,7 @@ class EEStackController(CementBaseController): "default.sieve") EEGit.add(self, ["/etc/postfix", "/etc/dovecot"], msg="Installed mail server") + EEService.reload_service(self, ['dovecot', 'postfix']) if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): # Set up Custom amavis configuration @@ -487,6 +558,8 @@ class EEStackController(CementBaseController): self.app.log.debug("Restarting service clamav-daemon") EEShellExec.cmd_exec(self, "service clamav-daemon restart") EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git") + EEService.reload_service(self, ['dovecot', 'amavis', + 'postfix']) if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): @@ -703,6 +776,8 @@ class EEStackController(CementBaseController): self.app.render((data), '50-user.mustache', out=vm_config) vm_config.close() + EEService.reload_service(self, ['nginx', 'php5-fpm', + 'dovecot']) if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): # Extract RoundCubemail @@ -752,6 +827,41 @@ class EEStackController(CementBaseController): "=4190;\" >> /var/www/roundcubemail" "/htdocs/config/config.inc.php") + data = dict(site_name='webmail', www_domain='webmail', + static=False, + basic=True, wp=False, w3tc=False, wpfc=False, + wpsc=False, multisite=False, wpsubdir=False, + webroot='/var/www', ee_db_name='', + ee_db_user='', ee_db_pass='', ee_db_host='', + rc=True) + + self.app.log.debug('Writting the nginx configration for' + ' RoundCubemail') + ee_rc = open('/etc/nginx/sites-available/webmail.conf', 'w') + self.app.render((data), 'virtualconf.mustache', + out=ee_rc) + ee_rc.close() + + # Create Symbolic link for webmail.conf + EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available' + '/webmail.conf', + '/etc/nginx/sites-enabled/' + 'webmail.conf']) + # Create log folder and softlinks + if not os.path.exists('/var/www/roundcubemail/logs'): + os.makedirs('/var/www/roundcubemail/logs') + + EEFileUtils.create_symlink(self, ['/var/log/nginx/' + 'webmail.access.log', + '/var/www/roundcubemail/' + 'logs/access.log']) + + EEFileUtils.create_symlink(self, ['/var/log/nginx/' + 'webmail.error.log', + '/var/www/roundcubemail/' + 'logs/error.log']) + EEService.reload_service(self, ['nginx']) + @expose() def install(self, packages=[], apt_packages=[]): if self.app.pargs.web: diff --git a/ee/cli/templates/22222.mustache b/ee/cli/templates/22222.mustache new file mode 100644 index 00000000..ab6d6a5c --- /dev/null +++ b/ee/cli/templates/22222.mustache @@ -0,0 +1,61 @@ +# EasyEngine admin NGINX CONFIGURATION + +server { + + listen 22222 default_server ssl spdy; + + access_log /var/log/nginx/22222.access.log rt_cache; + error_log /var/log/nginx/22222.error.log; + + ssl_certificate /var/www/22222/cert/22222.crt; + ssl_certificate_key /var/www/22222/cert/22222.key; + + # Force HTTP to HTTPS + error_page 497 =200 https://$host:22222$request_uri; + + root /var/www/22222/htdocs; + index index.php index.htm index.html; + + # Turn on directory listing + autoindex on; + + location / { + include common/acl.conf; + try_files $uri $uri/ /index.php?$args; + } + + location = /fpm/status/ {} + + location ~ /fpm/status/(.*) { + include fastcgi_params; + fastcgi_param SCRIPT_NAME /status; + fastcgi_pass $1; + } + + location ~ \.php$ { + include common/acl.conf; + try_files $uri =404; + include fastcgi_params; + fastcgi_pass php; + } + + # ViMbAdmin Rules + location = /vimbadmin/ { + return 301 $scheme://$host:22222/vimbadmin/public/; + } + + location ~* \.(js|css|jpg|gif|png)$ { + root /var/www/22222/htdocs/; + } + + location ~* /vimbadmin/public/(.*)/(.*) { + root /var/www/22222/htdocs/vimbadmin/public; + try_files $uri $uri/ /vimbadmin/public/index.php?$args; + } + + location ~* /vimbadmin/public/(.*) { + root /var/www/22222/htdocs/vimbadmin/public; + try_files $uri $uri/ /vimbadmin/public/index.php?$args; + } + +} diff --git a/ee/cli/templates/virtualconf.mustache b/ee/cli/templates/virtualconf.mustache index fa29eb4a..cadb946b 100644 --- a/ee/cli/templates/virtualconf.mustache +++ b/ee/cli/templates/virtualconf.mustache @@ -6,7 +6,7 @@ server { # listen 80 default_server; {{/multisite}} - server_name {{^vma}}{{^rc}}{{site_name}}{{/rc}}{{/vma}} {{#vma}}vma.*{{/vma}} {{#rc}}webmail.*{{/rc}} {{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{^vma}}{{^rc}}{{site_name}}{{/rc}}{{/vma}}; + server_name {{^vma}}{{^rc}}{{site_name}}{{/rc}}{{/vma}} {{#vma}}vma.*{{/vma}} {{#rc}}webmail.*{{/rc}} {{^vma}}{{^rc}}{{#multisite}}*{{/multisite}}{{^multisite}}www{{/multisite}}.{{site_name}}{{/rc}}{{/vma}}; {{#multisite}} # Uncomment the following line for domain mapping diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 654970ca..99e3d6f9 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -32,12 +32,15 @@ class EEFileUtils(): def create_symlink(self, paths): src = paths[0] dst = paths[1] - try: - os.symlink(src, dst) - except Exception as e: - self.app.log.error("Unable to create symbolic link ...\n {0} {1}" - .format(e.errno, e.strerror)) - sys.exit(1) + if not os.path.islink(dst): + try: + os.symlink(src, dst) + except Exception as e: + self.app.log.error("Unable to create symbolic link ...\n {0}" + " {1}".format(e.errno, e.strerror)) + sys.exit(1) + else: + self.app.log.debug("Destination: {0} exists".format(dst)) def remove_symlink(self, filepath): try: From 66a20c5a0e98b893cdf4ff6b97a941b98e98ee3c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 9 Jan 2015 16:24:08 +0530 Subject: [PATCH 628/829] Fixed wrong file path --- ee/cli/plugins/stack.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index e8a4015c..482e3176 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -258,8 +258,10 @@ class EEStackController(CementBaseController): # 22222 port settings self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/22222.conf') - ee_nginx = open('/etc/nginx/common/22222.conf', 'w') + 'file /etc/nginx/sites-available/' + '22222.conf') + ee_nginx = open('/etc/nginx/sites-available/22222.conf', + 'w') self.app.render((data), '22222.mustache', out=ee_nginx) ee_nginx.close() From e52a6a43bbf0d71c68b4e1536e559a63e2d51b44 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 9 Jan 2015 16:49:32 +0530 Subject: [PATCH 629/829] Fixed service not reloading issue --- ee/cli/plugins/stack.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 482e3176..bb442834 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -145,7 +145,7 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): EEGit.add(self, ["/etc/postfix"], msg="Adding Postfix into Git") - EEService.reload_service(self, ['postfix']) + 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 @@ -324,7 +324,7 @@ class EEStackController(CementBaseController): # Nginx Configation into GIT EEGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git") - EEService.reload_service(self, ['nginx']) + EEService.reload_service(self, 'nginx') if set(EEVariables.ee_php).issubset(set(apt_packages)): # Create log directories @@ -386,7 +386,7 @@ class EEStackController(CementBaseController): " /etc/php5/fpm/pool.d/debug.conf") config.write(confifile) EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") - EEService.reload_service(self, ['php5-fpm']) + EEService.reload_service(self, 'php5-fpm') if set(EEVariables.ee_mysql).issubset(set(apt_packages)): # TODO: Currently we are using, we need to remove it in future @@ -411,7 +411,7 @@ class EEStackController(CementBaseController): "/etc/mysql/my.cnf") EEGit.add(self, ["/etc/mysql"], msg="Adding Nginx into Git") - EEService.reload_service(self, ['mysql']) + EEService.reload_service(self, 'mysql') if set(EEVariables.ee_mail).issubset(set(apt_packages)): self.app.log.debug("Executing mail commands") @@ -524,7 +524,8 @@ class EEStackController(CementBaseController): "default.sieve") EEGit.add(self, ["/etc/postfix", "/etc/dovecot"], msg="Installed mail server") - EEService.reload_service(self, ['dovecot', 'postfix']) + EEService.reload_service(self, 'dovecot') + EEService.reload_service(self, 'postfix') if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): # Set up Custom amavis configuration @@ -560,8 +561,9 @@ class EEStackController(CementBaseController): self.app.log.debug("Restarting service clamav-daemon") EEShellExec.cmd_exec(self, "service clamav-daemon restart") EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git") - EEService.reload_service(self, ['dovecot', 'amavis', - 'postfix']) + EEService.reload_service(self, 'dovecot') + EEService.reload_service(self, 'postfix') + EEService.reload_service(self, 'amavis') if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): @@ -778,8 +780,9 @@ class EEStackController(CementBaseController): self.app.render((data), '50-user.mustache', out=vm_config) vm_config.close() - EEService.reload_service(self, ['nginx', 'php5-fpm', - 'dovecot']) + EEService.reload_service(self, 'dovecot') + EEService.reload_service(self, 'nginx') + EEService.reload_service(self, 'php5-fpm') if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): # Extract RoundCubemail @@ -862,7 +865,7 @@ class EEStackController(CementBaseController): 'webmail.error.log', '/var/www/roundcubemail/' 'logs/error.log']) - EEService.reload_service(self, ['nginx']) + EEService.reload_service(self, 'nginx') @expose() def install(self, packages=[], apt_packages=[]): From e6f942105a4bb81d433b137ef804ea24ad567cc3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 12 Jan 2015 13:58:54 +0530 Subject: [PATCH 630/829] Fixed some bugs --- ee/cli/plugins/stack.py | 2 ++ ee/core/variables.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index bb442834..67a850b1 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -865,6 +865,8 @@ class EEStackController(CementBaseController): 'webmail.error.log', '/var/www/roundcubemail/' 'logs/error.log']) + # Remove roundcube installer + EEFileUtils.remove() EEService.reload_service(self, 'nginx') @expose() diff --git a/ee/core/variables.py b/ee/core/variables.py index f804ed03..81d35a71 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -56,7 +56,7 @@ class EEVariables(): .format(codename=ee_platform_codename)) ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-cli", "php5-imap", "php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", - "php5-mysql"] + "php5-mysql", "memcached"] # MySQL repo and packages ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main" From f189c8d175a92ce7484be803ab9baf7bdd9e1728 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 12 Jan 2015 14:53:09 +0530 Subject: [PATCH 631/829] site backup module added --- ee/cli/plugins/site_functions.py | 35 ++++++++++++++++-- ee/core/fileutils.py | 61 ++++++++++++++++++++++++-------- ee/core/variables.py | 3 ++ 3 files changed, 83 insertions(+), 16 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 3ec10f92..3c5f3b12 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -8,6 +8,7 @@ from ee.core.mysql import EEMysql from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables from ee.core.logging import Log +import glob def SetupDomain(self, data): @@ -141,7 +142,8 @@ def SetupWordpress(self, data): EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") - data = SetupDatabase(self, data) + if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']): + data = SetupDatabase(self, data) if prompt_wpprefix == 'True' or prompt_wpprefix == 'true': try: ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' @@ -247,7 +249,9 @@ def SetupWordpressNetwork(self, data): ee_site_webroot = data['webroot'] EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert' - '--title=') + '--title={0} {subdomains}' + .format(data['www_domain'], subdomains='--subdomains' + if not data['wpsubdir'] else '')) def InstallWP_Plugin(self, plugin_name, data): @@ -271,3 +275,30 @@ def SetWebrootPermissions(self, webroot): self.app.log.debug("Setting Up Permissions...") EEFileUtils.chown(self, webroot, EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) + + +def siteBackup(self, data): + ee_site_webroot = data['webroot'] + backup_path = ee_site_webroot + '/backup/{0}'.format(EEVariables.ee_date) + if not EEFileUtils.isexist(self, backup_path): + EEFileUtils.mkdir(self, backup_path) + Log.info(self, "Backup Location : {0}".format(backup_path)) + EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}.conf' + .format(data['ee_domain']), backup_path) + + if data['currsitetype'] in ['html', 'php', 'mysql']: + Log.info(self, "Backup Webroot ...") + EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path) + + configfiles = glob(ee_site_webroot + '/htdocs/*-config.php') + + for file in configfiles: + if EEFileUtils.isexist(self, file): + ee_db_name = (EEFileUtils.grep(self, file, 'DB_NAME').split(',')[1] + .split(')')[0].strip()) + Log.info(self, 'Backup Database, please wait') + EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" + .format(ee_db_name, backup_path), + "Failed: Backup Database") + # move wp-config.php/ee-config.php to backup + EEFileUtils.mvfile(self, file, backup_path) diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 654970ca..90c95e24 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -5,6 +5,7 @@ import sys import glob import shutil import fileinput +from ee.core.logging import Log class EEFileUtils(): @@ -25,26 +26,29 @@ class EEFileUtils(): shutil.rmtree(file) self.app.log.info("Done") except shutil.Error as e: - self.app.log.error('Unable to Remove file {err}' - .format(err=str(e.reason))) + Log.error(self, 'Unable to Remove file {err}' + .format(err=str(e.reason))) sys.exit(1) - def create_symlink(self, paths): + def create_symlink(self, paths, errormsg=''): src = paths[0] dst = paths[1] try: os.symlink(src, dst) except Exception as e: - self.app.log.error("Unable to create symbolic link ...\n {0} {1}" - .format(e.errno, e.strerror)) + if errormsg: + Log.error(self, errormsg + 'n {0} {1}'. + format(e.errno, e.strerror)) + Log.debug(self, "Unable to create symbolic link ...\n {0} {1}" + .format(e.errno, e.strerror)) sys.exit(1) def remove_symlink(self, filepath): try: os.unlink(filepath) except Exception as e: - self.app.log.error("Unable to reomove symbolic link ...\n {0} {1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to reomove symbolic link ...\n {0} {1}" + .format(e.errno, e.strerror)) sys.exit(1) def copyfile(self, src, dest): @@ -67,16 +71,16 @@ class EEFileUtils(): try: shutil.move(src, dst) except shutil.Error as e: - self.app.log.error('Unable to move file {err}' - .format(err=str(e.reason))) + Log.error(self, 'Unable to move file {err}' + .format(err=str(e.reason))) sys.exit(1) def chdir(self, path): try: os.chdir(path) except OSError as e: - self.app.log.error('Unable to Change Directory {err}' - .format(err=e.strerror)) + Log.error(self, 'Unable to Change Directory {err}' + .format(err=e.strerror)) sys.exit(1) def chown(self, path, user, group, recursive=False): @@ -92,10 +96,10 @@ class EEFileUtils(): else: shutil.chown(path, user=user, group=group) except shutil.Error as e: - self.app.log.error("Unable to change owner : {0} ".format(e)) + Log.error(self, "Unable to change owner : {0} ".format(e)) sys.exit(1) except Exception as e: - self.app.log.error("Unable to change owner {0}".format(e)) + Log.error(self, "Unable to change owner {0}".format(e)) sys.exit(1) def chmod(self, path, perm, recursive=False): @@ -109,5 +113,34 @@ class EEFileUtils(): else: os.chmod(path, perm) except OSError as e: - self.log.error("Unable to change owner {0}".format(e.strerror)) + Log.error(self, "Unable to change owner {0}".format(e.strerror)) + sys.exit(1) + + def mkdir(self, path): + try: + os.makedirs(path) + except OSError as e: + Log.error(self, "Unable to create directory {0}" + .format(e.strerror)) + sys.exit(1) + + def isexist(self, path): + try: + if os.path.exists(path): + return (True) + else: + return (False) + except OSError as e: + Log.error(self, "Unable to check path {0}" + .format(e.strerror)) + sys.exit(1) + + def grep(self, fnm, sstr): + try: + for line in open(fnm): + if sstr in line: + return line + except OSError as e: + Log.error(self, "Unable to Search string {0}" + .format(e.strerror)) sys.exit(1) diff --git a/ee/core/variables.py b/ee/core/variables.py index f804ed03..38f8bc31 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -5,6 +5,7 @@ import configparser import os import sys import psutil +import datetime class EEVariables(): @@ -12,6 +13,8 @@ class EEVariables(): config = configparser.ConfigParser() config.read(os.path.expanduser("~")+'/.gitconfig') + ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S') + # EasyEngine core variables ee_platform_distro = platform.linux_distribution()[0] ee_platform_version = platform.linux_distribution()[1] From dbd8799e3adf6b720edd6790139eb724d25ead82 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 12 Jan 2015 14:59:35 +0530 Subject: [PATCH 632/829] ee site update module completed --- ee/cli/plugins/site.py | 383 +++++++++++++++++++++++++++++++++++++-- ee/cli/plugins/sitedb.py | 30 ++- ee/core/shellexec.py | 11 +- 3 files changed, 400 insertions(+), 24 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index eb3fec4f..401062ca 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -7,6 +7,7 @@ from ee.core.fileutils import EEFileUtils from ee.cli.plugins.site_functions import * from ee.core.services import EEService from ee.cli.plugins.sitedb import * +from ee.core.git import EEGit import sys import os @@ -127,11 +128,12 @@ class EESiteCreateController(CementBaseController): sys.exit(1) # setup nginx configuration for site - # HTmL + # HTML if (self.app.pargs.html and not (self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=True, basic=False, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, @@ -144,17 +146,19 @@ class EESiteCreateController(CementBaseController): self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot) stype = 'php' cache = 'basic' - #ySQL + #MySQL if (self.app.pargs.mysql and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, @@ -168,8 +172,10 @@ class EESiteCreateController(CementBaseController): self.app.pargs.wpsc) and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + if (self.app.pargs.wp and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=False, @@ -178,8 +184,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wp' cache = 'basic' + if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=False, @@ -188,8 +196,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wp' cache = 'w3tc' + if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=False, @@ -198,8 +208,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wp' cache = 'wpfc' + if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=False, @@ -208,10 +220,12 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wp' cache = 'wpsc' + #WPSUBDIR if (self.app.pargs.wpsubdir and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdomain or self.app.pargs.wp)): + if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -222,8 +236,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wpsubdir' cache = 'basic' + if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, @@ -232,8 +248,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wpsubdir' cache = 'w3tc' + if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, @@ -242,8 +260,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wpsubdir' cache = 'wpfc' + if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, @@ -252,12 +272,15 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wpsubdir' cache = 'wpsc' + #WPSUBDOAIN if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdir or self.app.pargs.wp)): + if (self.app.pargs.wpsubdomain and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=True, w3tc=False, wpfc=False, wpsc=False, multisite=True, @@ -266,8 +289,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wpsubdomain' cache = 'basic' + if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=True, wpfc=False, wpsc=False, multisite=True, @@ -276,8 +301,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wpsubdomain' cache = 'w3tc' + if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=True, wpsc=False, multisite=True, @@ -286,8 +313,10 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'wpsubdomain' cache = 'wpfc' + if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): + data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, wpfc=False, wpsc=True, multisite=True, @@ -325,6 +354,10 @@ class EESiteCreateController(CementBaseController): ee_wp_creds = SetupWordpress(self, data) # Service Nginx Reload EEService.reload_service(self, 'nginx') + + EEGit.add(self, ["/etc/nginx"], + msg="{0} created with {1} {2}" + .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot SetWebrootPermissions(self, data['webroot']) if data['wp']: @@ -334,7 +367,7 @@ class EESiteCreateController(CementBaseController): .format(ee_wp_creds['wp_pass'])) addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot) Log.info(self, "Successfully created site" - " http://{0}".format(ee_www_domain)) + " http://{0}".format(ee_domain)) class EESiteUpdateController(CementBaseController): @@ -370,21 +403,335 @@ class EESiteUpdateController(CementBaseController): @expose(help="update example.com") def default(self): # TODO Write code for ee site update here - print("Inside EESiteUpdateController.default().") - - # site command Options and subcommand calls and definations to - # mention here - - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. - # + (ee_domain, + ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) + ee_site_webroot = EEVariables.ee_webroot + ee_domain + + check_site = getSiteInfo(self, ee_domain) + + if check_site is None: + Log.error(self, "Site {0} does not exist.".format(ee_domain)) + else: + oldsitetype = check_site.site_type + oldcachetype = check_site.cache_type + + if (self.app.pargs.html and not (self.app.pargs.php or + self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc or + self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + pass + + #PHP + if (self.app.pargs.php and not (self.app.pargs.html or + self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc or + self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + + if oldsitetype != 'html': + Log.error("Cannot update {0} to php".format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=True, wp=False, w3tc=False, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False, webroot=ee_site_webroot, + currsitetype=oldsitetype, currcachetype=oldcachetype) + + #MySQL + if (self.app.pargs.mysql and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc or + self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + + if oldsitetype != 'html' or oldsitetype != 'php': + Log.error("Cannot update {0} to mysql".format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=True, wp=False, w3tc=False, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + #WP + if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or + self.app.pargs.wpsc) and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.mysql or + self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + if (self.app.pargs.wp and not (self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc)): + + if (oldsitetype not in ['html', 'php', 'wp'] + and oldsitetype not in ['w3tc', 'wpfc', 'wpsc']): + Log.error("Cannot update {0} to wp basic" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.w3tc and not + (self.app.pargs.wpfc or self.app.pargs.wpsc)): + + if (oldsitetype not in ['html', 'php', 'wp'] + and oldsitetype not in ['basic', 'wpfc', 'wpsc']): + Log.error("Cannot update {0} to wp w3tc".format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=True, + wpfc=False, wpsc=False, multisite=False, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.wpfc and not + (self.app.pargs.wpsc or self.app.pargs.w3tc)): + + if (oldsitetype not in ['html', 'php', 'wp'] + and oldsitetype not in ['basic', 'w3tc', 'wpsc']): + Log.error("Cannot update {0} to wp wpfc".format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=False, + wpfc=True, wpsc=False, multisite=False, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.wpsc and not + (self.app.pargs.w3tc or self.app.pargs.wpfc)): + + if (oldsitetype not in ['html', 'php', 'wp'] + and oldsitetype not in ['basic', 'w3tc', 'wpfc']): + Log.error("Cannot update {0} to wp wpsc".format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=False, + wpfc=False, wpsc=True, multisite=False, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + #WPSUBDIR + if (self.app.pargs.wpsubdir and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.mysql or + self.app.pargs.wpsubdomain or self.app.pargs.wp)): + if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc)): + + if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdir'] + and oldsitetype not in ['w3tc', 'wpfc', 'wpsc']): + Log.error("Cannot update {0} to wpsubdir basic" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=True, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.w3tc and not + (self.app.pargs.wpfc or self.app.pargs.wpsc)): + + if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdir'] + and oldsitetype not in ['basic', 'wpfc', 'wpsc']): + Log.error("Cannot update {0} to wpsubdir w3tc" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=True, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=True, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.wpfc and not + (self.app.pargs.wpsc or self.app.pargs.w3tc)): + + if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdir'] + and oldsitetype not in ['basic', 'w3tc', 'wpsc']): + Log.error("Cannot update {0} to wpsubdir wpfc" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=False, + wpfc=True, wpsc=False, multisite=True, + wpsubdir=True, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.wpsc and not + (self.app.pargs.w3tc or self.app.pargs.wpfc)): + + if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdir'] + and oldsitetype not in ['basic', 'w3tc', 'wpfc']): + Log.error("Cannot update {0} to wpsubdir wpsc" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=False, + wpfc=False, wpsc=True, multisite=True, + wpsubdir=True, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.mysql or + self.app.pargs.wpsubdir or self.app.pargs.wp)): + + if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdomain'] + and oldsitetype not in ['w3tc', 'wpfc', 'wpsc']): + Log.error("Cannot update {0} to wpsubdomain basic" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=True, wp=True, w3tc=False, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.w3tc and not + (self.app.pargs.wpfc or self.app.pargs.wpsc)): + + if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdomain'] + and oldsitetype not in ['basic', 'wpfc', 'wpsc']): + Log.error("Cannot update {0} to wpsubdomain w3tc" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=True, + wpfc=False, wpsc=False, multisite=True, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.wpfc and not + (self.app.pargs.wpsc or self.app.pargs.w3tc)): + + if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdomain'] + and oldsitetype not in ['basic', 'w3tc', 'wpsc']): + Log.error("Cannot update {0} to wpsubdomain wpfc" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=False, + wpfc=True, wpsc=False, multisite=True, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + if (self.app.pargs.wpsc and not + (self.app.pargs.w3tc or self.app.pargs.wpfc)): + + if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdomain'] + and oldsitetype not in ['basic', 'w3tc', 'wpfc']): + Log.error("Cannot update {0} to wpsubdomain wpsc" + .format(ee_domain)) + sys.exit(1) + + data = dict(site_name=ee_domain, www_domain=ee_www_domain, + static=False, basic=False, wp=True, w3tc=False, + wpfc=False, wpsc=True, multisite=True, + wpsubdir=False, webroot=ee_site_webroot, + ee_db_name='', ee_db_user='', ee_db_pass='', + ee_db_host='', currsitetype=oldsitetype, + currcachetype=oldcachetype) + + # TODO take site backup before site update + siteBackup(self, data) + # TODO Check for required packages before update + + # setup NGINX configuration, and webroot + SetupDomain(self, data) + + if 'ee_db_name' in data.keys() and not data['wp']: + data = SetupDatabase(self, data) + try: + eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), + 'w') + eedbconfig.write("" + .format(data['ee_db_name'], + data['ee_db_user'], + data['ee_db_pass'], + data['ee_db_host'])) + eedbconfig.close() + stype = mysql + except IOError as e: + self.app.log.error("Unable to create ee-config.php for " + "{2} ({0}): {1}" + .format(e.errno, e.strerror, ee_domain)) + sys.exit(1) + + if oldsitetype == 'mysql': + config_file = (ee_site_webroot + '/backup/{0}/ee-config.php' + .format(EEVariables.ee_date)) + data['ee_db_name'] = EEFileUtils.grep(EEFileUtils + .grep(self, config_file, + 'DB_NAME') + .split(',')[1] + .split(')')[0].strip()) + data['ee_db_user'] = EEFileUtils.grep(EEFileUtils + .grep(self, config_file, + 'DB_USER') + .split(',')[1] + .split(')')[0].strip()) + data['ee_db_pass'] = EEFileUtils.grep(EEFileUtils + .grep(self, config_file, + 'DB_PASSWORD') + .split(',')[1] + .split(')')[0].strip()) + + # Setup WordPress if Wordpress site + if data['wp']: + ee_wp_creds = SetupWordpress(self, data) + # Service Nginx Reload + EEService.reload_service(self, 'nginx') + + EEGit.add(self, ["/etc/nginx"], + msg="{0} created with {1} {2}" + .format(ee_www_domain, stype, cache)) + # Setup Permissions for webroot + SetWebrootPermissions(self, data['webroot']) + if data['wp']: + Log.info(self, '\033[94m'+"WordPress Admin User :" + " {0}".format(ee_wp_creds['wp_user'])+'\033[0m') + Log.info(self, "WordPress Admin User Password : {0}" + .format(ee_wp_creds['wp_pass'])) + addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot) + Log.info(self, "Successfully created site" + " http://{0}".format(ee_domain)) def load(app): diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index 4fd1a322..165c49c3 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -27,9 +27,18 @@ class SiteDB(Base): storage_fs = Column(String) storage_db = Column(String) - # def __init__(self): + def __init__(self): # from sqlalchemy import create_engine # self.engine = create_engine('sqlite:///orm_in_detail.sqlite') + self.sitename = sitename + self.site_type = site_type + self.cache_type = cache_type + self.site_path = site_path + self.created_on = created_on + self.site_enabled = site_enabled + self.is_ssl = is_ssl + self.storage_fs = storage_fs + self.storage_db = storage_db # if __name__ == "__main__": # @@ -69,3 +78,22 @@ def addNewSite(self, site, stype, cache, path, Log.error(self, "Unable to add site to database : {0}" .format(e)) sys.exit(1) + + +def getSiteInfo(self, site): + db_path = self.app.config.get('site', 'db_path') + try: + from sqlalchemy import create_engine + engine = create_engine(db_path) + from sqlalchemy.orm import sessionmaker + session = sessionmaker() + session.configure(bind=engine) + Base.metadata.create_all(engine) + s = session() + q = s.query(SiteDB).filter_by(sitename=site).first() + s.flush() + return q + except Exception as e: + Log.error(self, "Unable to add site to database : {0}" + .format(e)) + sys.exit(1) diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index fe09dedc..27d7cca9 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -3,6 +3,7 @@ import os import sys import subprocess from subprocess import Popen +from ee.core.logging import Log class EEShellExec(): @@ -21,10 +22,10 @@ class EEShellExec(): return False except OSError as e: if errormsg: - self.app.log.error("{0}", errormsg) + Log.error(self, errormsg) else: - self.app.log.error("Unable to execute command \ {0}{1}" - .format(e.errno, e.strerror)) - self.app.log.debug("Unable to execute command \ {0}{1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to execute command \ {0}{1}" + .format(e.errno, e.strerror)) + Log.debug(self, "Unable to execute command \ {0}{1}" + .format(e.errno, e.strerror)) sys.exit(1) From c71e597fa764b7ccf579b2b6b2259883850e92be Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 12 Jan 2015 15:17:14 +0530 Subject: [PATCH 633/829] Fixed typos --- ee/cli/plugins/stack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 67a850b1..404fe14b 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -865,8 +865,8 @@ class EEStackController(CementBaseController): 'webmail.error.log', '/var/www/roundcubemail/' 'logs/error.log']) - # Remove roundcube installer - EEFileUtils.remove() + # Remove roundcube installe[r + EEFileUtils.remove(self, ["/var/www/roundcubemail/installer"]) EEService.reload_service(self, 'nginx') @expose() From 3722800156fe379395e0488d68757513be927be7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 12 Jan 2015 15:29:26 +0530 Subject: [PATCH 634/829] Now using Python function for permission instead of shell --- ee/cli/plugins/stack.py | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 404fe14b..3442d478 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -518,8 +518,10 @@ class EEStackController(CementBaseController): # Compile sieve rules self.app.log.debug("Privillages to dovecot ") - EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" - "/dovecot") + # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" + # "/dovecot") + EEFileUtils.chown(self, "/var/lig/dovecot", "vmail", "vmail" + recursive=True) EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/" "default.sieve") EEGit.add(self, ["/etc/postfix", "/etc/dovecot"], @@ -582,8 +584,11 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/db/pma/') self.app.log.debug('Privillages to www-data:www-data ' '/var/www/22222/htdocs/db/pma ') - EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - '/var/www/22222/htdocs/db/pma') + # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' + # '/var/www/22222/htdocs/db/pma') + EEFileUtils.chown(self, '/var/www/22222', + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) if any('/tmp/memcache.tar.gz' == x[1] for x in packages): self.app.log.debug("Extracting memcache.tar.gz to location" @@ -592,8 +597,11 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/cache/memcache') self.app.log.debug("Privillages to" " /var/www/22222/htdocs/cache/memcache") - EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - '/var/www/22222/htdocs/cache/memcache') + # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' + # '/var/www/22222/htdocs/cache/memcache') + EEFileUtils.chown(self, '/var/www/22222', + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) if any('/tmp/webgrind.tar.gz' == x[1] for x in packages): @@ -608,8 +616,11 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/php/webgrind') self.app.log.debug("Privillages www-data:www-data " "/var/www/22222/htdocs/php/webgrind/ ") - EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - '/var/www/22222/htdocs/php/webgrind/') + # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' + # '/var/www/22222/htdocs/php/webgrind/') + EEFileUtils.chown(self, '/var/www/22222', + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) if any('/tmp/anemometer.tar.gz' == x[1] for x in packages): @@ -733,6 +744,10 @@ class EEStackController(CementBaseController): "/bin/doctrine2-cli.php orm:schema-tool:" "create") + EEFileUtils.chown(self, '/var/www/22222', + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) + # Copy Dovecot and Postfix templates which are depednet on # Vimbadmin @@ -865,8 +880,12 @@ class EEStackController(CementBaseController): 'webmail.error.log', '/var/www/roundcubemail/' 'logs/error.log']) - # Remove roundcube installe[r + # Remove roundcube installer EEFileUtils.remove(self, ["/var/www/roundcubemail/installer"]) + EEFileUtils.chown(self, '/var/www/roundcubemail', + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) + EEService.reload_service(self, 'nginx') @expose() @@ -1023,8 +1042,8 @@ class EEStackController(CementBaseController): packages = packages + ["/var/www/22222/htdocs/vimbadmin", "/var/www/roundcubemail"] if EEShellExec.cmd_exec("mysqladmin ping"): - EEMysql.execute("drop database vimbadmin") - EEMysql.execute("drop database roundcubemail") + EEMysql.execute("drop database IF EXISTS vimbadmin") + EEMysql.execute("drop database IF EXISTS roundcubemail") if self.app.pargs.nginx: self.app.log.debug("Removing apt_packages variable of Nginx") From 7feedc1207dfb88ddd5fe492bb9c653eea048d68 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 12 Jan 2015 15:43:10 +0530 Subject: [PATCH 635/829] Fixed depedencies of ee admin tools --- ee/cli/plugins/stack.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 3442d478..8d2ec323 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -900,6 +900,8 @@ class EEStackController(CementBaseController): self.app.pargs.postfix = True if self.app.pargs.admin: + self.app.pargs.nginx = True + self.app.pargs.php = True self.app.pargs.adminer = True self.app.pargs.phpmyadmin = True self.app.pargs.utils = True @@ -1041,9 +1043,9 @@ class EEStackController(CementBaseController): apt_packages = apt_packages + EEVariables.ee_mailscanner packages = packages + ["/var/www/22222/htdocs/vimbadmin", "/var/www/roundcubemail"] - if EEShellExec.cmd_exec("mysqladmin ping"): - EEMysql.execute("drop database IF EXISTS vimbadmin") - EEMysql.execute("drop database IF EXISTS roundcubemail") + if EEShellExec.cmd_exec(self, "mysqladmin ping"): + EEMysql.execute(self, "drop database IF EXISTS vimbadmin") + EEMysql.execute(self, "drop database IF EXISTS roundcubemail") if self.app.pargs.nginx: self.app.log.debug("Removing apt_packages variable of Nginx") @@ -1106,8 +1108,8 @@ class EEStackController(CementBaseController): packages = packages + ["/var/www/22222/htdocs/vimbadmin", "/var/www/roundcubemail"] if EEShellExec.cmd_exec(self, "mysqladmin ping"): - EEMysql.execute(self, "drop database vimbadmin") - EEMysql.execute(self, "drop database roundcubemail") + EEMysql.execute(self, "drop database IF EXISTS vimbadmin") + EEMysql.execute(self, "drop database IF EXISTS roundcubemail") if self.app.pargs.nginx: self.app.log.debug("Purge apt_packages variable of Nginx") From e0895afa49c4110bd0485133f3270816befe80f7 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 12 Jan 2015 16:54:03 +0530 Subject: [PATCH 636/829] Fixed roundcube installer error --- ee/cli/plugins/stack.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 8d2ec323..f0922446 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -520,7 +520,7 @@ class EEStackController(CementBaseController): self.app.log.debug("Privillages to dovecot ") # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" # "/dovecot") - EEFileUtils.chown(self, "/var/lig/dovecot", "vmail", "vmail" + EEFileUtils.chown(self, "/var/lig/dovecot", "vmail", "vmail", recursive=True) EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/" "default.sieve") @@ -881,13 +881,13 @@ class EEStackController(CementBaseController): '/var/www/roundcubemail/' 'logs/error.log']) # Remove roundcube installer - EEFileUtils.remove(self, ["/var/www/roundcubemail/installer"]) + EEService.reload_service(self, 'nginx') + EEFileUtils.remove(self, ["/var/www/roundcubemail" + "/htdocs/installer"]) EEFileUtils.chown(self, '/var/www/roundcubemail', EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) - EEService.reload_service(self, 'nginx') - @expose() def install(self, packages=[], apt_packages=[]): if self.app.pargs.web: From 03588155bc822854981e6d65f9aeb2cfd5a59a9a Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 12 Jan 2015 18:04:58 +0530 Subject: [PATCH 637/829] Fixed dependancies of admin tool --- ee/cli/plugins/stack.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index f0922446..ea12eac8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -902,6 +902,7 @@ class EEStackController(CementBaseController): if self.app.pargs.admin: self.app.pargs.nginx = True self.app.pargs.php = True + self.app.pargs.mysql = True self.app.pargs.adminer = True self.app.pargs.phpmyadmin = True self.app.pargs.utils = True From 3b78cf0b1f3f73cbf3d84f4b3707e8d11b4c61ae Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 13 Jan 2015 16:22:35 +0530 Subject: [PATCH 638/829] added log messages --- ee/cli/plugins/clean.py | 24 +- ee/cli/plugins/debug.py | 117 +++++----- ee/cli/plugins/secure.py | 15 +- ee/cli/plugins/stack.py | 373 ++++++++++++++++--------------- ee/cli/plugins/stack_services.py | 59 ++--- ee/core/aptget.py | 1 - ee/core/download.py | 21 +- ee/core/extract.py | 5 +- ee/core/fileutils.py | 22 +- ee/core/git.py | 15 +- ee/core/mysql.py | 9 +- ee/core/services.py | 27 +-- ee/core/shellexec.py | 4 +- 13 files changed, 353 insertions(+), 339 deletions(-) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 21138e3b..76dc2ac6 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -5,6 +5,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook import os import urllib.request +from ee.core.logging import Log def clean_plugin_hook(app): @@ -49,30 +50,31 @@ class EECleanController(CementBaseController): @expose(hide=True) def clean_memcache(self): - if(EEAptGet.is_installed("memcached")): - self.app.log.info("memcache is installed") - EEService.restart_service(self, "memcached") - self.app.log.info("Cleaning memcache..") - else: - self.app.log.info("memcache is not installed") + try: + if(EEAptGet.is_installed("memcached")): + EEService.restart_service(self, "memcached") + Log.info(self, "Cleaning memcache..") + else: + Log.error(self, "Memcache not installed") + except: + Log.error(self, "Unable to restart memcached") @expose(hide=True) def clean_fastcgi(self): if(os.path.isdir("/var/run/nginx-cache")): - self.app.log.info("Cleaning fastcgi...") + Log.info(self, "Cleaning NGINX FastCGI cache, please wait...") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") else: - self.app.log.info("Error occur while Cleaning fastcgi..") + Log.error(self, "Unable to clean FastCGI cache") @expose(hide=True) def clean_opcache(self): try: - self.app.log.info("Cleaning opcache.... ") + Log.info(self, "Cleaning opcache.... ") wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" "/opcache/opgui.php?page=reset").read() except Exception as e: - self.app.log.info("Unable to clean opacache\n {0}{1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to clean opacache {0}".format(e)) def load(app): diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index b181dc29..2beb5d50 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -6,6 +6,7 @@ from ee.core.shellexec import EEShellExec from ee.core.mysql import EEMysql from ee.core.services import EEService import os +from ee.core.logging import Log def debug_plugin_hook(app): @@ -57,8 +58,8 @@ class EEDebugController(CementBaseController): for ip_addr in debug_address: if not ("debug_connection "+ip_addr in open('/etc/nginx/' 'nginx.conf').read()): - self.app.log.info("Setting up NGINX debug connection" - " for "+ip_addr) + Log.info(self, "Setting up NGINX debug connection" + " for "+ip_addr) EEShellExec.cmd_exec(self, "sed -i \"/events {{/a\\ \\ \\ " "\\ $(echo debug_connection " "{ip}\;)\" /etc/nginx/" @@ -66,19 +67,19 @@ class EEDebugController(CementBaseController): self.trigger_nginx = True if not self.trigger_nginx: - self.app.log.info("NGINX debug connection already enabled") + Log.info(self, "NGINX debug connection already enabled") self.msg = self.msg + [" /var/log/nginx/*.error.log"] # stop global debug elif not self.start and not self.app.pargs.site_name: if "debug_connection " in open('/etc/nginx/nginx.conf').read(): - self.app.log.info("Disabling Nginx debug connections") + Log.info(self, "Disabling Nginx debug connections") EEShellExec.cmd_exec(self, "sed -i \"/debug_connection.*/d\"" " /etc/nginx/nginx.conf") self.trigger_nginx = True else: - self.app.log.info("Nginx debug connection already disbaled") + Log.info(self, "Nginx debug connection already disbaled") # start site specific debug elif self.start and self.app.pargs.site_name: @@ -87,22 +88,21 @@ class EEDebugController(CementBaseController): if os.path.isfile(config_path): if not EEShellExec.cmd_exec("grep \"error.log debug\" {0}" .format(config_path)): - self.app.log.info("Starting NGINX debug connection for " - "{0}" - .format(self.app.pargs.site_name)) + Log.info(self, "Starting NGINX debug connection for " + "{0}".format(self.app.pargs.site_name)) EEShellExec.cmd_exec("sed -i \"s/error.log;/error.log " "debug;/\" {0}".format(config_path)) self.trigger_nginx = True else: - self.app.log.info("Debug for site allready enabled") + Log.info(self, "Debug for site allready enabled") self.msg = self.msg + ['/var/www//logs/error.log' .format(self.app.pargs.site_name)] else: - self.app.log.info("{0} domain not valid" - .format(self.app.pargs.site_name)) + Log.info(self, "{0} domain not valid" + .format(self.app.pargs.site_name)) # stop site specific debug elif not self.start and self.app.pargs.site_name: @@ -111,19 +111,19 @@ class EEDebugController(CementBaseController): if os.path.isfile(config_path): if EEShellExec.cmd_exec("grep \"error.log debug\" {0}" .format(config_path)): - self.app.log.info("Stoping NGINX debug connection for {0}" - .format(self.app.pargs.site_name)) + Log.info(self, "Stoping NGINX debug connection for {0}" + .format(self.app.pargs.site_name)) EEShellExec.cmd_exec("sed -i \"s/error.log debug;/" "error.log;/\" {0}" .format(config_path)) self.trigger_nginx = True else: - self.app.log.info("Debug for site allready disbaled") + Log.info(self, "Debug for site allready disbaled") else: - self.app.log.info("{0} domain not valid" - .format(self.app.pargs.site_name)) + Log.info(self, "{0} domain not valid" + .format(self.app.pargs.site_name)) @expose(hide=True) def debug_php(self): @@ -133,16 +133,16 @@ class EEDebugController(CementBaseController): "{/,/}/p \" /etc/nginx/" "conf.d/upstream.conf " "| grep 9001")): - self.app.log.info("Enabling PHP debug") + Log.info(self, "Enabling PHP debug") data = dict(php="9001", debug="9001") - self.app.log.info('writting the nginx configration to file' - '/etc/nginx/conf.d/upstream.conf ') + Log.info(self, 'writting the nginx configration to file' + '/etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() self.trigger_php = True else: - self.app.log.info("PHP debug is allready enabled") + Log.info(self, "PHP debug is allready enabled") self.msg = self.msg + ['/var/log/php5/slow.log'] @@ -151,16 +151,16 @@ class EEDebugController(CementBaseController): if EEShellExec.cmd_exec(self, "sed -n \"/upstream php {/,/}/p\" " "/etc/nginx/conf.d/upstream.conf " "| grep 9001"): - self.app.log.info("Disabling PHP debug") + Log.info(self, "Disabling PHP debug") data = dict(php="9000", debug="9001") - self.app.log.info('writting the nginx configration to file' - '/etc/nginx/conf.d/upstream.conf ') + Log.info(self, 'writting the nginx configration to file' + '/etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() self.trigger_php = True else: - self.app.log.info("PHP debug is allready disbaled") + Log.info(self, "PHP debug is allready disbaled") @expose(hide=True) def debug_fpm(self): @@ -168,27 +168,27 @@ class EEDebugController(CementBaseController): if self.start: if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): - self.app.log.info("Setting up PHP5-FPM log_level = debug") + Log.info(self, "Setting up PHP5-FPM log_level = debug") EEShellExec.cmd_exec(self, "sed -i \"s\';log_level.*\'log_" "level = debug\'\" /etc/php5/fpm" "/php-fpm.conf") self.trigger_php = True else: - self.app.log.info("PHP5-FPM log_level = debug already setup") + Log.info(self, "PHP5-FPM log_level = debug already setup") self.msg = self.msg + ['/var/log/php5/fpm.log'] # PHP5-FPM stop global debug else: if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): - self.app.log.info("Disabling PHP5-FPM log_level = debug") + Log.info(self, "Disabling PHP5-FPM log_level = debug") EEShellExec.cmd_exec(self, "sed -i \"s\'log_level.*\';log_" "level = notice\'\" /etc/php5/fpm" "/php-fpm.conf") self.trigger_php = True else: - self.app.log.info("PHP5-FPM log_level = debug " - " already disabled") + Log.info(self, "PHP5-FPM log_level = debug " + " already disabled") @expose(hide=True) def debug_mysql(self): @@ -197,7 +197,7 @@ class EEDebugController(CementBaseController): if not EEShellExec.cmd_exec(self, "mysql -e \"show variables like" " \'slow_query_log\';\" | " "grep ON"): - print("Setting up MySQL slow log") + Log.info(self, "Setting up MySQL slow log") EEMysql.execute(self, "set global slow_query_log = " "\'ON\';") EEMysql.execute(self, "set global slow_query_log_file = " @@ -218,7 +218,7 @@ class EEDebugController(CementBaseController): "n#EasyEngine end MySQL slow log\\\";" " }} | crontab -\"".format(cron_time)) else: - self.app.log.info("MySQL slow log is allready enabled") + Log.info(self, "MySQL slow log is allready enabled") self.msg = self.msg + ['/var/log/mysql/mysql-slow.log'] @@ -226,7 +226,7 @@ class EEDebugController(CementBaseController): else: if EEShellExec.cmd_exec(self, "mysql -e \"show variables like \'" "slow_query_log\';\" | grep ON"): - print("Disabling MySQL slow log") + Log.info(self, "Disabling MySQL slow log") EEMysql.execute(self, "set global slow_query_log = \'OFF\';") EEMysql.execute(self, "set global slow_query_log_file = \'" "/var/log/mysql/mysql-slow.log\';") @@ -236,7 +236,7 @@ class EEDebugController(CementBaseController): EEShellExec.cmd_exec(self, "crontab -l | sed \'/#EasyEngine " "start/,/#EasyEngine end/d\' | crontab -") else: - self.app.log.info("MySQL slow log already disabled") + Log.info(self, "MySQL slow log already disabled") @expose(hide=True) def debug_wp(self): @@ -247,7 +247,7 @@ class EEDebugController(CementBaseController): if os.path.isfile(wp_config): if not EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |" " grep true".format(wp_config)): - self.app.log.info("Starting WordPress debug") + Log.info(self, "Starting WordPress debug") open("{0}/htdocs/wp-content/debug.log".format(webroot), 'a').close() EEShellExec.cmd_exec(self, "chown www-data: {0}/htdocs/wp-" @@ -265,10 +265,10 @@ class EEDebugController(CementBaseController): "wp-content/plugins" .format(webroot)) else: - self.app.log.info("WordPress debug log already enabled") + Log.info(self, "WordPress debug log already enabled") else: - self.app.log.info("{0} domain not valid" - .format(self.app.pargs.site_name)) + Log.info(self, "{0} domain not valid" + .format(self.app.pargs.site_name)) elif not self.start and self.app.pargs.site_name: wp_config = ("/var/www/{0}/wp-config.php" @@ -277,7 +277,7 @@ class EEDebugController(CementBaseController): if os.path.isfile(wp_config): if EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | " "grep true".format(wp_config)): - self.app.log.info("Disabling WordPress debug") + Log.info(self, "Disabling WordPress debug") EEShellExec.cmd_exec(self, "sed -i \"s/define(\'WP_DEBUG\'" ", true);/define(\'WP_DEBUG\', " "false);/\" {0}".format(wp_config)) @@ -291,12 +291,12 @@ class EEDebugController(CementBaseController): "SAVEQUERIES\', " "true);/d\" {0}".format(wp_config)) else: - print("WordPress debug all already disbaled") + Log.info(self, "WordPress debug all already disbaled") else: - self.app.log.info("{0} domain not valid" - .format(self.app.pargs.site_name)) + Log.info(self, "{0} domain not valid" + .format(self.app.pargs.site_name)) else: - self.app.log.info("Missing argument site_name") + Log.info(self, "Missing argument site_name") @expose(hide=True) def debug_rewrite(self): @@ -304,12 +304,12 @@ class EEDebugController(CementBaseController): if self.start and not self.app.pargs.site_name: if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " "/etc/nginx/nginx.conf"): - self.app.log.info("Setting up Nginx rewrite logs") + Log.info(self, "Setting up Nginx rewrite logs") EEShellExec.cmd_exec(self, "sed -i \'/http {/a \\\\t" "rewrite_log on;\' /etc/nginx/nginx.conf") self.trigger_nginx = True else: - self.app.log.info("NGINX rewrite logs already enabled") + Log.info(self, "NGINX rewrite logs already enabled") if '/var/log/nginx/*.error.log' not in self.msg: self.msg = self.msg + ['/var/log/nginx/*.error.log'] @@ -318,27 +318,27 @@ class EEDebugController(CementBaseController): elif not self.start and not self.app.pargs.site_name: if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " "/etc/nginx/nginx.conf"): - self.app.log.info("Disabling Nginx rewrite logs") + Log.info(self, "Disabling Nginx rewrite logs") EEShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\"" " /etc/nginx/nginx.conf") self.trigger_nginx = True else: - self.app.log.info("NGINX rewrite logs already disbaled") + Log.info(self, "NGINX rewrite logs already disbaled") # Start Nginx rewrite for site elif self.start and self.app.pargs.site_name: config_path = ("/etc/nginx/sites-available/{0}.conf" .format(self.app.pargs.site_name)) if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" .format(config_path)): - self.app.log.info("Setting up NGINX rewrite logs for {0}" - .format(self.app.pargs.site_name)) + Log.info(self, "Setting up NGINX rewrite logs for {0}" + .format(self.app.pargs.site_name)) EEShellExec.cmd_exec(self, "sed -i \"/access_log/i \\\\\\t" "rewrite_log on;\" {0}" .format(config_path)) self.trigger_nginx = True else: - self.app.log.info("Nginx rewrite logs for {0} allready setup" - .format(self.app.pargs.site_name)) + Log.info(self, "Nginx rewrite logs for {0} allready setup" + .format(self.app.pargs.site_name)) if ('/var/www/{0}/logs/error.log'.format(self.app.pargs.site_name) not in self.msg): @@ -351,15 +351,14 @@ class EEDebugController(CementBaseController): .format(self.app.pargs.site_name)) if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" .format(config_path)): - self.app.log.info("Disabling NGINX rewrite logs for {0}" - .format(self.app.pargs.site_name)) + Log.info(self, "Disabling NGINX rewrite logs for {0}" + .format(self.app.pargs.site_name)) EEShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\" {0}" .format(config_path)) self.trigger_nginx = True else: - self.app.log.info("Nginx rewrite logs for {0} allready " - " disbaled" - .format(self.app.pargs.site_name)) + Log.info(self, "Nginx rewrite logs for {0} allready " + " disbaled".format(self.app.pargs.site_name)) @expose(hide=True) def default(self): @@ -404,10 +403,10 @@ class EEDebugController(CementBaseController): # Reload PHP if self.trigger_php: EEService.reload_service(self, ['php5-fpm']) - - if len(self.msg) > 0: - self.app.log.info("Use following command to check debug logs:" - "\n{0}".format(self.msg.join())) + # + # if len(self.msg) > 0: + # self.app.log.info("Use following command to check debug logs:" + # "\n{0}".format(self.msg.join())) def load(app): diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 79bcc4cf..3e9ba394 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -7,6 +7,7 @@ import random import sys import hashlib import getpass +from ee.core.logging import Log def secure_plugin_hook(app): @@ -50,12 +51,12 @@ class EEsecureController(CementBaseController): "password [{0}]".format(passwd)) if username == "": username = EEVariables.ee_user - self.app.log.info("HTTP authentication username:{username}" - .format(username=username)) + Log.info(self, "HTTP authentication username:{username}" + .format(username=username)) if password == "": password = passwd - self.app.log.info("HTTP authentication password:{password}" - .format(password=password)) + Log.info(self, "HTTP authentication password:{password}" + .format(password=password)) EEShellExec.cmd_exec(self, "printf \"{username}:" "$(openssl passwd -crypt " "{password} 2> /dev/null)\n\"" @@ -73,11 +74,15 @@ class EEsecureController(CementBaseController): "{port} default_server ssl spdy;/\" " "/etc/nginx/sites-available/22222" .format(port=port)) - elif EEVariables.ee_platform_distro == 'Debian': + else: + Log.info(self, "Unable to change EasyEngine admin port") + if EEVariables.ee_platform_distro == 'Debian': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl;/\" " "/etc/nginx/sites-available/22222" .format(port=port)) + else: + Log.info(self, "Unable to change EasyEngine admin port") @expose(hide=True) def secure_ip(self): diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index ea12eac8..c1be06cc 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -23,6 +23,7 @@ import os import pwd import grp from ee.cli.plugins.stack_services import EEStackStatusController +from ee.core.logging import Log def ee_stack_hook(app): @@ -69,12 +70,12 @@ class EEStackController(CementBaseController): @expose(hide=True) def default(self): # TODO Default action for ee stack command - print("Inside EEStackController.default().") + Log.info(self, "Inside EEStackController.default().") @expose(hide=True) def pre_pref(self, apt_packages): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): - print("Pre-seeding postfix variables ... ") + Log.info(self, "Pre-seeding postfix variables ... ") EEShellExec.cmd_exec(self, "echo \"postfix postfix" "/main_mailer_type string \'Internet Site\'\"" " | debconf-set-selections") @@ -82,12 +83,12 @@ class EEStackController(CementBaseController): " $(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): - print("Adding repository for MySQL ... ") + Log.info(self, "Adding repository for MySQL ... ") EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) - self.app.log.debug('Adding key of MySQL.') + Log.debug(self, 'Adding key of MySQL.') EERepo.add_key(self, '1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) - print("Pre-seeding MySQL variables ... ") + Log.info(self, "Pre-seeding MySQL variables ... ") EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " "percona-server-server/root_password " "password {chars}\" | " @@ -103,35 +104,35 @@ class EEStackController(CementBaseController): """.format(chars=chars) config = configparser.ConfigParser() config.read_string(mysql_config) - self.app.log.debug('writting configartion into MySQL file.') + Log.debug(self, 'writting configartion into MySQL file.') with open(os.path.expanduser("~")+'/.my.cnf', 'w') as configfile: config.write(configfile) if set(EEVariables.ee_nginx).issubset(set(apt_packages)): - print("Adding repository for Nginx ... ") + Log.info(self, "Adding repository for Nginx ... ") if EEVariables.ee_platform_distro == 'Debian': - self.app.log.debug('Adding Dotdeb/nginx GPG key') + Log.debug(self, 'Adding Dotdeb/nginx GPG key') EERepo.add(self, repo_url=EEVariables.ee_nginx_repo) else: - self.app.log.debug('Adding ppa of Nginx') + Log.debug(self, 'Adding ppa of Nginx') EERepo.add(self, ppa=EEVariables.ee_nginx_repo) if set(EEVariables.ee_php).issubset(set(apt_packages)): - print("Adding repository for PHP ... ") + Log.info(self, "Adding repository for PHP ... ") if EEVariables.ee_platform_distro == 'Debian': - self.app.log.debug('Adding repo_url of php for Debian') + Log.debug(self, 'Adding repo_url of php for Debian') EERepo.add(self, repo_url=EEVariables.ee_php_repo) - self.app.log.debug('Adding Dotdeb/php GPG key') + Log.debug(self, 'Adding Dotdeb/php GPG key') EERepo.add_key(self, '89DF5277') else: - self.app.log.debug('Adding ppa for PHP') + Log.debug(self, 'Adding ppa for PHP') EERepo.add(self, ppa=EEVariables.ee_php_repo) if set(EEVariables.ee_mail).issubset(set(apt_packages)): if EEVariables.ee_platform_codename == 'squeeze': - print("Adding repository for dovecot ... ") + Log.info(self, "Adding repository for dovecot ... ") EERepo.add(self, repo_url=EEVariables.ee_dovecot_repo) - self.app.log.debug('Executing the command debconf-set-selections.') + Log.debug(self, 'Executing the command debconf-set-selections.') EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/" "create-ssl-cert boolean yes\" " "| debconf-set-selections") @@ -151,7 +152,7 @@ class EEStackController(CementBaseController): if ((not os.path.isfile('/etc/nginx/conf.d/ee-nginx.conf')) and os.path.isfile('/etc/nginx/nginx.conf')): nc = NginxConfig() - self.app.log.debug('Loading file /etc/nginx/nginx.conf ') + Log.debug(self, 'Loading file /etc/nginx/nginx.conf ') nc.loadf('/etc/nginx/nginx.conf') nc.set('worker_processes', 'auto') nc.append(('worker_rlimit_nofile', '100000'), position=2) @@ -160,106 +161,106 @@ class EEStackController(CementBaseController): [('worker_connections', '4096'), ('multi_accept', 'on')]}, position=4) nc.set([('http',), 'keepalive_timeout'], '30') - self.app.log.debug("Writting nginx configration to " - "file /etc/nginx/nginx.conf ") + Log.debug(self, "Writting nginx configration to " + "file /etc/nginx/nginx.conf ") nc.savef('/etc/nginx/nginx.conf') # Custom Nginx configuration by EasyEngine data = dict(version='EasyEngine 3.0.1') - self.app.log.debug('writting the nginx configration to ' - 'file /etc/nginx/conf.d/ee-nginx.conf ') + Log.debug(self, 'writting the nginx configration to ' + 'file /etc/nginx/conf.d/ee-nginx.conf ') ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') self.app.render((data), 'nginx-core.mustache', out=ee_nginx) ee_nginx.close() data = dict() - self.app.log.debug('writting the nginx configration to' - 'file /etc/nginx/conf.d/blockips.conf') + Log.debug(self, 'writting the nginx configration to' + 'file /etc/nginx/conf.d/blockips.conf') ee_nginx = open('/etc/nginx/conf.d/blockips.conf', 'w') self.app.render((data), 'blockips.mustache', out=ee_nginx) ee_nginx.close() - self.app.log.debug('writting the nginx configration to' - ' file /etc/nginx/conf.d/fastcgi.conf') + Log.debug(self, 'writting the nginx configration to' + ' file /etc/nginx/conf.d/fastcgi.conf') ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf', 'w') self.app.render((data), 'fastcgi.mustache', out=ee_nginx) ee_nginx.close() data = dict(php="9000", debug="9001") - self.app.log.debug('writting the nginx configration to' - 'file /etc/nginx/conf.d/upstream.conf ') + Log.debug(self, 'writting the nginx configration to' + 'file /etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() # Setup Nginx common directory if not os.path.exists('/etc/nginx/common'): - self.app.log.debug('Creating directory' - '/etc/nginx/common') + Log.debug(self, 'Creating directory' + '/etc/nginx/common') os.makedirs('/etc/nginx/common') data = dict() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/acl.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/common/acl.conf') ee_nginx = open('/etc/nginx/common/acl.conf', 'w') self.app.render((data), 'acl.mustache', out=ee_nginx) ee_nginx.close() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/locations.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/common/locations.conf') ee_nginx = open('/etc/nginx/common/locations.conf', 'w') self.app.render((data), 'locations.mustache', out=ee_nginx) ee_nginx.close() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/ php.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/common/ php.conf') ee_nginx = open('/etc/nginx/common/php.conf', 'w') self.app.render((data), 'php.mustache', out=ee_nginx) ee_nginx.close() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/w3tc.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/common/w3tc.conf') ee_nginx = open('/etc/nginx/common/w3tc.conf', 'w') self.app.render((data), 'w3tc.mustache', out=ee_nginx) ee_nginx.close() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/wpcommon.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/common/wpcommon.conf') ee_nginx = open('/etc/nginx/common/wpcommon.conf', 'w') self.app.render((data), 'wpcommon.mustache', out=ee_nginx) ee_nginx.close() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/wpfc.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/common/wpfc.conf') ee_nginx = open('/etc/nginx/common/wpfc.conf', 'w') self.app.render((data), 'wpfc.mustache', out=ee_nginx) ee_nginx.close() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/wpsc.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/common/wpsc.conf') ee_nginx = open('/etc/nginx/common/wpsc.conf', 'w') self.app.render((data), 'wpsc.mustache', out=ee_nginx) ee_nginx.close() - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/common/wpsubdir.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/common/wpsubdir.conf') ee_nginx = open('/etc/nginx/common/wpsubdir.conf', 'w') self.app.render((data), 'wpsubdir.mustache', out=ee_nginx) ee_nginx.close() # 22222 port settings - self.app.log.debug('Writting the nginx configration to' - 'file /etc/nginx/sites-available/' - '22222.conf') + Log.debug(self, 'Writting the nginx configration to' + 'file /etc/nginx/sites-available/' + '22222.conf') ee_nginx = open('/etc/nginx/sites-available/22222.conf', 'w') self.app.render((data), '22222.mustache', @@ -269,7 +270,7 @@ class EEStackController(CementBaseController): passwd = ''.join([random.choice (string.ascii_letters + string.digits) for n in range(6)]) - EEShellExec.cmd_exec(self, "printf \"easyengine:" + EEShellExec.cmd_exec(self, "Log.infof \"easyengine:" "$(openssl passwd -crypt " "{password} 2> /dev/null)\n\"" "> /etc/nginx/htpasswd-ee 2>/dev/null" @@ -329,12 +330,12 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_php).issubset(set(apt_packages)): # Create log directories if not os.path.exists('/var/log/php5/'): - self.app.log.debug('Creating directory /var/log/php5/') + Log.debug(self, 'Creating directory /var/log/php5/') os.makedirs('/var/log/php5/') # Parse etc/php5/fpm/php.ini config = configparser.ConfigParser() - self.app.log.debug("configring php file /etc/php5/fpm/php.ini") + Log.debug(self, "configring php file /etc/php5/fpm/php.ini") config.read('/etc/php5/fpm/php.ini') config['PHP']['expose_php'] = 'Off' config['PHP']['post_max_size'] = '100M' @@ -342,8 +343,8 @@ class EEStackController(CementBaseController): config['PHP']['max_execution_time'] = '300' config['PHP']['date.timezone'] = time.tzname[time.daylight] with open('/etc/php5/fpm/php.ini', 'w') as configfile: - self.app.log.debug("writting configration of php in to" - "file /etc/php5/fpm/php.ini") + Log.debug(self, "writting configration of php in to" + "file /etc/php5/fpm/php.ini") config.write(configfile) # Prase /etc/php5/fpm/php-fpm.conf @@ -351,8 +352,8 @@ class EEStackController(CementBaseController): config.read('/etc/php5/fpm/php-fpm.conf') config['global']['error_log'] = '/var/log/php5/fpm.log' with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: - self.app.log.debug("writting php5 configartion into " - " /etc/php5/fpm/php-fpm.conf") + Log.debug(self, "writting php5 configartion into " + " /etc/php5/fpm/php-fpm.conf") config.write(configfile) # Parse /etc/php5/fpm/pool.d/www.conf @@ -369,8 +370,8 @@ class EEStackController(CementBaseController): config['www']['pm'] = 'ondemand' config['www']['listen'] = '127.0.0.1:9000' with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile: - self.app.log.debug("writting PHP5 configartion into " - " /etc/php5/fpm/pool.d/www.conf") + Log.debug(self, "writting PHP5 configartion into " + " /etc/php5/fpm/pool.d/www.conf") config.write(configfile) # Generate /etc/php5/fpm/pool.d/debug.conf @@ -382,8 +383,8 @@ class EEStackController(CementBaseController): config.read('/etc/php5/fpm/pool.d/debug.conf') config['debug']['listen'] = '127.0.0.1:9001' with open('/etc/php5/fpm/pool.d/debug.conf', 'w') as confifile: - self.app.log.debug("writting PHP5 configartion into " - " /etc/php5/fpm/pool.d/debug.conf") + Log.debug(self, "writting PHP5 configartion into " + " /etc/php5/fpm/pool.d/debug.conf") config.write(confifile) EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") EEService.reload_service(self, 'php5-fpm') @@ -414,7 +415,7 @@ class EEStackController(CementBaseController): EEService.reload_service(self, 'mysql') if set(EEVariables.ee_mail).issubset(set(apt_packages)): - self.app.log.debug("Executing mail commands") + Log.debug(self, "Executing mail commands") EEShellExec.cmd_exec(self, "adduser --uid 5000 --home /var" "/vmail --disabled-password --gecos ''" " vmail") @@ -425,15 +426,15 @@ class EEStackController(CementBaseController): "pem -keyout /etc/ssl/private/dovecot.pem" .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) - self.app.log.debug("Adding Privillages to file " - "/etc/ssl/private/dovecot.pem ") + Log.debug(self, "Adding Privillages to file " + "/etc/ssl/private/dovecot.pem ") EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private" "/dovecot.pem") # Custom Dovecot configuration by EasyEngine data = dict() - self.app.log.debug("Writting configration into file" - "/etc/dovecot/conf.d/99-ee.conf ") + Log.debug(self, "Writting configration into file" + "/etc/dovecot/conf.d/99-ee.conf ") ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf', 'w') self.app.render((data), 'dovecot.mustache', out=ee_dovecot) ee_dovecot.close() @@ -503,21 +504,21 @@ class EEStackController(CementBaseController): # Sieve configuration if not os.path.exists('/var/lib/dovecot/sieve/'): - self.app.log.debug('Creating directory' - '/var/lib/dovecot/sieve/ ') + Log.debug(self, 'Creating directory' + '/var/lib/dovecot/sieve/ ') os.makedirs('/var/lib/dovecot/sieve/') # Custom sieve configuration by EasyEngine data = dict() - self.app.log.debug("Writting configaration of EasyEngine into" - "file /var/lib/dovecot/sieve/default.sieve") + Log.debug(self, "Writting configaration of EasyEngine into" + "file /var/lib/dovecot/sieve/default.sieve") ee_sieve = open('/var/lib/dovecot/sieve/default.sieve', 'w') self.app.render((data), 'default-sieve.mustache', out=ee_sieve) ee_sieve.close() # Compile sieve rules - self.app.log.debug("Privillages to dovecot ") + Log.debug(self, "Privillages to dovecot ") # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" # "/dovecot") EEFileUtils.chown(self, "/var/lig/dovecot", "vmail", "vmail", @@ -532,8 +533,8 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): # Set up Custom amavis configuration data = dict() - self.app.log.debug("Configuring file /etc/amavis/conf.d" - "/15-content_filter_mode") + Log.debug(self, "Configuring file /etc/amavis/conf.d" + "/15-content_filter_mode") ee_amavis = open('/etc/amavis/conf.d/15-content_filter_mode', 'w') self.app.render((data), '15-content_filter_mode.mustache', @@ -550,17 +551,17 @@ class EEStackController(CementBaseController): "_checks/\" /etc/postfix/master.cf") # Amavis ClamAV configuration - self.app.log.debug("Adding new user clamav amavis") + Log.debug(self, "Adding new user clamav amavis") EEShellExec.cmd_exec(self, "adduser clamav amavis") - self.app.log.debug("Adding new user amavis clamav") + Log.debug(self, "Adding new user amavis clamav") EEShellExec.cmd_exec(self, "adduser amavis clamav") - self.app.log.debug("Privillages to file /var/lib/amavis/tmp ") + Log.debug(self, "Privillages to file /var/lib/amavis/tmp ") EEShellExec.cmd_exec(self, "chmod -R 775 /var/lib/amavis/tmp") # Update ClamAV database - self.app.log.debug("Updating database") + Log.debug(self, "Updating database") EEShellExec.cmd_exec(self, "freshclam") - self.app.log.debug("Restarting service clamav-daemon") + Log.debug(self, "Restarting service clamav-daemon") EEShellExec.cmd_exec(self, "service clamav-daemon restart") EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git") EEService.reload_service(self, 'dovecot') @@ -569,21 +570,21 @@ class EEStackController(CementBaseController): if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): - self.app.log.debug("Privillages to /usr/bin/wp ") + Log.debug(self, "Privillages to /usr/bin/wp ") EEShellExec.cmd_exec(self, "chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] for x in packages): EEExtract.extract(self, '/tmp/pma.tar.gz', '/tmp/') - self.app.log.debug('Extracting file /tmp/pma.tar.gz to ' - 'loaction /tmp/') + Log.debug(self, 'Extracting file /tmp/pma.tar.gz to ' + 'loaction /tmp/') if not os.path.exists('/var/www/22222/htdocs/db'): - self.app.log.debug("Creating new directory " - "/var/www/22222/htdocs/db") + Log.debug(self, "Creating new directory " + "/var/www/22222/htdocs/db") os.makedirs('/var/www/22222/htdocs/db') shutil.move('/tmp/phpmyadmin-STABLE/', '/var/www/22222/htdocs/db/pma/') - self.app.log.debug('Privillages to www-data:www-data ' - '/var/www/22222/htdocs/db/pma ') + Log.debug(self, 'Privillages to www-data:www-data ' + '/var/www/22222/htdocs/db/pma ') # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/db/pma') EEFileUtils.chown(self, '/var/www/22222', @@ -591,12 +592,12 @@ class EEStackController(CementBaseController): EEVariables.ee_php_user, recursive=True) if any('/tmp/memcache.tar.gz' == x[1] for x in packages): - self.app.log.debug("Extracting memcache.tar.gz to location" - " /var/www/22222/htdocs/cache/memcache ") + Log.debug(self, "Extracting memcache.tar.gz to location" + " /var/www/22222/htdocs/cache/memcache ") EEExtract.extract(self, '/tmp/memcache.tar.gz', '/var/www/22222/htdocs/cache/memcache') - self.app.log.debug("Privillages to" - " /var/www/22222/htdocs/cache/memcache") + Log.debug(self, "Privillages to" + " /var/www/22222/htdocs/cache/memcache") # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/cache/memcache') EEFileUtils.chown(self, '/var/www/22222', @@ -605,17 +606,17 @@ class EEStackController(CementBaseController): if any('/tmp/webgrind.tar.gz' == x[1] for x in packages): - self.app.log.debug("Extracting file webgrind.tar.gz to " - "location /tmp/ ") + Log.debug(self, "Extracting file webgrind.tar.gz to " + "location /tmp/ ") EEExtract.extract(self, '/tmp/webgrind.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/php'): - self.app.log.debug("Creating directroy " - "/var/www/22222/htdocs/php") + Log.debug(self, "Creating directroy " + "/var/www/22222/htdocs/php") os.makedirs('/var/www/22222/htdocs/php') shutil.move('/tmp/webgrind-master/', '/var/www/22222/htdocs/php/webgrind') - self.app.log.debug("Privillages www-data:www-data " - "/var/www/22222/htdocs/php/webgrind/ ") + Log.debug(self, "Privillages www-data:www-data " + "/var/www/22222/htdocs/php/webgrind/ ") # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/php/webgrind/') EEFileUtils.chown(self, '/var/www/22222', @@ -624,11 +625,11 @@ class EEStackController(CementBaseController): if any('/tmp/anemometer.tar.gz' == x[1] for x in packages): - self.app.log.debug("Extracting file anemometer.tar.gz to " - "location /tmp/ ") + Log.debug(self, "Extracting file anemometer.tar.gz to " + "location /tmp/ ") EEExtract.extract(self, '/tmp/anemometer.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/db/'): - self.app.log.debug("Creating directory") + Log.debug(self, "Creating directory") os.makedirs('/var/www/22222/htdocs/db/') shutil.move('/tmp/Anemometer-master', '/var/www/22222/htdocs/db/anemometer') @@ -642,7 +643,7 @@ class EEStackController(CementBaseController): ' BY \''+chars+'\'') # Custom Anemometer configuration - self.app.log.debug("configration Anemometer") + Log.debug(self, "configration Anemometer") data = dict(host='localhost', port='3306', user='anemometer', password=chars) ee_anemometer = open('/var/www/22222/htdocs/db/anemometer' @@ -658,24 +659,24 @@ class EEStackController(CementBaseController): if any('/tmp/vimbadmin.tar.gz' == x[1] for x in packages): # Extract ViMbAdmin - self.app.log.debug("Extracting ViMbAdmin.tar.gz to " - "location /tmp/") + Log.debug(self, "Extracting ViMbAdmin.tar.gz to " + "location /tmp/") EEExtract.extract(self, '/tmp/vimbadmin.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/'): - self.app.log.debug("Creating directory " - " /var/www/22222/htdocs/") + Log.debug(self, "Creating directory " + " /var/www/22222/htdocs/") os.makedirs('/var/www/22222/htdocs/') shutil.move('/tmp/ViMbAdmin-3.0.10/', '/var/www/22222/htdocs/vimbadmin/') # Donwload composer and install ViMbAdmin - self.app.log.debug("Downloading composer " - "https://getcomposer.org/installer | php ") + Log.debug(self, "Downloading composer " + "https://getcomposer.org/installer | php ") EEShellExec.cmd_exec(self, "cd /var/www/22222/htdocs" "/vimbadmin; curl" " -sS https://getcomposer.org/installer |" " php") - self.app.log.debug("installation of composer") + Log.debug(self, "installation of composer") EEShellExec.cmd_exec(self, "cd /var/www/22222/htdocs" "/vimbadmin && " "php composer.phar install --prefer-dist" @@ -684,17 +685,17 @@ class EEStackController(CementBaseController): # Configure vimbadmin database vm_passwd = ''.join(random.sample(string.ascii_letters, 8)) - self.app.log.debug("Creating vimbadmin database if not exist") + Log.debug(self, "Creating vimbadmin database if not exist") EEMysql.execute(self, "create database if not exists" " vimbadmin") - self.app.log.debug("Granting all privileges on vimbadmin ") + Log.debug(self, "Granting all privileges on vimbadmin ") EEMysql.execute(self, "grant all privileges on vimbadmin.* to" " vimbadmin@localhost IDENTIFIED BY" " '{password}'".format(password=vm_passwd)) # Configure ViMbAdmin settings config = configparser.ConfigParser(strict=False) - self.app.log.debug("configuring ViMbAdmin ") + Log.debug(self, "configuring ViMbAdmin ") config.read('/var/www/22222/htdocs/vimbadmin/application/' 'configs/application.ini.dist') config['user']['defaults.mailbox.uid'] = '5000' @@ -725,9 +726,9 @@ class EEStackController(CementBaseController): (string.ascii_letters + string.ascii_letters, 64))) - self.app.log.debug("Writting configration to file " - "/var/www/22222/htdocs/vimbadmin" - "/application/configs/application.ini ") + Log.debug(self, "Writting configration to file " + "/var/www/22222/htdocs/vimbadmin" + "/application/configs/application.ini ") with open('/var/www/22222/htdocs/vimbadmin/application' '/configs/application.ini', 'w') as configfile: config.write(configfile) @@ -736,10 +737,10 @@ class EEStackController(CementBaseController): ".htaccess.dist", "/var/www/22222/htdocs/vimbadmin/public/" ".htaccess") - self.app.log.debug("Executing command " - "/var/www/22222/htdocs/vimbadmin/bin" - "/doctrine2-cli.php orm:schema-tool:" - "create") + Log.debug(self, "Executing command " + "/var/www/22222/htdocs/vimbadmin/bin" + "/doctrine2-cli.php orm:schema-tool:" + "create") EEShellExec.cmd_exec(self, "/var/www/22222/htdocs/vimbadmin" "/bin/doctrine2-cli.php orm:schema-tool:" "create") @@ -752,8 +753,8 @@ class EEStackController(CementBaseController): # Vimbadmin if not os.path.exists('/etc/postfix/mysql/'): - self.app.log.debug("Creating directory " - "/etc/postfix/mysql/") + Log.debug(self, "Creating directory " + "/etc/postfix/mysql/") os.makedirs('/etc/postfix/mysql/') data = dict(password=vm_passwd) vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf', @@ -762,25 +763,25 @@ class EEStackController(CementBaseController): out=vm_config) vm_config.close() - self.app.log.debug("Configration of file " - "/etc/postfix/mysql" - "/virtual_domains_maps.cf") + Log.debug(self, "Configration of file " + "/etc/postfix/mysql" + "/virtual_domains_maps.cf") vm_config = open('/etc/postfix/mysql/virtual_domains_maps.cf', 'w') self.app.render((data), 'virtual_domains_maps.mustache', out=vm_config) vm_config.close() - self.app.log.debug("Configation of file " - "/etc/postfix/mysql" - "/virtual_mailbox_maps.cf ") + Log.debug(self, "Configation of file " + "/etc/postfix/mysql" + "/virtual_mailbox_maps.cf ") vm_config = open('/etc/postfix/mysql/virtual_mailbox_maps.cf', 'w') self.app.render((data), 'virtual_mailbox_maps.mustache', out=vm_config) vm_config.close() - self.app.log.debug("Configration of file ") + Log.debug(self, "Configration of file ") vm_config = open('/etc/dovecot/dovecot-sql.conf.ext', 'w') self.app.render((data), 'dovecot-sql-conf.mustache', @@ -801,22 +802,22 @@ class EEStackController(CementBaseController): if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): # Extract RoundCubemail - self.app.log.debug("Extracting file /tmp/roundcube.tar.gz " - "to location /tmp/ ") + Log.debug(self, "Extracting file /tmp/roundcube.tar.gz " + "to location /tmp/ ") EEExtract.extract(self, '/tmp/roundcube.tar.gz', '/tmp/') if not os.path.exists('/var/www/roundcubemail'): - self.app.log.debug("Creating new directory " - " /var/www/roundcubemail/") + Log.debug(self, "Creating new directory " + " /var/www/roundcubemail/") os.makedirs('/var/www/roundcubemail/') shutil.move('/tmp/roundcubemail-1.0.4/', '/var/www/roundcubemail/htdocs') # Configure roundcube database rc_passwd = ''.join(random.sample(string.ascii_letters, 8)) - self.app.log.debug("Creating Database roundcubemail") + Log.debug(self, "Creating Database roundcubemail") EEMysql.execute(self, "create database if not exists " " roundcubemail") - self.app.log.debug("Grant all privileges on roundcubemail") + Log.debug(self, "Grant all privileges on roundcubemail") EEMysql.execute(self, "grant all privileges" " on roundcubemail.* to " " roundcube@localhost IDENTIFIED BY " @@ -855,8 +856,8 @@ class EEStackController(CementBaseController): ee_db_user='', ee_db_pass='', ee_db_host='', rc=True) - self.app.log.debug('Writting the nginx configration for' - ' RoundCubemail') + Log.debug(self, 'Writting the nginx configration for' + ' RoundCubemail') ee_rc = open('/etc/nginx/sites-available/webmail.conf', 'w') self.app.render((data), 'virtualconf.mustache', out=ee_rc) @@ -891,8 +892,8 @@ class EEStackController(CementBaseController): @expose() def install(self, packages=[], apt_packages=[]): if self.app.pargs.web: - self.app.log.debug("Setting apt_packages variable for Nginx ,PHP" - " ,MySQL ") + Log.debug(self, "Setting apt_packages variable for Nginx ,PHP" + " ,MySQL ") self.app.pargs.nginx = True self.app.pargs.php = True self.app.pargs.mysql = True @@ -914,111 +915,115 @@ class EEStackController(CementBaseController): self.app.pargs.postfix = True if not EEAptGet.is_installed('dovecot-core'): - self.app.log.debug("Setting apt_packages variable for mail") + Log.debug(self, "Setting apt_packages variable for mail") apt_packages = apt_packages + EEVariables.ee_mail packages = packages + [["https://github.com/opensolutions/" "ViMbAdmin/archive/3.0.10.tar.gz", - "/tmp/vimbadmin.tar.gz"], + "/tmp/vimbadmin.tar.gz", "ViMbAdmin"], ["https://github.com/roundcube/" "roundcubemail/releases/download/" "1.0.4/roundcubemail-1.0.4.tar.gz", - "/tmp/roundcube.tar.gz"]] + "/tmp/roundcube.tar.gz", + "roundcubemail"]] if EEVariables.ee_ram > 1024: apt_packages = apt_packages + EEVariables.ee_mailscanner else: - self.app.log.info("Mail server is allready installed") + Log.info(self, "Mail server is allready installed") if self.app.pargs.nginx: - self.app.log.debug("Setting apt_packages variable for Nginx") + Log.debug(self, "Setting apt_packages variable for Nginx") if not EEAptGet.is_installed('nginx-common'): apt_packages = apt_packages + EEVariables.ee_nginx else: - self.app.log.info("Nginx allready installed") + Log.info(self, "Nginx allready installed") if self.app.pargs.php: - self.app.log.debug("Setting apt_packages variable for PHP") + Log.debug(self, "Setting apt_packages variable for PHP") if not EEAptGet.is_installed('php5-common'): apt_packages = apt_packages + EEVariables.ee_php else: - self.app.log.info("PHP allready installed") + Log.info(self, "PHP allready installed") if self.app.pargs.mysql: - self.app.log.debug("Setting apt_packages variable for MySQL") + Log.debug(self, "Setting apt_packages variable for MySQL") if not EEShellExec.cmd_exec(self, "mysqladmin ping"): apt_packages = apt_packages + EEVariables.ee_mysql else: - self.app.log.info("MySQL connection is allready alive") + Log.info(self, "MySQL connection is allready alive") if self.app.pargs.postfix: - self.app.log.debug("Setting apt_packages variable for PostFix") + Log.debug(self, "Setting apt_packages variable for PostFix") if not EEAptGet.is_installed('postfix'): apt_packages = apt_packages + EEVariables.ee_postfix else: - self.app.log.info("Postfix is allready installed") + Log.info(self, "Postfix is allready installed") if self.app.pargs.wpcli: - self.app.log.debug("Setting packages variable for WPCLI") + Log.debug(self, "Setting packages variable for WPCLI") 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.phar", "/usr/bin/wp", + "wp-cli"]] else: - self.app.log.info("WP-CLI is allready installed") + Log.info(self, "WP-CLI is allready installed") if self.app.pargs.phpmyadmin: - self.app.log.debug("Setting packages varible for phpMyAdmin ") + Log.debug(self, "Setting packages varible for phpMyAdmin ") packages = packages + [["https://github.com/phpmyadmin/phpmyadmin" "/archive/STABLE.tar.gz", - "/tmp/pma.tar.gz"]] + "/tmp/pma.tar.gz", "phpMyAdmin"]] if self.app.pargs.adminer: - self.app.log.debug("Setting packages variable for Adminer ") + Log.debug(self, "Setting packages variable for Adminer ") packages = packages + [["http://downloads.sourceforge.net/adminer" "/adminer-4.1.0.php", "/var/www/22222/" - "htdocs/db/adminer/index.php"]] + "htdocs/db/adminer/index.php", "adminer"]] if self.app.pargs.utils: - self.app.log.debug("Setting packages variable for utils") + Log.debug(self, "Setting packages variable for utils") packages = packages + [["http://phpmemcacheadmin.googlecode.com/" "files/phpMemcachedAdmin-1.2.2" - "-r262.tar.gz", '/tmp/memcache.tar.gz'], + "-r262.tar.gz", '/tmp/memcache.tar.gz', + 'phpMemcachedAdmin'], ["https://raw.githubusercontent.com/rtCamp/" "eeadmin/master/cache/nginx/clean.php", "/var/www/22222/htdocs/cache/" - "nginx/clean.php"], + "nginx/clean.php", "clean.php"], ["https://raw.github.com/rlerdorf/opcache-" "status/master/opcache.php", "/var/www/22222/htdocs/cache/" - "opcache/opcache.php"], + "opcache/opcache.php", "opcache.php"], ["https://raw.github.com/amnuts/opcache-gui" "/master/index.php", "/var/www/22222/htdocs/" - "cache/opcache/opgui.php"], + "cache/opcache/opgui.php", "index.php"], ["https://gist.github.com/ck-on/4959032/raw" "/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb" "/ocp.php", "/var/www/22222/htdocs/cache/" - "opcache/ocp.php"], + "opcache/ocp.php", "ocp.php"], ["https://github.com/jokkedk/webgrind/" "archive/master.tar.gz", - '/tmp/webgrind.tar.gz'], + '/tmp/webgrind.tar.gz', 'webgrind.tar.gz'], ["http://bazaar.launchpad.net/~percona-too" "lkit-dev/percona-toolkit/2.1/download/he" "ad:/ptquerydigest-20110624220137-or26tn4" "expb9ul2a-16/pt-query-digest", - "/usr/bin/pt-query-advisor"], + "/usr/bin/pt-query-advisor", + "pt-query-digest"], ["https://github.com/box/Anemometer/archive" "/master.tar.gz", - '/tmp/anemometer.tar.gz'] + '/tmp/anemometer.tar.gz', 'Anemometer'] ] - self.app.log.debug("Calling pre_pref ") + Log.debug(self, "Calling pre_pref ") self.pre_pref(apt_packages) if len(apt_packages): EESwap.add(self) - self.app.log.debug("Updating apt-cache") + Log.debug(self, "Updating apt-cache") EEAptGet.update() - self.app.log.debug("Installing all apt_packages") + Log.debug(self, "Installing all apt_packages") EEAptGet.install(apt_packages) if len(packages): - self.app.log.debug("Downloading all packages") + Log.debug(self, "Downloading all packages") EEDownload.download(self, packages) - self.app.log.debug("Calling post_pref") + Log.debug(self, "Calling post_pref") self.post_pref(apt_packages, packages) @expose() @@ -1039,7 +1044,7 @@ class EEStackController(CementBaseController): self.app.pargs.utils = True if self.app.pargs.mail: - self.app.log.debug("Removing mail server packages") + Log.debug(self, "Removing mail server packages") apt_packages = apt_packages + EEVariables.ee_mail apt_packages = apt_packages + EEVariables.ee_mailscanner packages = packages + ["/var/www/22222/htdocs/vimbadmin", @@ -1049,28 +1054,28 @@ class EEStackController(CementBaseController): EEMysql.execute(self, "drop database IF EXISTS roundcubemail") if self.app.pargs.nginx: - self.app.log.debug("Removing apt_packages variable of Nginx") + Log.debug(self, "Removing apt_packages variable of Nginx") apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: - self.app.log.debug("Removing apt_packages variable of PHP") + Log.debug(self, "Removing apt_packages variable of PHP") apt_packages = apt_packages + EEVariables.ee_php if self.app.pargs.mysql: - self.app.log.debug("Removing apt_packages variable of MySQL") + Log.debug(self, "Removing apt_packages variable of MySQL") apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: - self.app.log.debug("Removing apt_packages variable of Postfix") + Log.debug(self, "Removing apt_packages variable of Postfix") apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: - self.app.log.debug("Removing package variable of WPCLI ") + Log.debug(self, "Removing package variable of WPCLI ") packages = packages + ['/usr/bin/wp'] if self.app.pargs.phpmyadmin: - self.app.log.debug("Removing package variable of phpMyAdmin ") + Log.debug(self, "Removing package variable of phpMyAdmin ") packages = packages + ['/var/www/22222/htdocs/db/pma'] if self.app.pargs.adminer: - self.app.log.debug("Removing package variable of Adminer ") + Log.debug(self, "Removing package variable of Adminer ") packages = packages + ['/var/www/22222/htdocs/db/adminer'] if self.app.pargs.utils: - self.app.log.debug("Removing package variable of utils ") + Log.debug(self, "Removing package variable of utils ") packages = packages + ['/var/www/22222/htdocs/php/webgrind/', '/var/www/22222/htdocs/cache/opcache', '/var/www/22222/htdocs/cache/nginx/' @@ -1080,7 +1085,7 @@ class EEStackController(CementBaseController): '/var/www/22222/htdocs/db/anemometer'] if len(apt_packages): - self.app.log.debug("Removing apt_packages") + Log.debug(self, "Removing apt_packages") EEAptGet.remove(apt_packages) if len(packages): EEFileUtils.remove(self, packages) @@ -1103,7 +1108,7 @@ class EEStackController(CementBaseController): self.app.pargs.utils = True if self.app.pargs.mail: - self.app.log.debug("Removing mail server packages") + Log.debug(self, "Removing mail server packages") apt_packages = apt_packages + EEVariables.ee_mail apt_packages = apt_packages + EEVariables.ee_mailscanner packages = packages + ["/var/www/22222/htdocs/vimbadmin", @@ -1113,28 +1118,28 @@ class EEStackController(CementBaseController): EEMysql.execute(self, "drop database IF EXISTS roundcubemail") if self.app.pargs.nginx: - self.app.log.debug("Purge apt_packages variable of Nginx") + Log.debug(self, "Purge apt_packages variable of Nginx") apt_packages = apt_packages + EEVariables.ee_nginx if self.app.pargs.php: - self.app.log.debug("Purge apt_packages variable PHP") + Log.debug(self, "Purge apt_packages variable PHP") apt_packages = apt_packages + EEVariables.ee_php if self.app.pargs.mysql: - self.app.log.debug("Purge apt_packages variable MySQL") + Log.debug(self, "Purge apt_packages variable MySQL") apt_packages = apt_packages + EEVariables.ee_mysql if self.app.pargs.postfix: - self.app.log.debug("Purge apt_packages variable PostFix") + Log.debug(self, "Purge apt_packages variable PostFix") apt_packages = apt_packages + EEVariables.ee_postfix if self.app.pargs.wpcli: - self.app.log.debug("Purge package variable WPCLI") + Log.debug(self, "Purge package variable WPCLI") packages = packages + ['/usr/bin/wp'] if self.app.pargs.phpmyadmin: packages = packages + ['/var/www/22222/htdocs/db/pma'] - self.app.log.debug("Purge package variable phpMyAdmin") + Log.debug(self, "Purge package variable phpMyAdmin") if self.app.pargs.adminer: - self.app.log.debug("Purge package variable Adminer") + Log.debug(self, "Purge package variable Adminer") packages = packages + ['/var/www/22222/htdocs/db/adminer'] if self.app.pargs.utils: - self.app.log.debug("Purge package variable utils") + Log.debug(self, "Purge package variable utils") packages = packages + ['/var/www/22222/htdocs/php/webgrind/', '/var/www/22222/htdocs/cache/opcache', '/var/www/22222/htdocs/cache/nginx/' diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index 650027b1..4f081d15 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -1,6 +1,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.services import EEService +from ee.core.logging import Log class EEStackStatusController(CementBaseController): @@ -20,25 +21,25 @@ class EEStackStatusController(CementBaseController): def start(self): services = [] if self.app.pargs.nginx: - self.app.log.debug("nginx service start") + Log.debug(self, "nginx service start") services = services + ['nginx'] elif self.app.pargs.php: - self.app.log.debug("php5-fpm service start") + Log.debug(self, "php5-fpm service start") services = services + ['php5-fpm'] elif self.app.pargs.mysql: - self.app.log.debug("mysql service start") + Log.debug(self, "mysql service start") services = services + ['mysql'] elif self.app.pargs.postfix: - self.app.log.debug("postfix service start") + Log.debug(self, "postfix service start") services = services + ['postfix'] elif self.app.pargs.memcache: - self.app.log.debug("memcached service start") + Log.debug(self, "memcached service start") services = services + ['memcached'] elif self.app.pargs.dovecot: - self.app.log.debug("dovecot service start") + Log.debug(self, "dovecot service start") services = services + ['dovecot'] else: - self.app.log.debug("nginx,php5-fpm,mysql,postfix services start") + Log.debug(self, "nginx,php5-fpm,mysql,postfix services start") services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: EEService.start_service(self, service) @@ -47,26 +48,26 @@ class EEStackStatusController(CementBaseController): def stop(self): services = [] if self.app.pargs.nginx: - self.app.log.debug("nginx service stop") + Log.debug(self, "nginx service stop") services = services + ['nginx'] elif self.app.pargs.php: - self.app.log.debug("php5-fpm service stop") + Log.debug(self, "php5-fpm service stop") services = services + ['php5-fpm'] elif self.app.pargs.mysql: - self.app.log.debug("mysql service stop") + Log.debug(self, "mysql service stop") services = services + ['mysql'] elif self.app.pargs.postfix: - self.app.log.debug("postfix service stop") + Log.debug(self, "postfix service stop") services = services + ['postfix'] elif self.app.pargs.memcache: - self.app.log.debug("memcached service stop") + Log.debug(self, "memcached service stop") services = services + ['memcached'] elif self.app.pargs.dovecot: - self.app.log.debug("dovecot service stop") + Log.debug(self, "dovecot service stop") services = services + ['dovecot'] else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] - self.app.log.debug("nginx,php5-fpm,mysql,postfix services stop") + Log.debug(self, "nginx,php5-fpm,mysql,postfix services stop") for service in services: EEService.stop_service(self, service) @@ -74,53 +75,53 @@ class EEStackStatusController(CementBaseController): def restart(self): services = [] if self.app.pargs.nginx: - self.app.log.debug("nginx service restart") + Log.debug(self, "nginx service restart") services = services + ['nginx'] elif self.app.pargs.php: - self.app.log.debug("php5-fpm service restart") + Log.debug(self, "php5-fpm service restart") services = services + ['php5-fpm'] elif self.app.pargs.mysql: - self.app.log.debug("mysql service restart") + Log.debug(self, "mysql service restart") services = services + ['mysql'] elif self.app.pargs.postfix: - self.app.log.debug("postfix service restart") + Log.debug(self, "postfix service restart") services = services + ['postfix'] elif self.app.pargs.memcache: - self.app.log.debug("memcached service restart") + Log.debug(self, "memcached service restart") services = services + ['memcached'] elif self.app.pargs.dovecot: - self.app.log.debug("dovecot service restart") + Log.debug(self, "dovecot service restart") services = services + ['dovecot'] else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: - self.app.log.debug("nginx,php5-fpm,mysql,postfix services restart") + Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart") EEService.restart_service(self, service) @expose(help="get stack status") def status(self): services = [] if self.app.pargs.nginx: - self.app.log.debug("nginx service status") + Log.debug(self, "nginx service status") services = services + ['nginx'] elif self.app.pargs.php: - self.app.log.debug("php5-fpm service status") + Log.debug(self, "php5-fpm service status") services = services + ['php5-fpm'] elif self.app.pargs.mysql: - self.app.log.debug("mysql service status") + Log.debug(self, "mysql service status") services = services + ['mysql'] elif self.app.pargs.postfix: services = services + ['postfix'] - self.app.log.debug("postfix service status") + Log.debug(self, "postfix service status") elif self.app.pargs.memcache: - self.app.log.debug("memcached service status") + Log.debug(self, "memcached service status") services = services + ['memcached'] elif self.app.pargs.dovecot: - self.app.log.debug("dovecot service status") + Log.debug(self, "dovecot service status") services = services + ['dovecot'] else: - self.app.log.debug("nginx,php5-fpm,mysql,postfix services status") + Log.debug(self, "nginx,php5-fpm,mysql,postfix services status") services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: if EEService.get_service_status(self, service): - print("{0}: Running".format(service)) + Log.info(self, "{0}: Running".format(service)) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index bba60353..40d03b0c 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -261,4 +261,3 @@ class EEAptGet(): except Exception as e: cache.close() return False - diff --git a/ee/core/download.py b/ee/core/download.py index 81cf0f46..f2f6294b 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -2,6 +2,7 @@ import urllib.request import urllib.error import os +from ee.core.logging import Log class EEDownload(): @@ -13,24 +14,24 @@ class EEDownload(): for package in packages: url = package[0] filename = package[1] + pkg_name = package[2] try: directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) - self.app.log.info("Downloading "+os.path.basename(url)+" ...") + Log.info(self, "Downloading "+pkg_name+" ...") urllib.request.urlretrieve(url, filename) - self.app.log.info("Done") except urllib.error.URLError as e: - self.app.log.info("Unable to donwload file, [{err}]" - .format(err=str(e.reason))) + Log.info(self, "Unable to donwload file, [{err}]" + .format(err=str(e.reason))) return False except urllib.error.HTTPError as e: - self.app.log.error("Package download failed. [{err}]" - .format(err=str(e.reason))) + Log.error(self, "Package download failed. [{err}]" + .format(err=str(e.reason))) return False except urllib.error.ContentTooShortError as e: - self.app.log.error("Package download failed. The amount of the" - " downloaded data is less than " - "the expected amount \{0} {1}" - .format(e.errno, e.strerror)) + Log.error(self, "Package download failed. The amount of the" + " downloaded data is less than " + "the expected amount \{0} {1}" + .format(e.errno, e.strerror)) return False diff --git a/ee/core/extract.py b/ee/core/extract.py index fcb8a2d8..47e45015 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -1,6 +1,7 @@ """EasyEngine extarct core classes.""" import tarfile import os +from ee.core.logging import Log class EEExtract(): @@ -14,6 +15,6 @@ class EEExtract(): os.remove(file) return True except tarfile.TarError as e: - self.app.log.error('Unable to extract file \{0} {1}' - .format(e.errno, e.strerror)) + Log.error(self, 'Unable to extract file \{0} {1}' + .format(e.errno, e.strerror)) return False diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 24943dd0..f52cfcc3 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -16,15 +16,13 @@ class EEFileUtils(): def remove(self, filelist): for file in filelist: if os.path.isfile(file): - self.app.log.info("Removing "+os.path.basename(file)+" ...") + Log.info(self, "Removing "+os.path.basename(file)+" ...") os.remove(file) - self.app.log.debug('file Removed') - self.app.log.info("Done") + Log.debug(self, 'file Removed') if os.path.isdir(file): try: - print("Removing "+os.path.basename(file)+"...") + Log.info(self, "Removing "+os.path.basename(file)+"...") shutil.rmtree(file) - self.app.log.info("Done") except shutil.Error as e: Log.error(self, 'Unable to Remove file {err}' .format(err=str(e.reason))) @@ -37,11 +35,11 @@ class EEFileUtils(): try: os.symlink(src, dst) except Exception as e: - self.app.log.error("Unable to create symbolic link ...\n {0}" - " {1}".format(e.errno, e.strerror)) + Log.error(self, "Unable to create symbolic link ...\n {0}" + " {1}".format(e.errno, e.strerror)) sys.exit(1) else: - self.app.log.debug("Destination: {0} exists".format(dst)) + Log.debug(self, "Destination: {0} exists".format(dst)) def remove_symlink(self, filepath): try: @@ -55,17 +53,17 @@ class EEFileUtils(): try: shutil.copy2(src, dest) except shutil.Error as e: - print('Error: {0}'.format(e)) + Log.info(self, 'Error: {0}'.format(e)) except IOError as e: - print('Error: {e}'.format(e.strerror)) + Log.info(self, 'Error: {e}'.format(e.strerror)) def searchreplace(self, fnm, sstr, rstr): try: for line in fileinput.input(fnm, inplace=True): - print(line.replace(sstr, rstr), end='') + Log.info(line.replace(sstr, rstr), end='') fileinput.close() except Exception as e: - print('Error : {0}'.format(e)) + Log.info(self, 'Error : {0}'.format(e)) def mvfile(self, src, dst): try: diff --git a/ee/core/git.py b/ee/core/git.py index 6ed576ae..863d99af 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -1,5 +1,6 @@ from sh import git, ErrorReturnCode import os +from ee.core.logging import Log class EEGit: @@ -16,21 +17,21 @@ class EEGit: if os.path.isdir(path): if not os.path.isdir(path+"/.git"): try: - self.app.log.debug("EEGit: git init at {0}" - .format(path)) + Log.debug(self, "EEGit: git init at {0}" + .format(path)) git.init(path) except ErrorReturnCode as e: - self.app.log.error(e) + Log.error(e) sys.exit(1) status = git.status("-s") if len(status.splitlines()) > 0: try: - self.app.log.debug("EEGit: git commit at {0}" - .format(path)) + Log.debug(self, "EEGit: git commit at {0}" + .format(path)) git.add("--all") git.commit("-am {0}".format(msg)) except ErrorReturnCode as e: - self.app.log.error(e) + Log.error(e) sys.exit(1) else: - self.app.log.debug("EEGit: Path {0} not present".format(path)) + Log.debug(self, "EEGit: Path {0} not present".format(path)) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 5b19661f..883752f2 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -3,6 +3,7 @@ import pymysql import configparser from os.path import expanduser import sys +from ee.core.logging import Log class EEMysql(): @@ -29,15 +30,15 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() except Exception as e: - self.app.log.error('Unable to connect to database: {0}' - .format(e)) + Log.error(self, 'Unable to connect to database: {0}' + .format(e)) sys.exit(1) try: cur.execute(statement) except Exception as e: - self.app.log.error('Error occured while executing: {0}' - .format(e)) + Log.error(self, 'Error occured while executing: {0}' + .format(e)) cur.close() conn.close() sys.exit(1) diff --git a/ee/core/services.py b/ee/core/services.py index 9a52b4f6..7f6f10e9 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -3,6 +3,7 @@ import os import sys import subprocess from subprocess import Popen +from ee.core.logging import Log class EEService(): @@ -16,12 +17,12 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} start' .format(service_name)) if retcode[0] == 0: - self.app.log.info("Started : {0}".format(service_name)) + Log.info(self, "Started : {0}".format(service_name)) else: - self.app.log.error(retcode[1]) + Log.error(self, retcode[1]) except OSError as e: - self.app.log.error("Failed to start service {0} {1}" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to start service {0} {1}" + .format(e.errno, e.strerror)) return False def stop_service(self, service_name): @@ -29,13 +30,13 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} stop' .format(service_name)) if retcode[0] == 0: - self.app.log.info("Stopped : {0}".format(service_name)) + Log.info(self, "Stopped : {0}".format(service_name)) return True else: return False except OSError as e: - self.app.log.error("Failed to stop service : {0}{1}" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to stop service : {0}{1}" + .format(e.errno, e.strerror)) return False def restart_service(self, service_name): @@ -43,20 +44,20 @@ class EEService(): EEService.stop_service(self, service_name) EEService.start_service(self, service_name) except OSError as e: - self.app.log.error("Failed to restart services \{0} {1}" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to restart services \{0} {1}" + .format(e.errno, e.strerror)) def reload_service(self, service_name): try: retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: - self.app.log.info("reload : {0}".format(service_name)) + Log.info(self, "reload : {0}".format(service_name)) return True else: return False except OSError as e: - self.app.log.error("Failed to reload NGINX:", e) + Log.error(self, "Failed to reload NGINX:".format(e)) return False def get_service_status(self, service_name): @@ -73,6 +74,6 @@ class EEService(): else: return False except OSError as e: - self.app.log.error("Unable to get services status \ {0}{1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to get services status \ {0}{1}" + .format(e.errno, e.strerror)) return False diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 27d7cca9..325e2e77 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -13,12 +13,12 @@ class EEShellExec(): def cmd_exec(self, command, errormsg=''): try: - self.app.log.debug("Running command: {0}".format(command)) + Log.debug(self, "Running command: {0}".format(command)) retcode = subprocess.getstatusoutput(command) if retcode[0] == 0: return True else: - self.app.log.debug(retcode[1]) + Log.debug(self, retcode[1]) return False except OSError as e: if errormsg: From 7713f844ac9ec89cd1e910055d3343f3de607d7e Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 13 Jan 2015 16:30:35 +0530 Subject: [PATCH 639/829] ee site info, enable, disable, log completed --- ee/cli/plugins/site.py | 105 ++++++++++++++++++++++++----- ee/cli/plugins/site_functions.py | 31 +++++---- ee/cli/templates/siteinfo.mustache | 10 +++ ee/core/git.py | 10 +++ ee/core/services.py | 19 +++++- ee/core/shellexec.py | 13 ++++ 6 files changed, 156 insertions(+), 32 deletions(-) create mode 100644 ee/cli/templates/siteinfo.mustache diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 401062ca..b871ac76 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -10,6 +10,7 @@ from ee.cli.plugins.sitedb import * from ee.core.git import EEGit import sys import os +import glob def ee_site_hook(app): @@ -41,33 +42,108 @@ class EESiteController(CementBaseController): @expose(help="enable site example.com") def enable(self): - # TODO Write code for ee site enable command here - print("Inside EESiteController.enable().") + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + EEFileUtils.create_symlink(self, + ['/etc/nginx/sites-available/{0}.conf' + .format(ee_domain_name), + '/etc/nginx/sites-enabled/{0}.conf' + .format(ee_domain_name)]) + else: + Log.error(self, "site {0} does not exists".format(ee_domain)) + sys.exit(1) @expose(help="disable site example.com") def disable(self): - # TODO Write code for ee site disable command here - print("Inside EESiteController.disable().") + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + EEFileUtils.remove_symlink(self, + ['/etc/nginx/sites-available/{0}.conf' + .format(ee_domain_name), + '/etc/nginx/sites-enabled/{0}.conf' + .format(ee_domain_name)]) + else: + Log.error(self, "site {0} does not exists".format(ee_domain)) + sys.exit(1) @expose(help="get example.com information") def info(self): - # TODO Write code for ee site info command here - print("Inside EESiteController.info().") + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + ee_db_name = '' + ee_db_user = '' + ee_db_pass = '' + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + ee_site_webroot = EEVariables.ee_webroot + ee_domain + access_log = (ee_site_webroot + '/logs/access.log') + error_log = (ee_site_webroot + '/logs/error.log') + configfiles = glob.glob(ee_site_webroot + '/*-config.php') + if configfiles: + if EEFileUtils.isexist(self, configfiles[0]): + ee_db_name = (EEFileUtils.grep(self, configfiles[0], + 'DB_NAME').split(',')[1] + .split(')')[0].strip().replace('\'', '')) + ee_db_user = (EEFileUtils.grep(self, configfiles[0], + 'DB_USER').split(',')[1] + .split(')')[0].strip().replace('\'', '')) + ee_db_pass = (EEFileUtils.grep(self, configfiles[0], + 'DB_PASSWORD').split(',')[1] + .split(')')[0].strip().replace('\'', '')) + + data = dict(domain=ee_domain, webroot=ee_site_webroot, + accesslog=access_log, errorlog=error_log, + dbname=ee_db_name, dbuser=ee_db_user, + dbpass=ee_db_pass) + self.app.render((data), 'siteinfo.mustache') + else: + Log.error(self, "site {0} does not exists".format(ee_domain)) + sys.exit(1) @expose(help="Monitor example.com logs") def log(self): - # TODO Write code for ee site log command here - print("Inside EESiteController.log().") + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + EEShellExec.cmd_exec(self, 'tail -f /var/log/nginx/{0}.*.log' + .format(ee_domain)) + else: + Log.error(self, "site {0} does not exists".format(ee_domain)) + sys.exit(1) @expose(help="Edit example.com's nginx configuration") def edit(self): - # TODO Write code for ee site edit command here - print("Inside EESiteController.edit().") + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + EEShellExec.invoke_editor(self, '/etc/nginx/sites-available/{0}' + .format(ee_domain)) + if (EEGit.checkfilestatus(self, "/etc/nginx", + '/etc/nginx/sites-available/{0}'.format(ee_domain))): + EEGit.add(self, ["/etc/nginx"], msg="Edit website: {0}" + .format(ee_domain)) + # Reload NGINX + EEService.reload_service(self, 'nginx') + else: + Log.error(self, "site {0} does not exists".format(ee_domain)) + sys.exit(1) @expose(help="Display example.com's nginx configuration") def show(self): # TODO Write code for ee site edit command here - print("Inside EESiteController.show().") + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + Log.info(self, "Display NGINX configuration for {0}" + .format(ee_domain)) + f = open('/etc/nginx/sites-available/{0}'.format(ee_domain), "r") + text = f.read() + print(text) + f.close() + else: + Log.error(self, "site {0} does not exists".format(ee_domain)) + sys.exit(1) @expose(help="list sites currently available") def list(self): @@ -116,14 +192,13 @@ class EESiteCreateController(CementBaseController): # data = dict(foo='EESiteCreateController.default().') # self.app.render((data), 'default.mustache') # Check domain name validation - (ee_domain, - ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = EEVariables.ee_webroot + ee_domain # Check if doain previously exists or not - if os.path.isfile('/etc/nginx/sites-available/{0}.conf' + if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): - self.app.log.error("site {0} already exists" + self.app.log.error(self, "site {0} already exists" .format(ee_domain)) sys.exit(1) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 3c5f3b12..ef18ae4c 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -18,7 +18,7 @@ def SetupDomain(self, data): self.app.log.info("Creating {0} ...".format(ee_domain_name)) # write nginx config for file try: - ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}.conf' + ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}' .format(ee_domain_name), 'w') self.app.render((data), 'virtualconf.mustache', @@ -33,9 +33,9 @@ def SetupDomain(self, data): sys.exit(1) # create symbolic link for - EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}.conf' + EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}' .format(ee_domain_name), - '/etc/nginx/sites-enabled/{0}.conf' + '/etc/nginx/sites-enabled/{0}' .format(ee_domain_name)]) # Creating htdocs & logs directory @@ -283,22 +283,21 @@ def siteBackup(self, data): if not EEFileUtils.isexist(self, backup_path): EEFileUtils.mkdir(self, backup_path) Log.info(self, "Backup Location : {0}".format(backup_path)) - EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}.conf' + EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}' .format(data['ee_domain']), backup_path) if data['currsitetype'] in ['html', 'php', 'mysql']: Log.info(self, "Backup Webroot ...") EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path) - configfiles = glob(ee_site_webroot + '/htdocs/*-config.php') - - for file in configfiles: - if EEFileUtils.isexist(self, file): - ee_db_name = (EEFileUtils.grep(self, file, 'DB_NAME').split(',')[1] - .split(')')[0].strip()) - Log.info(self, 'Backup Database, please wait') - EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" - .format(ee_db_name, backup_path), - "Failed: Backup Database") - # move wp-config.php/ee-config.php to backup - EEFileUtils.mvfile(self, file, backup_path) + configfiles = glob(ee_site_webroot + '/*-config.php') + + if EEFileUtils.isexist(self, configfiles[0]): + ee_db_name = (EEFileUtils.grep(self, file, 'DB_NAME').split(',')[1] + .split(')')[0].strip().replace('\'', '')) + Log.info(self, 'Backup Database, please wait') + EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" + .format(ee_db_name, backup_path), + "Failed: Backup Database") + # move wp-config.php/ee-config.php to backup + EEFileUtils.mvfile(self, file, backup_path) diff --git a/ee/cli/templates/siteinfo.mustache b/ee/cli/templates/siteinfo.mustache new file mode 100644 index 00000000..dfe7d917 --- /dev/null +++ b/ee/cli/templates/siteinfo.mustache @@ -0,0 +1,10 @@ +Information about {{domain}}: + +Nginx configuration {{type}} {{enable}} +access_log {{accesslog}} +error_log {{errorlog}} +Webroot {{webroot}} +{{#dbname}}DB_NAME {{dbname}}{{/dbname}} +{{#dbname}}DB_USER {{dbuser}}{{/dbname}} +{{#dbname}}DB_PASS {{dbpass}}{{/dbname}} +{{#tablepref}}table_prefix {{tableprefix}}{{/tablepref}} diff --git a/ee/core/git.py b/ee/core/git.py index 6ed576ae..19553a04 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -34,3 +34,13 @@ class EEGit: sys.exit(1) else: self.app.log.debug("EEGit: Path {0} not present".format(path)) + + def checkfilestatus(self, repo, filepath): + global git + git = git.bake("--git-dir={0}/.git".format(repo), + "--work-tree={0}".format(repo)) + status = git.status("-s", "{0}".format(filepath)) + if len(status.splitlines()) > 0: + return True + else: + return False diff --git a/ee/core/services.py b/ee/core/services.py index 9a52b4f6..315fa326 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -48,6 +48,22 @@ class EEService(): def reload_service(self, service_name): try: + if service_name in ['nginx', 'php5-fpm']: + retcode = subprocess.getstatusoutput('{0} -t' + .format(service_name)) + if retcode[0] == 0: + subprocess.getstatusoutput('service {0} reload' + .format(service_name)) + self.app.log.info("reload : {0} [OK]" + .format(service_name)) + return True + else: + self.app.log.error("reload : {0} [FAIL]" + .format(service_name)) + self.app.log.debug("{0}" + .format(retcode[1])) + return False + retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: @@ -56,7 +72,8 @@ class EEService(): else: return False except OSError as e: - self.app.log.error("Failed to reload NGINX:", e) + self.app.log.error("Failed to reload {0} {1}" + .format(service_name, e)) return False def get_service_status(self, service_name): diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 27d7cca9..93b45f93 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -29,3 +29,16 @@ class EEShellExec(): Log.debug(self, "Unable to execute command \ {0}{1}" .format(e.errno, e.strerror)) sys.exit(1) + + def invoke_editor(self, filepath, errormsg=''): + try: + subprocess.call(['sensible-editor', filepath]) + except OSError as e: + if errormsg: + Log.error(self, errormsg) + else: + Log.error(self, "Unable to edit file \ {0}{1}" + .format(e.errno, e.strerror)) + Log.debug(self, "Unable to edit file \ {0}{1}" + .format(e.errno, e.strerror)) + sys.exit(1) From 805b90c27ab9fee7f204c77a00fdc604a20c61ee Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 13 Jan 2015 18:23:00 +0530 Subject: [PATCH 640/829] Added log messges --- ee/cli/plugins/stack.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c1be06cc..3bb28c8e 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -270,7 +270,7 @@ class EEStackController(CementBaseController): passwd = ''.join([random.choice (string.ascii_letters + string.digits) for n in range(6)]) - EEShellExec.cmd_exec(self, "Log.infof \"easyengine:" + EEShellExec.cmd_exec(self, "printf \"easyengine:" "$(openssl passwd -crypt " "{password} 2> /dev/null)\n\"" "> /etc/nginx/htpasswd-ee 2>/dev/null" @@ -326,6 +326,8 @@ class EEStackController(CementBaseController): EEGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git") EEService.reload_service(self, 'nginx') + self.msg = (self.msg + ["HTTP Auth User Name: easyengine"] + + ["HTTP Auth Password: {0}".format(passwd)]) if set(EEVariables.ee_php).issubset(set(apt_packages)): # Create log directories @@ -721,11 +723,10 @@ class EEStackController(CementBaseController): + string. ascii_letters, 64))) + vm_salt = (''.join(random.sample(string.ascii_letters + + string.ascii_letters, 64))) config['user']['defaults.mailbox.' - 'password_salt'] = (''.join(random.sample - (string.ascii_letters - + string.ascii_letters, - 64))) + 'password_salt'] = vm_salt Log.debug(self, "Writting configration to file " "/var/www/22222/htdocs/vimbadmin" "/application/configs/application.ini ") @@ -799,6 +800,9 @@ class EEStackController(CementBaseController): EEService.reload_service(self, 'dovecot') EEService.reload_service(self, 'nginx') EEService.reload_service(self, 'php5-fpm') + self.msg = (self.msg + ["Configure ViMbAdmin:\thttps://{0}:" + "22222/vimbadmin".format(EEVariables.ee_fqdn)] + + ["Security Salt: {0}".format(vm_salt)]) if any('/tmp/roundcube.tar.gz' == x[1] for x in packages): # Extract RoundCubemail @@ -891,6 +895,7 @@ class EEStackController(CementBaseController): @expose() def install(self, packages=[], apt_packages=[]): + self.msg = [] if self.app.pargs.web: Log.debug(self, "Setting apt_packages variable for Nginx ,PHP" " ,MySQL ") @@ -1025,6 +1030,10 @@ class EEStackController(CementBaseController): EEDownload.download(self, packages) Log.debug(self, "Calling post_pref") self.post_pref(apt_packages, packages) + if len(self.msg): + for msg in self.msg: + Log.info(self, msg) + Log.info(self, "Successfully installed packages") @expose() def remove(self): @@ -1089,6 +1098,7 @@ class EEStackController(CementBaseController): EEAptGet.remove(apt_packages) if len(packages): EEFileUtils.remove(self, packages) + Log.info(self, "Successfully removed packages") @expose() def purge(self): @@ -1153,6 +1163,7 @@ class EEStackController(CementBaseController): EEAptGet.remove(apt_packages, purge=True) if len(packages): EEFileUtils.remove(self, packages) + Log.info(self, "Successfully purged packages") def load(app): From 39ccf393245ea0fe27196c84dc08fa4ba40967a3 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 14 Jan 2015 12:01:28 +0530 Subject: [PATCH 641/829] updated log message --- ee/cli/plugins/clean.py | 4 ++-- ee/cli/plugins/secure.py | 4 ++-- ee/cli/plugins/site.py | 2 +- ee/cli/plugins/stack.py | 8 ++++---- ee/core/addswap.py | 3 ++- ee/core/download.py | 6 +++--- ee/core/extract.py | 2 +- ee/core/fileutils.py | 6 +++--- ee/core/services.py | 33 +++++++++++++++++++-------------- setup.py | 10 +++++----- 10 files changed, 42 insertions(+), 36 deletions(-) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 76dc2ac6..b345150c 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -18,8 +18,8 @@ class EECleanController(CementBaseController): label = 'clean' stacked_on = 'base' stacked_type = 'nested' - description = 'clean command cleans different cache with following \ - options' + description = ('clean command cleans different cache with following ' + 'options') arguments = [ (['--all'], dict(help='clean all cache', action='store_true')), diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 3e9ba394..400962f6 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -20,8 +20,8 @@ class EEsecureController(CementBaseController): label = 'secure' stacked_on = 'base' stacked_type = 'nested' - description = 'clean command cleans different cache with following \ - options' + description = ('clean command cleans different cache with following ' + 'options') arguments = [ (['--auth'], dict(help='secure auth', action='store_true')), diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index b871ac76..35f54081 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -24,7 +24,7 @@ class EESiteController(CementBaseController): stacked_on = 'base' stacked_type = 'nested' description = ('site command manages website configuration' - 'with the help of the following subcommands') + ' with the help of the following subcommands') arguments = [ (['site_name'], dict(help='website name')), diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c1be06cc..91e5b16e 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -924,7 +924,7 @@ class EEStackController(CementBaseController): "roundcubemail/releases/download/" "1.0.4/roundcubemail-1.0.4.tar.gz", "/tmp/roundcube.tar.gz", - "roundcubemail"]] + "Roundcube"]] if EEVariables.ee_ram > 1024: apt_packages = apt_packages + EEVariables.ee_mailscanner @@ -961,7 +961,7 @@ class EEStackController(CementBaseController): packages = packages + [["https://github.com/wp-cli/wp-cli/" "releases/download/v0.17.1/" "wp-cli.phar", "/usr/bin/wp", - "wp-cli"]] + "WP_CLI"]] else: Log.info(self, "WP-CLI is allready installed") if self.app.pargs.phpmyadmin: @@ -974,7 +974,7 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting packages variable for Adminer ") packages = packages + [["http://downloads.sourceforge.net/adminer" "/adminer-4.1.0.php", "/var/www/22222/" - "htdocs/db/adminer/index.php", "adminer"]] + "htdocs/db/adminer/index.php", "Adminer"]] if self.app.pargs.utils: Log.debug(self, "Setting packages variable for utils") @@ -1001,7 +1001,7 @@ class EEStackController(CementBaseController): "opcache/ocp.php", "ocp.php"], ["https://github.com/jokkedk/webgrind/" "archive/master.tar.gz", - '/tmp/webgrind.tar.gz', 'webgrind.tar.gz'], + '/tmp/webgrind.tar.gz', 'Webgrind'], ["http://bazaar.launchpad.net/~percona-too" "lkit-dev/percona-toolkit/2.1/download/he" "ad:/ptquerydigest-20110624220137-or26tn4" diff --git a/ee/core/addswap.py b/ee/core/addswap.py index 192ba79d..b1727a9a 100644 --- a/ee/core/addswap.py +++ b/ee/core/addswap.py @@ -1,6 +1,7 @@ from ee.core.variables import EEVariables from ee.core.shellexec import EEShellExec from ee.core.fileutils import EEFileUtils +from ee.core.logging import Log class EESwap(): @@ -13,7 +14,7 @@ class EESwap(): def add(self): if EEVariables.ee_ram < 512: if EEVariables.ee_swap < 1000: - self.app.log.info("Adding SWAP") + Log.info(self, "Adding SWAP") EEShellExec.cmd_exec(self, "dd if=/dev/zero of=/ee-swapfile " "bs=1024 count=1048k") EEShellExec.cmd_exec(self, "mkswap /ee-swapfile") diff --git a/ee/core/download.py b/ee/core/download.py index f2f6294b..c7a22e8f 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -22,11 +22,11 @@ class EEDownload(): Log.info(self, "Downloading "+pkg_name+" ...") urllib.request.urlretrieve(url, filename) except urllib.error.URLError as e: - Log.info(self, "Unable to donwload file, [{err}]" - .format(err=str(e.reason))) + Log.error(self, "Unable to donwload file, [{err}] [FAIL]" + .format(err=str(e.reason))) return False except urllib.error.HTTPError as e: - Log.error(self, "Package download failed. [{err}]" + Log.error(self, "Package download failed. [{err}] [FAIL]" .format(err=str(e.reason))) return False except urllib.error.ContentTooShortError as e: diff --git a/ee/core/extract.py b/ee/core/extract.py index 47e45015..91f58d53 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -15,6 +15,6 @@ class EEExtract(): os.remove(file) return True except tarfile.TarError as e: - Log.error(self, 'Unable to extract file \{0} {1}' + Log.error(self, 'Unable to extract file \{0} {1} [FAIL]' .format(e.errno, e.strerror)) return False diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index f52cfcc3..9a537878 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -53,9 +53,9 @@ class EEFileUtils(): try: shutil.copy2(src, dest) except shutil.Error as e: - Log.info(self, 'Error: {0}'.format(e)) + Log.error(self, '{0}'.format(e)) except IOError as e: - Log.info(self, 'Error: {e}'.format(e.strerror)) + Log.error(self, '{e}'.format(e.strerror)) def searchreplace(self, fnm, sstr, rstr): try: @@ -63,7 +63,7 @@ class EEFileUtils(): Log.info(line.replace(sstr, rstr), end='') fileinput.close() except Exception as e: - Log.info(self, 'Error : {0}'.format(e)) + Log.error(self, '{0}'.format(e)) def mvfile(self, src, dst): try: diff --git a/ee/core/services.py b/ee/core/services.py index 020a5d93..97cea2d3 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -17,11 +17,12 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} start' .format(service_name)) if retcode[0] == 0: - Log.info(self, "Started : {0}".format(service_name)) + Log.info(self, "Started : {0} [ok]" + .format(service_name)) else: Log.error(self, retcode[1]) except OSError as e: - Log.error(self, "Failed to start service {0} {1}" + Log.error(self, "Failed to start service {0} {1} [FAIL]" .format(e.errno, e.strerror)) return False @@ -30,12 +31,13 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} stop' .format(service_name)) if retcode[0] == 0: - Log.info(self, "Stopped : {0}".format(service_name)) + Log.info(self, "Stopped : {0} [OK]" + .format(service_name)) return True else: return False except OSError as e: - Log.error(self, "Failed to stop service : {0}{1}" + Log.error(self, "Failed to stop service : {0}{1} [FAIL]" .format(e.errno, e.strerror)) return False @@ -43,8 +45,10 @@ class EEService(): try: EEService.stop_service(self, service_name) EEService.start_service(self, service_name) + Log.info(self, "restart : {0} [OK]" + .format(service_name)) except OSError as e: - Log.error(self, "Failed to restart services \{0} {1}" + Log.error(self, "Failed to restart services \{0} {1} [FAIL]" .format(e.errno, e.strerror)) def reload_service(self, service_name): @@ -55,26 +59,27 @@ class EEService(): if retcode[0] == 0: subprocess.getstatusoutput('service {0} reload' .format(service_name)) - self.app.log.info("reload : {0} [OK]" - .format(service_name)) + Log.info("reload : {0} [OK]" + .format(service_name)) return True else: - self.app.log.error("reload : {0} [FAIL]" - .format(service_name)) - self.app.log.debug("{0}" - .format(retcode[1])) + Log.error("reload : {0} [FAIL]" + .format(service_name)) + Log.debug("{0}" + .format(retcode[1])) return False retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: - Log.info(self, "reload : {0}".format(service_name)) + Log.info(self, "reload : {0} [OK]" + .format(service_name)) return True else: return False except OSError as e: - Log.error(self, "Failed to reload {0} {1}" + Log.error(self, "Failed to reload {0} {1} [FAIL]" .format(service_name, e)) sys.exit(1) @@ -92,6 +97,6 @@ class EEService(): else: return False except OSError as e: - Log.error(self, "Unable to get services status \ {0}{1}" + Log.error(self, "Unable to get services status \ {0}{1} [FAIL]" .format(e.errno, e.strerror)) return False diff --git a/setup.py b/setup.py index 98d787a1..b650b5fe 100644 --- a/setup.py +++ b/setup.py @@ -16,11 +16,11 @@ for name in glob.glob('ee/cli/templates/*.mustache'): setup(name='ee', version='3.0', - description="EasyEngine is the commandline tool to manage your Websites" - " based on WordPress and NGINX with easy to use commands.", - long_description="EasyEngine is the commandline tool to manage your " - "Websites based on WordPress and NGINX with easy" - " to use commands.", + description=('EasyEngine is the commandline tool to manage your Websites' + 'based on WordPress and NGINX with easy to use commands.'), + long_description=('EasyEngine is the commandline tool to manage your ' + 'Websites based on WordPress and NGINX with easy' + 'to use commands.'), classifiers=[], keywords='', author='rtCamp Soultions Pvt. LTD', From 2f594b4b805385a46c3310528ed66559caaa733f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 14 Jan 2015 12:03:55 +0530 Subject: [PATCH 642/829] changes before merge --- ee/cli/plugins/site.py | 127 ++++++++++++++++++++++++++++++++++++++--- ee/core/fileutils.py | 2 +- 2 files changed, 119 insertions(+), 10 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index b871ac76..88f21329 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -23,8 +23,8 @@ class EESiteController(CementBaseController): label = 'site' stacked_on = 'base' stacked_type = 'nested' - description = ('site command manages website configuration' - 'with the help of the following subcommands') + description = ('''site command manages website configuration + with the help of the following subcommands''') arguments = [ (['site_name'], dict(help='website name')), @@ -35,11 +35,6 @@ class EESiteController(CementBaseController): # TODO Default action for ee site command print("Inside EESiteController.default().") - @expose(help="delete site example.com") - def delete(self): - # TODO Write code for ee site delete command here - print("Inside EESiteController.delete().") - @expose(help="enable site example.com") def enable(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -152,8 +147,18 @@ class EESiteController(CementBaseController): @expose(help="change to example.com's webroot") def cd(self): - # TODO Write code for ee site cd here - print("Inside EESiteController.cd().") + + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + ee_site_webroot = EEVariables.ee_webroot + ee_domain + EEFileutils.chdir(self, ee_site_webroot) + try: + subprocess.call(['bash']) + except OSError as e: + Log.error(self, "Unable to edit file \ {0}{1}" + .format(e.errno, e.strerror)) + sys.exit(1) class EESiteCreateController(CementBaseController): @@ -809,11 +814,115 @@ class EESiteUpdateController(CementBaseController): " http://{0}".format(ee_domain)) +class EESiteDeleteController(CementBaseController): + class Meta: + label = 'delete' + stacked_on = 'site' + stacked_type = 'nested' + description = 'delete command deletes website' + arguments = [ + (['site_name'], + dict(help='domain name to be deleted')), + (['--no-prompt'], + dict(help="dont ask for permission for delete", + action='store_true')), + (['--all'], + dict(help="delete all", action='store_true')), + (['--db'], + dict(help="delete db only", action='store_true')), + (['--files'], + dict(help="delete webroot only", action='store_true')), + ] + + @expose(help="update example.com") + def default(self): + # TODO Write code for ee site update here + (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + ee_db_name = '' + ee_prompt = '' + if os.path.isfile('/etc/nginx/sites-available/{0}' + .format(ee_domain)): + ee_site_webroot = EEVariables.ee_webroot + ee_domain + + if self.app.pargs.no_prompt: + ee_prompt = 'Y' + + if self.app.pargs.db: + if not ee_prompt: + ee_db_prompt = input('Do you want to delete database:[Y/N]' + ) + else: + ee_db_prompt = 'Y' + if ee_db_prompt == 'Y': + deleteDB(ee_site_webroot) + + if self.app.pargs.files: + if not ee_prompt: + ee_web_prompt = input('Do you want to delete webroot:[Y/N]' + ) + else: + ee_web_prompt = 'Y' + if ee_web_prompt == 'Y': + deleteWebRoot(ee_site_webroot) + + if self.app.pargs.all: + if not ee_prompt: + ee_db_prompt = input('Do you want to delete database:[Y/N]' + ) + ee_web_prompt = input('Do you want to delete webroot:[Y/N]' + ) + ee_nginx_prompt = input('Do you want to delete NGINX' + ' configuration:[Y/N]') + else: + ee_db_prompt = 'Y' + ee_web_prompt = 'Y' + ee_nginx_prompt = 'Y' + + if ee_db_prompt: + deleteDB(self, ee_site_webroot) + if ee_web_prompt: + deleteWebRoot(ee_site_webroot) + if ee_nginx_prompt: + EEFileutils.delete(self, '/etc/nginx/sites-available/{0}' + .format(ee_domain)) + + def deleteDB(self, webroot): + configfiles = glob.glob(webroot + '/*-config.php') + if configfiles: + if EEFileUtils.isexist(self, configfiles[0]): + ee_db_name = (EEFileUtils.grep(self, configfiles[0], + 'DB_NAME').split(',')[1] + .split(')')[0].strip().replace('\'', '')) + ee_db_user = (EEFileUtils.grep(self, configfiles[0], + 'DB_USER').split(',')[1] + .split(')')[0].strip().replace('\'', '')) + ee_db_pass = (EEFileUtils.grep(self, configfiles[0], + 'DB_PASSWORD').split(',')[1] + .split(')')[0].strip().replace('\'', '')) + ee_db_host = (EEFileUtils.grep(self, configfiles[0], + 'DB_HOST').split(',')[1] + .split(')')[0].strip().replace('\'', '')) + + EEMysql.execute(self, + "drop database {0}" + .format(ee_db_name)) + if ee_db_user != 'root': + EEMysql.execute(self, + "drop user {0}@{1}" + .format(ee_db_user, ee_db_host)) + EEMysql.execute(self, + "flush privileges") + + def deleteWebRoot(webroot): + EEFileutils.delete(self, webroot) + + def load(app): # register the plugin class.. this only happens if the plugin is enabled handler.register(EESiteController) handler.register(EESiteCreateController) handler.register(EESiteUpdateController) + handler.register(EESiteDeleteController) # register a hook (function) to run after arguments are parsed. hook.register('post_argument_parsing', ee_site_hook) diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index f52cfcc3..a4cc502a 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -60,7 +60,7 @@ class EEFileUtils(): def searchreplace(self, fnm, sstr, rstr): try: for line in fileinput.input(fnm, inplace=True): - Log.info(line.replace(sstr, rstr), end='') + Log.info(line.replace(sstr, rstr)) fileinput.close() except Exception as e: Log.info(self, 'Error : {0}'.format(e)) From b56bd47f911be1cd3b2c627110c5d2b0ca599ae3 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 14 Jan 2015 12:23:45 +0530 Subject: [PATCH 643/829] fixed info message bug --- ee/cli/plugins/site.py | 9 +++------ ee/core/services.py | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index df29d550..b0b69962 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -11,6 +11,8 @@ from ee.core.git import EEGit import sys import os import glob +import subprocess +from subprocess import Popen def ee_site_hook(app): @@ -23,13 +25,8 @@ class EESiteController(CementBaseController): label = 'site' stacked_on = 'base' stacked_type = 'nested' -<<<<<<< HEAD - description = ('''site command manages website configuration - with the help of the following subcommands''') -======= description = ('site command manages website configuration' ' with the help of the following subcommands') ->>>>>>> 78782f7a7595c1e9d9c8e041c9f081e331f156f8 arguments = [ (['site_name'], dict(help='website name')), @@ -157,7 +154,7 @@ class EESiteController(CementBaseController): if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): ee_site_webroot = EEVariables.ee_webroot + ee_domain - EEFileutils.chdir(self, ee_site_webroot) + EEFileUtils.chdir(self, ee_site_webroot) try: subprocess.call(['bash']) except OSError as e: diff --git a/ee/core/services.py b/ee/core/services.py index 97cea2d3..b8c3ee0f 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -59,11 +59,11 @@ class EEService(): if retcode[0] == 0: subprocess.getstatusoutput('service {0} reload' .format(service_name)) - Log.info("reload : {0} [OK]" + Log.info(self, "reload : {0} [OK]" .format(service_name)) return True else: - Log.error("reload : {0} [FAIL]" + Log.error(self, "reload : {0} [FAIL]" .format(service_name)) Log.debug("{0}" .format(retcode[1])) From 1ac2ac31892a8a49e05b472e686e1d59d97bc531 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 14 Jan 2015 13:27:22 +0530 Subject: [PATCH 644/829] Fixed Debian 6 installation compatibilty --- ee/core/variables.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 1e2e87c2..36797587 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -31,7 +31,7 @@ class EEVariables(): try: ee_user = config['user']['name'] ee_email = config['user']['email'] - except KeyError as e: + except Exception as e: print("Unable to find GIT user name and Email") sys.exit(1) diff --git a/setup.py b/setup.py index 98d787a1..ec10e930 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ setup(name='ee', 'pystache', 'python-apt', 'pynginxconfig', - 'pymysql3', + 'pymysql3 == 0.4', 'psutil', 'sh', 'sqlalchemy', From 49a08aa1fde9e264f1539878b1aa8e1e2250c6f2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 14 Jan 2015 14:03:53 +0530 Subject: [PATCH 645/829] Updated Travis --- .travis.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 181138e8..93488bfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,15 +19,5 @@ script: - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig - sudo echo "Travis Banch = $TRAVIS_BRANCH" - sudo apt-get install git python3-setuptools python3-dev python3-apt - - sudo easy_install3 pip - - sudo pip3 install virtualenv - - virtualenv ./env --system-site-packages - - source ./env/bin/activate - - sudo pip3 install -r requirements.txt - - sudo python3 setup.py develop - - mkdir ~/.ee - - ln -s /home/travis/build/rtCamp/easyengine/config/plugins.d ~/.ee/plugins.d - - ln -s /home/travis/build/rtCamp/easyengineee/cli/plugins ~/.ee/plugins - - ee --help - - sudo pip3 install nose coverage - - sudo nosetests + - sudo python3 setup.py install + - sudo ee --help From 801be991b4dd735c492245fd10e46abe9f582890 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 14 Jan 2015 14:20:45 +0530 Subject: [PATCH 646/829] Added more travis test cases --- .travis.yml | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/.travis.yml b/.travis.yml index 93488bfc..61aef98f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,3 +21,86 @@ script: - sudo apt-get install git python3-setuptools python3-dev python3-apt - sudo python3 setup.py install - sudo ee --help + - sudo ee stack install + - sudo ee stack install --web + - sudo ee stack install --mail + - sudo ee stack install --admin + - sudo bash ee site create html.com + - sudo bash ee site create html.net --html + - sudo bash ee site create php.com --php + - sudo bash ee site create mysql.com --mysql + - sudo bash ee site create site1.com --wp + - sudo bash ee site create site1.net --basic + - sudo bash ee site create site1.org --wp --basic + - sudo bash ee site create site1.in --basic --wp + - sudo bash ee site create subdomain.site1.in --basic --wp + - sudo bash ee site create site2.com --wpsc + - sudo bash ee site create site2.net --wp --wpsc + - sudo bash ee site create site2.org --wpsc --wp + - sudo bash ee site create site3.com --w3tc + - sudo bash ee site create site3.net --wp --w3tc + - sudo bash ee site create site3.org --w3tc --wp + - sudo bash ee site create site4.com --wpfc + - sudo bash ee site create site4.net --wp --wpfc + - sudo bash ee site create site4.org --wpfc --wp + - sudo bash ee site create site5.com --wpsubdir + - sudo bash ee site create site5.net --wpsubdir --basic + - sudo bash ee site create site5.org --basic --wpsubdir + - sudo bash ee site create site5.in --wpsubdirectory + - sudo bash ee site create site5.co --wpsubdirectory --basic + - sudo bash ee site create site5.co.in --basic --wpsubdirector + - sudo bash ee site create site6.com --wpsubdir --wpsc + - sudo bash ee site create site6.net --wpsc --wpsubdir + - sudo bash ee site create site6.org --wpsubdirectory --wpsc + - sudo bash ee site create site6.in --wpsc --wpsubdirectory + - sudo bash ee site create site7.com --wpsubdir --w3tc + - sudo bash ee site create site7.net --w3tc --wpsubdir + - sudo bash ee site create site7.org --wpsubdirectory --w3tc + - sudo bash ee site create site7.in --w3tc --wpsubdirectory + - sudo bash ee site create site8.com --wpsubdir --wpfc + - sudo bash ee site create site8.net --wpfc --wpsubdir + - sudo bash ee site create site8.org --wpsubdirectory --wpfc + - sudo bash ee site create site8.in --wpfc --wpsubdirectory + - sudo bash ee site create site9.com --wpsubdom + - sudo bash ee site create site9.net --wpsubdom --basic + - sudo bash ee site create site9.org --basic --wpsubdom + - sudo bash ee site create site9.in --wpsubdomain + - sudo bash ee site create site9.co --wpsubdomain --basic + - sudo bash ee site create site9.co.in --basic --wpsubdomain + - sudo bash ee site create site10.com --wpsubdom --wpsc + - sudo bash ee site create site10.net --wpsc --wpsubdom + - sudo bash ee site create site10.org --wpsubdomain --wpsc + - sudo bash ee site create site10.in --wpsc --wpsubdomain + - sudo bash ee site create site11.com --wpsubdom --w3tc + - sudo bash ee site create site11.net --w3tc --wpsubdom + - sudo bash ee site create site11.org --wpsubdomain --w3tc + - sudo bash ee site create site11.in --w3tc --wpsubdomain + - sudo bash ee site create site12.com --wpsubdom --wpfc + - sudo bash ee site create site12.net --wpfc --wpsubdom + - sudo bash ee site create site12.org --wpsubdomain --wpfc + - sudo bash ee site create site12.in --wpfc --wpsubdomain + + - sudo bash ee debug + - sudo bash ee debug --stop + - sudo bash ee site create 1.com --html + - sudo bash ee site create 2.com --php + - sudo bash ee site create 3.com --mysql + - sudo bash ee site update 1.com --wp + - sudo bash ee site update 2.com --wpsubdir + - sudo bash ee site update 3.com --wpsubdomain + - sudo bash ee site update site1.com --wp --wpfc + - sudo bash ee site update site1.com --wp --w3tc + - sudo bash ee site update site1.com --wp --wpsc + - sudo bash ee site update site5.com --wpsubdir --wpfc + - sudo bash ee site update site5.com --wpsubdir --w3tc + - sudo bash ee site update site5.com --wpsubdir --wpsc + - sudo bash ee site update site9.com --wpsubdom --wpfc + - sudo bash ee site update site9.com --wpsubdom --w3tc + - sudo bash ee site update site9.com --wpsubdom --wpsc + - sudo ee site delete site12.com --no-prompt + - sudo ee site delete site12.net --no-prompt + - sudo ee site delete site12.org --no-prompt + + - sudo bash ee stack install mail + - sudo ls /var/www/ + - sudo wp --allow-root --info From 5a7eea43534bad30576fa4f8b10cbe96f81918fa Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 14 Jan 2015 14:21:48 +0530 Subject: [PATCH 647/829] Added more travis test cases --- .travis.yml | 145 ++++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 73 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61aef98f..a2b1ae4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,84 +23,83 @@ script: - sudo ee --help - sudo ee stack install - sudo ee stack install --web - - sudo ee stack install --mail - sudo ee stack install --admin - - sudo bash ee site create html.com - - sudo bash ee site create html.net --html - - sudo bash ee site create php.com --php - - sudo bash ee site create mysql.com --mysql - - sudo bash ee site create site1.com --wp - - sudo bash ee site create site1.net --basic - - sudo bash ee site create site1.org --wp --basic - - sudo bash ee site create site1.in --basic --wp - - sudo bash ee site create subdomain.site1.in --basic --wp - - sudo bash ee site create site2.com --wpsc - - sudo bash ee site create site2.net --wp --wpsc - - sudo bash ee site create site2.org --wpsc --wp - - sudo bash ee site create site3.com --w3tc - - sudo bash ee site create site3.net --wp --w3tc - - sudo bash ee site create site3.org --w3tc --wp - - sudo bash ee site create site4.com --wpfc - - sudo bash ee site create site4.net --wp --wpfc - - sudo bash ee site create site4.org --wpfc --wp - - sudo bash ee site create site5.com --wpsubdir - - sudo bash ee site create site5.net --wpsubdir --basic - - sudo bash ee site create site5.org --basic --wpsubdir - - sudo bash ee site create site5.in --wpsubdirectory - - sudo bash ee site create site5.co --wpsubdirectory --basic - - sudo bash ee site create site5.co.in --basic --wpsubdirector - - sudo bash ee site create site6.com --wpsubdir --wpsc - - sudo bash ee site create site6.net --wpsc --wpsubdir - - sudo bash ee site create site6.org --wpsubdirectory --wpsc - - sudo bash ee site create site6.in --wpsc --wpsubdirectory - - sudo bash ee site create site7.com --wpsubdir --w3tc - - sudo bash ee site create site7.net --w3tc --wpsubdir - - sudo bash ee site create site7.org --wpsubdirectory --w3tc - - sudo bash ee site create site7.in --w3tc --wpsubdirectory - - sudo bash ee site create site8.com --wpsubdir --wpfc - - sudo bash ee site create site8.net --wpfc --wpsubdir - - sudo bash ee site create site8.org --wpsubdirectory --wpfc - - sudo bash ee site create site8.in --wpfc --wpsubdirectory - - sudo bash ee site create site9.com --wpsubdom - - sudo bash ee site create site9.net --wpsubdom --basic - - sudo bash ee site create site9.org --basic --wpsubdom - - sudo bash ee site create site9.in --wpsubdomain - - sudo bash ee site create site9.co --wpsubdomain --basic - - sudo bash ee site create site9.co.in --basic --wpsubdomain - - sudo bash ee site create site10.com --wpsubdom --wpsc - - sudo bash ee site create site10.net --wpsc --wpsubdom - - sudo bash ee site create site10.org --wpsubdomain --wpsc - - sudo bash ee site create site10.in --wpsc --wpsubdomain - - sudo bash ee site create site11.com --wpsubdom --w3tc - - sudo bash ee site create site11.net --w3tc --wpsubdom - - sudo bash ee site create site11.org --wpsubdomain --w3tc - - sudo bash ee site create site11.in --w3tc --wpsubdomain - - sudo bash ee site create site12.com --wpsubdom --wpfc - - sudo bash ee site create site12.net --wpfc --wpsubdom - - sudo bash ee site create site12.org --wpsubdomain --wpfc - - sudo bash ee site create site12.in --wpfc --wpsubdomain + - sudo ee site create html.com + - sudo ee site create html.net --html + - sudo ee site create php.com --php + - sudo ee site create mysql.com --mysql + - sudo ee site create site1.com --wp + - sudo ee site create site1.net --basic + - sudo ee site create site1.org --wp --basic + - sudo ee site create site1.in --basic --wp + - sudo ee site create subdomain.site1.in --basic --wp + - sudo ee site create site2.com --wpsc + - sudo ee site create site2.net --wp --wpsc + - sudo ee site create site2.org --wpsc --wp + - sudo ee site create site3.com --w3tc + - sudo ee site create site3.net --wp --w3tc + - sudo ee site create site3.org --w3tc --wp + - sudo ee site create site4.com --wpfc + - sudo ee site create site4.net --wp --wpfc + - sudo ee site create site4.org --wpfc --wp + - sudo ee site create site5.com --wpsubdir + - sudo ee site create site5.net --wpsubdir --basic + - sudo ee site create site5.org --basic --wpsubdir + - sudo ee site create site5.in --wpsubdirectory + - sudo ee site create site5.co --wpsubdirectory --basic + - sudo ee site create site5.co.in --basic --wpsubdirector + - sudo ee site create site6.com --wpsubdir --wpsc + - sudo ee site create site6.net --wpsc --wpsubdir + - sudo ee site create site6.org --wpsubdirectory --wpsc + - sudo ee site create site6.in --wpsc --wpsubdirectory + - sudo ee site create site7.com --wpsubdir --w3tc + - sudo ee site create site7.net --w3tc --wpsubdir + - sudo ee site create site7.org --wpsubdirectory --w3tc + - sudo ee site create site7.in --w3tc --wpsubdirectory + - sudo ee site create site8.com --wpsubdir --wpfc + - sudo ee site create site8.net --wpfc --wpsubdir + - sudo ee site create site8.org --wpsubdirectory --wpfc + - sudo ee site create site8.in --wpfc --wpsubdirectory + - sudo ee site create site9.com --wpsubdom + - sudo ee site create site9.net --wpsubdom --basic + - sudo ee site create site9.org --basic --wpsubdom + - sudo ee site create site9.in --wpsubdomain + - sudo ee site create site9.co --wpsubdomain --basic + - sudo ee site create site9.co.in --basic --wpsubdomain + - sudo ee site create site10.com --wpsubdom --wpsc + - sudo ee site create site10.net --wpsc --wpsubdom + - sudo ee site create site10.org --wpsubdomain --wpsc + - sudo ee site create site10.in --wpsc --wpsubdomain + - sudo ee site create site11.com --wpsubdom --w3tc + - sudo ee site create site11.net --w3tc --wpsubdom + - sudo ee site create site11.org --wpsubdomain --w3tc + - sudo ee site create site11.in --w3tc --wpsubdomain + - sudo ee site create site12.com --wpsubdom --wpfc + - sudo ee site create site12.net --wpfc --wpsubdom + - sudo ee site create site12.org --wpsubdomain --wpfc + - sudo ee site create site12.in --wpfc --wpsubdomain - - sudo bash ee debug - - sudo bash ee debug --stop - - sudo bash ee site create 1.com --html - - sudo bash ee site create 2.com --php - - sudo bash ee site create 3.com --mysql - - sudo bash ee site update 1.com --wp - - sudo bash ee site update 2.com --wpsubdir - - sudo bash ee site update 3.com --wpsubdomain - - sudo bash ee site update site1.com --wp --wpfc - - sudo bash ee site update site1.com --wp --w3tc - - sudo bash ee site update site1.com --wp --wpsc - - sudo bash ee site update site5.com --wpsubdir --wpfc - - sudo bash ee site update site5.com --wpsubdir --w3tc - - sudo bash ee site update site5.com --wpsubdir --wpsc - - sudo bash ee site update site9.com --wpsubdom --wpfc - - sudo bash ee site update site9.com --wpsubdom --w3tc - - sudo bash ee site update site9.com --wpsubdom --wpsc + - sudo ee debug + - sudo ee debug --stop + - sudo ee site create 1.com --html + - sudo ee site create 2.com --php + - sudo ee site create 3.com --mysql + - sudo ee site update 1.com --wp + - sudo ee site update 2.com --wpsubdir + - sudo ee site update 3.com --wpsubdomain + - sudo ee site update site1.com --wp --wpfc + - sudo ee site update site1.com --wp --w3tc + - sudo ee site update site1.com --wp --wpsc + - sudo ee site update site5.com --wpsubdir --wpfc + - sudo ee site update site5.com --wpsubdir --w3tc + - sudo ee site update site5.com --wpsubdir --wpsc + - sudo ee site update site9.com --wpsubdom --wpfc + - sudo ee site update site9.com --wpsubdom --w3tc + - sudo ee site update site9.com --wpsubdom --wpsc - sudo ee site delete site12.com --no-prompt - sudo ee site delete site12.net --no-prompt - sudo ee site delete site12.org --no-prompt - - sudo bash ee stack install mail + - sudo ee stack install --mail - sudo ls /var/www/ - sudo wp --allow-root --info From a25487d1b443011551a1eb38ba4dd3a1725f9675 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 14 Jan 2015 14:44:33 +0530 Subject: [PATCH 648/829] Added installation instructions --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5399829d..0f300886 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,20 @@ sudo python3 setup.py develop ee --help ``` +How to install this version on your system?? +```bash +sudo apt-get update +sudo apt-get install python3 python3-apt python3-setuptools python3-dev git +git clone -b python https://github.com/rtCamp/easyengine.git +cd easyengine +sudo python3 setup.py install +ee --help +``` EasyEngine 3.x Developement version - Thinking To Contribute??? refer docs to know more on EasyEngine Developement From f51359f5baf3fddaad71c856ee0d439d9f70efff Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 14 Jan 2015 16:17:01 +0530 Subject: [PATCH 649/829] Noe debug logs goes into file --- config/ee.conf | 14 +++++++------- ee/cli/controllers/base.py | 14 -------------- ee/cli/main.py | 4 ---- setup.py | 6 ++++++ 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/config/ee.conf b/config/ee.conf index 1f89eeee..d3d8aafb 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -18,25 +18,25 @@ # template_dir = /var/lib/ee/templates/ -[log] +[log.logging] ### Where the log file lives (no log file by default) -# file = none +file = /var/log/ee/ee.log ### The level for which to log. One of: info, warn, error, fatal, debug -# level = info +level = debug ### Whether or not to log to console -# to_console = true +to_console = true ### Whether or not to rotate the log file when it reaches `max_bytes` -# rotate = false +rotate = true ### Max size in bytes that a log file can grow until it is rotated. -# max_bytes = 512000 +max_bytes = 512000 ### The maximun number of log files to maintain when rotating -# max_files = 4 +max_files = 7 [stack] diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index 4ccc2869..aad1d5c5 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -31,17 +31,3 @@ class EEBaseController(CementBaseController): # # The 'default.mustache' file would be loaded from # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. - # - # ViMbAdmin Nginx configuration - data = dict(site_name='webmail', www_domain='webmail', static=False, - basic=True, wp=False, w3tc=False, wpfc=False, - wpsc=False, multisite=False, wpsubdir=False, - webroot='/var/www', ee_db_name='', - ee_db_user='', ee_db_pass='', ee_db_host='', - rc=True) - self.app.log.debug('Writting the nginx configration for' - ' ViMbAdmin') - ee_rc = open('/etc/nginx/sites-available/webmail.conf', 'w') - self.app.render((data), 'virtualconf.mustache', - out=ee_rc) - ee_rc.close() diff --git a/ee/cli/main.py b/ee/cli/main.py index f5c84d76..17c8281f 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -23,10 +23,6 @@ class EEApp(foundation.CementApp): class Meta: label = 'ee' - # Log writing to file - defaults = init_defaults('ee', 'log.logging') - defaults['log.logging']['file'] = '/tmp/my.log' - config_defaults = defaults # All built-in application bootstrapping (always run) diff --git a/setup.py b/setup.py index 171d57dd..3064be7d 100644 --- a/setup.py +++ b/setup.py @@ -14,6 +14,12 @@ for name in glob.glob('config/plugins.d/*.conf'): for name in glob.glob('ee/cli/templates/*.mustache'): templates.insert(1, name) +if not os.path.exists('/var/log/ee/'): + os.makedirs('/var/log/ee/') + +if not os.path.exists('/var/lib/ee/'): + os.makedirs('/var/lib/ee/') + setup(name='ee', version='3.0', description=('EasyEngine is the commandline tool to manage your Websites' From ddb21226f812e47ee3dfb51cc15ed269dd44f3dc Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 14 Jan 2015 17:06:10 +0530 Subject: [PATCH 650/829] update --- ee/cli/plugins/clean.py | 14 ++++++---- ee/cli/plugins/secure.py | 6 ++-- ee/cli/plugins/stack_services.py | 2 +- ee/core/download.py | 8 +++--- ee/core/extract.py | 4 +-- ee/core/fileutils.py | 37 +++++++++++++------------ ee/core/mysql.py | 8 +++--- ee/core/services.py | 47 ++++++++++++++++---------------- ee/core/shellexec.py | 12 +++----- 9 files changed, 71 insertions(+), 67 deletions(-) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index b345150c..13d3d805 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -53,11 +53,11 @@ class EECleanController(CementBaseController): try: if(EEAptGet.is_installed("memcached")): EEService.restart_service(self, "memcached") - Log.info(self, "Cleaning memcache..") + Log.info(self, "Cleaning memcache...") else: - Log.error(self, "Memcache not installed") + Log.error(self, "Memcache not installed{0}".format("[FAIL]")) except: - Log.error(self, "Unable to restart memcached") + Log.error(self, "Unable to restart memcached{0}".format("[FAIL]")) @expose(hide=True) def clean_fastcgi(self): @@ -65,16 +65,18 @@ class EECleanController(CementBaseController): Log.info(self, "Cleaning NGINX FastCGI cache, please wait...") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") else: - Log.error(self, "Unable to clean FastCGI cache") + Log.error(self, "Unable to clean FastCGI cache{0}" + .format("[FAIL]")) @expose(hide=True) def clean_opcache(self): try: - Log.info(self, "Cleaning opcache.... ") + Log.info(self, "Cleaning opcache... ") wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" "/opcache/opgui.php?page=reset").read() except Exception as e: - Log.error(self, "Unable to clean opacache {0}".format(e)) + Log.error(self, "Unable to clean opacache {0:10}{1}" + .format(e, "[FAIL]")) def load(app): diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 400962f6..fc336e77 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -75,14 +75,16 @@ class EEsecureController(CementBaseController): "/etc/nginx/sites-available/22222" .format(port=port)) else: - Log.info(self, "Unable to change EasyEngine admin port") + Log.info(self, "Unable to change EasyEngine admin port{0}" + .format("[FAIL]")) if EEVariables.ee_platform_distro == 'Debian': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl;/\" " "/etc/nginx/sites-available/22222" .format(port=port)) else: - Log.info(self, "Unable to change EasyEngine admin port") + Log.info(self, "Unable to change EasyEngine admin port{0}" + .format("[FAIL]")) @expose(hide=True) def secure_ip(self): diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index 4f081d15..666b404e 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -124,4 +124,4 @@ class EEStackStatusController(CementBaseController): services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: if EEService.get_service_status(self, service): - Log.info(self, "{0}: Running".format(service)) + Log.info(self, "{0:10}: {1}".format(service, "Running")) diff --git a/ee/core/download.py b/ee/core/download.py index c7a22e8f..f2be973a 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -22,12 +22,12 @@ class EEDownload(): Log.info(self, "Downloading "+pkg_name+" ...") urllib.request.urlretrieve(url, filename) except urllib.error.URLError as e: - Log.error(self, "Unable to donwload file, [{err}] [FAIL]" - .format(err=str(e.reason))) + Log.error(self, "Unable to donwload file, [{err}]{1}" + .format("[FAIL]", err=str(e.reason))) return False except urllib.error.HTTPError as e: - Log.error(self, "Package download failed. [{err}] [FAIL]" - .format(err=str(e.reason))) + Log.error(self, "Package download failed. [{err}] {1}" + .format("[FAIL]", err=str(e.reason))) return False except urllib.error.ContentTooShortError as e: Log.error(self, "Package download failed. The amount of the" diff --git a/ee/core/extract.py b/ee/core/extract.py index 91f58d53..a25d7306 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -15,6 +15,6 @@ class EEExtract(): os.remove(file) return True except tarfile.TarError as e: - Log.error(self, 'Unable to extract file \{0} {1} [FAIL]' - .format(e.errno, e.strerror)) + Log.error(self, 'Unable to extract file \{0} {1}{2}' + .format(e.errno, e.strerror, "[FAIL]")) return False diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 9a537878..30d52511 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -35,8 +35,8 @@ class EEFileUtils(): try: os.symlink(src, dst) except Exception as e: - Log.error(self, "Unable to create symbolic link ...\n {0}" - " {1}".format(e.errno, e.strerror)) + Log.error(self, "Unable to create symbolic link ...\n {0} " + " {1} {2}".format(e.errno, e.strerror, "[FAIL]")) sys.exit(1) else: Log.debug(self, "Destination: {0} exists".format(dst)) @@ -45,8 +45,8 @@ class EEFileUtils(): try: os.unlink(filepath) except Exception as e: - Log.error(self, "Unable to reomove symbolic link ...\n {0} {1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to reomove symbolic link ...\n {0} {1} {2}" + .format(e.errno, e.strerror, "[FAIL]")) sys.exit(1) def copyfile(self, src, dest): @@ -69,16 +69,16 @@ class EEFileUtils(): try: shutil.move(src, dst) except shutil.Error as e: - Log.error(self, 'Unable to move file {err}' - .format(err=str(e.reason))) + Log.error(self, 'Unable to move file {err}{1}' + .format("[FAIL]", err=str(e.reason))) sys.exit(1) def chdir(self, path): try: os.chdir(path) except OSError as e: - Log.error(self, 'Unable to Change Directory {err}' - .format(err=e.strerror)) + Log.error(self, 'Unable to Change Directory {1}{err}' + .format("[FAIL]", err=e.strerror)) sys.exit(1) def chown(self, path, user, group, recursive=False): @@ -94,10 +94,12 @@ class EEFileUtils(): else: shutil.chown(path, user=user, group=group) except shutil.Error as e: - Log.error(self, "Unable to change owner : {0} ".format(e)) + Log.error(self, "Unable to change owner : {0}{1}" + .format(e, "[FAIL]")) sys.exit(1) except Exception as e: - Log.error(self, "Unable to change owner {0}".format(e)) + Log.error(self, "Unable to change owner {0}{1}" + .format(e, "[FAIL]")) sys.exit(1) def chmod(self, path, perm, recursive=False): @@ -111,15 +113,16 @@ class EEFileUtils(): else: os.chmod(path, perm) except OSError as e: - Log.error(self, "Unable to change owner {0}".format(e.strerror)) + Log.error(self, "Unable to change owner {0}{1}" + .format(e.strerror, "[FAIL]")) sys.exit(1) def mkdir(self, path): try: os.makedirs(path) except OSError as e: - Log.error(self, "Unable to create directory {0}" - .format(e.strerror)) + Log.error(self, "Unable to create directory {0}{1} " + .format(e.strerror, "[FAIL]")) sys.exit(1) def isexist(self, path): @@ -129,8 +132,8 @@ class EEFileUtils(): else: return (False) except OSError as e: - Log.error(self, "Unable to check path {0}" - .format(e.strerror)) + Log.error(self, "Unable to check path {0}{1}" + .format(e.strerror, "[FAIL]")) sys.exit(1) def grep(self, fnm, sstr): @@ -139,6 +142,6 @@ class EEFileUtils(): if sstr in line: return line except OSError as e: - Log.error(self, "Unable to Search string {0}" - .format(e.strerror)) + Log.error(self, "Unable to Search string {0}{1}" + .format(e.strerror, "[FAIL]")) sys.exit(1) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 883752f2..ff2ee15e 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -30,15 +30,15 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() except Exception as e: - Log.error(self, 'Unable to connect to database: {0}' - .format(e)) + Log.error(self, 'Unable to connect to database: {0} {1}' + .format(e, "[FAIL]")) sys.exit(1) try: cur.execute(statement) except Exception as e: - Log.error(self, 'Error occured while executing: {0}' - .format(e)) + Log.error(self, 'Unable to execute statement: {0} {1}' + .format(e, "[FAIL]")) cur.close() conn.close() sys.exit(1) diff --git a/ee/core/services.py b/ee/core/services.py index 97cea2d3..7c5d0e71 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -4,6 +4,7 @@ import sys import subprocess from subprocess import Popen from ee.core.logging import Log +import pystache class EEService(): @@ -17,13 +18,13 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} start' .format(service_name)) if retcode[0] == 0: - Log.info(self, "Started : {0} [ok]" - .format(service_name)) + Log.info(self, "Started : {0:10}{1}" + .format(service_name, "[OK]")) else: Log.error(self, retcode[1]) except OSError as e: - Log.error(self, "Failed to start service {0} {1} [FAIL]" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to start service {0} {1} {2}" + .format(e.errno, e.strerror, "[FAIL]")) return False def stop_service(self, service_name): @@ -31,25 +32,25 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} stop' .format(service_name)) if retcode[0] == 0: - Log.info(self, "Stopped : {0} [OK]" - .format(service_name)) + Log.info(self, "Stopped : {0:10}{1}" + .format(service_name, "[OK]")) return True else: return False except OSError as e: - Log.error(self, "Failed to stop service : {0}{1} [FAIL]" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to stop service : {0}{1}{2}" + .format(e.errno, e.strerror, "[FAIL]")) return False def restart_service(self, service_name): try: EEService.stop_service(self, service_name) EEService.start_service(self, service_name) - Log.info(self, "restart : {0} [OK]" - .format(service_name)) + Log.info(self, "restart : {0:10}{1}" + .format(service_name, "[OK]")) except OSError as e: - Log.error(self, "Failed to restart services \{0} {1} [FAIL]" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to restart services \{0} {1} {2}" + .format(e.errno, e.strerror, "[FAIL]")) def reload_service(self, service_name): try: @@ -59,28 +60,28 @@ class EEService(): if retcode[0] == 0: subprocess.getstatusoutput('service {0} reload' .format(service_name)) - Log.info("reload : {0} [OK]" - .format(service_name)) + Log.info(self, "reload : {0} {0:10}" + .format(service_name, "[OK]")) return True else: - Log.error("reload : {0} [FAIL]" - .format(service_name)) - Log.debug("{0}" + Log.error(self, "reload : {0} {1}" + .format(service_name, "[FAIL]")) + Log.debug(self, "{0}" .format(retcode[1])) return False retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: - Log.info(self, "reload : {0} [OK]" - .format(service_name)) + Log.info(self, "reload : {0:10}{1}" + .format(service_name, "[OK]")) return True else: return False except OSError as e: - Log.error(self, "Failed to reload {0} {1} [FAIL]" - .format(service_name, e)) + Log.error(self, "Failed to reload {0} {1} {2}" + .format(service_name, e, "[FAIL]")) sys.exit(1) def get_service_status(self, service_name): @@ -97,6 +98,6 @@ class EEService(): else: return False except OSError as e: - Log.error(self, "Unable to get services status \ {0}{1} [FAIL]" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to get services status \ {0}{1}{2}" + .format(e.errno, e.strerror, "[FAIL]")) return False diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 45130607..54c85f1f 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -24,10 +24,8 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: - Log.error(self, "Unable to execute command \ {0}{1}" - .format(e.errno, e.strerror)) - Log.debug(self, "Unable to execute command \ {0}{1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to execute command \ {0}{1}{2}" + .format(e.errno, e.strerror, "[FAIL]")) sys.exit(1) def invoke_editor(self, filepath, errormsg=''): @@ -37,8 +35,6 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: - Log.error(self, "Unable to edit file \ {0}{1}" - .format(e.errno, e.strerror)) - Log.debug(self, "Unable to edit file \ {0}{1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to edit file \ {0}{1}{2}" + .format(e.errno, e.strerror, "[FAIL]")) sys.exit(1) From d87ecd4f89b8f9cc5b2d4bbfacfc7758f645c2cf Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 14 Jan 2015 19:50:43 +0530 Subject: [PATCH 651/829] added log message --- ee/cli/plugins/clean.py | 14 +++++------ ee/core/download.py | 14 ++++++----- ee/core/extract.py | 4 +-- ee/core/fileutils.py | 55 +++++++++++++++++++++++------------------ ee/core/git.py | 8 ++++-- ee/core/mysql.py | 8 +++--- ee/core/services.py | 28 ++++++++++++--------- ee/core/shellexec.py | 9 ++++--- 8 files changed, 79 insertions(+), 61 deletions(-) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 13d3d805..e2eb41b9 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -55,9 +55,10 @@ class EECleanController(CementBaseController): EEService.restart_service(self, "memcached") Log.info(self, "Cleaning memcache...") else: - Log.error(self, "Memcache not installed{0}".format("[FAIL]")) - except: - Log.error(self, "Unable to restart memcached{0}".format("[FAIL]")) + Log.error(self, "Memcache not installed") + except Exception as e: + Log.error(self, "Unable to restart memcached") + Log.debug(self, "{0}".format(e)) @expose(hide=True) def clean_fastcgi(self): @@ -65,8 +66,7 @@ class EECleanController(CementBaseController): Log.info(self, "Cleaning NGINX FastCGI cache, please wait...") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") else: - Log.error(self, "Unable to clean FastCGI cache{0}" - .format("[FAIL]")) + Log.error(self, "Unable to clean FastCGI cache") @expose(hide=True) def clean_opcache(self): @@ -75,8 +75,8 @@ class EECleanController(CementBaseController): wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" "/opcache/opgui.php?page=reset").read() except Exception as e: - Log.error(self, "Unable to clean opacache {0:10}{1}" - .format(e, "[FAIL]")) + Log.error(self, "Unable to clean opacache") + Log.debug(self, "{0}".format(e)) def load(app): diff --git a/ee/core/download.py b/ee/core/download.py index f2be973a..062c3451 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -22,16 +22,18 @@ class EEDownload(): Log.info(self, "Downloading "+pkg_name+" ...") urllib.request.urlretrieve(url, filename) except urllib.error.URLError as e: - Log.error(self, "Unable to donwload file, [{err}]{1}" - .format("[FAIL]", err=str(e.reason))) + Log.error(self, "Unable to donwload file, {0}" + .format(filename)) + Log.debug(self, "[{err}]".format(err=str(e.reason))) return False except urllib.error.HTTPError as e: - Log.error(self, "Package download failed. [{err}] {1}" - .format("[FAIL]", err=str(e.reason))) + Log.error(self, "Package download failed. {0}" + .format(pkg_name)) + Log.debug(self, "[{err}]".format(err=str(e.reason))) return False except urllib.error.ContentTooShortError as e: Log.error(self, "Package download failed. The amount of the" " downloaded data is less than " - "the expected amount \{0} {1}" - .format(e.errno, e.strerror)) + "the expected amount \{0} ".format(pkg_name)) + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) return False diff --git a/ee/core/extract.py b/ee/core/extract.py index a25d7306..3a012883 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -15,6 +15,6 @@ class EEExtract(): os.remove(file) return True except tarfile.TarError as e: - Log.error(self, 'Unable to extract file \{0} {1}{2}' - .format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, 'Unable to extract file \{0}'.format(file)) + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) return False diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 66afde52..90f8349e 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -24,8 +24,8 @@ class EEFileUtils(): Log.info(self, "Removing "+os.path.basename(file)+"...") shutil.rmtree(file) except shutil.Error as e: - Log.error(self, 'Unable to Remove file {err}' - .format(err=str(e.reason))) + Log.error(self, 'Unable to Remove file ') + Log.debug(self, "{err}".format(err=str(e.reason))) sys.exit(1) def create_symlink(self, paths, errormsg=''): @@ -35,8 +35,8 @@ class EEFileUtils(): try: os.symlink(src, dst) except Exception as e: - Log.error(self, "Unable to create symbolic link ...\n {0} " - " {1} {2}".format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, "Unable to create symbolic link ...\n ") + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) sys.exit(1) else: Log.debug(self, "Destination: {0} exists".format(dst)) @@ -45,40 +45,47 @@ class EEFileUtils(): try: os.unlink(filepath) except Exception as e: - Log.error(self, "Unable to reomove symbolic link ...\n {0} {1} {2}" - .format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, "Unable to reomove symbolic link ...\n") + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) sys.exit(1) def copyfile(self, src, dest): try: shutil.copy2(src, dest) except shutil.Error as e: - Log.error(self, '{0}'.format(e)) + Log.error(self, 'Unable to copy file from {0} to {1}' + .format(src, dest)) + Log.debug(self, "{0}".format(e)) except IOError as e: - Log.error(self, '{e}'.format(e.strerror)) + Log.error(self, "Unable to copy file from {0} to {1}" + .fromat(src, dest)) + Log.debug(self, "{e}".format(e.strerror)) def searchreplace(self, fnm, sstr, rstr): try: for line in fileinput.input(fnm, inplace=True): - Log.info(line.replace(sstr, rstr)) + print(line.replace(sstr, rstr), end='') fileinput.close() except Exception as e: - Log.error(self, '{0}'.format(e)) + Log.error(self, "Unable to search {0} and replace {1} {2}" + .format(fnm, sstr, rstr)) + Log.debug(self, "{0}".format(e)) def mvfile(self, src, dst): try: shutil.move(src, dst) except shutil.Error as e: - Log.error(self, 'Unable to move file {err}{1}' - .format("[FAIL]", err=str(e.reason))) + Log.error(self, 'Unable to move file from {0} to {1}' + .format(src, dst)) + Log.debug(self, "{err}".format(err=str(e.reason))) sys.exit(1) def chdir(self, path): try: os.chdir(path) except OSError as e: - Log.error(self, 'Unable to Change Directory {1}{err}' - .format("[FAIL]", err=e.strerror)) + Log.error(self, 'Unable to Change Directory {0}'.format(path)) + Log.debug(self, "{err}".format(err=e.strerror)) sys.exit(1) def chown(self, path, user, group, recursive=False): @@ -94,12 +101,12 @@ class EEFileUtils(): else: shutil.chown(path, user=user, group=group) except shutil.Error as e: - Log.error(self, "Unable to change owner : {0}{1}" - .format(e, "[FAIL]")) + Log.error(self, "Unable to change owner : {0}".format(path)) + Log.debug(self, "{0}".format(e)) sys.exit(1) except Exception as e: - Log.error(self, "Unable to change owner {0}{1}" - .format(e, "[FAIL]")) + Log.error(self, "Unable to change owner : {0} ".format(path)) + Log.debug(self, "{0}".format(e)) sys.exit(1) def chmod(self, path, perm, recursive=False): @@ -113,16 +120,16 @@ class EEFileUtils(): else: os.chmod(path, perm) except OSError as e: - Log.error(self, "Unable to change owner {0}{1}" - .format(e.strerror, "[FAIL]")) + Log.error(self, "Unable to change owner : {0}".format(path)) + Log.debug(self, "{0}".format(e.strerror)) sys.exit(1) def mkdir(self, path): try: os.makedirs(path) except OSError as e: - Log.error(self, "Unable to create directory {0}{1} " - .format(e.strerror, "[FAIL]")) + Log.error(self, "Unable to create directory {0} ".format(path)) + Log.debug(self, "{0}".format(e.strerror)) sys.exit(1) def isexist(self, path): @@ -132,8 +139,8 @@ class EEFileUtils(): else: return (False) except OSError as e: - Log.error(self, "Unable to check path {0}{1}" - .format(e.strerror, "[FAIL]")) + Log.error(self, "Unable to check path {0}".format(path)) + Log.debug(self, "{0}".format(e.strerror)) sys.exit(1) def grep(self, fnm, sstr): diff --git a/ee/core/git.py b/ee/core/git.py index 659d51d0..768c3aa6 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -21,7 +21,9 @@ class EEGit: .format(path)) git.init(path) except ErrorReturnCode as e: - Log.error(e) + Log.error(self, "Unable to git init at {0}" + .format(path)) + Log.error(self, "{0}".format(e)) sys.exit(1) status = git.status("-s") if len(status.splitlines()) > 0: @@ -31,7 +33,9 @@ class EEGit: git.add("--all") git.commit("-am {0}".format(msg)) except ErrorReturnCode as e: - Log.error(e) + Log.error(self, "Unable to git commit at {0} " + .format(path)) + Log.debug(self, "{0}".format(e)) sys.exit(1) else: Log.debug(self, "EEGit: Path {0} not present".format(path)) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index ff2ee15e..ea40453c 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -30,15 +30,15 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() except Exception as e: - Log.error(self, 'Unable to connect to database: {0} {1}' - .format(e, "[FAIL]")) + Log.error(self, 'Unable to connect to database: ') + Log.debug(self, "{0}".format(e)) sys.exit(1) try: cur.execute(statement) except Exception as e: - Log.error(self, 'Unable to execute statement: {0} {1}' - .format(e, "[FAIL]")) + Log.error(self, 'Unable to execute statement:') + Lod.debug(self, "{0}".format(e)) cur.close() conn.close() sys.exit(1) diff --git a/ee/core/services.py b/ee/core/services.py index 445c522c..a55959eb 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -23,8 +23,9 @@ class EEService(): else: Log.error(self, retcode[1]) except OSError as e: - Log.error(self, "Failed to start service {0} {1} {2}" - .format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, "Failed to start service {0}" + .format(service_name)) + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) return False def stop_service(self, service_name): @@ -38,8 +39,9 @@ class EEService(): else: return False except OSError as e: - Log.error(self, "Failed to stop service : {0}{1}{2}" - .format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, "Failed to stop service : {0}" + .format(service_name)) + Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) return False def restart_service(self, service_name): @@ -49,8 +51,9 @@ class EEService(): Log.info(self, "restart : {0:10}{1}" .format(service_name, "[OK]")) except OSError as e: - Log.error(self, "Failed to restart services \{0} {1} {2}" - .format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, "Failed to restart services \{0}" + .format(service_name)) + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) def reload_service(self, service_name): try: @@ -64,8 +67,7 @@ class EEService(): .format(service_name, "[OK]")) return True else: - Log.error(self, "reload : {0}{1}" - .format(service_name, "[FAIL]")) + Log.error(self, "reload : {0}".format(service_name)) Log.debug("{0}".format(retcode[1])) return False @@ -78,8 +80,9 @@ class EEService(): else: return False except OSError as e: - Log.error(self, "Failed to reload {0} {1} {2}" - .format(service_name, e, "[FAIL]")) + Log.error(self, "Failed to reload service {0}" + .format(service_name)) + Log.debug(self, "{0}".format(e)) sys.exit(1) def get_service_status(self, service_name): @@ -96,6 +99,7 @@ class EEService(): else: return False except OSError as e: - Log.error(self, "Unable to get services status \ {0}{1}{2}" - .format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, "Unable to get services status of {0}" + .format(service_name)) + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) return False diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 54c85f1f..5f31f969 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -24,8 +24,9 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: - Log.error(self, "Unable to execute command \ {0}{1}{2}" - .format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, "Unable to execute command {0}" + .format(command)) + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) sys.exit(1) def invoke_editor(self, filepath, errormsg=''): @@ -35,6 +36,6 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: - Log.error(self, "Unable to edit file \ {0}{1}{2}" - .format(e.errno, e.strerror, "[FAIL]")) + Log.error(self, "Unable to edit file {0}".format(filepath)) + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) sys.exit(1) From 5a8c9f1b7dde5488989154d276d606cfd512a530 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 15 Jan 2015 11:55:12 +0530 Subject: [PATCH 652/829] custom error msg --- ee/core/fileutils.py | 16 ++++++++++++++++ ee/core/mysql.py | 10 ++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index d497eed3..a07d2f7d 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -142,3 +142,19 @@ class EEFileUtils(): Log.error(self, "Unable to Search string {0}" .format(e.strerror)) sys.exit(1) + + def rm(self, path): + if EEFileUtils.isexist(self, path): + try: + if os.path.isdir(path): + shutil.rmtree(path) + else: + os.remove(path) + except shutil.Error as e: + Log.error(self, "Unable to remove directory : {0} {1}" + .format(path, e)) + sys.exit(1) + except OSError as e: + Log.error(self, "Unable to remove file : {0} {1}" + .format(path, e)) + sys.exit(1) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 883752f2..4bf07cac 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -9,7 +9,7 @@ from ee.core.logging import Log class EEMysql(): """Method for MySQL connection""" - def execute(self, statement): + def execute(self, statement, errormsg=''): config = configparser.RawConfigParser() cnfpath = expanduser("~")+"/.my.cnf" if [cnfpath] == config.read(cnfpath): @@ -30,7 +30,13 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() except Exception as e: - Log.error(self, 'Unable to connect to database: {0}' + if errormsg: + Log.error(self, '{0}' + .format(errormsg)) + else: + Log.error(self, 'Unable to connect to database: {0}' + .format(e)) + Log.debug(self, 'Unable to connect to database: {0}' .format(e)) sys.exit(1) From 766ac5116de711119eded6a23a746ad96ffd8775 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Thu, 15 Jan 2015 12:08:49 +0530 Subject: [PATCH 653/829] removed sys.exit() --- ee/cli/plugins/clean.py | 4 ++-- ee/core/download.py | 4 ++-- ee/core/extract.py | 2 +- ee/core/fileutils.py | 42 ++++++++++++++++------------------------- ee/core/git.py | 6 ++---- ee/core/services.py | 13 ++++++------- ee/core/shellexec.py | 6 ++---- 7 files changed, 31 insertions(+), 46 deletions(-) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index e2eb41b9..a61e6fd6 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -57,8 +57,8 @@ class EECleanController(CementBaseController): else: Log.error(self, "Memcache not installed") except Exception as e: - Log.error(self, "Unable to restart memcached") Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to restart memcached") @expose(hide=True) def clean_fastcgi(self): @@ -75,8 +75,8 @@ class EECleanController(CementBaseController): wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" "/opcache/opgui.php?page=reset").read() except Exception as e: - Log.error(self, "Unable to clean opacache") Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to clean opacache") def load(app): diff --git a/ee/core/download.py b/ee/core/download.py index 062c3451..a4bc97a0 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -22,9 +22,9 @@ class EEDownload(): Log.info(self, "Downloading "+pkg_name+" ...") urllib.request.urlretrieve(url, filename) except urllib.error.URLError as e: + Log.debug(self, "[{err}]".format(err=str(e.reason))) Log.error(self, "Unable to donwload file, {0}" .format(filename)) - Log.debug(self, "[{err}]".format(err=str(e.reason))) return False except urllib.error.HTTPError as e: Log.error(self, "Package download failed. {0}" @@ -32,8 +32,8 @@ class EEDownload(): Log.debug(self, "[{err}]".format(err=str(e.reason))) return False except urllib.error.ContentTooShortError as e: + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) Log.error(self, "Package download failed. The amount of the" " downloaded data is less than " "the expected amount \{0} ".format(pkg_name)) - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) return False diff --git a/ee/core/extract.py b/ee/core/extract.py index 3a012883..534f7062 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -15,6 +15,6 @@ class EEExtract(): os.remove(file) return True except tarfile.TarError as e: - Log.error(self, 'Unable to extract file \{0}'.format(file)) Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) + Log.error(self, 'Unable to extract file \{0}'.format(file)) return False diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 90f8349e..74bf424a 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -24,9 +24,8 @@ class EEFileUtils(): Log.info(self, "Removing "+os.path.basename(file)+"...") shutil.rmtree(file) except shutil.Error as e: - Log.error(self, 'Unable to Remove file ') Log.debug(self, "{err}".format(err=str(e.reason))) - sys.exit(1) + Log.error(self, 'Unable to Remove file ') def create_symlink(self, paths, errormsg=''): src = paths[0] @@ -35,9 +34,8 @@ class EEFileUtils(): try: os.symlink(src, dst) except Exception as e: - Log.error(self, "Unable to create symbolic link ...\n ") Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) - sys.exit(1) + Log.error(self, "Unable to create symbolic link ...\n ") else: Log.debug(self, "Destination: {0} exists".format(dst)) @@ -45,21 +43,20 @@ class EEFileUtils(): try: os.unlink(filepath) except Exception as e: - Log.error(self, "Unable to reomove symbolic link ...\n") Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) - sys.exit(1) + Log.error(self, "Unable to reomove symbolic link ...\n") def copyfile(self, src, dest): try: shutil.copy2(src, dest) except shutil.Error as e: + Log.debug(self, "{0}".format(e)) Log.error(self, 'Unable to copy file from {0} to {1}' .format(src, dest)) - Log.debug(self, "{0}".format(e)) except IOError as e: + Log.debug(self, "{e}".format(e.strerror)) Log.error(self, "Unable to copy file from {0} to {1}" .fromat(src, dest)) - Log.debug(self, "{e}".format(e.strerror)) def searchreplace(self, fnm, sstr, rstr): try: @@ -67,26 +64,24 @@ class EEFileUtils(): print(line.replace(sstr, rstr), end='') fileinput.close() except Exception as e: + Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to search {0} and replace {1} {2}" .format(fnm, sstr, rstr)) - Log.debug(self, "{0}".format(e)) def mvfile(self, src, dst): try: shutil.move(src, dst) except shutil.Error as e: + Log.debug(self, "{err}".format(err=str(e.reason))) Log.error(self, 'Unable to move file from {0} to {1}' .format(src, dst)) - Log.debug(self, "{err}".format(err=str(e.reason))) - sys.exit(1) def chdir(self, path): try: os.chdir(path) except OSError as e: - Log.error(self, 'Unable to Change Directory {0}'.format(path)) Log.debug(self, "{err}".format(err=e.strerror)) - sys.exit(1) + Log.error(self, 'Unable to Change Directory {0}'.format(path)) def chown(self, path, user, group, recursive=False): try: @@ -101,13 +96,11 @@ class EEFileUtils(): else: shutil.chown(path, user=user, group=group) except shutil.Error as e: - Log.error(self, "Unable to change owner : {0}".format(path)) Log.debug(self, "{0}".format(e)) - sys.exit(1) + Log.error(self, "Unable to change owner : {0}".format(path)) except Exception as e: - Log.error(self, "Unable to change owner : {0} ".format(path)) Log.debug(self, "{0}".format(e)) - sys.exit(1) + Log.error(self, "Unable to change owner : {0} ".format(path)) def chmod(self, path, perm, recursive=False): try: @@ -120,17 +113,15 @@ class EEFileUtils(): else: os.chmod(path, perm) except OSError as e: - Log.error(self, "Unable to change owner : {0}".format(path)) Log.debug(self, "{0}".format(e.strerror)) - sys.exit(1) + Log.error(self, "Unable to change owner : {0}".format(path)) def mkdir(self, path): try: os.makedirs(path) except OSError as e: - Log.error(self, "Unable to create directory {0} ".format(path)) Log.debug(self, "{0}".format(e.strerror)) - sys.exit(1) + Log.error(self, "Unable to create directory {0} ".format(path)) def isexist(self, path): try: @@ -139,9 +130,8 @@ class EEFileUtils(): else: return (False) except OSError as e: - Log.error(self, "Unable to check path {0}".format(path)) Log.debug(self, "{0}".format(e.strerror)) - sys.exit(1) + Log.error(self, "Unable to check path {0}".format(path)) def grep(self, fnm, sstr): try: @@ -149,6 +139,6 @@ class EEFileUtils(): if sstr in line: return line except OSError as e: - Log.error(self, "Unable to Search string {0}{1}" - .format(e.strerror, "[FAIL]")) - sys.exit(1) + Log.debug(self, "{0}".format(e.strerror)) + Log.error(self, "Unable to Search string {0} in {1}" + .format(sstr, fnm)) diff --git a/ee/core/git.py b/ee/core/git.py index 768c3aa6..3863719f 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -21,10 +21,9 @@ class EEGit: .format(path)) git.init(path) except ErrorReturnCode as e: + Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to git init at {0}" .format(path)) - Log.error(self, "{0}".format(e)) - sys.exit(1) status = git.status("-s") if len(status.splitlines()) > 0: try: @@ -33,10 +32,9 @@ class EEGit: git.add("--all") git.commit("-am {0}".format(msg)) except ErrorReturnCode as e: + Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to git commit at {0} " .format(path)) - Log.debug(self, "{0}".format(e)) - sys.exit(1) else: Log.debug(self, "EEGit: Path {0} not present".format(path)) diff --git a/ee/core/services.py b/ee/core/services.py index a55959eb..961710c3 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -23,9 +23,9 @@ class EEService(): else: Log.error(self, retcode[1]) except OSError as e: + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) Log.error(self, "Failed to start service {0}" .format(service_name)) - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) return False def stop_service(self, service_name): @@ -39,9 +39,9 @@ class EEService(): else: return False except OSError as e: + Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) Log.error(self, "Failed to stop service : {0}" .format(service_name)) - Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) return False def restart_service(self, service_name): @@ -51,9 +51,9 @@ class EEService(): Log.info(self, "restart : {0:10}{1}" .format(service_name, "[OK]")) except OSError as e: + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) Log.error(self, "Failed to restart services \{0}" .format(service_name)) - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) def reload_service(self, service_name): try: @@ -67,8 +67,8 @@ class EEService(): .format(service_name, "[OK]")) return True else: - Log.error(self, "reload : {0}".format(service_name)) Log.debug("{0}".format(retcode[1])) + Log.error(self, "reload : {0}".format(service_name)) return False retcode = subprocess.getstatusoutput('service {0} reload' @@ -80,10 +80,9 @@ class EEService(): else: return False except OSError as e: + Log.debug(self, "{0}".format(e)) Log.error(self, "Failed to reload service {0}" .format(service_name)) - Log.debug(self, "{0}".format(e)) - sys.exit(1) def get_service_status(self, service_name): try: @@ -99,7 +98,7 @@ class EEService(): else: return False except OSError as e: + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) Log.error(self, "Unable to get services status of {0}" .format(service_name)) - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) return False diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 5f31f969..ed0d4691 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -24,10 +24,9 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) Log.error(self, "Unable to execute command {0}" .format(command)) - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) - sys.exit(1) def invoke_editor(self, filepath, errormsg=''): try: @@ -36,6 +35,5 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: - Log.error(self, "Unable to edit file {0}".format(filepath)) Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) - sys.exit(1) + Log.error(self, "Unable to edit file {0}".format(filepath)) From c2ed387ed6a5b7ec046cb39f89119d2b9f573a29 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 15 Jan 2015 16:54:51 +0530 Subject: [PATCH 654/829] ee info command done --- config/plugins.d/info.conf | 11 ++ ee/cli/bootstrap.py | 2 - ee/cli/controllers/info.py | 26 ---- ee/cli/plugins/info.py | 197 +++++++++++++++++++++++++++ ee/cli/plugins/stack.py | 8 ++ ee/cli/templates/info_mysql.mustache | 9 ++ ee/cli/templates/info_nginx.mustache | 10 ++ ee/cli/templates/info_php.mustache | 35 +++++ 8 files changed, 270 insertions(+), 28 deletions(-) create mode 100644 config/plugins.d/info.conf delete mode 100644 ee/cli/controllers/info.py create mode 100644 ee/cli/plugins/info.py create mode 100644 ee/cli/templates/info_mysql.mustache create mode 100644 ee/cli/templates/info_nginx.mustache create mode 100644 ee/cli/templates/info_php.mustache diff --git a/config/plugins.d/info.conf b/config/plugins.d/info.conf new file mode 100644 index 00000000..59f51a03 --- /dev/null +++ b/config/plugins.d/info.conf @@ -0,0 +1,11 @@ +### Example Plugin Configuration for EasyEngine + +[info] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true + +### Additional plugin configuration settings +foo = bar diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index 48b62d3b..a14aacd2 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -6,10 +6,8 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController from ee.cli.controllers.isl import EEImportslowlogController -from ee.cli.controllers.info import EEInfoController def load(app): handler.register(EEBaseController) - handler.register(EEInfoController) handler.register(EEImportslowlogController) diff --git a/ee/cli/controllers/info.py b/ee/cli/controllers/info.py deleted file mode 100644 index 70e56ae3..00000000 --- a/ee/cli/controllers/info.py +++ /dev/null @@ -1,26 +0,0 @@ -from cement.core.controller import CementBaseController, expose - - -class EEInfoController(CementBaseController): - class Meta: - label = 'info' - stacked_on = 'base' - stacked_type = 'nested' - description = 'info command used for debugging issued with stack or \ - site specific configuration' - arguments = [ - (['--mysql'], - dict(help='get mysql configuration information', - action='store_true')), - (['--php'], - dict(help='get php configuration information', - action='store_true')), - (['--nginx'], - dict(help='get nginx configuration information', - action='store_true')), - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee debug command - print("Inside EEInfoController.default().") diff --git a/ee/cli/plugins/info.py b/ee/cli/plugins/info.py new file mode 100644 index 00000000..58a81ab5 --- /dev/null +++ b/ee/cli/plugins/info.py @@ -0,0 +1,197 @@ +"""EEInfo Plugin for EasyEngine.""" + +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +from pynginxconfig import NginxConfig +from ee.core.aptget import EEAptGet +from ee.core.shellexec import EEShellExec +import os +import configparser + + +def info_plugin_hook(app): + # do something with the ``app`` object here. + pass + + +class EEInfoController(CementBaseController): + class Meta: + label = 'info' + stacked_on = 'base' + stacked_type = 'nested' + description = 'info command used for debugging issued with stack or \ + site specific configuration' + arguments = [ + (['--mysql'], + dict(help='get mysql configuration information', + action='store_true')), + (['--php'], + dict(help='get php configuration information', + action='store_true')), + (['--nginx'], + dict(help='get nginx configuration information', + action='store_true')), + ] + + @expose(hide=True) + def info_nginx(self): + version = os.popen("nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2 | " + "cut -d'/' -f2 | tr -d '\n'").read() + allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | " + "cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read() + nc = NginxConfig() + nc.loadf('/etc/nginx/nginx.conf') + user = nc.get('user')[1] + worker_processes = nc.get('worker_processes')[1] + worker_connections = nc.get([('events',), 'worker_connections'])[1] + keepalive_timeout = nc.get([('http',), 'keepalive_timeout'])[1] + if os.path.isfile('/etc/nginx/conf.d/ee-nginx.conf'): + nc.loadf('/etc/nginx/conf.d/ee-nginx.conf') + fastcgi_read_timeout = nc.get('fastcgi_read_timeout')[1] + client_max_body_size = nc.get('client_max_body_size')[1] + else: + fastcgi_read_timeout = nc.get([('http',), + 'fastcgi_read_timeout'])[1] + client_max_body_size = nc.get([('http',), + 'client_max_body_size'])[1] + data = dict(version=version, allow=allow, user=user, + worker_processes=worker_processes, + keepalive_timeout=keepalive_timeout, + worker_connections=worker_connections, + fastcgi_read_timeout=fastcgi_read_timeout, + client_max_body_size=client_max_body_size) + self.app.render((data), 'info_nginx.mustache') + + @expose(hide=True) + def info_php(self): + version = os.popen("php -v | head -n1 | cut -d' ' -f2 |" + " cut -d'+' -f1 | tr -d '\n'").read + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/php.ini') + expose_php = config['PHP']['expose_php'] + memory_limit = config['PHP']['memory_limit'] + post_max_size = config['PHP']['post_max_size'] + upload_max_filesize = config['PHP']['upload_max_filesize'] + max_execution_time = config['PHP']['max_execution_time'] + + config.read('/etc/php5/fpm/pool.d/www.conf') + www_listen = config['www']['listen'] + www_ping_path = config['www']['ping.path'] + www_pm_status_path = config['www']['pm.status_path'] + www_pm = config['www']['pm'] + www_pm_max_requests = config['www']['pm.max_requests'] + www_pm_max_children = config['www']['pm.max_children'] + www_pm_start_servers = config['www']['pm.start_servers'] + www_pm_min_spare_servers = config['www']['pm.min_spare_servers'] + www_pm_max_spare_servers = config['www']['pm.max_spare_servers'] + www_request_terminate_time = (config['www'] + ['request_terminate_timeout']) + try: + www_xdebug = (config['www']['php_admin_flag[xdebug.profiler_enable' + '_trigger]']) + except Exception as e: + www_xdebug = 'off' + + config.read('/etc/php5/fpm/pool.d/debug.conf') + debug_listen = config['debug']['listen'] + debug_ping_path = config['debug']['ping.path'] + debug_pm_status_path = config['debug']['pm.status_path'] + debug_pm = config['debug']['pm'] + debug_pm_max_requests = config['debug']['pm.max_requests'] + debug_pm_max_children = config['debug']['pm.max_children'] + debug_pm_start_servers = config['debug']['pm.start_servers'] + debug_pm_min_spare_servers = config['debug']['pm.min_spare_servers'] + debug_pm_max_spare_servers = config['debug']['pm.max_spare_servers'] + debug_request_terminate = (config['debug'] + ['request_terminate_timeout']) + try: + debug_xdebug = (config['debug']['php_admin_flag[xdebug.profiler_' + 'enable_trigger]']) + except Exception as e: + debug_xdebug = 'off' + + data = dict(version=version, expose_php=expose_php, + memory_limit=memory_limit, post_max_size=post_max_size, + upload_max_filesize=upload_max_filesize, + max_execution_time=max_execution_time, + www_listen=www_listen, www_ping_path=www_ping_path, + www_pm_status_path=www_pm_status_path, www_pm=www_pm, + www_pm_max_requests=www_pm_max_requests, + www_pm_max_children=www_pm_max_children, + www_pm_start_servers=www_pm_start_servers, + www_pm_min_spare_servers=www_pm_min_spare_servers, + www_pm_max_spare_servers=www_pm_max_spare_servers, + www_request_terminate_timeout=www_request_terminate_time, + www_xdebug_profiler_enable_trigger=www_xdebug, + debug_listen=debug_listen, debug_ping_path=debug_ping_path, + debug_pm_status_path=debug_pm_status_path, + debug_pm=debug_pm, + debug_pm_max_requests=debug_pm_max_requests, + debug_pm_max_children=debug_pm_max_children, + debug_pm_start_servers=debug_pm_start_servers, + debug_pm_min_spare_servers=debug_pm_min_spare_servers, + debug_pm_max_spare_servers=debug_pm_max_spare_servers, + debug_request_terminate_timeout=debug_request_terminate, + debug_xdebug_profiler_enable_trigger=debug_xdebug) + self.app.render((data), 'info_php.mustache') + + @expose(hide=True) + def info_mysql(self): + version = os.popen("mysql -V | awk '{print($5)}' | cut -d ',' " + "-f1 | tr -d '\n'").read() + host = "localhost" + port = os.popen("mysql -e \"show variables\" | grep ^port | awk " + "'{print($2)}' | tr -d '\n'").read() + wait_timeout = os.popen("mysql -e \"show variables\" | grep " + "^wait_timeout | awk '{print($2)}' | " + "tr -d '\n'").read() + interactive_timeout = os.popen("mysql -e \"show variables\" | grep " + "^interactive_timeout | awk " + "'{print($2)}' | tr -d '\n'").read() + max_used_connections = os.popen("mysql -e \"show global status\" | " + "grep Max_used_connections | awk " + "'{print($2)}' | tr -d '\n'").read() + datadir = os.popen("mysql -e \"show variables\" | grep datadir | awk" + " '{print($2)}' | tr -d '\n'").read() + socket = os.popen("mysql -e \"show variables\" | grep \"^socket\" | " + "awk '{print($2)}' | tr -d '\n'").read() + data = dict(version=version, host=host, port=port, + wait_timeout=wait_timeout, + interactive_timeout=interactive_timeout, + max_used_connections=max_used_connections, + datadir=datadir, socket=socket) + self.app.render((data), 'info_mysql.mustache') + + @expose(hide=True) + def default(self): + if (not self.app.pargs.nginx and not self.app.pargs.php + and not self.app.pargs.mysql): + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + + if self.app.pargs.nginx: + if EEAptGet.is_installed('nginx-common'): + self.info_nginx() + else: + print("Nginx is not installed") + + if self.app.pargs.php: + if EEAptGet.is_installed('php5-fpm'): + self.info_php() + else: + print("PHP5 is installed") + + if self.app.pargs.mysql: + if EEShellExec.cmd_exec(self, "mysqladmin ping"): + self.info_mysql() + else: + print("MySQL is not installed") + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EEInfoController) + + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', info_plugin_hook) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 1e9f1c5a..51d3ef3f 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -388,6 +388,14 @@ class EEStackController(CementBaseController): Log.debug(self, "writting PHP5 configartion into " " /etc/php5/fpm/pool.d/debug.conf") config.write(confifile) + + with open("/etc/php5/fpm/pool.d/debug.conf", "a") as myfile: + myfile.write("php_admin_value[xdebug.profiler_output_dir] " + "= /tmp/ \nphp_admin_value[xdebug.profiler_" + "output_name] = cachegrind.out.%p-%H-%R " + "\nphp_admin_flag[xdebug.profiler_enable" + "_trigger] = on \nphp_admin_flag[xdebug." + "profiler_enable] = off\n") EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") EEService.reload_service(self, 'php5-fpm') diff --git a/ee/cli/templates/info_mysql.mustache b/ee/cli/templates/info_mysql.mustache new file mode 100644 index 00000000..29a5d81e --- /dev/null +++ b/ee/cli/templates/info_mysql.mustache @@ -0,0 +1,9 @@ + +MySQL ({{version}}) on {{host}}: + +port {{port}} +wait_timeout {{wait_timeout}} +interactive_timeout {{interactive_timeout}} +max_used_connections {{max_used_connections}} +datadir {{datadir}} +socket {{socket}} diff --git a/ee/cli/templates/info_nginx.mustache b/ee/cli/templates/info_nginx.mustache new file mode 100644 index 00000000..6420405b --- /dev/null +++ b/ee/cli/templates/info_nginx.mustache @@ -0,0 +1,10 @@ + +NGINX ({{version}}): + +user {{user}} +worker_processes {{worker_processes}} +worker_connections {{worker_connections}} +keepalive_timeout {{keepalive_timeout}} +fastcgi_read_timeout {{fastcgi_read_timeout}} +client_max_body_size {{client_max_body_size}} +allow {{allow}} diff --git a/ee/cli/templates/info_php.mustache b/ee/cli/templates/info_php.mustache new file mode 100644 index 00000000..1638cf8a --- /dev/null +++ b/ee/cli/templates/info_php.mustache @@ -0,0 +1,35 @@ + +PHP ({{version}}): + +user {{user}} +expose_php {{expose_php}} +memory_limit {{memory_limit}} +post_max_size {{post_max_size}} +upload_max_filesize {{upload_max_filesize}} +max_execution_time {{max_execution_time}} + +Information about www.conf +ping.path {{www_ping_path}} +pm.status_path {{www_pm_status_path}} +process_manager {{www_pm}} +pm.max_requests {{www_pm_max_requests}} +pm.max_children {{www_pm_max_children}} +pm.start_servers {{www_pm_start_servers}} +pm.min_spare_servers {{www_pm_min_spare_servers}} +pm.max_spare_servers {{www_pm_max_spare_servers}} +request_terminate_timeout {{www_request_terminate_timeout}} +xdebug.profiler_enable_trigger {{www_xdebug_profiler_enable_trigger}} +listen {{www_listen}} + +Information about debug.conf +ping.path {{debug_ping_path}} +pm.status_path {{debug_pm_status_path}} +process_manager {{debug_pm}} +pm.max_requests {{debug_pm_max_requests}} +pm.max_children {{debug_pm_max_children}} +pm.start_servers {{debug_pm_start_servers}} +pm.min_spare_servers {{debug_pm_min_spare_servers}} +pm.max_spare_servers {{debug_pm_max_spare_servers}} +request_terminate_timeout {{debug_request_terminate_timeout}} +xdebug.profiler_enable_trigger {{debug_xdebug_profiler_enable_trigger}} +listen {{debug_listen}} From c3c8eccf1e74c60046e1f08386b5d6cce28f3239 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 15 Jan 2015 17:09:59 +0530 Subject: [PATCH 655/829] ee stack purge --mail pkgResolveProblem solved --- ee/cli/plugins/stack.py | 17 +++--- ee/core/aptget.py | 122 ++++++++++++++++------------------------ ee/core/logging.py | 1 + 3 files changed, 60 insertions(+), 80 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 1e9f1c5a..b82d5d25 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -919,7 +919,7 @@ class EEStackController(CementBaseController): self.app.pargs.mysql = True self.app.pargs.postfix = True - if not EEAptGet.is_installed('dovecot-core'): + if not EEAptGet.is_installed(self, 'dovecot-core'): Log.debug(self, "Setting apt_packages variable for mail") apt_packages = apt_packages + EEVariables.ee_mail packages = packages + [["https://github.com/opensolutions/" @@ -938,13 +938,13 @@ class EEStackController(CementBaseController): if self.app.pargs.nginx: Log.debug(self, "Setting apt_packages variable for Nginx") - if not EEAptGet.is_installed('nginx-common'): + if not EEAptGet.is_installed(self, 'nginx-common'): apt_packages = apt_packages + EEVariables.ee_nginx else: Log.info(self, "Nginx allready installed") if self.app.pargs.php: Log.debug(self, "Setting apt_packages variable for PHP") - if not EEAptGet.is_installed('php5-common'): + if not EEAptGet.is_installed(self, 'php5-fpm'): apt_packages = apt_packages + EEVariables.ee_php else: Log.info(self, "PHP allready installed") @@ -956,7 +956,7 @@ class EEStackController(CementBaseController): Log.info(self, "MySQL connection is allready alive") if self.app.pargs.postfix: Log.debug(self, "Setting apt_packages variable for PostFix") - if not EEAptGet.is_installed('postfix'): + if not EEAptGet.is_installed(self, 'postfix'): apt_packages = apt_packages + EEVariables.ee_postfix else: Log.info(self, "Postfix is allready installed") @@ -1022,9 +1022,10 @@ class EEStackController(CementBaseController): if len(apt_packages): EESwap.add(self) Log.debug(self, "Updating apt-cache") - EEAptGet.update() + EEAptGet.update(self) Log.debug(self, "Installing all apt_packages") - EEAptGet.install(apt_packages) + print(apt_packages) + EEAptGet.install(self, apt_packages) if len(packages): Log.debug(self, "Downloading all packages") EEDownload.download(self, packages) @@ -1095,7 +1096,7 @@ class EEStackController(CementBaseController): if len(apt_packages): Log.debug(self, "Removing apt_packages") - EEAptGet.remove(apt_packages) + EEAptGet.remove(self, apt_packages) if len(packages): EEFileUtils.remove(self, packages) Log.info(self, "Successfully removed packages") @@ -1160,7 +1161,7 @@ class EEStackController(CementBaseController): ] if len(apt_packages): - EEAptGet.remove(apt_packages, purge=True) + EEAptGet.remove(self, apt_packages, purge=True) if len(packages): EEFileUtils.remove(self, packages) Log.info(self, "Successfully purged packages") diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 40d03b0c..9a499d4b 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -1,13 +1,16 @@ """EasyEngine package installation using apt-get module.""" import apt +import apt_pkg import sys +from ee.core.logging import Log class EEAptGet(): """Generic apt-get intialisation""" - def update(): + def update(self): """Similar to apt-get update""" + # app.log.debug("Update cache") cache = apt.Cache() fprogress = apt.progress.text.AcquireProgress() @@ -15,7 +18,7 @@ class EEAptGet(): cache.update(fprogress) cache.close() - def upgrade(packages): + def upgrade(self, packages): """Similar to apt-get update""" cache = apt.Cache() fprogress = apt.progress.text.AcquireProgress() @@ -63,7 +66,7 @@ class EEAptGet(): return(False) return(True) - def install(packages): + def install(self, packages): """Installation of packages""" cache = apt.Cache() fprogress = apt.progress.text.AcquireProgress() @@ -97,6 +100,7 @@ class EEAptGet(): with cache.actiongroup(): # Mark Package for Installation pkg.mark_install() + pkg.mark_auto(auto=False) my_selected_packages.append(pkg.name) # Check if packages available for install. @@ -110,7 +114,7 @@ class EEAptGet(): .format(req_download=cache.required_download)) print("After this operation, {space} bytes of" "additional disk space will be used." - .format(space=cache.required_space)) + .format(space=cache.required_space/1e6)) try: # Commit changes in cache (actually install) cache.commit(fprogress, iprogress) @@ -122,7 +126,7 @@ class EEAptGet(): cache.close() return(True) - def remove(packages, auto=True, purge=False): + def remove(self, packages, auto=False, purge=False): def __dependencies_loop(cache, deplist, pkg, onelevel=True): """ Loops through pkg's dependencies. Returns a list with every package found. """ @@ -132,15 +136,18 @@ class EEAptGet(): return for depf in pkg.installed.dependencies: for dep in depf: - if (dep.name in cache and not cache[dep.name] - in deplist): - deplist.append(cache[dep.name]) - __dependencies_loop(cache, deplist, cache[dep.name]) - if onelevel: - if dep.name in cache: + # if (dep.name in cache and not cache[dep.name] + # in deplist): + # deplist.append(cache[dep.name]) + # __dependencies_loop(cache, deplist, cache[dep.name]) + # if onelevel: + if dep.name in cache: + if (cache[dep.name].is_installed and + not cache[dep.name].is_auto_installed and + not cache[dep.name].marked_delete): onelevellist.append(cache[dep.name]) - if onelevel: - return onelevellist + # if onelevel: + return onelevellist cache = apt.Cache() fprogress = apt.progress.text.AcquireProgress() @@ -154,68 +161,37 @@ class EEAptGet(): cache.open() for package in packages: print("processing", package) - package = cache[package] - if not package.is_installed: - print("Package '{package_name}' is not installed," - " so not removed." - .format(package_name=package.name)) + try: + pkg = cache[package] + except KeyError as e: + Log.debug(self, "{0}".format(e)) continue - if package.marked_delete: - my_selected_packages.append(package.name) - # Mark for deletion the first package, to fire up - # auto_removable Purge? - if purge: - package.mark_delete(purge=True) - else: - package.mark_delete(purge=False) + if not pkg.is_installed: + Log.info(self, "Package '{package_name}' is not installed," + " so not removed." + .format(package_name=pkg.name)) continue - else: - my_selected_packages.append(package.name) - print(my_selected_packages) - # How logic works: - # 1) We loop trough dependencies's dependencies and add them to - # the list. - # 2) We sequentially remove every package in list - # - via is_auto_installed we check if we can safely remove it - deplist = [] - onelevel = __dependencies_loop(cache, deplist, package, - onelevel=True) - # Mark for deletion the first package, to fire up - # auto_removable Purge? + my_selected_packages.append(pkg.name) + print(my_selected_packages) + # How logic works: + # 1) We loop trough dependencies's dependencies and add them to + # the list. + # 2) We sequentially remove every package in list + # - via is_auto_installed we check if we can safely remove it + deplist = [] + onelevel = __dependencies_loop(cache, deplist, pkg, + onelevel=True) + # Mark for deletion the first package, to fire up + # auto_removable Purge? + packages = packages + onelevel + try: if purge: - package.mark_delete(purge=True) - else: - package.mark_delete(purge=False) - - # Also ensure we remove AT LEAST the first level of - # dependencies (that is, the actual package's dependencies). - if auto: - markedauto = [] - for pkg in onelevel: - if (not pkg.marked_install and pkg.is_installed - and not pkg.is_auto_installed): - pkg.mark_auto() - markedauto.append(pkg) - - for pkg in deplist: - if (not pkg.marked_install and pkg.is_installed and - pkg.is_auto_removable): - # Purge? - if purge: - pkg.mark_delete(purge=True) - else: - pkg.mark_delete(purge=False) - # Restore auted items - for pkg in markedauto: - if not pkg.marked_delete: - pkg.mark_auto(False) + pkg.mark_delete(purge=True) else: - # We need to ensure that the onelevel packages are not - # marked as automatically installed, otherwise the user may - # drop them via autoremove or aptitude. - for pkg in onelevel: - if pkg.is_installed and pkg.is_auto_installed: - pkg.mark_auto(auto=False) + pkg.mark_delete(purge=False) + except SystemError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to purge packages.") # Check if packages available for remove/update. if cache.delete_count > 0: @@ -239,7 +215,7 @@ class EEAptGet(): cache.close() return(True) - def is_installed(package): + def is_installed(self, package): cache = apt.Cache() fprogress = apt.progress.text.AcquireProgress() iprogress = apt.progress.base.InstallProgress() @@ -258,6 +234,8 @@ class EEAptGet(): else: cache.close() return False + except KeyError as e: + Log.debug(self, "{0}".format(e)) except Exception as e: cache.close() return False diff --git a/ee/core/logging.py b/ee/core/logging.py index 86c72278..8e44ca3f 100644 --- a/ee/core/logging.py +++ b/ee/core/logging.py @@ -12,6 +12,7 @@ class Log: def error(self, msg): self.app.log.error(Log.FAIL + msg + Log.ENDC) + self.app.close(1) def info(self, msg): self.app.log.info(Log.OKBLUE + msg + Log.ENDC) From c8aaa8b91eeb97b478b1c03671c9ed1020cd2839 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 15 Jan 2015 19:51:01 +0530 Subject: [PATCH 656/829] minor change --- ee/core/aptget.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 9a499d4b..cfa7509c 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -100,7 +100,6 @@ class EEAptGet(): with cache.actiongroup(): # Mark Package for Installation pkg.mark_install() - pkg.mark_auto(auto=False) my_selected_packages.append(pkg.name) # Check if packages available for install. @@ -143,8 +142,7 @@ class EEAptGet(): # if onelevel: if dep.name in cache: if (cache[dep.name].is_installed and - not cache[dep.name].is_auto_installed and - not cache[dep.name].marked_delete): + cache[dep.name].is_auto_installed): onelevellist.append(cache[dep.name]) # if onelevel: return onelevellist @@ -183,7 +181,18 @@ class EEAptGet(): onelevel=True) # Mark for deletion the first package, to fire up # auto_removable Purge? - packages = packages + onelevel + + for dep in onelevel: + my_selected_packages.append(dep.name) + try: + if purge: + dep.mark_delete(purge=True) + else: + dep.mark_delete(purge=False) + except SystemError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to purge depedencies.") + try: if purge: pkg.mark_delete(purge=True) From b5f04c1912ad8d93f96487875fd5894073ac7eaa Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 16 Jan 2015 11:58:36 +0530 Subject: [PATCH 657/829] Disabled Cement debug messages, source: https://github.com/datafolklabs/cement/issues/290#issuecomment-70128449 --- ee/cli/main.py | 11 +++++++++++ setup.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ee/cli/main.py b/ee/cli/main.py index 17c8281f..fd2c5285 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -1,4 +1,13 @@ """EasyEngine main application entry point.""" +import sys + +# this has to happen after you import sys, but before you import anything +# from Cement "source: https://github.com/datafolklabs/cement/issues/290" +if '--debug' in sys.argv: + sys.argv.remove('--debug') + TOGGLE_DEBUG = True +else: + TOGGLE_DEBUG = False from cement.core import foundation from cement.utils.misc import init_defaults @@ -42,6 +51,8 @@ class EEApp(foundation.CementApp): # default output handler output_handler = 'mustache' + debug = TOGGLE_DEBUG + class EETestApp(EEApp): """A test app that is better suited for testing.""" diff --git a/setup.py b/setup.py index 3064be7d..d98e9f4d 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ setup(name='ee', # "nose", # "coverage", # Required to function - 'cement>=2.4', + 'cement == 2.4', 'pystache', 'python-apt', 'pynginxconfig', From 5748abc5decafd90429ebc38013f8614c96f3e48 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 16 Jan 2015 12:54:45 +0530 Subject: [PATCH 658/829] added sqlite db model --- ee/cli/plugins/site.py | 326 ++++++++++++++++++------------- ee/cli/plugins/site_functions.py | 30 ++- ee/cli/plugins/sitedb.py | 124 +++++------- ee/cli/plugins/stack.py | 2 +- ee/core/database.py | 19 ++ ee/core/models.py | 40 ++++ ee/core/services.py | 2 +- ee/core/variables.py | 2 +- 8 files changed, 325 insertions(+), 220 deletions(-) create mode 100644 ee/core/database.py create mode 100644 ee/core/models.py diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index b0b69962..21505028 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -17,7 +17,8 @@ from subprocess import Popen def ee_site_hook(app): # do something with the ``app`` object here. - pass + from ee.core.database import init_db + init_db() class EESiteController(CementBaseController): @@ -48,8 +49,7 @@ class EESiteController(CementBaseController): '/etc/nginx/sites-enabled/{0}.conf' .format(ee_domain_name)]) else: - Log.error(self, "site {0} does not exists".format(ee_domain)) - sys.exit(1) + Log.error(self, "!! site {0} does not exists".format(ee_domain)) @expose(help="disable site example.com") def disable(self): @@ -62,8 +62,7 @@ class EESiteController(CementBaseController): '/etc/nginx/sites-enabled/{0}.conf' .format(ee_domain_name)]) else: - Log.error(self, "site {0} does not exists".format(ee_domain)) - sys.exit(1) + Log.error(self, "!! site {0} does not exists".format(ee_domain)) @expose(help="get example.com information") def info(self): @@ -95,8 +94,7 @@ class EESiteController(CementBaseController): dbpass=ee_db_pass) self.app.render((data), 'siteinfo.mustache') else: - Log.error(self, "site {0} does not exists".format(ee_domain)) - sys.exit(1) + Log.error(self, "!! site {0} does not exists".format(ee_domain)) @expose(help="Monitor example.com logs") def log(self): @@ -106,8 +104,7 @@ class EESiteController(CementBaseController): EEShellExec.cmd_exec(self, 'tail -f /var/log/nginx/{0}.*.log' .format(ee_domain)) else: - Log.error(self, "site {0} does not exists".format(ee_domain)) - sys.exit(1) + Log.error(self, "!! site {0} does not exists".format(ee_domain)) @expose(help="Edit example.com's nginx configuration") def edit(self): @@ -123,8 +120,7 @@ class EESiteController(CementBaseController): # Reload NGINX EEService.reload_service(self, 'nginx') else: - Log.error(self, "site {0} does not exists".format(ee_domain)) - sys.exit(1) + Log.error(self, "!! site {0} does not exists".format(ee_domain)) @expose(help="Display example.com's nginx configuration") def show(self): @@ -139,8 +135,7 @@ class EESiteController(CementBaseController): print(text) f.close() else: - Log.error(self, "site {0} does not exists".format(ee_domain)) - sys.exit(1) + Log.error(self, "!! site {0} does not exists".format(ee_domain)) @expose(help="list sites currently available") def list(self): @@ -158,9 +153,8 @@ class EESiteController(CementBaseController): try: subprocess.call(['bash']) except OSError as e: - Log.error(self, "Unable to edit file \ {0}{1}" - .format(e.errno, e.strerror)) - sys.exit(1) + Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) + Log.error(self, "!! cannot change directory") class EESiteCreateController(CementBaseController): @@ -205,9 +199,8 @@ class EESiteCreateController(CementBaseController): # Check if doain previously exists or not if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): - self.app.log.error(self, "site {0} already exists" - .format(ee_domain)) - sys.exit(1) + Log.error(self, "!! site {0} already exists" + .format(ee_domain)) # setup nginx configuration for site # HTML @@ -425,12 +418,12 @@ class EESiteCreateController(CementBaseController): data['ee_db_pass'], data['ee_db_host'])) eedbconfig.close() - stype = mysql + stype = 'mysql' except IOError as e: - self.app.log.error("Unable to create ee-config.php for " - "{2} ({0}): {1}" - .format(e.errno, e.strerror, ee_domain)) - sys.exit(1) + Log.debug(self, "{2} ({0}): {1}" + .format(e.errno, e.strerror, ee_domain)) + Log.error(self, "!! Unable to create ee-config.php for ") + # Setup WordPress if Wordpress site if data['wp']: ee_wp_creds = SetupWordpress(self, data) @@ -492,11 +485,13 @@ class EESiteUpdateController(CementBaseController): check_site = getSiteInfo(self, ee_domain) if check_site is None: - Log.error(self, "Site {0} does not exist.".format(ee_domain)) + Log.error(self, "!! Site {0} does not exist.".format(ee_domain)) else: oldsitetype = check_site.site_type oldcachetype = check_site.cache_type + print(oldsitetype, oldcachetype) + if (self.app.pargs.html and not (self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or @@ -510,14 +505,17 @@ class EESiteUpdateController(CementBaseController): self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): if oldsitetype != 'html': - Log.error("Cannot update {0} to php".format(ee_domain)) - sys.exit(1) + + Log.error(self, "!! Cannot update {0} {1} to php" + .format(ee_domain, oldsitetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, webroot=ee_site_webroot, currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'php' + cache = 'basic' #MySQL if (self.app.pargs.mysql and not (self.app.pargs.html or @@ -525,9 +523,9 @@ class EESiteUpdateController(CementBaseController): or self.app.pargs.wpfc or self.app.pargs.wpsc or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): - if oldsitetype != 'html' or oldsitetype != 'php': - Log.error("Cannot update {0} to mysql".format(ee_domain)) - sys.exit(1) + if oldsitetype not in ['html', 'php']: + Log.error(self, "!! Cannot update {0}, {1} to mysql" + .format(ee_domain, oldsitetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=False, w3tc=False, @@ -536,6 +534,8 @@ class EESiteUpdateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'mysql' + cache = 'basic' #WP if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or @@ -545,11 +545,11 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wp and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype not in ['html', 'php', 'wp'] - and oldsitetype not in ['w3tc', 'wpfc', 'wpsc']): - Log.error("Cannot update {0} to wp basic" - .format(ee_domain)) - sys.exit(1) + if ((oldsitetype in ['html', 'php', 'mysql', 'wp']) + and (oldcachetype not in ['w3tc', 'wpfc', 'wpsc'])): + print(oldsitetype, oldcachetype) + Log.error(self, "!! Cannot update {0}, {1} {2} to wp basic" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=True, w3tc=False, @@ -558,14 +558,16 @@ class EESiteUpdateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wp' + cache = 'basic' if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype not in ['html', 'php', 'wp'] - and oldsitetype not in ['basic', 'wpfc', 'wpsc']): - Log.error("Cannot update {0} to wp w3tc".format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp'] + and oldcachetype not in ['basic', 'wpfc', 'wpsc']): + Log.error(self, "!! Cannot update {0}, {1} {2}to wp w3tc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=True, @@ -575,13 +577,16 @@ class EESiteUpdateController(CementBaseController): ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wp' + cache = 'w3tc' + if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - if (oldsitetype not in ['html', 'php', 'wp'] - and oldsitetype not in ['basic', 'w3tc', 'wpsc']): - Log.error("Cannot update {0} to wp wpfc".format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp'] + and oldcachetype not in ['basic', 'w3tc', 'wpsc']): + Log.error(self, "Cannot update {0}, {1} {2} to wp wpfc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, @@ -590,14 +595,16 @@ class EESiteUpdateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wp' + cache = 'wpfc' if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - if (oldsitetype not in ['html', 'php', 'wp'] - and oldsitetype not in ['basic', 'w3tc', 'wpfc']): - Log.error("Cannot update {0} to wp wpsc".format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp'] + and oldcachetype not in ['basic', 'w3tc', 'wpfc']): + Log.error(self, "Cannot update {0}, {1} {2} to wp wpsc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, @@ -606,6 +613,8 @@ class EESiteUpdateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wp' + cache = 'wpsc' #WPSUBDIR if (self.app.pargs.wpsubdir and not (self.app.pargs.html or @@ -614,11 +623,11 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdir'] - and oldsitetype not in ['w3tc', 'wpfc', 'wpsc']): - Log.error("Cannot update {0} to wpsubdir basic" - .format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] + and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']): + Log.error(self, "!! Cannot update {0}, {1} {2} " + "to wpsubdir basic" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=True, w3tc=False, @@ -627,15 +636,17 @@ class EESiteUpdateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wpsubdir' + cache = 'basic' if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdir'] - and oldsitetype not in ['basic', 'wpfc', 'wpsc']): - Log.error("Cannot update {0} to wpsubdir w3tc" - .format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] + and oldcachetype not in ['basic', 'wpfc', 'wpsc']): + Log.error(self, "!! Cannot update {0} {1} {2}" + "to wpsubdir w3tc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=True, @@ -645,14 +656,17 @@ class EESiteUpdateController(CementBaseController): ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wpsubdir' + cache = 'w3tc' + if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdir'] - and oldsitetype not in ['basic', 'w3tc', 'wpsc']): - Log.error("Cannot update {0} to wpsubdir wpfc" - .format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] + and oldcachetype not in ['basic', 'w3tc', 'wpsc']): + Log.error(self, "!! Cannot update {0} {1} {2}" + " to wpsubdir wpfc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, @@ -661,15 +675,17 @@ class EESiteUpdateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wpsubdir' + cache = 'wpfc' if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdir'] - and oldsitetype not in ['basic', 'w3tc', 'wpfc']): - Log.error("Cannot update {0} to wpsubdir wpsc" - .format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] + and oldcachetype not in ['basic', 'w3tc', 'wpfc']): + Log.error(self, "!! Cannot update {0} {1} {2}" + " to wpsubdir wpsc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, @@ -678,16 +694,18 @@ class EESiteUpdateController(CementBaseController): ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wpsubdir' + cache = 'wpsc' if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdir or self.app.pargs.wp)): - if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdomain'] - and oldsitetype not in ['w3tc', 'wpfc', 'wpsc']): - Log.error("Cannot update {0} to wpsubdomain basic" - .format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] + and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']): + Log.error(self, "!! Cannot update {0} {1} {2}" + " to wpsubdomain basic" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=True, w3tc=False, @@ -697,14 +715,18 @@ class EESiteUpdateController(CementBaseController): ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wpsubdomain' + cache = 'basic' + if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdomain'] - and oldsitetype not in ['basic', 'wpfc', 'wpsc']): - Log.error("Cannot update {0} to wpsubdomain w3tc" - .format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp', + 'wpsubdomain'] + and oldcachetype not in ['basic', 'wpfc', 'wpsc']): + Log.error(self, "!! Cannot update {0}, {1} {2}" + " to wpsubdomain w3tc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=True, @@ -714,14 +736,18 @@ class EESiteUpdateController(CementBaseController): ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wpsubdomain' + cache = 'w3tc' + if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdomain'] - and oldsitetype not in ['basic', 'w3tc', 'wpsc']): - Log.error("Cannot update {0} to wpsubdomain wpfc" - .format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp', + 'wpsubdomain'] + and oldcachetype not in ['basic', 'w3tc', 'wpsc']): + Log.error(self, "!! Cannot update {0}, {1} {2} " + "to wpsubdomain wpfc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, @@ -731,14 +757,18 @@ class EESiteUpdateController(CementBaseController): ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) + stype = 'wpsubdomain' + cache = 'wpfc' + if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - if (oldsitetype not in ['html', 'php', 'wp', 'wpsubdomain'] - and oldsitetype not in ['basic', 'w3tc', 'wpfc']): - Log.error("Cannot update {0} to wpsubdomain wpsc" - .format(ee_domain)) - sys.exit(1) + if (oldsitetype in ['html', 'php', 'mysql', 'wp', + 'wpsubdomain'] + and oldcachetype not in ['basic', 'w3tc', 'wpfc']): + Log.error(self, "!! Cannot update {0}, {1} {2}" + " to wpsubdomain wpsc" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=False, wp=True, w3tc=False, @@ -748,7 +778,12 @@ class EESiteUpdateController(CementBaseController): ee_db_host='', currsitetype=oldsitetype, currcachetype=oldcachetype) - # TODO take site backup before site update + stype = 'wpsubdomain' + cache = 'wpsc' + + if not data: + Log.error(self, "!! Cannot update" + .format(ee_domain)) siteBackup(self, data) # TODO Check for required packages before update @@ -769,12 +804,11 @@ class EESiteUpdateController(CementBaseController): data['ee_db_pass'], data['ee_db_host'])) eedbconfig.close() - stype = mysql except IOError as e: - self.app.log.error("Unable to create ee-config.php for " - "{2} ({0}): {1}" - .format(e.errno, e.strerror, ee_domain)) - sys.exit(1) + Log.error(self, "!! Unable to create ee-config.php for " + "{0}" + .format(ee_domain)) + Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) if oldsitetype == 'mysql': config_file = (ee_site_webroot + '/backup/{0}/ee-config.php' @@ -795,24 +829,41 @@ class EESiteUpdateController(CementBaseController): .split(',')[1] .split(')')[0].strip()) - # Setup WordPress if Wordpress site - if data['wp']: + # Setup WordPress if old sites are html/php/mysql sites + if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: ee_wp_creds = SetupWordpress(self, data) + + # Uninstall unnecessary plugins + if oldsitetype in ['wp', 'wpsubdir', 'wpsubdomain']: + # Setup WordPress Network if update option is multisite + # and oldsite is WordPress single site + if data['multisite'] and oldsitetype == 'wp': + SetupWordpressNetwork(self, data) + + if (oldcachetype == 'w3tc' or oldcachetype == 'wpfc' and + not data['w3tc', 'wpfc']): + UnInstallWP_Plugin(self, 'w3-total-cache', data) + + if oldcachetype == 'wpsc' and not data['wpsc']: + UnInstallWP_Plugin(self, 'wp-super-cache', data) + + if oldcachetype != 'w3tc' or oldcachetype != 'wpfc'and data['w3tc']: + InstallWP_Plugin(self, 'w3-total-cache', data) + + if oldcachetype != 'wpsc' and data['wpsc']: + InstallWP_Plugin(self, 'wp-super-cache', data) + # Service Nginx Reload EEService.reload_service(self, 'nginx') EEGit.add(self, ["/etc/nginx"], - msg="{0} created with {1} {2}" + msg="{0} updated with {1} {2}" .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot - SetWebrootPermissions(self, data['webroot']) - if data['wp']: - Log.info(self, '\033[94m'+"WordPress Admin User :" - " {0}".format(ee_wp_creds['wp_user'])+'\033[0m') - Log.info(self, "WordPress Admin User Password : {0}" - .format(ee_wp_creds['wp_pass'])) - addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot) - Log.info(self, "Successfully created site" + #SetWebrootPermissions(self, data['webroot']) + + updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) + Log.info(self, "Successfully updated site" " http://{0}".format(ee_domain)) @@ -836,7 +887,7 @@ class EESiteDeleteController(CementBaseController): dict(help="delete webroot only", action='store_true')), ] - @expose(help="update example.com") + @expose(help="delete example.com") def default(self): # TODO Write code for ee site update here (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -851,43 +902,48 @@ class EESiteDeleteController(CementBaseController): if self.app.pargs.db: if not ee_prompt: - ee_db_prompt = input('Do you want to delete database:[Y/N]' - ) + ee_db_prompt = input('Do you want to delete database:' + '[Y/N] ') else: ee_db_prompt = 'Y' if ee_db_prompt == 'Y': - deleteDB(ee_site_webroot) + self.deleteDB(ee_site_webroot) if self.app.pargs.files: if not ee_prompt: - ee_web_prompt = input('Do you want to delete webroot:[Y/N]' - ) + ee_web_prompt = input('Do you want to delete webroot:' + '[Y/N] ') else: ee_web_prompt = 'Y' if ee_web_prompt == 'Y': - deleteWebRoot(ee_site_webroot) + self.deleteWebRoot(ee_site_webroot) if self.app.pargs.all: if not ee_prompt: - ee_db_prompt = input('Do you want to delete database:[Y/N]' + ee_db_prompt = input('Do you want to delete database:' + '[Y/N] ' ) - ee_web_prompt = input('Do you want to delete webroot:[Y/N]' - ) + ee_web_prompt = input('Do you want to delete webroot:' + '[Y/N] ') ee_nginx_prompt = input('Do you want to delete NGINX' - ' configuration:[Y/N]') + ' configuration:[Y/N] ') else: ee_db_prompt = 'Y' ee_web_prompt = 'Y' ee_nginx_prompt = 'Y' - if ee_db_prompt: - deleteDB(self, ee_site_webroot) - if ee_web_prompt: - deleteWebRoot(ee_site_webroot) - if ee_nginx_prompt: - EEFileutils.delete(self, '/etc/nginx/sites-available/{0}' - .format(ee_domain)) + if ee_db_prompt == 'Y': + self.deleteDB(ee_site_webroot) + if ee_web_prompt == 'Y': + self.deleteWebRoot(ee_site_webroot) + if ee_nginx_prompt == 'Y': + EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}' + .format(ee_domain)) + deleteSiteInfo(self, ee_domain) + else: + Log.error(self, "!! site {0} does not exists".format(ee_domain)) + @expose(hide=True) def deleteDB(self, webroot): configfiles = glob.glob(webroot + '/*-config.php') if configfiles: @@ -904,19 +960,23 @@ class EESiteDeleteController(CementBaseController): ee_db_host = (EEFileUtils.grep(self, configfiles[0], 'DB_HOST').split(',')[1] .split(')')[0].strip().replace('\'', '')) - - EEMysql.execute(self, - "drop database {0}" - .format(ee_db_name)) - if ee_db_user != 'root': - EEMysql.execute(self, - "drop user {0}@{1}" - .format(ee_db_user, ee_db_host)) + try: EEMysql.execute(self, - "flush privileges") + "drop database {0}".format(ee_db_name), + errormsg='Unable to drop database {0}' + .format(ee_db_name)) + if ee_db_user != 'root': + EEMysql.execute(self, + "drop user {0}@{1}" + .format(ee_db_user, ee_db_host)) + EEMysql.execute(self, + "flush privileges") + except Exception as e: + Log.error(self, "!! Error occured while deleting database") - def deleteWebRoot(webroot): - EEFileutils.delete(self, webroot) + @expose(hide=True) + def deleteWebRoot(self, webroot): + EEFileUtils.rm(self, webroot) def load(app): diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index ef18ae4c..1a5c9ccc 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -15,7 +15,7 @@ def SetupDomain(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] - self.app.log.info("Creating {0} ...".format(ee_domain_name)) + self.app.log.info("Setting up NGINX config {0} ...".format(ee_domain_name)) # write nginx config for file try: ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}' @@ -138,9 +138,10 @@ def SetupWordpress(self, data): ee_wp_user = '' ee_wp_pass = '' - self.app.log.info("Downloading Wordpress...") + Log.info(self, "Downloading Wordpress...", end='') EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") + Log.info("[Done]") if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']): data = SetupDatabase(self, data) @@ -248,8 +249,9 @@ 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") EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert' - '--title={0} {subdomains}' + ' --title={0} {subdomains}' .format(data['www_domain'], subdomains='--subdomains' if not data['wpsubdir'] else '')) @@ -271,6 +273,16 @@ def InstallWP_Plugin(self, plugin_name, data): .format(plugin_name)) +def UnInstallWP_Plugin(self, plugin_name, data): + ee_site_webroot = data['webroot'] + self.app.log.debug("Uninstalling plugin {0}".format(plugin_name)) + EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) + EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root uninstall " + "{0}".format(plugin_name), + errormsg="Unable to Install plugin {0}" + .format(plugin_name)) + + def SetWebrootPermissions(self, webroot): self.app.log.debug("Setting Up Permissions...") EEFileUtils.chown(self, webroot, EEVariables.ee_php_user, @@ -284,20 +296,24 @@ def siteBackup(self, data): EEFileUtils.mkdir(self, backup_path) Log.info(self, "Backup Location : {0}".format(backup_path)) EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}' - .format(data['ee_domain']), backup_path) + .format(data['site_name']), backup_path) if data['currsitetype'] in ['html', 'php', 'mysql']: Log.info(self, "Backup Webroot ...") EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path) - configfiles = glob(ee_site_webroot + '/*-config.php') + configfiles = glob.glob(ee_site_webroot + '/*-config.php') if EEFileUtils.isexist(self, configfiles[0]): - ee_db_name = (EEFileUtils.grep(self, file, 'DB_NAME').split(',')[1] + ee_db_name = (EEFileUtils.grep(self, configfiles[0], + 'DB_NAME').split(',')[1] .split(')')[0].strip().replace('\'', '')) Log.info(self, 'Backup Database, please wait') EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" .format(ee_db_name, backup_path), "Failed: Backup Database") # move wp-config.php/ee-config.php to backup - EEFileUtils.mvfile(self, file, backup_path) + if data['currsitetype'] in ['mysql']: + EEFileUtils.mvfile(self, configfiles[0], backup_path) + else: + EEFileUtils.copyfile(self, configfiles[0], backup_path) diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index 165c49c3..c8f2acd6 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -4,96 +4,66 @@ from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import declarative_base from ee.core.logging import Log import sys +from ee.core.database import db_session +from ee.core.models import SiteDB -Base = declarative_base() +def addNewSite(self, site, stype, cache, path, + enabled=True, ssl=False, fs='ext4', db='mysql'): + try: + newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db) + db_session.add(newRec) + db_session.commit() + except Exception as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to add site to database") -class SiteDB(Base): - __tablename__ = 'Site' - id = Column(Integer, primary_key=True) - sitename = Column(String, unique=True) - site_type = Column(String) - cache_type = Column(String) - site_path = Column(String) +def getSiteInfo(self, site): + try: + q = SiteDB.query.filter(SiteDB.sitename == site).first() + return q + except Exception as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to query database for site info") - # Use default=func.now() to set the default created time - # of a site to be the current time when a - # Site record was created - created_on = Column(DateTime, default=func.now()) - site_enabled = Column(Boolean, unique=False, default=True, nullable=False) - is_ssl = Column(Boolean, unique=False, default=False) - storage_fs = Column(String) - storage_db = Column(String) +def updateSiteInfo(self, site, stype='', cache='', + enabled=True, ssl=False, fs='', db=''): + try: + q = SiteDB.query.filter(SiteDB.sitename == site).first() + except Exception as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to query database for site info") + if stype and q.site_type != stype: + q.site_type = stype - def __init__(self): - # from sqlalchemy import create_engine - # self.engine = create_engine('sqlite:///orm_in_detail.sqlite') - self.sitename = sitename - self.site_type = site_type - self.cache_type = cache_type - self.site_path = site_path - self.created_on = created_on - self.site_enabled = site_enabled - self.is_ssl = is_ssl - self.storage_fs = storage_fs - self.storage_db = storage_db + if cache and q.cache_type != cache: + q.cache_type = cache -# if __name__ == "__main__": -# -# from sqlalchemy import create_engine -# engine = create_engine('sqlite:///orm_in_detail.sqlite') -# from sqlalchemy.orm import sessionmaker -# session = sessionmaker() -# session.configure(bind=engine) -# Base.metadata.create_all(engine) -# s = session() -# newRec = SiteDB(sitename='exa.in', site_type='wp', cache_type='basic', - # site_path='/var/www', site_enabled=True, is_ssl=False, storage_fs='ext4', - # storage_db='mysql') -# s.add(newRec) -# s.commit() -# s.flush() + if enabled and q.is_enabled != enabled: + q.is_enabled = enabled + if ssl and q.is_ssl != ssl: + q.is_ssl = ssl -def addNewSite(self, site, stype, cache, path, - enabled=True, ssl=False, fs='ext4', db='mysql'): - db_path = self.app.config.get('site', 'db_path') try: - from sqlalchemy import create_engine - engine = create_engine(db_path) - from sqlalchemy.orm import sessionmaker - session = sessionmaker() - session.configure(bind=engine) - Base.metadata.create_all(engine) - s = session() - newRec = SiteDB(sitename=site, site_type=stype, cache_type=cache, - site_path=path, site_enabled=enabled, is_ssl=ssl, - storage_fs=fs, storage_db=db) - s.add(newRec) - s.commit() - s.flush() + q.created_on = func.now() + db_session.commit() except Exception as e: - Log.error(self, "Unable to add site to database : {0}" - .format(e)) - sys.exit(1) + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to update site info in application database.") -def getSiteInfo(self, site): - db_path = self.app.config.get('site', 'db_path') +def deleteSiteInfo(self, site): try: - from sqlalchemy import create_engine - engine = create_engine(db_path) - from sqlalchemy.orm import sessionmaker - session = sessionmaker() - session.configure(bind=engine) - Base.metadata.create_all(engine) - s = session() - q = s.query(SiteDB).filter_by(sitename=site).first() - s.flush() - return q + q = SiteDB.query.filter(SiteDB.sitename == site).first() + except Exception as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to query database :") + try: + db_session.delete(q) + db_session.commit() except Exception as e: - Log.error(self, "Unable to add site to database : {0}" - .format(e)) - sys.exit(1) + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to delete site from application database.") diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index a8595c5d..ee1f3657 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -1042,7 +1042,7 @@ class EEStackController(CementBaseController): if len(self.msg): for msg in self.msg: Log.info(self, msg) - Log.info(self, "Successfully installed packages") + Log.info(self, "Successfully installed packages") @expose() def remove(self): diff --git a/ee/core/database.py b/ee/core/database.py new file mode 100644 index 00000000..1cac3452 --- /dev/null +++ b/ee/core/database.py @@ -0,0 +1,19 @@ +from sqlalchemy import create_engine +from sqlalchemy.orm import scoped_session, sessionmaker +from sqlalchemy.ext.declarative import declarative_base + +#db_path = self.app.config.get('site', 'db_path') +engine = create_engine('sqlite:////var/lib/ee/ee.sqlite', convert_unicode=True) +db_session = scoped_session(sessionmaker(autocommit=False, + autoflush=False, + bind=engine)) +Base = declarative_base() +Base.query = db_session.query_property() + + +def init_db(): + # import all modules here that might define models so that + # they will be registered properly on the metadata. Otherwise + # you will have to import them first before calling init_db() + import ee.core.models + Base.metadata.create_all(bind=engine) diff --git a/ee/core/models.py b/ee/core/models.py new file mode 100644 index 00000000..bd62fc43 --- /dev/null +++ b/ee/core/models.py @@ -0,0 +1,40 @@ +from sqlalchemy import Column, DateTime, String, Integer, Boolean, func +from ee.core.database import Base + + +class SiteDB(Base): + __tablename__ = 'sites' + id = Column(Integer, primary_key=True) + sitename = Column(String, unique=True) + + site_type = Column(String) + cache_type = Column(String) + site_path = Column(String) + + # Use default=func.now() to set the default created time + # of a site to be the current time when a + # Site record was created + + created_on = Column(DateTime, default=func.now()) + is_enabled = Column(Boolean, unique=False, default=True, nullable=False) + is_ssl = Column(Boolean, unique=False, default=False) + storage_fs = Column(String) + storage_db = Column(String) + + def __init__(self, sitename=None, site_type=None, cache_type=None, + site_path=None, site_enabled=None, + is_ssl=None, storage_fs=None, storage_db=None): + self.sitename = sitename + self.site_type = site_type + self.cache_type = cache_type + self.site_path = site_path + self.is_enabled = site_enabled + self.is_ssl = is_ssl + self.storage_fs = storage_fs + self.storage_db = storage_db + + # def __repr__(self): + # return '' % (self.site_type) + # + # def getType(self): + # return '%r>' % (self.site_type) diff --git a/ee/core/services.py b/ee/core/services.py index 961710c3..556c8231 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -67,7 +67,7 @@ class EEService(): .format(service_name, "[OK]")) return True else: - Log.debug("{0}".format(retcode[1])) + Log.debug(self, "{0}".format(retcode[1])) Log.error(self, "reload : {0}".format(service_name)) return False diff --git a/ee/core/variables.py b/ee/core/variables.py index 36797587..9077de93 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -77,7 +77,7 @@ class EEVariables(): ee_mail = ["dovecot-core", "dovecot-imapd", "dovecot-pop3d", "dovecot-lmtpd", "dovecot-mysql", "dovecot-sieve", "dovecot-managesieved", "postfix-mysql", "php5-cgi", - "php5-json", "php-gettext"] + "php-gettext"] # Mailscanner repo and packages ee_mailscanner_repo = () From 303db4635dd93de062eed47c695569e5fbb0d792 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 16 Jan 2015 12:55:55 +0530 Subject: [PATCH 659/829] Now log messages goes to log file and screen will display only messages --- config/ee.conf | 2 +- ee/core/logging.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/ee.conf b/config/ee.conf index d3d8aafb..ce68b3e5 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -27,7 +27,7 @@ file = /var/log/ee/ee.log level = debug ### Whether or not to log to console -to_console = true +to_console = false ### Whether or not to rotate the log file when it reaches `max_bytes` rotate = true diff --git a/ee/core/logging.py b/ee/core/logging.py index 8e44ca3f..5feb15e1 100644 --- a/ee/core/logging.py +++ b/ee/core/logging.py @@ -14,7 +14,8 @@ class Log: self.app.log.error(Log.FAIL + msg + Log.ENDC) self.app.close(1) - def info(self, msg): + def info(self, msg, end='\n'): + print(Log.OKBLUE + msg + Log.ENDC, end=end) self.app.log.info(Log.OKBLUE + msg + Log.ENDC) def warn(self, msg): From 5ef5392a33af8a067907381328c0d0476cde72fa Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 16 Jan 2015 13:14:40 +0530 Subject: [PATCH 660/829] Fixed minor bugs --- config/ee.conf | 2 +- ee/cli/plugins/site_functions.py | 2 +- ee/core/logging.py | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/ee.conf b/config/ee.conf index ce68b3e5..d3d8aafb 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -27,7 +27,7 @@ file = /var/log/ee/ee.log level = debug ### Whether or not to log to console -to_console = false +to_console = true ### Whether or not to rotate the log file when it reaches `max_bytes` rotate = true diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 1a5c9ccc..bde91af8 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -141,7 +141,7 @@ def SetupWordpress(self, data): Log.info(self, "Downloading Wordpress...", end='') EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") - Log.info("[Done]") + Log.info(self, "[Done]") if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']): data = SetupDatabase(self, data) diff --git a/ee/core/logging.py b/ee/core/logging.py index 5feb15e1..56847a38 100644 --- a/ee/core/logging.py +++ b/ee/core/logging.py @@ -11,6 +11,7 @@ class Log: UNDERLINE = '\033[4m' def error(self, msg): + print(Log.FAIL + msg + Log.ENDC) self.app.log.error(Log.FAIL + msg + Log.ENDC) self.app.close(1) From b5005967a724923e128e54fcca8452b8bae05e66 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 16 Jan 2015 16:07:37 +0530 Subject: [PATCH 661/829] Added package insttallation during site creation, finally :) --- ee/cli/plugins/site.py | 23 +-- ee/cli/plugins/site_functions.py | 41 ++++- ee/cli/plugins/stack.py | 288 ++++++++++++++++--------------- 3 files changed, 202 insertions(+), 150 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 21505028..784bb5f0 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -216,7 +216,7 @@ class EESiteCreateController(CementBaseController): stype = 'html' cache = 'basic' - #PHP + # PHP if (self.app.pargs.php and not (self.app.pargs.html or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or @@ -228,7 +228,7 @@ class EESiteCreateController(CementBaseController): wpsubdir=False, webroot=ee_site_webroot) stype = 'php' cache = 'basic' - #MySQL + # MySQL if (self.app.pargs.mysql and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or @@ -242,7 +242,7 @@ class EESiteCreateController(CementBaseController): ee_db_host='') stype = 'mysql' cache = 'basic' - #WP + # WP if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc) and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or @@ -296,7 +296,7 @@ class EESiteCreateController(CementBaseController): stype = 'wp' cache = 'wpsc' - #WPSUBDIR + # WPSUBDIR if (self.app.pargs.wpsubdir and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdomain or self.app.pargs.wp)): @@ -348,7 +348,7 @@ class EESiteCreateController(CementBaseController): stype = 'wpsubdir' cache = 'wpsc' - #WPSUBDOAIN + # WPSUBDOAIN if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdir or self.app.pargs.wp)): @@ -401,6 +401,9 @@ class EESiteCreateController(CementBaseController): stype = 'wpsubdomain' cache = 'wpsc' + # Check rerequired packages are installed or not + site_package_check(self, stype) + # setup NGINX configuration, and webroot SetupDomain(self, data) # Setup database for MySQL site @@ -498,7 +501,7 @@ class EESiteUpdateController(CementBaseController): self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): pass - #PHP + # PHP if (self.app.pargs.php and not (self.app.pargs.html or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or @@ -517,7 +520,7 @@ class EESiteUpdateController(CementBaseController): stype = 'php' cache = 'basic' - #MySQL + # MySQL if (self.app.pargs.mysql and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or @@ -537,7 +540,7 @@ class EESiteUpdateController(CementBaseController): stype = 'mysql' cache = 'basic' - #WP + # WP if ((self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc) and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or @@ -616,7 +619,7 @@ class EESiteUpdateController(CementBaseController): stype = 'wp' cache = 'wpsc' - #WPSUBDIR + # WPSUBDIR if (self.app.pargs.wpsubdir and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdomain or self.app.pargs.wp)): @@ -860,7 +863,7 @@ class EESiteUpdateController(CementBaseController): msg="{0} updated with {1} {2}" .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot - #SetWebrootPermissions(self, data['webroot']) + # SetWebrootPermissions(self, data['webroot']) updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) Log.info(self, "Successfully updated site" diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index bde91af8..0bc7fa5e 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -3,10 +3,12 @@ import random import string import sys import getpass +from ee.cli.plugins.stack import EEStackController from ee.core.fileutils import EEFileUtils from ee.core.mysql import EEMysql from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables +from ee.core.aptget import EEAptGet from ee.core.logging import Log import glob @@ -178,9 +180,9 @@ def SetupWordpress(self, data): + "--dbuser={0} --dbpass={1} " "--extra-php< 1024: - apt_packages = apt_packages + EEVariables.ee_mailscanner - else: - Log.info(self, "Mail server is allready installed") - - if self.app.pargs.nginx: - Log.debug(self, "Setting apt_packages variable for Nginx") - if not EEAptGet.is_installed(self, 'nginx-common'): - apt_packages = apt_packages + EEVariables.ee_nginx - else: - Log.info(self, "Nginx allready installed") - if self.app.pargs.php: - Log.debug(self, "Setting apt_packages variable for PHP") - if not EEAptGet.is_installed(self, 'php5-fpm'): - apt_packages = apt_packages + EEVariables.ee_php - else: - Log.info(self, "PHP allready installed") - if self.app.pargs.mysql: - Log.debug(self, "Setting apt_packages variable for MySQL") - if not EEShellExec.cmd_exec(self, "mysqladmin ping"): - apt_packages = apt_packages + EEVariables.ee_mysql - else: - Log.info(self, "MySQL connection is allready alive") - if self.app.pargs.postfix: - Log.debug(self, "Setting apt_packages variable for PostFix") - if not EEAptGet.is_installed(self, 'postfix'): - apt_packages = apt_packages + EEVariables.ee_postfix - else: - Log.info(self, "Postfix is allready installed") - if self.app.pargs.wpcli: - Log.debug(self, "Setting packages variable for WPCLI") - 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"]] - else: - Log.info(self, "WP-CLI is allready installed") - if self.app.pargs.phpmyadmin: - Log.debug(self, "Setting packages varible for phpMyAdmin ") - packages = packages + [["https://github.com/phpmyadmin/phpmyadmin" - "/archive/STABLE.tar.gz", - "/tmp/pma.tar.gz", "phpMyAdmin"]] - - if self.app.pargs.adminer: - Log.debug(self, "Setting packages variable for Adminer ") - packages = packages + [["http://downloads.sourceforge.net/adminer" - "/adminer-4.1.0.php", "/var/www/22222/" - "htdocs/db/adminer/index.php", "Adminer"]] + try: + if self.app.pargs.web: + Log.debug(self, "Setting apt_packages variable for Nginx ,PHP" + " ,MySQL ") + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.wpcli = True + self.app.pargs.postfix = True + + if self.app.pargs.admin: + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.adminer = True + self.app.pargs.phpmyadmin = True + self.app.pargs.utils = True + + if self.app.pargs.mail: + self.app.pargs.nginx = True + self.app.pargs.php = True + self.app.pargs.mysql = True + self.app.pargs.postfix = True + + if not EEAptGet.is_installed(self, 'dovecot-core'): + Log.debug(self, "Setting apt_packages variable for mail") + apt_packages = apt_packages + EEVariables.ee_mail + packages = packages + [["https://github.com/opensolutions/" + "ViMbAdmin/archive/3.0.10.tar.gz", + "/tmp/vimbadmin.tar.gz", + "ViMbAdmin"], + ["https://github.com/roundcube/" + "roundcubemail/releases/download/" + "1.0.4/roundcubemail-1.0.4.tar.gz", + "/tmp/roundcube.tar.gz", + "Roundcube"]] + + if EEVariables.ee_ram > 1024: + apt_packages = (apt_packages + + EEVariables.ee_mailscanner) + else: + Log.info(self, "Mail server is allready installed") - if self.app.pargs.utils: - Log.debug(self, "Setting packages variable for utils") - packages = packages + [["http://phpmemcacheadmin.googlecode.com/" - "files/phpMemcachedAdmin-1.2.2" - "-r262.tar.gz", '/tmp/memcache.tar.gz', - 'phpMemcachedAdmin'], - ["https://raw.githubusercontent.com/rtCamp/" - "eeadmin/master/cache/nginx/clean.php", - "/var/www/22222/htdocs/cache/" - "nginx/clean.php", "clean.php"], - ["https://raw.github.com/rlerdorf/opcache-" - "status/master/opcache.php", - "/var/www/22222/htdocs/cache/" - "opcache/opcache.php", "opcache.php"], - ["https://raw.github.com/amnuts/opcache-gui" - "/master/index.php", - "/var/www/22222/htdocs/" - "cache/opcache/opgui.php", "index.php"], - ["https://gist.github.com/ck-on/4959032/raw" - "/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb" - "/ocp.php", - "/var/www/22222/htdocs/cache/" - "opcache/ocp.php", "ocp.php"], - ["https://github.com/jokkedk/webgrind/" - "archive/master.tar.gz", - '/tmp/webgrind.tar.gz', 'Webgrind'], - ["http://bazaar.launchpad.net/~percona-too" - "lkit-dev/percona-toolkit/2.1/download/he" - "ad:/ptquerydigest-20110624220137-or26tn4" - "expb9ul2a-16/pt-query-digest", - "/usr/bin/pt-query-advisor", - "pt-query-digest"], - ["https://github.com/box/Anemometer/archive" - "/master.tar.gz", - '/tmp/anemometer.tar.gz', 'Anemometer'] - ] - Log.debug(self, "Calling pre_pref ") - self.pre_pref(apt_packages) - if len(apt_packages): - EESwap.add(self) - Log.debug(self, "Updating apt-cache") - EEAptGet.update(self) - Log.debug(self, "Installing all apt_packages") - print(apt_packages) - EEAptGet.install(self, apt_packages) - if len(packages): - Log.debug(self, "Downloading all packages") - EEDownload.download(self, packages) - Log.debug(self, "Calling post_pref") - self.post_pref(apt_packages, packages) - if len(self.msg): - for msg in self.msg: - Log.info(self, msg) - Log.info(self, "Successfully installed packages") + if self.app.pargs.nginx: + Log.debug(self, "Setting apt_packages variable for Nginx") + if not EEAptGet.is_installed(self, 'nginx-common'): + apt_packages = apt_packages + EEVariables.ee_nginx + else: + Log.info(self, "Nginx allready installed") + if self.app.pargs.php: + Log.debug(self, "Setting apt_packages variable for PHP") + if not EEAptGet.is_installed(self, 'php5-fpm'): + apt_packages = apt_packages + EEVariables.ee_php + else: + Log.info(self, "PHP allready installed") + if self.app.pargs.mysql: + Log.debug(self, "Setting apt_packages variable for MySQL") + if not EEShellExec.cmd_exec(self, "mysqladmin ping"): + apt_packages = apt_packages + EEVariables.ee_mysql + else: + Log.info(self, "MySQL connection is allready alive") + if self.app.pargs.postfix: + Log.debug(self, "Setting apt_packages variable for PostFix") + if not EEAptGet.is_installed(self, 'postfix'): + apt_packages = apt_packages + EEVariables.ee_postfix + else: + Log.info(self, "Postfix is allready installed") + if self.app.pargs.wpcli: + Log.debug(self, "Setting packages variable for WPCLI") + 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"]] + else: + Log.info(self, "WP-CLI is allready installed") + if self.app.pargs.phpmyadmin: + Log.debug(self, "Setting packages varible for phpMyAdmin ") + packages = packages + [["https://github.com/phpmyadmin/" + "phpmyadmin/archive/STABLE.tar.gz", + "/tmp/pma.tar.gz", "phpMyAdmin"]] + + if self.app.pargs.adminer: + Log.debug(self, "Setting packages variable for Adminer ") + packages = packages + [["http://downloads.sourceforge.net/" + "adminer/adminer-4.1.0.php", + "/var/www/22222/" + "htdocs/db/adminer/index.php", + "Adminer"]] + + if self.app.pargs.utils: + Log.debug(self, "Setting packages variable for utils") + packages = packages + [["http://phpmemcacheadmin.googlecode" + ".com/files/phpMemcachedAdmin-1.2.2" + "-r262.tar.gz", '/tmp/memcache.tar.gz', + 'phpMemcachedAdmin'], + ["https://raw.githubusercontent.com" + "/rtCamp/eeadmin/master/cache/nginx/" + "clean.php", + "/var/www/22222/htdocs/cache/" + "nginx/clean.php", "clean.php"], + ["https://raw.github.com/rlerdorf/" + "opcache-status/master/opcache.php", + "/var/www/22222/htdocs/cache/" + "opcache/opcache.php", "opcache.php"], + ["https://raw.github.com/amnuts/" + "opcache-gui/master/index.php", + "/var/www/22222/htdocs/" + "cache/opcache/opgui.php", + "index.php"], + ["https://gist.github.com/ck-on/4959032" + "/raw/0b871b345fd6cfcd6d2be030c1f33d1" + "ad6a475cb/ocp.php", + "/var/www/22222/htdocs/cache/" + "opcache/ocp.php", "ocp.php"], + ["https://github.com/jokkedk/webgrind/" + "archive/master.tar.gz", + '/tmp/webgrind.tar.gz', 'Webgrind'], + ["http://bazaar.launchpad.net/~" + "percona-toolkit-dev/percona-toolkit/" + "2.1/download/head:/ptquerydigest-" + "20110624220137-or26tn4" + "expb9ul2a-16/pt-query-digest", + "/usr/bin/pt-query-advisor", + "pt-query-digest"], + ["https://github.com/box/Anemometer/" + "archive/master.tar.gz", + '/tmp/anemometer.tar.gz', 'Anemometer'] + ] + except Exception as e: + pass + + if len(apt_packages) or len(packages): + Log.debug(self, "Calling pre_pref ") + self.pre_pref(apt_packages) + if len(apt_packages): + EESwap.add(self) + Log.debug(self, "Updating apt-cache") + EEAptGet.update(self) + Log.debug(self, "Installing all apt_packages") + print(apt_packages) + EEAptGet.install(self, apt_packages) + if len(packages): + Log.debug(self, "Downloading all packages") + EEDownload.download(self, packages) + Log.debug(self, "Calling post_pref") + self.post_pref(apt_packages, packages) + if len(self.msg): + for msg in self.msg: + Log.info(self, msg) + Log.info(self, "Successfully installed packages") @expose() def remove(self): From 5d8923e67ad857e3a26a43a239a5f94c2fcbedc1 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 16 Jan 2015 16:27:44 +0530 Subject: [PATCH 662/829] updated messages --- ee/cli/plugins/site.py | 165 ++++++++++++++++++------------- ee/cli/plugins/site_functions.py | 117 +++++++++++++--------- 2 files changed, 167 insertions(+), 115 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 21505028..cdaa284b 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -35,8 +35,7 @@ class EESiteController(CementBaseController): @expose(hide=True) def default(self): - # TODO Default action for ee site command - print("Inside EESiteController.default().") + self.app.args.print_help() @expose(help="enable site example.com") def enable(self): @@ -44,12 +43,13 @@ class EESiteController(CementBaseController): if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): EEFileUtils.create_symlink(self, - ['/etc/nginx/sites-available/{0}.conf' - .format(ee_domain_name), - '/etc/nginx/sites-enabled/{0}.conf' - .format(ee_domain_name)]) + ['/etc/nginx/sites-available/{0}' + .format(ee_domain), + '/etc/nginx/sites-enabled/{0}' + .format(ee_domain)]) + updateSiteInfo(self, ee_domain, enabled=True) else: - Log.error(self, "!! site {0} does not exists".format(ee_domain)) + Log.error(self, " site {0} does not exists".format(ee_domain)) @expose(help="disable site example.com") def disable(self): @@ -57,12 +57,11 @@ class EESiteController(CementBaseController): if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): EEFileUtils.remove_symlink(self, - ['/etc/nginx/sites-available/{0}.conf' - .format(ee_domain_name), - '/etc/nginx/sites-enabled/{0}.conf' - .format(ee_domain_name)]) + '/etc/nginx/sites-enabled/{0}' + .format(ee_domain)) + updateSiteInfo(self, ee_domain, enabled=False) else: - Log.error(self, "!! site {0} does not exists".format(ee_domain)) + Log.error(self, " site {0} does not exists".format(ee_domain)) @expose(help="get example.com information") def info(self): @@ -94,7 +93,7 @@ class EESiteController(CementBaseController): dbpass=ee_db_pass) self.app.render((data), 'siteinfo.mustache') else: - Log.error(self, "!! site {0} does not exists".format(ee_domain)) + Log.error(self, " site {0} does not exists".format(ee_domain)) @expose(help="Monitor example.com logs") def log(self): @@ -104,7 +103,7 @@ class EESiteController(CementBaseController): EEShellExec.cmd_exec(self, 'tail -f /var/log/nginx/{0}.*.log' .format(ee_domain)) else: - Log.error(self, "!! site {0} does not exists".format(ee_domain)) + Log.error(self, " site {0} does not exists".format(ee_domain)) @expose(help="Edit example.com's nginx configuration") def edit(self): @@ -120,7 +119,7 @@ class EESiteController(CementBaseController): # Reload NGINX EEService.reload_service(self, 'nginx') else: - Log.error(self, "!! site {0} does not exists".format(ee_domain)) + Log.error(self, " site {0} does not exists".format(ee_domain)) @expose(help="Display example.com's nginx configuration") def show(self): @@ -135,14 +134,9 @@ class EESiteController(CementBaseController): print(text) f.close() else: - Log.error(self, "!! site {0} does not exists".format(ee_domain)) + Log.error(self, " site {0} does not exists".format(ee_domain)) - @expose(help="list sites currently available") - def list(self): - # TODO Write code for ee site list command here - print("Inside EESiteController.list().") - - @expose(help="change to example.com's webroot") + @expose(help="change directory to site webroot") def cd(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -154,7 +148,7 @@ class EESiteController(CementBaseController): subprocess.call(['bash']) except OSError as e: Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) - Log.error(self, "!! cannot change directory") + Log.error(self, " cannot change directory") class EESiteCreateController(CementBaseController): @@ -166,31 +160,35 @@ class EESiteCreateController(CementBaseController): help of the following subcommands' arguments = [ (['site_name'], - dict(help='the notorious foo option')), + dict(help='domain name for the site to be created.')), (['--html'], - dict(help="html site", action='store_true')), + dict(help="create html site", action='store_true')), (['--php'], - dict(help="php site", action='store_true')), + dict(help="create php site", action='store_true')), (['--mysql'], - dict(help="mysql site", action='store_true')), + dict(help="create mysql site", action='store_true')), (['--wp'], - dict(help="wordpress site", action='store_true')), + dict(help="create wordpress single site", + action='store_true')), (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), + dict(help="create wordpress multisite with subdirectory setup", + action='store_true')), (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), + dict(help="create wordpress multisite with subdomain setup", + action='store_true')), (['--w3tc'], - dict(help="w3tc", action='store_true')), + dict(help="create wordpress single/multi site with w3tc cache", + action='store_true')), (['--wpfc'], - dict(help="wpfc", action='store_true')), + dict(help="create wordpress single/multi site with wpfc cache", + action='store_true')), (['--wpsc'], - dict(help="wpsc", action='store_true')), + dict(help="create wordpress single/multi site with wpsc cache", + action='store_true')), ] @expose(hide=True) def default(self): - # TODO Default action for ee site command - # data = dict(foo='EESiteCreateController.default().') # self.app.render((data), 'default.mustache') # Check domain name validation (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -199,7 +197,7 @@ class EESiteCreateController(CementBaseController): # Check if doain previously exists or not if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): - Log.error(self, "!! site {0} already exists" + Log.error(self, " site {0} already exists" .format(ee_domain)) # setup nginx configuration for site @@ -401,11 +399,15 @@ class EESiteCreateController(CementBaseController): stype = 'wpsubdomain' cache = 'wpsc' + if not data: + self.app.args.print_help() + self.app.close(1) + # setup NGINX configuration, and webroot - SetupDomain(self, data) + setupDomain(self, data) # Setup database for MySQL site if 'ee_db_name' in data.keys() and not data['wp']: - data = SetupDatabase(self, data) + data = setupDatabase(self, data) try: eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), 'w') @@ -422,11 +424,11 @@ class EESiteCreateController(CementBaseController): except IOError as e: Log.debug(self, "{2} ({0}): {1}" .format(e.errno, e.strerror, ee_domain)) - Log.error(self, "!! Unable to create ee-config.php for ") + Log.error(self, " Unable to create ee-config.php for ") # Setup WordPress if Wordpress site if data['wp']: - ee_wp_creds = SetupWordpress(self, data) + ee_wp_creds = setupWordpress(self, data) # Service Nginx Reload EEService.reload_service(self, 'nginx') @@ -485,7 +487,7 @@ class EESiteUpdateController(CementBaseController): check_site = getSiteInfo(self, ee_domain) if check_site is None: - Log.error(self, "!! Site {0} does not exist.".format(ee_domain)) + Log.error(self, " Site {0} does not exist.".format(ee_domain)) else: oldsitetype = check_site.site_type oldcachetype = check_site.cache_type @@ -506,7 +508,7 @@ class EESiteUpdateController(CementBaseController): if oldsitetype != 'html': - Log.error(self, "!! Cannot update {0} {1} to php" + Log.error(self, " Cannot update {0} {1} to php" .format(ee_domain, oldsitetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -524,7 +526,7 @@ class EESiteUpdateController(CementBaseController): self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): if oldsitetype not in ['html', 'php']: - Log.error(self, "!! Cannot update {0}, {1} to mysql" + Log.error(self, " Cannot update {0}, {1} to mysql" .format(ee_domain, oldsitetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -548,7 +550,7 @@ class EESiteUpdateController(CementBaseController): if ((oldsitetype in ['html', 'php', 'mysql', 'wp']) and (oldcachetype not in ['w3tc', 'wpfc', 'wpsc'])): print(oldsitetype, oldcachetype) - Log.error(self, "!! Cannot update {0}, {1} {2} to wp basic" + Log.error(self, " Cannot update {0}, {1} {2} to wp basic" .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -566,7 +568,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp'] and oldcachetype not in ['basic', 'wpfc', 'wpsc']): - Log.error(self, "!! Cannot update {0}, {1} {2}to wp w3tc" + Log.error(self, " Cannot update {0}, {1} {2}to wp w3tc" .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -625,7 +627,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']): - Log.error(self, "!! Cannot update {0}, {1} {2} " + Log.error(self, " Cannot update {0}, {1} {2} " "to wpsubdir basic" .format(ee_domain, oldsitetype, oldcachetype)) @@ -644,7 +646,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] and oldcachetype not in ['basic', 'wpfc', 'wpsc']): - Log.error(self, "!! Cannot update {0} {1} {2}" + Log.error(self, " Cannot update {0} {1} {2}" "to wpsubdir w3tc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -664,7 +666,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] and oldcachetype not in ['basic', 'w3tc', 'wpsc']): - Log.error(self, "!! Cannot update {0} {1} {2}" + Log.error(self, " Cannot update {0} {1} {2}" " to wpsubdir wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -683,7 +685,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] and oldcachetype not in ['basic', 'w3tc', 'wpfc']): - Log.error(self, "!! Cannot update {0} {1} {2}" + Log.error(self, " Cannot update {0} {1} {2}" " to wpsubdir wpsc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -703,7 +705,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']): - Log.error(self, "!! Cannot update {0} {1} {2}" + Log.error(self, " Cannot update {0} {1} {2}" " to wpsubdomain basic" .format(ee_domain, oldsitetype, oldcachetype)) @@ -724,7 +726,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] and oldcachetype not in ['basic', 'wpfc', 'wpsc']): - Log.error(self, "!! Cannot update {0}, {1} {2}" + Log.error(self, " Cannot update {0}, {1} {2}" " to wpsubdomain w3tc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -745,7 +747,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] and oldcachetype not in ['basic', 'w3tc', 'wpsc']): - Log.error(self, "!! Cannot update {0}, {1} {2} " + Log.error(self, " Cannot update {0}, {1} {2} " "to wpsubdomain wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -766,7 +768,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] and oldcachetype not in ['basic', 'w3tc', 'wpfc']): - Log.error(self, "!! Cannot update {0}, {1} {2}" + Log.error(self, " Cannot update {0}, {1} {2}" " to wpsubdomain wpsc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -782,16 +784,16 @@ class EESiteUpdateController(CementBaseController): cache = 'wpsc' if not data: - Log.error(self, "!! Cannot update" + Log.error(self, " Cannot update" .format(ee_domain)) siteBackup(self, data) # TODO Check for required packages before update # setup NGINX configuration, and webroot - SetupDomain(self, data) + setupDomain(self, data) if 'ee_db_name' in data.keys() and not data['wp']: - data = SetupDatabase(self, data) + data = setupDatabase(self, data) try: eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), 'w') @@ -805,7 +807,7 @@ class EESiteUpdateController(CementBaseController): data['ee_db_host'])) eedbconfig.close() except IOError as e: - Log.error(self, "!! Unable to create ee-config.php for " + Log.error(self, " Unable to create ee-config.php for " "{0}" .format(ee_domain)) Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) @@ -831,27 +833,27 @@ class EESiteUpdateController(CementBaseController): # Setup WordPress if old sites are html/php/mysql sites if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: - ee_wp_creds = SetupWordpress(self, data) + ee_wp_creds = setupWordpress(self, data) # Uninstall unnecessary plugins if oldsitetype in ['wp', 'wpsubdir', 'wpsubdomain']: # Setup WordPress Network if update option is multisite # and oldsite is WordPress single site if data['multisite'] and oldsitetype == 'wp': - SetupWordpressNetwork(self, data) + setupWordpressNetwork(self, data) if (oldcachetype == 'w3tc' or oldcachetype == 'wpfc' and not data['w3tc', 'wpfc']): - UnInstallWP_Plugin(self, 'w3-total-cache', data) + uninstallWP_Plugin(self, 'w3-total-cache', data) if oldcachetype == 'wpsc' and not data['wpsc']: - UnInstallWP_Plugin(self, 'wp-super-cache', data) + uninstallWP_Plugin(self, 'wp-super-cache', data) - if oldcachetype != 'w3tc' or oldcachetype != 'wpfc'and data['w3tc']: - InstallWP_Plugin(self, 'w3-total-cache', data) + if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and data['w3tc']: + installWP_Plugin(self, 'w3-total-cache', data) if oldcachetype != 'wpsc' and data['wpsc']: - InstallWP_Plugin(self, 'wp-super-cache', data) + installWP_Plugin(self, 'wp-super-cache', data) # Service Nginx Reload EEService.reload_service(self, 'nginx') @@ -941,7 +943,7 @@ class EESiteDeleteController(CementBaseController): .format(ee_domain)) deleteSiteInfo(self, ee_domain) else: - Log.error(self, "!! site {0} does not exists".format(ee_domain)) + Log.error(self, " site {0} does not exists".format(ee_domain)) @expose(hide=True) def deleteDB(self, webroot): @@ -972,19 +974,48 @@ class EESiteDeleteController(CementBaseController): EEMysql.execute(self, "flush privileges") except Exception as e: - Log.error(self, "!! Error occured while deleting database") + Log.error(self, " Error occured while deleting database") @expose(hide=True) def deleteWebRoot(self, webroot): EEFileUtils.rm(self, webroot) +class EESiteListController(CementBaseController): + class Meta: + label = 'list' + stacked_on = 'site' + stacked_type = 'nested' + description = 'list websites' + arguments = [ + (['--enabled'], + dict(help='list enabled sites', action='store_true')), + (['--disabled'], + dict(help="list disabled sites", action='store_true')), + ] + + @expose(help="delete example.com") + def default(self): + sites = getAllsites(self) + if not sites: + self.app.close(1) + + if self.app.pargs.enabled: + for site in sites: + if site.is_enabled: + Log.info(self, "{0}".format(site.sitename)) + elif self.app.pargs.disabled: + for site in sites: + if not site.is_enabled: + Log.info(self, "{0}".format(site.sitename)) + + def load(app): # register the plugin class.. this only happens if the plugin is enabled handler.register(EESiteController) handler.register(EESiteCreateController) handler.register(EESiteUpdateController) handler.register(EESiteDeleteController) - + handler.register(EESiteListController) # register a hook (function) to run after arguments are parsed. hook.register('post_argument_parsing', ee_site_hook) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index bde91af8..b636a952 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -11,11 +11,11 @@ from ee.core.logging import Log import glob -def SetupDomain(self, data): +def setupDomain(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] - self.app.log.info("Setting up NGINX config {0} ...".format(ee_domain_name)) + Log.info(self, "Setting up NGINX configuration ", end='') # write nginx config for file try: ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}' @@ -25,12 +25,12 @@ def SetupDomain(self, data): out=ee_site_nginx_conf) ee_site_nginx_conf.close() except IOError as e: - Log.error(self, "Unable to create nginx conf for {2} ({0}): {1}" - .format(e.errno, e.strerror, ee_domain_name)) - sys.exit(1) + Log.debug(self, "{0}".format(e)) + Log.error(self, "\nUnable to create NGINX configuration") except Exception as e: - Log.error(self, "{0}".format(e)) - sys.exit(1) + Log.debug(self, "{0}".format(e)) + Log.error(self, "\nUnable to create NGINX configuration") + Log.info(self, "[Done]") # create symbolic link for EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}' @@ -39,14 +39,15 @@ def SetupDomain(self, data): .format(ee_domain_name)]) # Creating htdocs & logs directory + Log.info(self, "Setting up webroot ", end='') try: if not os.path.exists('{0}/htdocs'.format(ee_site_webroot)): os.makedirs('{0}/htdocs'.format(ee_site_webroot)) if not os.path.exists('{0}/logs'.format(ee_site_webroot)): os.makedirs('{0}/logs'.format(ee_site_webroot)) except Exception as e: - Log.error(self, "{0}".format(e)) - sys.exit(1) + Log.debug(self, "{0}".format(e)) + Log.error(self, "\nUnable to setup webroot") EEFileUtils.create_symlink(self, ['/var/log/nginx/{0}.access.log' .format(ee_domain_name), @@ -56,9 +57,10 @@ def SetupDomain(self, data): .format(ee_domain_name), '{0}/logs/error.log' .format(ee_site_webroot)]) + Log.info(self, "[Done]") -def SetupDatabase(self, data): +def setupDatabase(self, data): ee_domain_name = data['site_name'] ee_random = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 15))) @@ -75,8 +77,8 @@ def SetupDatabase(self, data): ee_db_name = input('Enter the MySQL database name [{0}]:' .format(ee_replace_dot)) except EOFError as e: - Log.error(self, "{0} {1}".format(e.errorno, e.strerror)) - sys.exit(0) + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to input database name") if not ee_db_name: ee_db_name = ee_replace_dot @@ -88,8 +90,8 @@ def SetupDatabase(self, data): ee_db_password = input('Enter the MySQL database password [{0}]: ' .format(ee_random)) except EOFError as e: - Log.error(self, "{0} {1}".format(e.errorno, e.strerror)) - sys.exit(1) + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to input database credentials") if not ee_db_username: ee_db_username = ee_replace_dot @@ -97,26 +99,31 @@ def SetupDatabase(self, data): ee_db_password = ee_random if len(ee_db_username) > 16: - self.app.log.info('Autofix MySQL username (ERROR 1470 (HY000)),' - ' please wait...') + Log.info(self, 'Autofix MySQL username (ERROR 1470 (HY000)),' + ' please wait...') ee_random10 = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 10))) ee_db_name = (ee_db_name[0:6] + ee_random10) # create MySQL database - self.app.log.info("Setting Up Database ...") + Log.info(self, "Setting Up Database ", end='') + Log.debug(self, "creating databse {0}".format(ee_db_name)) EEMysql.execute(self, "create database {0}" .format(ee_db_name)) # Create MySQL User + Log.debug(self, "creating user {0}".format(ee_db_username)) EEMysql.execute(self, "create user {0}@{1} identified by '{2}'" .format(ee_db_username, ee_mysql_host, ee_db_password)) # Grant permission + Log.debug(self, "setting up user privileges") EEMysql.execute(self, "grant all privileges on {0}.* to {1}@{2}" .format(ee_db_name, ee_db_username, ee_mysql_host)) + Log.info(self, "[Done]") + data['ee_db_name'] = ee_db_name data['ee_db_user'] = ee_db_username data['ee_db_pass'] = ee_db_password @@ -124,7 +131,7 @@ def SetupDatabase(self, data): return(data) -def SetupWordpress(self, data): +def setupWordpress(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] prompt_wpprefix = self.app.config.get('wordpress', 'prefix') @@ -138,25 +145,25 @@ def SetupWordpress(self, data): ee_wp_user = '' ee_wp_pass = '' - Log.info(self, "Downloading Wordpress...", end='') + Log.info(self, "Downloading Wordpress ", end='') EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") Log.info(self, "[Done]") if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']): - data = SetupDatabase(self, data) + data = setupDatabase(self, data) if prompt_wpprefix == 'True' or prompt_wpprefix == 'true': try: ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' .format(ee_replace_dot)) while re.match('^[A-Za-z0-9_]*$', ee_wp_prefix): - self.app.log.warn("table prefix can only " - "contain numbers, letters, and underscores") + Log.warn(self, "table prefix can only " + "contain numbers, letters, and underscores") ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' ) except EOFError as e: - Log.error(self, "{0} {1}".format(e.errorno, e.strerror)) - sys.exit(1) + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to input table prefix") if not ee_wp_prefix: ee_wp_prefix = 'wp_' @@ -164,14 +171,16 @@ def SetupWordpress(self, data): # Modify wp-config.php & move outside the webroot EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) - self.app.log.debug("Setting Up WordPress Configuration...") + Log.debug(self, "Setting up wp-config file") if not data['multisite']: + Log.debug(self, "Generating wp-config for WordPress Single site") EEShellExec.cmd_exec(self, "wp --allow-root core config " + "--dbname={0} --dbprefix={1} --dbuser={2} " .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_user']) + "--dbpass={0}".format(data['ee_db_pass'])) else: + Log.debug(self, "Generating wp-config for WordPress multisite") EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core config " + "--dbname={0} --dbprefix={1} " .format(data['ee_db_name'], ee_wp_prefix) @@ -183,16 +192,19 @@ def SetupWordpress(self, data): var2= "\n define('WPMU_ACCEL_REDIRECT', true);") ) - EEFileUtils.mvfile(self, './wp-config.php', '../') if not ee_wp_user: ee_wp_user = EEVariables.ee_user while not ee_wp_user: - self.app.log.warn("Usernames can have only alphanumeric" - "characters, spaces, underscores, hyphens," - "periods and the @ symbol.") - ee_wp_user = input('Enter WordPress username: ') + Log.warn(self, "Usernames can have only alphanumeric" + "characters, spaces, underscores, hyphens," + "periods and the @ symbol.") + try: + ee_wp_user = input('Enter WordPress username: ') + except EOFError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to input wp user name") if not ee_wp_pass: ee_wp_pass = ee_random @@ -200,11 +212,16 @@ def SetupWordpress(self, data): if not ee_wp_email: ee_wp_email = EEVariables.ee_email while not ee_wp_email: - ee_wp_email = input('Enter WordPress email: ') + try: + ee_wp_email = input('Enter WordPress email: ') + except EOFError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to input wp user email") - self.app.log.debug("Setting up WordPress Tables, please wait...") + Log.debug(self, "setting up WordPress Tables") if not data['multisite']: + Log.debug(self, "creating tables for WordPress Single site") EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install " "--url={0} --title={0} --admin_name={1} " .format(data['www_domain'], ee_wp_user) @@ -212,6 +229,7 @@ def SetupWordpress(self, data): .format(ee_wp_pass, ee_wp_email), errormsg="Unable to setup WordPress Tables") else: + Log.debug(self, "creating tables for WordPress multisite") EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root " "core multisite-install " "--url={0} --title={0} --admin_name={1} " @@ -223,22 +241,22 @@ def SetupWordpress(self, data): if not data['wpsubdir'] else ''), errormsg="Unable to setup WordPress Tables") - self.app.log.debug("Updating WordPress permalink, please wait...") + Log.debug(self, "Updating WordPress permalink") EEShellExec.cmd_exec(self, " php /usr/bin/wp --allow-root " "rewrite structure " "/%year%/%monthnum%/%day%/%postname%/", errormsg="Unable to Update WordPress permalink") """Install nginx-helper plugin """ - InstallWP_Plugin(self, 'nginx-helper', data) + installWP_Plugin(self, 'nginx-helper', data) """Install Wp Super Cache""" if data['wpsc']: - InstallWP_Plugin(self, 'wp-super-cache', data) + installWP_Plugin(self, 'wp-super-cache', data) """Install W3 Total Cache""" if data['w3tc'] or data['wpfc']: - InstallWP_Plugin(self, 'w3-total-cache', data) + installWP_Plugin(self, 'w3-total-cache', data) wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass, wp_email=ee_wp_email) @@ -246,19 +264,20 @@ def SetupWordpress(self, data): return(wp_creds) -def SetupWordpressNetwork(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") + Log.info(self, "Setting up WordPress Network ", 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") -def InstallWP_Plugin(self, plugin_name, data): +def installWP_Plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] - self.app.log.debug("Installing plugin {0}".format(plugin_name)) + Log.debug(self, "Installing plugin {0}".format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root install " "{0}".format(plugin_name), @@ -273,18 +292,18 @@ def InstallWP_Plugin(self, plugin_name, data): .format(plugin_name)) -def UnInstallWP_Plugin(self, plugin_name, data): +def uninstallWP_Plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] - self.app.log.debug("Uninstalling plugin {0}".format(plugin_name)) + Log.debug(self, "Uninstalling plugin {0}".format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root uninstall " "{0}".format(plugin_name), - errormsg="Unable to Install plugin {0}" + errormsg="Unable to UnInstall plugin {0}" .format(plugin_name)) def SetWebrootPermissions(self, webroot): - self.app.log.debug("Setting Up Permissions...") + Log.debug(self, "Setting Up Permissions...") EEFileUtils.chown(self, webroot, EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) @@ -299,19 +318,21 @@ def siteBackup(self, data): .format(data['site_name']), backup_path) if data['currsitetype'] in ['html', 'php', 'mysql']: - Log.info(self, "Backup Webroot ...") + Log.info(self, "Backing up Webroot ", end='') EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path) + Log.info(self, "[Done]") configfiles = glob.glob(ee_site_webroot + '/*-config.php') - if EEFileUtils.isexist(self, configfiles[0]): + if configfiles and EEFileUtils.isexist(self, configfiles[0]): ee_db_name = (EEFileUtils.grep(self, configfiles[0], 'DB_NAME').split(',')[1] .split(')')[0].strip().replace('\'', '')) - Log.info(self, 'Backup Database, please wait') + Log.info(self, 'Backing up Database ', end='') EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" .format(ee_db_name, backup_path), - "Failed: Backup Database") + errormsg="\nFailed: Backup Database") + Log.info(self, "[Done]") # move wp-config.php/ee-config.php to backup if data['currsitetype'] in ['mysql']: EEFileUtils.mvfile(self, configfiles[0], backup_path) From af37ca3613d62b7d0f7b9951784731091d43deec Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Fri, 16 Jan 2015 17:01:14 +0530 Subject: [PATCH 663/829] updated 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 961710c3..6392709c 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -63,7 +63,7 @@ class EEService(): if retcode[0] == 0: subprocess.getstatusoutput('service {0} reload' .format(service_name)) - Log.info(self, "reload : {0} {0:10}" + Log.info(self, "reload :{0:10}{1}" .format(service_name, "[OK]")) return True else: From ef51625859dd1a9c4b1616e0eafe28bc8db99d07 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 16 Jan 2015 18:13:34 +0530 Subject: [PATCH 664/829] Added Privileges for root only --- ee/cli/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ee/cli/main.py b/ee/cli/main.py index fd2c5285..7e5c7efc 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -1,5 +1,6 @@ """EasyEngine main application entry point.""" import sys +import os # this has to happen after you import sys, but before you import anything # from Cement "source: https://github.com/datafolklabs/cement/issues/290" @@ -71,6 +72,11 @@ def main(): # Default our exit status to 0 (non-error) code = 0 + # if not root...kick out + if not os.geteuid() == 0: + print("\nOnly root or sudo user can run this EasyEngine\n") + app.close(1) + # Setup the application app.setup() From 36452005897fb1b6203a1fce0cc31aa088dbcdaf Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 16 Jan 2015 19:18:40 +0530 Subject: [PATCH 665/829] ee stack reload --- ee/cli/plugins/stack_services.py | 27 +++++++++++++ ee/core/services.py | 67 +++++++++++++++++++------------- 2 files changed, 68 insertions(+), 26 deletions(-) diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index 666b404e..b226cddb 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -125,3 +125,30 @@ class EEStackStatusController(CementBaseController): for service in services: if EEService.get_service_status(self, service): Log.info(self, "{0:10}: {1}".format(service, "Running")) + + @expose(help="reload stack services") + def reload(self): + services = [] + if self.app.pargs.nginx: + Log.debug(self, "nginx service restart") + services = services + ['nginx'] + elif self.app.pargs.php: + Log.debug(self, "php5-fpm service restart") + services = services + ['php5-fpm'] + elif self.app.pargs.mysql: + Log.debug(self, "mysql service restart") + services = services + ['mysql'] + elif self.app.pargs.postfix: + Log.debug(self, "postfix service restart") + services = services + ['postfix'] + elif self.app.pargs.memcache: + Log.debug(self, "memcached service restart") + services = services + ['memcached'] + elif self.app.pargs.dovecot: + Log.debug(self, "dovecot service restart") + services = services + ['dovecot'] + else: + services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] + for service in services: + Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart") + EEService.reload_service(self, service) diff --git a/ee/core/services.py b/ee/core/services.py index 297513b6..c344a2f8 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -10,74 +10,88 @@ import pystache class EEService(): """Intialization for service""" def ___init__(): - # TODO method for services pass def start_service(self, service_name): try: + Log.info(self, "Start : {0:10}" .format(service_name), end='') retcode = subprocess.getstatusoutput('service {0} start' .format(service_name)) if retcode[0] == 0: - Log.info(self, "Started : {0:10}{1}" - .format(service_name, "[OK]")) + Log.info(self, "[OK]") + return True else: - Log.error(self, retcode[1]) + Log.debug(self, "{0}".format(retcode[1])) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") + return False except OSError as e: - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) - Log.error(self, "Failed to start service {0}" + Log.debug(self, "{0}".format(e)) + Log.error(self, "\nFailed to start service {0}" .format(service_name)) - return False def stop_service(self, service_name): try: + Log.info(self, "Stop : {0:10}" .format(service_name), end='') retcode = subprocess.getstatusoutput('service {0} stop' .format(service_name)) if retcode[0] == 0: - Log.info(self, "Stopped : {0:10}{1}" - .format(service_name, "[OK]")) + Log.info(self, "[OK]") return True else: + Log.debug(self, "{0}".format(retcode[1])) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") return False except OSError as e: - Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) - Log.error(self, "Failed to stop service : {0}" + Log.debug(self, "{0}".format(e)) + Log.error(self, "\nFailed to stop service : {0}" .format(service_name)) - return False def restart_service(self, service_name): try: - EEService.stop_service(self, service_name) - EEService.start_service(self, service_name) - Log.info(self, "restart : {0:10}{1}" - .format(service_name, "[OK]")) + Log.info(self, "Restart : {0:10}".format(service_name), end='') + retcode = subprocess.getstatusoutput('service {0} restart' + .format(service_name)) + if retcode[0] == 0: + Log.info(self, "[OK]") + return True + else: + Log.debug(self, "{0}".format(retcode[1])) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") + return False except OSError as e: - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) - Log.error(self, "Failed to restart services \{0}" + Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) + Log.error(self, "\nFailed to restart service : {0}" .format(service_name)) def reload_service(self, service_name): try: if service_name in ['nginx', 'php5-fpm']: - retcode = subprocess.getstatusoutput('{0} -t' + Log.info(self, "Reload : {0:10}".format(service_name), + end='') + retcode = subprocess.getstatusoutput('{0} -t &&' + ' service {0} reload' .format(service_name)) if retcode[0] == 0: - subprocess.getstatusoutput('service {0} reload' - .format(service_name)) - Log.info(self, "reload :{0:10}{1}" - .format(service_name, "[OK]")) + # print(retcode[0]) + # subprocess.getstatusoutput('service {0} reload' + # .format(service_name)) + Log.info(self, "[OK]") return True else: Log.debug(self, "{0}".format(retcode[1])) - Log.error(self, "reload : {0}".format(service_name)) + Log.info(self, "[" + Log.FAIL + "Failed" + + Log.OKBLUE+"]") return False + Log.info(self, "Reload : {0:10}".format(service_name), end='') retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: - Log.info(self, "reload : {0:10}{1}" - .format(service_name, "[OK]")) + Log.info(self, "[OK]") return True else: + Log.debug(self, "{0}".format(retcode[1])) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") return False except OSError as e: Log.debug(self, "{0}".format(e)) @@ -94,6 +108,7 @@ class EEService(): if retcode[0] == 0: return True else: + Log.debug(self, "{0}".format(retcode[1])) return False else: return False From 5c266183133aec3852aedfcbbfb10331fb0df028 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 16 Jan 2015 19:19:43 +0530 Subject: [PATCH 666/829] ee description modified --- ee/cli/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/main.py b/ee/cli/main.py index fd2c5285..eb4c230a 100644 --- a/ee/cli/main.py +++ b/ee/cli/main.py @@ -98,8 +98,8 @@ def main(): if exc_traceback is not None: traceback.print_exc() - # Close the application - app.close(code) + # # Close the application + app.close(code) def get_test_app(**kw): From aa2eeb0b100f778cd6a9305c01d1f02f81eef873 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 16 Jan 2015 19:38:06 +0530 Subject: [PATCH 667/829] ee stack service messaged modified --- ee/cli/controllers/base.py | 26 ++---------- ee/cli/plugins/site.py | 81 ++++++++++++++++++++++---------------- ee/cli/plugins/sitedb.py | 13 +++++- ee/core/fileutils.py | 2 +- ee/core/services.py | 2 +- setup.py | 10 ++--- 6 files changed, 69 insertions(+), 65 deletions(-) diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index aad1d5c5..b19b224a 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -6,28 +6,10 @@ from cement.core.controller import CementBaseController, expose class EEBaseController(CementBaseController): class Meta: label = 'base' - description = 'easyengine is the commandline tool to manage your \ - websites based on wordpress and nginx with easy to \ - use commands.' - arguments = [ - (['-f', '--foo'], - dict(help='the notorious foo option', dest='foo', action='store', - metavar='TEXT')), - ] + description = ("easyengine is the commandline tool to manage your" + " websites based on wordpress and nginx with easy to" + " use commands.") @expose(hide=True) def default(self): - data = dict(foo='EEBaseController.default().') - self.app.render((data), 'default.mustache') - - # print("Inside EEBaseController.default().") - - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + self.app.args.print_help() diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 597ce5cb..b78de277 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -458,30 +458,30 @@ class EESiteUpdateController(CementBaseController): help of the following subcommands' arguments = [ (['site_name'], - dict(help='website name')), + dict(help='domain name for the site to be updated')), (['--html'], - dict(help="html site", action='store_true')), + dict(help="update to html site", action='store_true')), (['--php'], - dict(help="php site", action='store_true')), + dict(help="update to php site", action='store_true')), (['--mysql'], - dict(help="mysql site", action='store_true')), + dict(help="update to mysql site", action='store_true')), (['--wp'], - dict(help="wordpress site", action='store_true')), + dict(help="update to wordpress single site", + action='store_true')), (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), + dict(help="update to wpsubdir site", action='store_true')), (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), + dict(help="update to wpsubdomain site", action='store_true')), (['--w3tc'], - dict(help="w3tc", action='store_true')), + dict(help="update to w3tc cache", action='store_true')), (['--wpfc'], - dict(help="wpfc", action='store_true')), + dict(help="update to wpfc cache", action='store_true')), (['--wpsc'], - dict(help="wpsc", action='store_true')), + dict(help="update to wpsc cache", action='store_true')), ] - @expose(help="update example.com") + @expose(help="update site type or cache") def default(self): - # TODO Write code for ee site update here (ee_domain, ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = EEVariables.ee_webroot + ee_domain @@ -810,10 +810,8 @@ class EESiteUpdateController(CementBaseController): data['ee_db_host'])) eedbconfig.close() except IOError as e: - Log.error(self, " Unable to create ee-config.php for " - "{0}" - .format(ee_domain)) - Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) + Log.debug(self, "{0}".format(e)) + Log.error(self, " Unable to create ee-config.php.") if oldsitetype == 'mysql': config_file = (ee_site_webroot + '/backup/{0}/ee-config.php' @@ -892,12 +890,17 @@ class EESiteDeleteController(CementBaseController): dict(help="delete webroot only", action='store_true')), ] - @expose(help="delete example.com") + @expose(help="delete site") def default(self): # TODO Write code for ee site update here (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_db_name = '' ee_prompt = '' + + if ((not self.app.pargs.db) and (not self.app.pargs.files) and + (not self.app.pargs.all)): + self.app.pargs.all = True + if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): ee_site_webroot = EEVariables.ee_webroot + ee_domain @@ -907,44 +910,49 @@ class EESiteDeleteController(CementBaseController): if self.app.pargs.db: if not ee_prompt: - ee_db_prompt = input('Do you want to delete database:' - '[Y/N] ') + ee_db_prompt = input('Do you want to delete database' + '[Y/N]: ') else: ee_db_prompt = 'Y' - if ee_db_prompt == 'Y': + ee_nginx_prompt = 'Y' + if ee_db_prompt == 'Y' or ee_db_prompt == 'y': self.deleteDB(ee_site_webroot) if self.app.pargs.files: if not ee_prompt: - ee_web_prompt = input('Do you want to delete webroot:' - '[Y/N] ') + ee_web_prompt = input('Do you want to delete webroot' + '[Y/N]: ') else: ee_web_prompt = 'Y' - if ee_web_prompt == 'Y': + ee_nginx_prompt = 'Y' + + if ee_web_prompt == 'Y' or ee_web_prompt == 'y': self.deleteWebRoot(ee_site_webroot) if self.app.pargs.all: if not ee_prompt: - ee_db_prompt = input('Do you want to delete database:' - '[Y/N] ' + ee_db_prompt = input('Do you want to delete database' + '[Y/N]: ' ) - ee_web_prompt = input('Do you want to delete webroot:' - '[Y/N] ') + ee_web_prompt = input('Do you want to delete webroot' + '[Y/N]: ') ee_nginx_prompt = input('Do you want to delete NGINX' - ' configuration:[Y/N] ') + ' configuration [Y/N]: ') else: ee_db_prompt = 'Y' ee_web_prompt = 'Y' ee_nginx_prompt = 'Y' - if ee_db_prompt == 'Y': + if ee_db_prompt == 'Y' or ee_db_prompt == 'y': self.deleteDB(ee_site_webroot) - if ee_web_prompt == 'Y': + if ee_web_prompt == 'Y' or ee_web_prompt == 'y': self.deleteWebRoot(ee_site_webroot) - if ee_nginx_prompt == 'Y': + + if (ee_nginx_prompt == 'Y' or ee_nginx_prompt == 'y'): EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}' .format(ee_domain)) - deleteSiteInfo(self, ee_domain) + deleteSiteInfo(self, ee_domain) + Log.info(self, "Deleted site {0}".format(ee_domain)) else: Log.error(self, " site {0} does not exists".format(ee_domain)) @@ -966,18 +974,20 @@ class EESiteDeleteController(CementBaseController): 'DB_HOST').split(',')[1] .split(')')[0].strip().replace('\'', '')) try: + Log.debug(self, "dropping database {0}".format(ee_db_name)) EEMysql.execute(self, "drop database {0}".format(ee_db_name), errormsg='Unable to drop database {0}' .format(ee_db_name)) if ee_db_user != 'root': + Log.debug(self, "dropping user {0}".format(ee_db_user)) EEMysql.execute(self, "drop user {0}@{1}" .format(ee_db_user, ee_db_host)) EEMysql.execute(self, "flush privileges") except Exception as e: - Log.error(self, " Error occured while deleting database") + Log.error(self, "Error occured while deleting database") @expose(hide=True) def deleteWebRoot(self, webroot): @@ -1001,7 +1011,7 @@ class EESiteListController(CementBaseController): def default(self): sites = getAllsites(self) if not sites: - self.app.close(1) + pass if self.app.pargs.enabled: for site in sites: @@ -1011,6 +1021,9 @@ class EESiteListController(CementBaseController): for site in sites: if not site.is_enabled: Log.info(self, "{0}".format(site.sitename)) + else: + for site in sites: + Log.info(self, "{0}".format(site.sitename)) def load(app): diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index c8f2acd6..318beb46 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -9,7 +9,7 @@ from ee.core.models import SiteDB def addNewSite(self, site, stype, cache, path, - enabled=True, ssl=False, fs='ext4', db='mysql'): + enabled=True, ssl=False, fs='ext4', db=''): try: newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db) db_session.add(newRec) @@ -41,7 +41,7 @@ def updateSiteInfo(self, site, stype='', cache='', if cache and q.cache_type != cache: q.cache_type = cache - if enabled and q.is_enabled != enabled: + if q.is_enabled != enabled: q.is_enabled = enabled if ssl and q.is_ssl != ssl: @@ -67,3 +67,12 @@ def deleteSiteInfo(self, site): except Exception as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to delete site from application database.") + + +def getAllsites(self): + try: + q = SiteDB.query.all() + return q + except Exception as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to query database :") diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 74195a45..d67bd3a3 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -43,7 +43,7 @@ class EEFileUtils(): try: os.unlink(filepath) except Exception as e: - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) + Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to reomove symbolic link ...\n") def copyfile(self, src, dest): diff --git a/ee/core/services.py b/ee/core/services.py index c344a2f8..bf533e9f 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -95,7 +95,7 @@ class EEService(): return False except OSError as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Failed to reload service {0}" + Log.error(self, "\nFailed to reload service {0}" .format(service_name)) def get_service_status(self, service_name): diff --git a/setup.py b/setup.py index d98e9f4d..001b2fe6 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,9 @@ import glob conf = [] templates = [] +long_description = '''EasyEngine is the commandline tool to manage your + Websites based on WordPress and NGINX with easy to use + commands''' for name in glob.glob('config/plugins.d/*.conf'): conf.insert(1, name) @@ -22,11 +25,8 @@ if not os.path.exists('/var/lib/ee/'): setup(name='ee', version='3.0', - description=('EasyEngine is the commandline tool to manage your Websites' - 'based on WordPress and NGINX with easy to use commands.'), - long_description=('EasyEngine is the commandline tool to manage your ' - 'Websites based on WordPress and NGINX with easy' - 'to use commands.'), + description=long_description, + long_description=long_description, classifiers=[], keywords='', author='rtCamp Soultions Pvt. LTD', From f7576c617ba515cd7446d27a6a757e789f6ec7e2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 19 Jan 2015 11:09:39 +0530 Subject: [PATCH 668/829] Fixed self not defined in ee info --- ee/cli/plugins/info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/info.py b/ee/cli/plugins/info.py index 58a81ab5..346fd57a 100644 --- a/ee/cli/plugins/info.py +++ b/ee/cli/plugins/info.py @@ -171,13 +171,13 @@ class EEInfoController(CementBaseController): self.app.pargs.mysql = True if self.app.pargs.nginx: - if EEAptGet.is_installed('nginx-common'): + if EEAptGet.is_installed(self, 'nginx-common'): self.info_nginx() else: print("Nginx is not installed") if self.app.pargs.php: - if EEAptGet.is_installed('php5-fpm'): + if EEAptGet.is_installed(self, 'php5-fpm'): self.info_php() else: print("PHP5 is installed") From b68a15085055e4def71c917a107f83dae1006d81 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 19 Jan 2015 11:35:36 +0530 Subject: [PATCH 669/829] added test case of site --- tests/cli/test_site_cd.py | 16 ++++++++ tests/cli/test_site_create.py | 67 ++++++++++++++++++++++++++++++ tests/cli/test_site_disable.py | 16 ++++++++ tests/cli/test_site_edit.py | 16 ++++++++ tests/cli/test_site_enable.py | 16 ++++++++ tests/cli/test_site_info.py | 16 ++++++++ tests/cli/test_site_log.py | 16 ++++++++ tests/cli/test_site_show.py | 16 ++++++++ tests/cli/test_site_update.py | 74 ++++++++++++++++++++++++++++++++++ tests/test_site_delete.py | 38 +++++++++++++++++ tests/test_site_list.py | 22 ++++++++++ 11 files changed, 313 insertions(+) create mode 100644 tests/cli/test_site_cd.py create mode 100644 tests/cli/test_site_create.py create mode 100644 tests/cli/test_site_disable.py create mode 100644 tests/cli/test_site_edit.py create mode 100644 tests/cli/test_site_enable.py create mode 100644 tests/cli/test_site_info.py create mode 100644 tests/cli/test_site_log.py create mode 100644 tests/cli/test_site_show.py create mode 100644 tests/cli/test_site_update.py create mode 100644 tests/test_site_delete.py create mode 100644 tests/test_site_list.py diff --git a/tests/cli/test_site_cd.py b/tests/cli/test_site_cd.py new file mode 100644 index 00000000..fd8e3d01 --- /dev/null +++ b/tests/cli/test_site_cd.py @@ -0,0 +1,16 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_show_cd(self): + self.app = get_test_app(argv=['site', 'cd', 'site_name']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_create.py b/tests/cli/test_site_create.py new file mode 100644 index 00000000..fa3f1755 --- /dev/null +++ b/tests/cli/test_site_create.py @@ -0,0 +1,67 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_html(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', '--html']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_php(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', '--php']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_mysql(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', + '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_wp(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', '--wp']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_wpsubdir(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', + '--wpsubdir']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_wpsubdomain(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', + '--wpsubdomain']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_w3tc(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', '--w3tc']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_wpfc(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', '--wpfc']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_create_wpsc(self): + self.app = get_test_app(argv=['site', 'create', 'site_name', '--wpsc']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_disable.py b/tests/cli/test_site_disable.py new file mode 100644 index 00000000..1b946532 --- /dev/null +++ b/tests/cli/test_site_disable.py @@ -0,0 +1,16 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_disable(self): + self.app = get_test_app(argv=['site', 'disable', 'site_name']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_edit.py b/tests/cli/test_site_edit.py new file mode 100644 index 00000000..8a26d67d --- /dev/null +++ b/tests/cli/test_site_edit.py @@ -0,0 +1,16 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_edit(self): + self.app = get_test_app(argv=['site', 'edit', 'site_name']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_enable.py b/tests/cli/test_site_enable.py new file mode 100644 index 00000000..d2ec6f55 --- /dev/null +++ b/tests/cli/test_site_enable.py @@ -0,0 +1,16 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_enable(self): + self.app = get_test_app(argv=['site', 'enable', 'site_name']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_info.py b/tests/cli/test_site_info.py new file mode 100644 index 00000000..26575a42 --- /dev/null +++ b/tests/cli/test_site_info.py @@ -0,0 +1,16 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_info(self): + self.app = get_test_app(argv=['site', 'info', 'site_name']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_log.py b/tests/cli/test_site_log.py new file mode 100644 index 00000000..89717f10 --- /dev/null +++ b/tests/cli/test_site_log.py @@ -0,0 +1,16 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_log(self): + self.app = get_test_app(argv=['site', 'log', 'site_name']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_show.py b/tests/cli/test_site_show.py new file mode 100644 index 00000000..5c6b4b7c --- /dev/null +++ b/tests/cli/test_site_show.py @@ -0,0 +1,16 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_show_edit(self): + self.app = get_test_app(argv=['site', 'show', 'site_name']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_update.py b/tests/cli/test_site_update.py new file mode 100644 index 00000000..cae89092 --- /dev/null +++ b/tests/cli/test_site_update.py @@ -0,0 +1,74 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', + '--password']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_html(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', '--html']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_php(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', '--php']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_mysql(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', + '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_wp(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', '--wp']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_wpsubdir(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', + '--wpsubdir']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_wpsubdomain(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', + '--wpsubdomain']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_w3tc(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', '--w3tc']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_wpfc(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', '--wpfc']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_update_wpsc(self): + self.app = get_test_app(argv=['site', 'update', 'site_name', '--wpsc']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/test_site_delete.py b/tests/test_site_delete.py new file mode 100644 index 00000000..322a59ba --- /dev/null +++ b/tests/test_site_delete.py @@ -0,0 +1,38 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_detele(self): + self.app = get_test_app(argv=['site', 'delete', 'site_name', + '--no-prompt']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_detele_all(self): + self.app = get_test_app(argv=['site', 'delete', 'site_name', + '--all']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_detele_db(self): + self.app = get_test_app(argv=['site', 'delete', 'site_name', + '--db']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_detele_files(self): + self.app = get_test_app(argv=['site', 'delete', 'site_name', + '--files']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/test_site_list.py b/tests/test_site_list.py new file mode 100644 index 00000000..477e6915 --- /dev/null +++ b/tests/test_site_list.py @@ -0,0 +1,22 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSite(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_list_enable(self): + self.app = get_test_app(argv=['site', 'list', '--enabled']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_site_list_disable(self): + self.app = get_test_app(argv=['site', 'list', '--disabled']) + self.app.setup() + self.app.run() + self.app.close() From baaf2d9ec8efaf38bd8367cd3f9a23220705f7bd Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 19 Jan 2015 12:00:22 +0530 Subject: [PATCH 670/829] Now using packages variables as package name and WPCLI is updated to v0.18.0 --- ee/cli/plugins/stack.py | 22 ++++++++++++++-------- ee/core/variables.py | 12 ++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 103f96f7..69177dd7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -166,7 +166,7 @@ class EEStackController(CementBaseController): nc.savef('/etc/nginx/nginx.conf') # Custom Nginx configuration by EasyEngine - data = dict(version='EasyEngine 3.0.1') + data = dict(version=EEVariables.ee_version) Log.debug(self, 'writting the nginx configration to ' 'file /etc/nginx/conf.d/ee-nginx.conf ') ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') @@ -932,12 +932,14 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting apt_packages variable for mail") apt_packages = apt_packages + EEVariables.ee_mail packages = packages + [["https://github.com/opensolutions/" - "ViMbAdmin/archive/3.0.10.tar.gz", + "ViMbAdmin/archive/{0}.tar.gz" + .format(EEVariables.ee_vimbadmin), "/tmp/vimbadmin.tar.gz", "ViMbAdmin"], ["https://github.com/roundcube/" "roundcubemail/releases/download/" - "1.0.4/roundcubemail-1.0.4.tar.gz", + "{0}/roundcubemail-{0}.tar.gz" + .format(EEVariables.ee_roundcube), "/tmp/roundcube.tar.gz", "Roundcube"]] @@ -975,8 +977,10 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting packages variable for WPCLI") 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", + "releases/download/v{0}/" + "wp-cli-{0}.phar" + "".format(EEVariables.ee_wp_cli), + "/usr/bin/wp", "WP_CLI"]] else: Log.info(self, "WP-CLI is allready installed") @@ -989,7 +993,8 @@ class EEStackController(CementBaseController): if self.app.pargs.adminer: Log.debug(self, "Setting packages variable for Adminer ") packages = packages + [["http://downloads.sourceforge.net/" - "adminer/adminer-4.1.0.php", + "adminer/adminer-{0}.php" + "".format(EEVariables.ee_adminer), "/var/www/22222/" "htdocs/db/adminer/index.php", "Adminer"]] @@ -1043,11 +1048,12 @@ class EEStackController(CementBaseController): EESwap.add(self) Log.debug(self, "Updating apt-cache") EEAptGet.update(self) - Log.debug(self, "Installing all apt_packages") + Log.debug(self, "Installing following: {0}" + .format(apt_packages)) print(apt_packages) EEAptGet.install(self, apt_packages) if len(packages): - Log.debug(self, "Downloading all packages") + Log.debug(self, "Downloading following: {0}".format(packages)) EEDownload.download(self, packages) Log.debug(self, "Calling post_pref") self.post_pref(apt_packages, packages) diff --git a/ee/core/variables.py b/ee/core/variables.py index 9077de93..0a3f2bc3 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -13,6 +13,16 @@ class EEVariables(): config = configparser.ConfigParser() config.read(os.path.expanduser("~")+'/.gitconfig') + # EasyEngine version + ee_version = "3.0.0" + + # EasyEngine packages versions + ee_wp_cli = "0.18.0" + ee_adminer = "4.1.0" + ee_roundcube = "1.0.4" + ee_vimbadmin = "3.0.10" + + # Current date and time of System ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S') # EasyEngine core variables @@ -23,8 +33,10 @@ class EEVariables(): # Get FQDN of system ee_fqdn = socket.getfqdn() + # EasyEngien default webroot path ee_webroot = '/var/www/' + # PHP5 user ee_php_user = 'www-data' # Get git user name and EMail From fff4574318b5fcff1c7942f3ce2555a7de5f2353 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 19 Jan 2015 13:40:46 +0530 Subject: [PATCH 671/829] Fixed MySQL remote connectivity --- ee/cli/plugins/stack.py | 34 ++++++++++++------- ee/cli/templates/dovecot-sql-conf.mustache | 2 +- ee/cli/templates/virtual_alias_maps.mustache | 2 +- .../templates/virtual_domains_maps.mustache | 2 +- .../templates/virtual_mailbox_maps.mustache | 2 +- ee/core/variables.py | 12 +++++++ 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 69177dd7..4c54bd8b 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -647,15 +647,18 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec(self, 'mysql < /var/www/22222/htdocs/db' '/anemometer/install.sql') EEMysql.execute(self, 'grant select on *.* to \'anemometer\'' - '@\'localhost\'') + '@\'{0}\''.format(self.app.config.get('mysql', + 'grant-host'))) EEMysql.execute(self, 'grant all on slow_query_log.* to' - '\'anemometer\'@\'localhost\' IDENTIFIED' - ' BY \''+chars+'\'') + '\'anemometer\'@\'{0}\' IDENTIFIED' + ' BY \'{1}\''.format(self.app.config.get( + 'mysql', 'grant-host'), + chars)) # Custom Anemometer configuration Log.debug(self, "configration Anemometer") - data = dict(host='localhost', port='3306', user='anemometer', - password=chars) + data = dict(host=EEVariables.ee_mysql_host, port='3306', + user='anemometer', password=chars) ee_anemometer = open('/var/www/22222/htdocs/db/anemometer' '/conf/config.inc.php', 'w') self.app.render((data), 'anemometer.mustache', @@ -700,8 +703,9 @@ class EEStackController(CementBaseController): " vimbadmin") Log.debug(self, "Granting all privileges on vimbadmin ") EEMysql.execute(self, "grant all privileges on vimbadmin.* to" - " vimbadmin@localhost IDENTIFIED BY" - " '{password}'".format(password=vm_passwd)) + " vimbadmin@{0} IDENTIFIED BY" + " '{1}'".format(self.app.config.get('mysql', + 'grant-host'), vm_passwd)) # Configure ViMbAdmin settings config = configparser.ConfigParser(strict=False) @@ -719,7 +723,7 @@ class EEStackController(CementBaseController): config['user']['resources.doctrine2.connection.' 'options.password'] = vm_passwd config['user']['resources.doctrine2.connection.' - 'options.host'] = 'localhost' + 'options.host'] = EEVariables.ee_mysql_host config['user']['defaults.mailbox.password_scheme'] = 'md5' config['user']['securitysalt'] = (''.join(random.sample (string.ascii_letters @@ -765,7 +769,7 @@ class EEStackController(CementBaseController): Log.debug(self, "Creating directory " "/etc/postfix/mysql/") os.makedirs('/etc/postfix/mysql/') - data = dict(password=vm_passwd) + data = dict(password=vm_passwd, host=EEVariables.ee_mysql) vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf', 'w') self.app.render((data), 'virtual_alias_maps.mustache', @@ -832,8 +836,10 @@ class EEStackController(CementBaseController): Log.debug(self, "Grant all privileges on roundcubemail") EEMysql.execute(self, "grant all privileges" " on roundcubemail.* to " - " roundcube@localhost IDENTIFIED BY " - "'{password}'".format(password=rc_passwd)) + " roundcube@{0} IDENTIFIED BY " + "'{1}'".format(self.app.config.get( + 'mysql', 'grant-host'), + rc_passwd)) EEShellExec.cmd_exec(self, "mysql roundcubemail < /var/www/" "roundcubemail/htdocs/SQL/mysql" ".initial.sql") @@ -844,10 +850,12 @@ class EEStackController(CementBaseController): "config.inc.php") EEShellExec.cmd_exec(self, "sed -i \"s\'mysql://roundcube:" "pass@localhost/roundcubemail\'mysql://" - "roundcube:{password}@localhost/" + "roundcube:{0}@{1}/" "roundcubemail\'\" /var/www/roundcubemail" "/htdocs/config/config." - "inc.php".format(password=rc_passwd)) + "inc.php" + .format(rc_passwd, + EEVariables.ee_mysql_host)) # Sieve plugin configuration in roundcube EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\[" diff --git a/ee/cli/templates/dovecot-sql-conf.mustache b/ee/cli/templates/dovecot-sql-conf.mustache index 8c76123d..0ec50c11 100644 --- a/ee/cli/templates/dovecot-sql-conf.mustache +++ b/ee/cli/templates/dovecot-sql-conf.mustache @@ -1,5 +1,5 @@ driver = mysql -connect = host=localhost user=vimbadmin password={{password}} dbname=vimbadmin +connect = host={{host}} user=vimbadmin password={{password}} dbname=vimbadmin default_pass_scheme = MD5 password_query = SELECT username as user, password as password, \ homedir AS home, maildir AS mail, \ diff --git a/ee/cli/templates/virtual_alias_maps.mustache b/ee/cli/templates/virtual_alias_maps.mustache index f155569d..b7919c74 100644 --- a/ee/cli/templates/virtual_alias_maps.mustache +++ b/ee/cli/templates/virtual_alias_maps.mustache @@ -1,5 +1,5 @@ user = vimbadmin password = {{password}} -hosts = 127.0.0.1 +hosts = {{host}} dbname = vimbadmin query = SELECT goto FROM alias WHERE address = '%s' AND active = '1' diff --git a/ee/cli/templates/virtual_domains_maps.mustache b/ee/cli/templates/virtual_domains_maps.mustache index 5ca23900..2dce79a0 100644 --- a/ee/cli/templates/virtual_domains_maps.mustache +++ b/ee/cli/templates/virtual_domains_maps.mustache @@ -1,5 +1,5 @@ user = vimbadmin password = {{password}} -hosts = 127.0.0.1 +hosts = {{host}} dbname = vimbadmin query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1' diff --git a/ee/cli/templates/virtual_mailbox_maps.mustache b/ee/cli/templates/virtual_mailbox_maps.mustache index bb2e8b1b..f8aafdaf 100644 --- a/ee/cli/templates/virtual_mailbox_maps.mustache +++ b/ee/cli/templates/virtual_mailbox_maps.mustache @@ -1,6 +1,6 @@ user = vimbadmin password = {{password}} -hosts = 127.0.0.1 +hosts = {{host}} dbname = vimbadmin table = mailbox select_field = maildir diff --git a/ee/core/variables.py b/ee/core/variables.py index 0a3f2bc3..3b0c5cd7 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -51,6 +51,18 @@ class EEVariables(): ee_ram = psutil.virtual_memory().total / (1024 * 1024) ee_swap = psutil.swap_memory().total / (1024 * 1024) + # MySQL hostname + ee_mysql_host = "" + config = configparser.RawConfigParser() + cnfpath = os.path.expanduser("~")+"/.my.cnf" + if [cnfpath] == config.read(cnfpath): + try: + ee_mysql_host = config.get('client', 'host') + except configparser.NoOptionError as e: + ee_mysql_host = "localhost" + else: + ee_mysql_host = "localhost" + # EasyEngine stack installation varibales # Nginx repo and packages if ee_platform_distro == 'Ubuntu': From 11ca0fdd8cda2900071c69f3f6015494b40295d2 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 19 Jan 2015 14:19:17 +0530 Subject: [PATCH 672/829] changes done in test case --- tests/cli/test_clean.py | 40 +++++++++++ tests/cli/test_debug.py | 101 ++++++++++++++++++++++++++++ tests/cli/test_ee.py | 67 ------------------ tests/cli/test_info.py | 28 ++++++++ tests/cli/test_secure.py | 28 ++++++++ tests/cli/test_site_cd.py | 2 +- tests/cli/test_site_create.py | 24 ++++--- tests/{ => cli}/test_site_delete.py | 8 +-- tests/cli/test_site_disable.py | 2 +- tests/cli/test_site_edit.py | 2 +- tests/cli/test_site_enable.py | 2 +- tests/cli/test_site_info.py | 2 +- tests/{ => cli}/test_site_list.py | 0 tests/cli/test_site_log.py | 2 +- tests/cli/test_site_show.py | 2 +- tests/cli/test_site_update.py | 26 ++++--- 16 files changed, 239 insertions(+), 97 deletions(-) create mode 100644 tests/cli/test_clean.py create mode 100644 tests/cli/test_debug.py delete mode 100644 tests/cli/test_ee.py create mode 100644 tests/cli/test_info.py create mode 100644 tests/cli/test_secure.py rename tests/{ => cli}/test_site_delete.py (75%) rename tests/{ => cli}/test_site_list.py (100%) diff --git a/tests/cli/test_clean.py b/tests/cli/test_clean.py new file mode 100644 index 00000000..39254bff --- /dev/null +++ b/tests/cli/test_clean.py @@ -0,0 +1,40 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseClean(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_clean(self): + self.app = get_test_app(argv=['clean']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_clean_fastcgi(self): + self.app = get_test_app(argv=['clean', '--fastcgi']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_clean_all(self): + self.app = get_test_app(argv=['clean', '--all']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_clean_memcache(self): + self.app = get_test_app(argv=['clean', '--memcache']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_clean_opcache(self): + self.app = get_test_app(argv=['clean', '--opcache']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_debug.py b/tests/cli/test_debug.py new file mode 100644 index 00000000..8d02c28e --- /dev/null +++ b/tests/cli/test_debug.py @@ -0,0 +1,101 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseDebug(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_stop(self): + self.app = get_test_app(argv=['debug', '--stop']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_start(self): + self.app = get_test_app(argv=['debug', '--start']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_php(self): + self.app = get_test_app(argv=['debug', '--php']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_nginx(self): + self.app = get_test_app(argv=['debug', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_rewrite(self): + self.app = get_test_app(argv=['debug', '--rewrite']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_fpm(self): + self.app = get_test_app(argv=['debug', '--fpm']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_mysql(self): + self.app = get_test_app(argv=['debug', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_import_slow_log_interval(self): + self.app = get_test_app(argv=['debug', '--mysql', + '--import-slow-log-interval']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_site_name_mysql(self): + self.app = get_test_app(argv=['debug', 'example3.com', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_site_name_wp(self): + self.app = get_test_app(argv=['debug', 'example4.com', '--wp']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_site_name_nginx(self): + self.app = get_test_app(argv=['debug', 'example4.com', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_site_name_start(self): + self.app = get_test_app(argv=['debug', 'example.com', '--start']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_site_name_stop(self): + self.app = get_test_app(argv=['debug', 'example.com', '--stop']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug_site_name_rewrite(self): + self.app = get_test_app(argv=['debug', 'example.com', '--rewrite']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_debug(self): + self.app = get_test_app(argv=['debug']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_ee.py b/tests/cli/test_ee.py deleted file mode 100644 index f02da325..00000000 --- a/tests/cli/test_ee.py +++ /dev/null @@ -1,67 +0,0 @@ -"""CLI tests for ee.""" - -from ee.utils import test -from ee.cli.main import get_test_app - - -class CliTestCase(test.EETestCase): - def test_ee_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_create(self): - self.app = get_test_app(argv=['site', 'create', 'example.com']) - self.app.setup() - self.app.run() - data, output = self.app.last_rendered - self.eq(output, 'Inside EESiteCreateController.default().\n') - self.app.close() - - def test_ee_cli_site_update(self): - self.app = get_test_app(argv=['site', 'update', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_delete(self): - self.app = get_test_app(argv=['site', 'delete', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_cd(self): - self.app = get_test_app(argv=['site', 'cd', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_log(self): - self.app = get_test_app(argv=['site', 'log', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_info(self): - self.app = get_test_app(argv=['site', 'info', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_enable(self): - self.app = get_test_app(argv=['site', 'enable', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_disable(self): - self.app = get_test_app(argv=['site', 'disable', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_edit(self): - self.app = get_test_app(argv=['site', 'edit', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/test_info.py b/tests/cli/test_info.py new file mode 100644 index 00000000..0c36edb4 --- /dev/null +++ b/tests/cli/test_info.py @@ -0,0 +1,28 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseInfo(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_info_mysql(self): + self.app = get_test_app(argv=['info', '--mysql']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_info_php(self): + self.app = get_test_app(argv=['info', '--php']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_info_nginx(self): + self.app = get_test_app(argv=['info', '--nginx']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_secure.py b/tests/cli/test_secure.py new file mode 100644 index 00000000..d867a2e8 --- /dev/null +++ b/tests/cli/test_secure.py @@ -0,0 +1,28 @@ +from ee.utils import test +from ee.cli.main import get_test_app + + +class CliTestCaseSecure(test.EETestCase): + + def test_ee_cli(self): + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_secure_auth(self): + self.app = get_test_app(argv=['secure', '--auth']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_secure_port(self): + self.app = get_test_app(argv=['secure', '--port']) + self.app.setup() + self.app.run() + self.app.close() + + def test_ee_cli_secure_ip(self): + self.app = get_test_app(argv=['secure', '--ip']) + self.app.setup() + self.app.run() + self.app.close() diff --git a/tests/cli/test_site_cd.py b/tests/cli/test_site_cd.py index fd8e3d01..51d55bec 100644 --- a/tests/cli/test_site_cd.py +++ b/tests/cli/test_site_cd.py @@ -10,7 +10,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_show_cd(self): - self.app = get_test_app(argv=['site', 'cd', 'site_name']) + self.app = get_test_app(argv=['site', 'cd', 'example.com']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/test_site_create.py b/tests/cli/test_site_create.py index fa3f1755..3b3a2554 100644 --- a/tests/cli/test_site_create.py +++ b/tests/cli/test_site_create.py @@ -10,58 +10,64 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_create_html(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', '--html']) + self.app = get_test_app(argv=['site', 'create', 'example1.com', + '--html']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_create_php(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', '--php']) + self.app = get_test_app(argv=['site', 'create', 'example2.com', + '--php']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_create_mysql(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', + self.app = get_test_app(argv=['site', 'create', 'example3.com', '--mysql']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_create_wp(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', '--wp']) + self.app = get_test_app(argv=['site', 'create', 'example4.com', + '--wp']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_create_wpsubdir(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', + self.app = get_test_app(argv=['site', 'create', 'example5.com', '--wpsubdir']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_create_wpsubdomain(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', + self.app = get_test_app(argv=['site', 'create', 'example6.com', '--wpsubdomain']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_create_w3tc(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', '--w3tc']) + self.app = get_test_app(argv=['site', 'create', 'example7.com', + '--w3tc']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_create_wpfc(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', '--wpfc']) + self.app = get_test_app(argv=['site', 'create', 'example8.com', + '--wpfc']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_create_wpsc(self): - self.app = get_test_app(argv=['site', 'create', 'site_name', '--wpsc']) + self.app = get_test_app(argv=['site', 'create', 'example9.com', + '--wpsc']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/test_site_delete.py b/tests/cli/test_site_delete.py similarity index 75% rename from tests/test_site_delete.py rename to tests/cli/test_site_delete.py index 322a59ba..2a2dfe8d 100644 --- a/tests/test_site_delete.py +++ b/tests/cli/test_site_delete.py @@ -10,28 +10,28 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_detele(self): - self.app = get_test_app(argv=['site', 'delete', 'site_name', + self.app = get_test_app(argv=['site', 'delete', 'example1.com', '--no-prompt']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_detele_all(self): - self.app = get_test_app(argv=['site', 'delete', 'site_name', + self.app = get_test_app(argv=['site', 'delete', 'example2.com', '--all']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_detele_db(self): - self.app = get_test_app(argv=['site', 'delete', 'site_name', + self.app = get_test_app(argv=['site', 'delete', 'example3.com', '--db']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_detele_files(self): - self.app = get_test_app(argv=['site', 'delete', 'site_name', + self.app = get_test_app(argv=['site', 'delete', 'example4.com', '--files']) self.app.setup() self.app.run() diff --git a/tests/cli/test_site_disable.py b/tests/cli/test_site_disable.py index 1b946532..3d948f77 100644 --- a/tests/cli/test_site_disable.py +++ b/tests/cli/test_site_disable.py @@ -10,7 +10,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_disable(self): - self.app = get_test_app(argv=['site', 'disable', 'site_name']) + self.app = get_test_app(argv=['site', 'disable', 'example2.com']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/test_site_edit.py b/tests/cli/test_site_edit.py index 8a26d67d..ebeee4f5 100644 --- a/tests/cli/test_site_edit.py +++ b/tests/cli/test_site_edit.py @@ -10,7 +10,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_edit(self): - self.app = get_test_app(argv=['site', 'edit', 'site_name']) + self.app = get_test_app(argv=['site', 'edit', 'example1.com']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/test_site_enable.py b/tests/cli/test_site_enable.py index d2ec6f55..87cc4f85 100644 --- a/tests/cli/test_site_enable.py +++ b/tests/cli/test_site_enable.py @@ -10,7 +10,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_enable(self): - self.app = get_test_app(argv=['site', 'enable', 'site_name']) + self.app = get_test_app(argv=['site', 'enable', 'example2.com']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/test_site_info.py b/tests/cli/test_site_info.py index 26575a42..1ecc2062 100644 --- a/tests/cli/test_site_info.py +++ b/tests/cli/test_site_info.py @@ -10,7 +10,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_info(self): - self.app = get_test_app(argv=['site', 'info', 'site_name']) + self.app = get_test_app(argv=['site', 'info', 'example1.com']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/test_site_list.py b/tests/cli/test_site_list.py similarity index 100% rename from tests/test_site_list.py rename to tests/cli/test_site_list.py diff --git a/tests/cli/test_site_log.py b/tests/cli/test_site_log.py index 89717f10..e73f4c6f 100644 --- a/tests/cli/test_site_log.py +++ b/tests/cli/test_site_log.py @@ -10,7 +10,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_log(self): - self.app = get_test_app(argv=['site', 'log', 'site_name']) + self.app = get_test_app(argv=['site', 'log', 'example1.com']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/test_site_show.py b/tests/cli/test_site_show.py index 5c6b4b7c..ba6c4f1f 100644 --- a/tests/cli/test_site_show.py +++ b/tests/cli/test_site_show.py @@ -10,7 +10,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_show_edit(self): - self.app = get_test_app(argv=['site', 'show', 'site_name']) + self.app = get_test_app(argv=['site', 'show', 'example.com']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/test_site_update.py b/tests/cli/test_site_update.py index cae89092..3f46d400 100644 --- a/tests/cli/test_site_update.py +++ b/tests/cli/test_site_update.py @@ -10,65 +10,71 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_update(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', + self.app = get_test_app(argv=['site', 'update', 'example.com', '--password']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_html(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', '--html']) + self.app = get_test_app(argv=['site', 'update', 'example1.com', + '--html']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_php(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', '--php']) + self.app = get_test_app(argv=['site', 'update', 'example2.com', + '--php']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_mysql(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', + self.app = get_test_app(argv=['site', 'update', 'example3.com', '--mysql']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wp(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', '--wp']) + self.app = get_test_app(argv=['site', 'update', 'example4.com', + '--wp']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpsubdir(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', + self.app = get_test_app(argv=['site', 'update', 'example5.com', '--wpsubdir']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpsubdomain(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', + self.app = get_test_app(argv=['site', 'update', 'example6.com', '--wpsubdomain']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_w3tc(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', '--w3tc']) + self.app = get_test_app(argv=['site', 'update', 'example7.com', + '--w3tc']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpfc(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', '--wpfc']) + self.app = get_test_app(argv=['site', 'update', 'example8.com', + '--wpfc']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpsc(self): - self.app = get_test_app(argv=['site', 'update', 'site_name', '--wpsc']) + self.app = get_test_app(argv=['site', 'update', 'example9.com', + '--wpsc']) self.app.setup() self.app.run() self.app.close() From 287d283f65c86c6e70e0455194b2268ac9d70fa6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 19 Jan 2015 15:01:08 +0530 Subject: [PATCH 673/829] Added default action for ee stack --- ee/cli/plugins/stack.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 4c54bd8b..5c70d859 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -913,6 +913,15 @@ class EEStackController(CementBaseController): def install(self, packages=[], apt_packages=[]): self.msg = [] try: + # Default action for stack installation + if ((not self.app.pargs.web) and (not self.app.pargs.admin) and + (not self.app.pargs.mail) and (not self.app.pargs.nginx) and + (not self.app.pargs.php) and (not self.app.pargs.mysql) and + (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and + (not self.app.pargs.phpmyadmin) and + (not self.app.pargs.adminer) and (not self.app.pargs.utils)): + self.app.pargs.web = True + if self.app.pargs.web: Log.debug(self, "Setting apt_packages variable for Nginx ,PHP" " ,MySQL ") @@ -1075,6 +1084,15 @@ class EEStackController(CementBaseController): apt_packages = [] packages = [] + # Default action for stack remove + if ((not self.app.pargs.web) and (not self.app.pargs.admin) and + (not self.app.pargs.mail) and (not self.app.pargs.nginx) and + (not self.app.pargs.php) and (not self.app.pargs.mysql) and + (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and + (not self.app.pargs.phpmyadmin) and + (not self.app.pargs.adminer) and (not self.app.pargs.utils)): + self.app.pargs.web = True + if self.app.pargs.web: self.app.pargs.nginx = True self.app.pargs.php = True @@ -1140,6 +1158,15 @@ class EEStackController(CementBaseController): apt_packages = [] packages = [] + # Default action for stack purge + if ((not self.app.pargs.web) and (not self.app.pargs.admin) and + (not self.app.pargs.mail) and (not self.app.pargs.nginx) and + (not self.app.pargs.php) and (not self.app.pargs.mysql) and + (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and + (not self.app.pargs.phpmyadmin) and + (not self.app.pargs.adminer) and (not self.app.pargs.utils)): + self.app.pargs.web = True + if self.app.pargs.web: self.app.pargs.nginx = True self.app.pargs.php = True From 25cbb54ef38528ee40eaefca8ad43c0cdbacb061 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 19 Jan 2015 15:02:24 +0530 Subject: [PATCH 674/829] autocompletion for commands --- config/bash_completion.d/ee_auto.py | 184 ++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 config/bash_completion.d/ee_auto.py diff --git a/config/bash_completion.d/ee_auto.py b/config/bash_completion.d/ee_auto.py new file mode 100644 index 00000000..e0bf09ca --- /dev/null +++ b/config/bash_completion.d/ee_auto.py @@ -0,0 +1,184 @@ +function ee_single() +{ + for (( j=0; j<${#COMP_WORDS[@]}; j++ )); do + for (( i=0; i<${#COMPREPLY[@]}; i++ )); do + if [[ ${COMP_WORDS[COMP_CWORD-j]} == ${COMPREPLY[i]} ]]; then + rem=( ${COMP_WORDS[COMP_CWORD-j]} ); + COMPREPLY=( "${COMPREPLY[@]/$rem}" ) + fi + done + done +} + +_ee_complete() +{ + local cur prev BASE_LEVEL + + COMPREPLY=() + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + mprev=${COMP_WORDS[COMP_CWORD-2]} + + + # SETUP THE BASE LEVEL (everything after "ee") + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $(compgen \ + -W "stack site debug clean secure" \ + -- $cur) ) + + + # SETUP THE SECOND LEVEL (EVERYTHING AFTER "ee second") + elif [ $COMP_CWORD -eq 2 ]; then + case "$prev" in + + # HANDLE EVERYTHING AFTER THE SECOND LEVEL NAMESPACE + "clean") + COMPREPLY=( $(compgen \ + -W "--memcache --opcache --fastcgi --all" \ + -- $cur) ) + ;; + + # IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE + "debug") + COMPREPLY=( $(compgen \ + -W "--start --nginx --php --fpm --mysql -i --interactive" \ + -- $cur) ) + ;; + + "stack") + COMPREPLY=( $(compgen \ + -W "install purge reload remove restart start status stop" \ + -- $cur) ) + ;; + + "site") + COMPREPLY=( $(compgen \ + -W "create delete disable edit enable info list log show update" \ + -- $cur) ) + ;; + + "secure") + COMPREPLY=( $(compgen \ + -W "--auth --port --ip" \ + -- $cur) ) + ;; + + "info") + COMPREPLY=( $(compgen \ + -W "--mysql --php --nginx" \ + -- $cur) ) + ;; + + # EVERYTHING ELSE + *) + ;; + esac + + # SETUP THE THIRD LEVEL (EVERYTHING AFTER "ee second third") + elif [ $COMP_CWORD -eq 3 ]; then + case "$prev" in + # HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE + "install" | "purge" | "remove" | "start" | "stop" | "reload") + COMPREPLY=( $(compgen \ + -W "--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot" \ + -- $cur) ) + ;; + + "list") + COMPREPLY=( $(compgen \ + -W "--enabled --disabled" \ + -- $cur) ) + ;; + + "edit" | "enable" | "info" | "log" | "show" | "cd" | "update") + COMPREPLY=( $(compgen \ + -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)" \ + -- $cur) ) + ;; + + "disable") + COMPREPLY=( $(compgen \ + -W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)" \ + -- $cur) ) + ;; + + *) + ;; + esac + + # case "$mprev" in + # "debug") + # COMPREPLY=( $(compgen \ + # -W "--wp --nginx --rewrite --start --stop -i --interactive" \ + # -- $cur) ) + # ;; + # + # *) + # ;; + # esac + + elif [ $COMP_CWORD -eq 4 ]; then + case "$mprev" in + # HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE + + "create" | "update") + COMPREPLY=( $(compgen \ + -W "--html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc" \ + -- $cur) ) + ;; + "delete") + COMPREPLY=( $(compgen \ + -W "--db --files --all" \ + -- $cur) ) + + + esac + fi + + case "$prev" in + "--wpsubdir" | "--wpsubdomain") + COMPREPLY=( $(compgen \ + -W "--w3tc --wpfc --wpsc" \ + -- $cur) ) + ;; + + "--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot") + if [[ $COMP_WORDS =~ "stack" ]]; then + retlist="--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot" + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) + fi + ;; + + "--db" | "--files" | "--all") + retlist="--db --files --all" + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) + ;; + + "--memcache" | "--opcache" | "--fastcgi" | "--all") + retlist="--memcache --opcache --fastcgi --all" + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) + ;; + "--auth" | "--port" | "--ip") + retlist="--auth --port --ip" + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) + ;; + *) + ;; + esac + + return 0 + +} && +complete -F _ee_complete ee From 547b9585cd20ac1da7372b8d48b0bbd449261807 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 19 Jan 2015 16:54:43 +0530 Subject: [PATCH 675/829] Comments changed --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 103f96f7..9bf7d0e9 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -1,4 +1,4 @@ -"""Example Plugin for EasyEngine.""" +"""Stack Plugin for EasyEngine.""" from cement.core.controller import CementBaseController, expose from cement.core import handler, hook From ec4f9990ba9fc954d52f749328a5e35e4346ca5b Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 19 Jan 2015 18:39:38 +0530 Subject: [PATCH 676/829] updated with file name --- tests/cli/{test_stack.py => 1_test_stack.py} | 0 ...tart.py => 2_test_stack_services_start.py} | 0 ...tus.py => 3_test_stack_services_status.py} | 0 ..._stop.py => 4_test_stack_services_stop.py} | 0 .../cli/{test_secure.py => 51_test_secure.py} | 0 tests/cli/{test_clean.py => 52_test_clean.py} | 0 ...rt.py => 5_test_stack_services_restart.py} | 0 ...t_site_create.py => 8_test_site_create.py} | 0 ...test_site_info.py => 91_test_site_info.py} | 0 .../{test_site_cd.py => 92_test_site_cd.py} | 0 ...test_site_list.py => 93_test_site_list.py} | 0 ...test_site_edit.py => 94_test_site_edit.py} | 0 ...test_site_show.py => 95_test_site_show.py} | 2 +- ..._site_update.py => 97_test_site_update.py} | 20 +++++++++---------- ...t_site_enable.py => 9_test_site_enable.py} | 0 ...site_disable.py => a_test_site_disable.py} | 0 tests/cli/test_debug.py | 6 +++--- tests/cli/test_site_log.py | 16 --------------- 18 files changed, 14 insertions(+), 30 deletions(-) rename tests/cli/{test_stack.py => 1_test_stack.py} (100%) rename tests/cli/{test_stack_services_start.py => 2_test_stack_services_start.py} (100%) rename tests/cli/{test_stack_services_status.py => 3_test_stack_services_status.py} (100%) rename tests/cli/{test_stack_services_stop.py => 4_test_stack_services_stop.py} (100%) rename tests/cli/{test_secure.py => 51_test_secure.py} (100%) rename tests/cli/{test_clean.py => 52_test_clean.py} (100%) rename tests/cli/{test_stack_services_restart.py => 5_test_stack_services_restart.py} (100%) rename tests/cli/{test_site_create.py => 8_test_site_create.py} (100%) rename tests/cli/{test_site_info.py => 91_test_site_info.py} (100%) rename tests/cli/{test_site_cd.py => 92_test_site_cd.py} (100%) rename tests/cli/{test_site_list.py => 93_test_site_list.py} (100%) rename tests/cli/{test_site_edit.py => 94_test_site_edit.py} (100%) rename tests/cli/{test_site_show.py => 95_test_site_show.py} (81%) rename tests/cli/{test_site_update.py => 97_test_site_update.py} (99%) rename tests/cli/{test_site_enable.py => 9_test_site_enable.py} (100%) rename tests/cli/{test_site_disable.py => a_test_site_disable.py} (100%) delete mode 100644 tests/cli/test_site_log.py diff --git a/tests/cli/test_stack.py b/tests/cli/1_test_stack.py similarity index 100% rename from tests/cli/test_stack.py rename to tests/cli/1_test_stack.py diff --git a/tests/cli/test_stack_services_start.py b/tests/cli/2_test_stack_services_start.py similarity index 100% rename from tests/cli/test_stack_services_start.py rename to tests/cli/2_test_stack_services_start.py diff --git a/tests/cli/test_stack_services_status.py b/tests/cli/3_test_stack_services_status.py similarity index 100% rename from tests/cli/test_stack_services_status.py rename to tests/cli/3_test_stack_services_status.py diff --git a/tests/cli/test_stack_services_stop.py b/tests/cli/4_test_stack_services_stop.py similarity index 100% rename from tests/cli/test_stack_services_stop.py rename to tests/cli/4_test_stack_services_stop.py diff --git a/tests/cli/test_secure.py b/tests/cli/51_test_secure.py similarity index 100% rename from tests/cli/test_secure.py rename to tests/cli/51_test_secure.py diff --git a/tests/cli/test_clean.py b/tests/cli/52_test_clean.py similarity index 100% rename from tests/cli/test_clean.py rename to tests/cli/52_test_clean.py diff --git a/tests/cli/test_stack_services_restart.py b/tests/cli/5_test_stack_services_restart.py similarity index 100% rename from tests/cli/test_stack_services_restart.py rename to tests/cli/5_test_stack_services_restart.py diff --git a/tests/cli/test_site_create.py b/tests/cli/8_test_site_create.py similarity index 100% rename from tests/cli/test_site_create.py rename to tests/cli/8_test_site_create.py diff --git a/tests/cli/test_site_info.py b/tests/cli/91_test_site_info.py similarity index 100% rename from tests/cli/test_site_info.py rename to tests/cli/91_test_site_info.py diff --git a/tests/cli/test_site_cd.py b/tests/cli/92_test_site_cd.py similarity index 100% rename from tests/cli/test_site_cd.py rename to tests/cli/92_test_site_cd.py diff --git a/tests/cli/test_site_list.py b/tests/cli/93_test_site_list.py similarity index 100% rename from tests/cli/test_site_list.py rename to tests/cli/93_test_site_list.py diff --git a/tests/cli/test_site_edit.py b/tests/cli/94_test_site_edit.py similarity index 100% rename from tests/cli/test_site_edit.py rename to tests/cli/94_test_site_edit.py diff --git a/tests/cli/test_site_show.py b/tests/cli/95_test_site_show.py similarity index 81% rename from tests/cli/test_site_show.py rename to tests/cli/95_test_site_show.py index ba6c4f1f..606578a6 100644 --- a/tests/cli/test_site_show.py +++ b/tests/cli/95_test_site_show.py @@ -10,7 +10,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_show_edit(self): - self.app = get_test_app(argv=['site', 'show', 'example.com']) + self.app = get_test_app(argv=['site', 'show', 'example1.com']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/test_site_update.py b/tests/cli/97_test_site_update.py similarity index 99% rename from tests/cli/test_site_update.py rename to tests/cli/97_test_site_update.py index 3f46d400..538b5b15 100644 --- a/tests/cli/test_site_update.py +++ b/tests/cli/97_test_site_update.py @@ -10,70 +10,70 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_update(self): - self.app = get_test_app(argv=['site', 'update', 'example.com', + self.app = get_test_app(argv=['site', 'update', 'example5.com', '--password']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_html(self): - self.app = get_test_app(argv=['site', 'update', 'example1.com', + self.app = get_test_app(argv=['site', 'update', 'example2.com', '--html']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_php(self): - self.app = get_test_app(argv=['site', 'update', 'example2.com', + self.app = get_test_app(argv=['site', 'update', 'example3.com', '--php']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_mysql(self): - self.app = get_test_app(argv=['site', 'update', 'example3.com', + self.app = get_test_app(argv=['site', 'update', 'example4.com', '--mysql']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wp(self): - self.app = get_test_app(argv=['site', 'update', 'example4.com', + self.app = get_test_app(argv=['site', 'update', 'example5.com', '--wp']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpsubdir(self): - self.app = get_test_app(argv=['site', 'update', 'example5.com', + self.app = get_test_app(argv=['site', 'update', 'example6.com', '--wpsubdir']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpsubdomain(self): - self.app = get_test_app(argv=['site', 'update', 'example6.com', + self.app = get_test_app(argv=['site', 'update', 'example7.com', '--wpsubdomain']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_w3tc(self): - self.app = get_test_app(argv=['site', 'update', 'example7.com', + self.app = get_test_app(argv=['site', 'update', 'example8.com', '--w3tc']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpfc(self): - self.app = get_test_app(argv=['site', 'update', 'example8.com', + self.app = get_test_app(argv=['site', 'update', 'example9.com', '--wpfc']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpsc(self): - self.app = get_test_app(argv=['site', 'update', 'example9.com', + self.app = get_test_app(argv=['site', 'update', 'example1.com', '--wpsc']) self.app.setup() self.app.run() diff --git a/tests/cli/test_site_enable.py b/tests/cli/9_test_site_enable.py similarity index 100% rename from tests/cli/test_site_enable.py rename to tests/cli/9_test_site_enable.py diff --git a/tests/cli/test_site_disable.py b/tests/cli/a_test_site_disable.py similarity index 100% rename from tests/cli/test_site_disable.py rename to tests/cli/a_test_site_disable.py diff --git a/tests/cli/test_debug.py b/tests/cli/test_debug.py index 8d02c28e..643b34ec 100644 --- a/tests/cli/test_debug.py +++ b/tests/cli/test_debug.py @@ -77,19 +77,19 @@ class CliTestCaseDebug(test.EETestCase): self.app.close() def test_ee_cli_debug_site_name_start(self): - self.app = get_test_app(argv=['debug', 'example.com', '--start']) + self.app = get_test_app(argv=['debug', 'example1.com', '--start']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_debug_site_name_stop(self): - self.app = get_test_app(argv=['debug', 'example.com', '--stop']) + self.app = get_test_app(argv=['debug', 'example1.com', '--stop']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_debug_site_name_rewrite(self): - self.app = get_test_app(argv=['debug', 'example.com', '--rewrite']) + self.app = get_test_app(argv=['debug', 'example1.com', '--rewrite']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/test_site_log.py b/tests/cli/test_site_log.py deleted file mode 100644 index e73f4c6f..00000000 --- a/tests/cli/test_site_log.py +++ /dev/null @@ -1,16 +0,0 @@ -from ee.utils import test -from ee.cli.main import get_test_app - - -class CliTestCaseSite(test.EETestCase): - - def test_ee_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_log(self): - self.app = get_test_app(argv=['site', 'log', 'example1.com']) - self.app.setup() - self.app.run() - self.app.close() From 2134b3ccbb7dd4d5778306003d11b0740781a6fc Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 11:20:09 +0530 Subject: [PATCH 677/829] remote mysql connection fixes --- ee/cli/plugins/site_functions.py | 56 +++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 26659719..e47b80eb 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -69,7 +69,7 @@ def setupDatabase(self, data): ee_replace_dot = ee_domain_name.replace('.', '_') prompt_dbname = self.app.config.get('mysql', 'db-name') prompt_dbuser = self.app.config.get('mysql', 'db-user') - ee_mysql_host = self.app.config.get('mysql', 'grant-host') + ee_mysql_grant_host = self.app.config.get('mysql', 'grant-host') ee_db_name = '' ee_db_username = '' ee_db_password = '' @@ -117,19 +117,20 @@ def setupDatabase(self, data): Log.debug(self, "creating user {0}".format(ee_db_username)) EEMysql.execute(self, "create user {0}@{1} identified by '{2}'" - .format(ee_db_username, ee_mysql_host, ee_db_password)) + .format(ee_db_username, ee_mysql_grant_host, + ee_db_password)) # Grant permission Log.debug(self, "setting up user privileges") EEMysql.execute(self, "grant all privileges on {0}.* to {1}@{2}" - .format(ee_db_name, ee_db_username, ee_mysql_host)) + .format(ee_db_name, ee_db_username, ee_mysql_grant_host)) Log.info(self, "[Done]") data['ee_db_name'] = ee_db_name data['ee_db_user'] = ee_db_username data['ee_db_pass'] = ee_db_password - data['ee_db_host'] = ee_mysql_host + data['ee_db_host'] = EEVariables.ee_mysql_host return(data) @@ -375,3 +376,50 @@ def site_package_check(self, stype): "wp-cli.phar", "/usr/bin/wp", "WP_CLI"]] stack.install(apt_packages=apt_packages, packages=packages) + + +def updateWPuserPassword(self, ee_domain, ee_site_webroot): + + ee_wp_user = '' + ee_wp_pass = '' + EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) + + # Check if ee_domain is wordpress install + is_wp = EEShellExec.cmd_exec(self, "wp --allow-root core" + " version", + errormsg="{0} : Unable to check if wp install" + .format(ee_domain)) + + # Exit if ee_domain is not wordpress install + if not is_wp: + Log.error(self, "{0} does not seem to be a WordPress site" + .format(ee_domain)) + + ee_wp_user = input("Provide WordPress user name [admin]: ") + if ee_wp_user == "?": + Log.info(self, "Fetching WordPress user list") + EEShellExec.cmd_exec(self, "wp --allow-root user list " + "--fields=user_login | grep -v user_login", + errormsg="Unable to Fetch users list") + + if not ee_wp_user: + ee_wp_user = 'admin' + + is_user_exist = EEShellExec.cmd_exec(self, "wp --allow-root user list " + "--fields=user_login | grep {0}$ " + .format(ee_wp_user)) + + if is_user_exist: + ee_wp_pass = input("Provide password for {0} user: " + .format(ee_wp_user)) + if len(ee_wp_pass) < 8: + EEShellExec.cmd_exec(self, "wp --allow-root user update {0}" + " --user_pass={1}" + .format(ee_wp_user, ee_wp_pass)) + Log.info(self, "Password updated successfully") + else: + Log.error(self, "Password Unchanged. Hint : Your password must be " + "8 characters long") + else: + Log.error(self, "Invalid WordPress user {0} for {1}." + .format(ee_wp_user, ee_domain)) From 5da7d3462af0d3ac0e693d7b901e9de6133f9ec0 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 20 Jan 2015 12:23:31 +0530 Subject: [PATCH 678/829] ee import-slow-log done --- config/plugins.d/import_slow_log.conf | 8 ++++ ee/cli/bootstrap.py | 2 - ee/cli/controllers/isl.py | 26 ------------ ee/cli/plugins/import_slow_log.py | 61 +++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 28 deletions(-) create mode 100644 config/plugins.d/import_slow_log.conf delete mode 100644 ee/cli/controllers/isl.py create mode 100644 ee/cli/plugins/import_slow_log.py diff --git a/config/plugins.d/import_slow_log.conf b/config/plugins.d/import_slow_log.conf new file mode 100644 index 00000000..d7841dbe --- /dev/null +++ b/config/plugins.d/import_slow_log.conf @@ -0,0 +1,8 @@ +### Example Plugin Configuration for EasyEngine + +[import_slow_log] + +### If enabled, load a plugin named `example` either from the Python module +### `ee.cli.plugins.example` or from the file path +### `/var/lib/ee/plugins/example.py` +enable_plugin = true diff --git a/ee/cli/bootstrap.py b/ee/cli/bootstrap.py index a14aacd2..a5ce6d75 100644 --- a/ee/cli/bootstrap.py +++ b/ee/cli/bootstrap.py @@ -5,9 +5,7 @@ from cement.core import handler from ee.cli.controllers.base import EEBaseController -from ee.cli.controllers.isl import EEImportslowlogController def load(app): handler.register(EEBaseController) - handler.register(EEImportslowlogController) diff --git a/ee/cli/controllers/isl.py b/ee/cli/controllers/isl.py deleted file mode 100644 index 7ac8d40f..00000000 --- a/ee/cli/controllers/isl.py +++ /dev/null @@ -1,26 +0,0 @@ -from cement.core.controller import CementBaseController, expose - - -class EEImportslowlogController(CementBaseController): - class Meta: - label = 'import_slow_log' - stacked_on = 'base' - stacked_type = 'nested' - description = 'info command used for debugging issued with stack or \ - site specific configuration' - arguments = [ - (['--mysql'], - dict(help='get mysql configuration information', - action='store_true')), - (['--php'], - dict(help='get php configuration information', - action='store_true')), - (['--nginx'], - dict(help='get nginx configuration information', - action='store_true')), - ] - - @expose(hide=True) - def default(self): - # TODO Default action for ee debug command - print("Inside EEImportslowlogController.default().") diff --git a/ee/cli/plugins/import_slow_log.py b/ee/cli/plugins/import_slow_log.py new file mode 100644 index 00000000..a3cda476 --- /dev/null +++ b/ee/cli/plugins/import_slow_log.py @@ -0,0 +1,61 @@ +from cement.core.controller import CementBaseController, expose +from cement.core import handler, hook +from ee.core.shellexec import EEShellExec +from ee.core.logging import Log +import os + + +def import_slow_log_plugin_hook(app): + pass + + +class EEImportslowlogController(CementBaseController): + class Meta: + label = 'import_slow_log' + stacked_on = 'base' + stacked_type = 'nested' + description = 'Import MySQL slow log to Anemometer database' + + @expose(hide=True) + def default(self): + if os.path.isdir("/var/www/22222/htdocs/db/anemometer"): + if os.path.isfile("/var/log/mysql/mysql-slow.log"): + # Get Anemometer user name and password + host = os.popen("grep -e \"\'host\'\" /var/www/22222/htdocs/" + "db/anemometer/conf/config.inc.php " + "| head -1 | cut -d\\\' -f4 | " + "tr -d '\n'").read() + user = os.popen("grep -e \"\'user\'\" /var/www/22222/htdocs/" + "db/anemometer/conf/config.inc.php " + "| head -1 | cut -d\\\' -f4 | " + "tr -d '\n'").read() + password = os.popen("grep -e \"\'password\'\" /var/www/22222/" + "htdocs/db/anemometer/conf/config.inc.php " + "| head -1 | cut -d\\\' -f4 | " + "tr -d '\n'").read() + # Import slow log Anemometer using pt-query-digest + EEShellExec.cmd_exec(self, "pt-query-digest --user={0} " + "--password={1} " + "--review D=slow_query_log," + "t=global_query_review " + "--history D=slow_query_log,t=" + "global_query_review_history " + "--no-report --limit=0% " + "--filter=\" \\$event->{{Bytes}} = " + "length(\\$event->{{arg}}) " + "and \\$event->{{hostname}}=\\\"" + "{2}\\\"\" " + "/var/log/mysql/mysql-slow.log" + .format(user, password, host)) + else: + Log.error(self, "Unable to find MySQL slow log file") + else: + Log.error(self, "Anemometer is not installed") + + +def load(app): + # register the plugin class.. this only happens if the plugin is enabled + handler.register(EEImportslowlogController) + + # register a hook (function) to run after arguments are parsed. + hook.register('post_argument_parsing', import_slow_log_plugin_hook) From 52e7a50283ca8d789aef0643756033b46bb67f71 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 20 Jan 2015 13:04:32 +0530 Subject: [PATCH 679/829] Code clenaup --- config/plugins.d/example.conf | 11 ------- ee/cli/plugins/example.py | 50 ------------------------------- ee/cli/templates/default.mustache | 1 - ee/core/checkpackage.py | 9 ------ ee/core/domaincheck.py | 19 ------------ ee/core/dummy.py | 10 ------- ee/core/info.py | 23 -------------- ee/core/permissions.py | 11 ------- ee/core/swapcreation.py | 8 ----- ee/utils/test.py | 16 ---------- tests/core/test_exc.py | 0 11 files changed, 158 deletions(-) delete mode 100644 config/plugins.d/example.conf delete mode 100644 ee/cli/plugins/example.py delete mode 100644 ee/cli/templates/default.mustache delete mode 100644 ee/core/checkpackage.py delete mode 100644 ee/core/domaincheck.py delete mode 100644 ee/core/dummy.py delete mode 100644 ee/core/info.py delete mode 100644 ee/core/permissions.py delete mode 100644 ee/core/swapcreation.py delete mode 100644 ee/utils/test.py delete mode 100644 tests/core/test_exc.py diff --git a/config/plugins.d/example.conf b/config/plugins.d/example.conf deleted file mode 100644 index b78a2ff5..00000000 --- a/config/plugins.d/example.conf +++ /dev/null @@ -1,11 +0,0 @@ -### Example Plugin Configuration for EasyEngine - -[example] - -### If enabled, load a plugin named `example` either from the Python module -### `ee.cli.plugins.example` or from the file path -### `/var/lib/ee/plugins/example.py` -enable_plugin = false - -### Additional plugin configuration settings -foo = bar diff --git a/ee/cli/plugins/example.py b/ee/cli/plugins/example.py deleted file mode 100644 index 0c3184b3..00000000 --- a/ee/cli/plugins/example.py +++ /dev/null @@ -1,50 +0,0 @@ -"""Example Plugin for EasyEngine.""" - -from cement.core.controller import CementBaseController, expose -from cement.core import handler, hook - -def example_plugin_hook(app): - # do something with the ``app`` object here. - pass - -class ExamplePluginController(CementBaseController): - class Meta: - # name that the controller is displayed at command line - label = 'example' - - # text displayed next to the label in ``--help`` output - description = 'this is an example plugin controller' - - # stack this controller on-top of ``base`` (or any other controller) - stacked_on = 'base' - - # determines whether the controller is nested, or embedded - stacked_type = 'nested' - - # these arguments are only going to display under - # ``$ ee example --help`` - arguments = [ - ( - ['-f', '--foo'], - dict( - help='Notorious foo option', - action='store', - ) - ) - ] - - @expose(hide=True) - def default(self): - print("Inside ExamplePluginController.default()") - - @expose(help="this is an example sub-command.") - def example_plugin_command(self): - print("Inside ExamplePluginController.example_plugin_command()") - - -def load(app): - # register the plugin class.. this only happens if the plugin is enabled - handler.register(ExamplePluginController) - - # register a hook (function) to run after arguments are parsed. - hook.register('post_argument_parsing', example_plugin_hook) diff --git a/ee/cli/templates/default.mustache b/ee/cli/templates/default.mustache deleted file mode 100644 index c3bb921e..00000000 --- a/ee/cli/templates/default.mustache +++ /dev/null @@ -1 +0,0 @@ -Inside {{foo}} diff --git a/ee/core/checkpackage.py b/ee/core/checkpackage.py deleted file mode 100644 index 3d82150e..00000000 --- a/ee/core/checkpackage.py +++ /dev/null @@ -1,9 +0,0 @@ -"""EasyEngine package check module.""" - - -class EEPackageCheck(): - - """Intialization for package check""" - def ___init__(): - # TODO Intialization for package check - pass diff --git a/ee/core/domaincheck.py b/ee/core/domaincheck.py deleted file mode 100644 index ea318af3..00000000 --- a/ee/core/domaincheck.py +++ /dev/null @@ -1,19 +0,0 @@ -"""EasyEngine domain check module.""" - - -class EEDomainCheck(): - - """Intialization domain check""" - def ___init__(): - # TODO Intialization for domain check - pass - - """Check for proper domain""" - def isdomain(): - # TODO method for doamin check - pass - - """Check for proper Fully qualified domain""" - def isfqdn(): - # TODO method for FQDN check - pass diff --git a/ee/core/dummy.py b/ee/core/dummy.py deleted file mode 100644 index 7c260b6b..00000000 --- a/ee/core/dummy.py +++ /dev/null @@ -1,10 +0,0 @@ -"""EasyEngine dummy core classes.""" - - -class EEDummy(): - """Generic errors.""" - def __init__(): - pass - - def dummy(): - print("Dummy Function") diff --git a/ee/core/info.py b/ee/core/info.py deleted file mode 100644 index ce28cee8..00000000 --- a/ee/core/info.py +++ /dev/null @@ -1,23 +0,0 @@ -"""EasyEngine Nginx, PHP, MySQL info module.""" - - -class EEInfo(): - """Intialization for info""" - def ___init__(): - # TODO common method for info - pass - - """Method to disaply info for PHP""" - def infophp(): - # TODO info for php - pass - - """Method to disaply info for Nginx""" - def infonginx(): - # TODO info for Nginx - pass - - """Method to disaply info for MySQL""" - def infomysql(): - # TODO info for MySQL - pass diff --git a/ee/core/permissions.py b/ee/core/permissions.py deleted file mode 100644 index 9de98330..00000000 --- a/ee/core/permissions.py +++ /dev/null @@ -1,11 +0,0 @@ -"""EasyEngine set permission module""" - - -class EESetPermission(): - """Intialization set permission""" - def ___init__(): - # TODO method for set permission - pass - - def setPermissions(self, user, group, path, recursive=False): - pass diff --git a/ee/core/swapcreation.py b/ee/core/swapcreation.py deleted file mode 100644 index ea26542e..00000000 --- a/ee/core/swapcreation.py +++ /dev/null @@ -1,8 +0,0 @@ -"""EasyEngine swap creation module.""" - - -class EESwapCreation(): - """Generice swap creation intialisation""" - def __init__(): - # TODO method for swap creation - pass diff --git a/ee/utils/test.py b/ee/utils/test.py deleted file mode 100644 index c8925e97..00000000 --- a/ee/utils/test.py +++ /dev/null @@ -1,16 +0,0 @@ -"""Testing utilities for EasyEngine.""" - -from ee.cli.main import EETestApp -from cement.utils.test import * - - -class EETestCase(CementTestCase): - app_class = EETestApp - - def setUp(self): - """Override setup actions (for every test).""" - super(EETestCase, self).setUp() - - def tearDown(self): - """Override teardown actions (for every test).""" - super(EETestCase, self).tearDown() diff --git a/tests/core/test_exc.py b/tests/core/test_exc.py deleted file mode 100644 index e69de29b..00000000 From fbad8e7bb22aea819b3e5769263f182f150e575c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 20 Jan 2015 13:52:10 +0530 Subject: [PATCH 680/829] Improved messaging --- ee/cli/plugins/info.py | 6 +++--- ee/core/variables.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/info.py b/ee/cli/plugins/info.py index 346fd57a..cbf8b2e0 100644 --- a/ee/cli/plugins/info.py +++ b/ee/cli/plugins/info.py @@ -174,19 +174,19 @@ class EEInfoController(CementBaseController): if EEAptGet.is_installed(self, 'nginx-common'): self.info_nginx() else: - print("Nginx is not installed") + Log.error(self, "Nginx is not installed") if self.app.pargs.php: if EEAptGet.is_installed(self, 'php5-fpm'): self.info_php() else: - print("PHP5 is installed") + Log.error("PHP5 is not installed") if self.app.pargs.mysql: if EEShellExec.cmd_exec(self, "mysqladmin ping"): self.info_mysql() else: - print("MySQL is not installed") + Log.error("MySQL is not installed") def load(app): diff --git a/ee/core/variables.py b/ee/core/variables.py index 3b0c5cd7..6bc29135 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -44,8 +44,8 @@ class EEVariables(): ee_user = config['user']['name'] ee_email = config['user']['email'] except Exception as e: - print("Unable to find GIT user name and Email") - sys.exit(1) + ee_user = input("Enter username for Git:") + ee_email = input("Enter email for Git:") # Get System RAM and SWAP details ee_ram = psutil.virtual_memory().total / (1024 * 1024) From aa36506775ef62758b964321deb225c0742ad386 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 20 Jan 2015 15:37:12 +0530 Subject: [PATCH 681/829] Changed some display messages --- ee/cli/controllers/base.py | 6 ++-- ee/cli/plugins/clean.py | 52 +++++++++++++++---------------- ee/cli/plugins/debug.py | 41 ++++++++++++------------ ee/cli/plugins/import_slow_log.py | 2 ++ ee/cli/plugins/info.py | 10 +++--- ee/cli/plugins/secure.py | 20 ++++++------ ee/cli/plugins/site.py | 34 ++++++++++---------- ee/cli/plugins/site_functions.py | 34 ++++++++++---------- ee/cli/plugins/sitedb.py | 6 ++-- ee/cli/plugins/stack_services.py | 12 +++---- ee/core/addswap.py | 1 + ee/core/apt_repo.py | 3 +- ee/core/database.py | 3 +- ee/core/domainvalidate.py | 1 + ee/core/git.py | 3 +- ee/core/logging.py | 1 + ee/core/shellexec.py | 4 +-- ee/core/symboliclink.py | 8 ----- 18 files changed, 119 insertions(+), 122 deletions(-) delete mode 100644 ee/core/symboliclink.py diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index b19b224a..95118c6e 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -6,9 +6,9 @@ from cement.core.controller import CementBaseController, expose class EEBaseController(CementBaseController): class Meta: label = 'base' - description = ("easyengine is the commandline tool to manage your" - " websites based on wordpress and nginx with easy to" - " use commands.") + description = ("EasyEngine is the commandline tool to manage your" + " websites based on WordPress and Nginx with easy to" + " use commands") @expose(hide=True) def default(self): diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index a61e6fd6..2d6ab8dd 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -1,11 +1,13 @@ +"""Clean Plugin for EasyEngine.""" + from ee.core.shellexec import EEShellExec from ee.core.aptget import EEAptGet from ee.core.services import EEService +from ee.core.logging import Log from cement.core.controller import CementBaseController, expose from cement.core import handler, hook import os import urllib.request -from ee.core.logging import Log def clean_plugin_hook(app): @@ -18,52 +20,50 @@ class EECleanController(CementBaseController): label = 'clean' stacked_on = 'base' stacked_type = 'nested' - description = ('clean command cleans different cache with following ' - 'options') + description = ('Clean NGINX FastCGI cache, Opcacache, Memcache') arguments = [ (['--all'], - dict(help='clean all cache', action='store_true')), + dict(help='Clean all cache', action='store_true')), (['--fastcgi'], - dict(help='clean fastcgi cache', action='store_true')), + dict(help='Clean FastCGI cache', action='store_true')), (['--memcache'], - dict(help='clean memcache', action='store_true')), + dict(help='Clean MemCache', action='store_true')), (['--opcache'], - dict(help='clean opcode cache cache', action='store_true')) + dict(help='Clean OpCache', action='store_true')) ] @expose(hide=True) def default(self): - # TODO Default action for ee clean command here - if (not (self.app.pargs.all or self.app.pargs.fastcgi or - self.app.pargs.memcache or self.app.pargs.opcache)): - self.clean_fastcgi() - if self.app.pargs.all: - self.clean_memcache() - self.clean_fastcgi() - self.clean_opcache() - if self.app.pargs.fastcgi: - self.clean_fastcgi() - if self.app.pargs.memcache: - self.clean_memcache() - if self.app.pargs.opcache: - self.clean_opcache() + if (not (self.app.pargs.all or self.app.pargs.fastcgi or + self.app.pargs.memcache or self.app.pargs.opcache)): + self.clean_fastcgi() + if self.app.pargs.all: + self.clean_memcache() + self.clean_fastcgi() + self.clean_opcache() + if self.app.pargs.fastcgi: + self.clean_fastcgi() + if self.app.pargs.memcache: + self.clean_memcache() + if self.app.pargs.opcache: + self.clean_opcache() @expose(hide=True) def clean_memcache(self): try: if(EEAptGet.is_installed("memcached")): EEService.restart_service(self, "memcached") - Log.info(self, "Cleaning memcache...") + Log.info(self, "Cleaning MemCache") else: Log.error(self, "Memcache not installed") except Exception as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to restart memcached") + Log.error(self, "Unable to restart Memcached") @expose(hide=True) def clean_fastcgi(self): if(os.path.isdir("/var/run/nginx-cache")): - Log.info(self, "Cleaning NGINX FastCGI cache, please wait...") + Log.info(self, "Cleaning NGINX FastCGI cache") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") else: Log.error(self, "Unable to clean FastCGI cache") @@ -71,12 +71,12 @@ class EECleanController(CementBaseController): @expose(hide=True) def clean_opcache(self): try: - Log.info(self, "Cleaning opcache... ") + Log.info(self, "Cleaning opcache") wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" "/opcache/opgui.php?page=reset").read() except Exception as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to clean opacache") + Log.error(self, "Unable to clean OpCache") def load(app): diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 2beb5d50..930cf496 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -1,12 +1,12 @@ -"""Debug Plugin for EasyEngine.""" +"""Debug Plugin for EasyEngine""" from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.shellexec import EEShellExec from ee.core.mysql import EEMysql from ee.core.services import EEService -import os from ee.core.logging import Log +import os def debug_plugin_hook(app): @@ -17,7 +17,7 @@ def debug_plugin_hook(app): class EEDebugController(CementBaseController): class Meta: label = 'debug' - description = 'debug command enables/disbaled stack debug' + description = 'Used for server level debugging' stacked_on = 'base' stacked_type = 'nested' arguments = [ @@ -58,7 +58,7 @@ class EEDebugController(CementBaseController): for ip_addr in debug_address: if not ("debug_connection "+ip_addr in open('/etc/nginx/' 'nginx.conf').read()): - Log.info(self, "Setting up NGINX debug connection" + Log.info(self, "Setting up Nginx debug connection" " for "+ip_addr) EEShellExec.cmd_exec(self, "sed -i \"/events {{/a\\ \\ \\ " "\\ $(echo debug_connection " @@ -67,7 +67,7 @@ class EEDebugController(CementBaseController): self.trigger_nginx = True if not self.trigger_nginx: - Log.info(self, "NGINX debug connection already enabled") + Log.info(self, "Nginx debug connection already enabled") self.msg = self.msg + [" /var/log/nginx/*.error.log"] @@ -79,7 +79,7 @@ class EEDebugController(CementBaseController): " /etc/nginx/nginx.conf") self.trigger_nginx = True else: - Log.info(self, "Nginx debug connection already disbaled") + Log.info(self, "Nginx debug connection already disabled") # start site specific debug elif self.start and self.app.pargs.site_name: @@ -120,7 +120,7 @@ class EEDebugController(CementBaseController): else: - Log.info(self, "Debug for site allready disbaled") + Log.info(self, "Debug for site allready disabled") else: Log.info(self, "{0} domain not valid" .format(self.app.pargs.site_name)) @@ -135,7 +135,7 @@ class EEDebugController(CementBaseController): "| grep 9001")): Log.info(self, "Enabling PHP debug") data = dict(php="9001", debug="9001") - Log.info(self, 'writting the nginx configration to file' + Log.info(self, 'Writting the Nginx debug configration to file ' '/etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) @@ -153,14 +153,14 @@ class EEDebugController(CementBaseController): "| grep 9001"): Log.info(self, "Disabling PHP debug") data = dict(php="9000", debug="9001") - Log.info(self, 'writting the nginx configration to file' + Log.info(self, 'Writting the Nginx debug configration to file ' '/etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() self.trigger_php = True else: - Log.info(self, "PHP debug is allready disbaled") + Log.info(self, "PHP debug is allready disabled") @expose(hide=True) def debug_fpm(self): @@ -187,8 +187,7 @@ class EEDebugController(CementBaseController): "/php-fpm.conf") self.trigger_php = True else: - Log.info(self, "PHP5-FPM log_level = debug " - " already disabled") + Log.info(self, "PHP5-FPM log_level = debug already disabled") @expose(hide=True) def debug_mysql(self): @@ -291,12 +290,12 @@ class EEDebugController(CementBaseController): "SAVEQUERIES\', " "true);/d\" {0}".format(wp_config)) else: - Log.info(self, "WordPress debug all already disbaled") + Log.info(self, "WordPress debug all already disabled") else: - Log.info(self, "{0} domain not valid" - .format(self.app.pargs.site_name)) + Log.error(self, "{0} domain not valid" + .format(self.app.pargs.site_name)) else: - Log.info(self, "Missing argument site_name") + Log.error(self, "Missing argument site name") @expose(hide=True) def debug_rewrite(self): @@ -309,7 +308,7 @@ class EEDebugController(CementBaseController): "rewrite_log on;\' /etc/nginx/nginx.conf") self.trigger_nginx = True else: - Log.info(self, "NGINX rewrite logs already enabled") + Log.info(self, "Nginx rewrite logs already enabled") if '/var/log/nginx/*.error.log' not in self.msg: self.msg = self.msg + ['/var/log/nginx/*.error.log'] @@ -323,14 +322,14 @@ class EEDebugController(CementBaseController): " /etc/nginx/nginx.conf") self.trigger_nginx = True else: - Log.info(self, "NGINX rewrite logs already disbaled") + Log.info(self, "Nginx rewrite logs already disabled") # Start Nginx rewrite for site elif self.start and self.app.pargs.site_name: config_path = ("/etc/nginx/sites-available/{0}.conf" .format(self.app.pargs.site_name)) if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" .format(config_path)): - Log.info(self, "Setting up NGINX rewrite logs for {0}" + Log.info(self, "Setting up Nginx rewrite logs for {0}" .format(self.app.pargs.site_name)) EEShellExec.cmd_exec(self, "sed -i \"/access_log/i \\\\\\t" "rewrite_log on;\" {0}" @@ -351,14 +350,14 @@ class EEDebugController(CementBaseController): .format(self.app.pargs.site_name)) if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" .format(config_path)): - Log.info(self, "Disabling NGINX rewrite logs for {0}" + Log.info(self, "Disabling Nginx rewrite logs for {0}" .format(self.app.pargs.site_name)) EEShellExec.cmd_exec(self, "sed -i \"/rewrite_log.*/d\" {0}" .format(config_path)) self.trigger_nginx = True else: Log.info(self, "Nginx rewrite logs for {0} allready " - " disbaled".format(self.app.pargs.site_name)) + " disabled".format(self.app.pargs.site_name)) @expose(hide=True) def default(self): diff --git a/ee/cli/plugins/import_slow_log.py b/ee/cli/plugins/import_slow_log.py index a3cda476..72cd395c 100644 --- a/ee/cli/plugins/import_slow_log.py +++ b/ee/cli/plugins/import_slow_log.py @@ -21,6 +21,7 @@ class EEImportslowlogController(CementBaseController): if os.path.isdir("/var/www/22222/htdocs/db/anemometer"): if os.path.isfile("/var/log/mysql/mysql-slow.log"): # Get Anemometer user name and password + Log.error(self, "Importing MySQL slow log to Anemometer") host = os.popen("grep -e \"\'host\'\" /var/www/22222/htdocs/" "db/anemometer/conf/config.inc.php " "| head -1 | cut -d\\\' -f4 | " @@ -33,6 +34,7 @@ class EEImportslowlogController(CementBaseController): "htdocs/db/anemometer/conf/config.inc.php " "| head -1 | cut -d\\\' -f4 | " "tr -d '\n'").read() + # Import slow log Anemometer using pt-query-digest EEShellExec.cmd_exec(self, "pt-query-digest --user={0} " "--password={1} " diff --git a/ee/cli/plugins/info.py b/ee/cli/plugins/info.py index cbf8b2e0..8ba76f44 100644 --- a/ee/cli/plugins/info.py +++ b/ee/cli/plugins/info.py @@ -19,17 +19,17 @@ class EEInfoController(CementBaseController): label = 'info' stacked_on = 'base' stacked_type = 'nested' - description = 'info command used for debugging issued with stack or \ - site specific configuration' + description = ('Display configuration information related to Nginx,' + ' PHP and MySQL') arguments = [ (['--mysql'], - dict(help='get mysql configuration information', + dict(help='Get MySQL configuration information', action='store_true')), (['--php'], - dict(help='get php configuration information', + dict(help='Get PHP configuration information', action='store_true')), (['--nginx'], - dict(help='get nginx configuration information', + dict(help='Get Nginx configuration information', action='store_true')), ] diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index fc336e77..9fe1f5e9 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -2,12 +2,12 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables +from ee.core.logging import Log import string import random import sys import hashlib import getpass -from ee.core.logging import Log def secure_plugin_hook(app): @@ -15,7 +15,7 @@ def secure_plugin_hook(app): pass -class EEsecureController(CementBaseController): +class EESecureController(CementBaseController): class Meta: label = 'secure' stacked_on = 'base' @@ -43,8 +43,8 @@ class EEsecureController(CementBaseController): @expose(hide=True) def secure_auth(self): passwd = ''.join([random.choice - (string.ascii_letters + string.digits) - for n in range(6)]) + (string.ascii_letters + string.digits) + for n in range(6)]) username = input("Provide HTTP authentication user " "name [{0}] :".format(EEVariables.ee_user)) password = input("Provide HTTP authentication " @@ -75,20 +75,18 @@ class EEsecureController(CementBaseController): "/etc/nginx/sites-available/22222" .format(port=port)) else: - Log.info(self, "Unable to change EasyEngine admin port{0}" - .format("[FAIL]")) + Log.error(self, "Unable to change EasyEngine admin port") if EEVariables.ee_platform_distro == 'Debian': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl;/\" " "/etc/nginx/sites-available/22222" .format(port=port)) else: - Log.info(self, "Unable to change EasyEngine admin port{0}" - .format("[FAIL]")) + Log.error(self, "Unable to change EasyEngine admin port") @expose(hide=True) def secure_ip(self): - #TODO:remaining with ee.conf updation in file + # TODO:remaining with ee.conf updation in file newlist = [] ip = input("Enter the comma separated IP addresses " "to white list [127.0.0.1]:") @@ -102,7 +100,7 @@ class EEsecureController(CementBaseController): for check_ip in user_list_ip: if check_ip not in exist_ip_list: newlist.extend(exist_ip_list) - # changes in acl.conf file + # changes in acl.conf file if len(newlist) != 0: EEShellExec.cmd_exec(self, "sed -i \"/allow.*/d\" /etc/nginx" "/common/acl.conf") @@ -115,6 +113,6 @@ class EEsecureController(CementBaseController): def load(app): # register the plugin class.. this only happens if the plugin is enabled - handler.register(EEsecureController) + handler.register(EESecureController) # register a hook (function) to run after arguments are parsed. hook.register('post_argument_parsing', secure_plugin_hook) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index b78de277..beaa51be 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -8,11 +8,11 @@ from ee.cli.plugins.site_functions import * from ee.core.services import EEService from ee.cli.plugins.sitedb import * from ee.core.git import EEGit +from subprocess import Popen import sys import os import glob import subprocess -from subprocess import Popen def ee_site_hook(app): @@ -26,18 +26,18 @@ class EESiteController(CementBaseController): label = 'site' stacked_on = 'base' stacked_type = 'nested' - description = ('site command manages website configuration' + description = ('Site command manages website configuration' ' with the help of the following subcommands') arguments = [ (['site_name'], - dict(help='website name')), + dict(help='Website name')), ] @expose(hide=True) def default(self): self.app.args.print_help() - @expose(help="enable site example.com") + @expose(help="Enable site example.com") def enable(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) if os.path.isfile('/etc/nginx/sites-available/{0}' @@ -51,7 +51,7 @@ class EESiteController(CementBaseController): else: Log.error(self, " site {0} does not exists".format(ee_domain)) - @expose(help="disable site example.com") + @expose(help="Disable site example.com") def disable(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) if os.path.isfile('/etc/nginx/sites-available/{0}' @@ -63,7 +63,7 @@ class EESiteController(CementBaseController): else: Log.error(self, " site {0} does not exists".format(ee_domain)) - @expose(help="get example.com information") + @expose(help="Get example.com information") def info(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_db_name = '' @@ -105,7 +105,7 @@ class EESiteController(CementBaseController): else: Log.error(self, " site {0} does not exists".format(ee_domain)) - @expose(help="Edit example.com's nginx configuration") + @expose(help="Edit Nginx configuration of example.com") def edit(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) if os.path.isfile('/etc/nginx/sites-available/{0}' @@ -121,7 +121,7 @@ class EESiteController(CementBaseController): else: Log.error(self, " site {0} does not exists".format(ee_domain)) - @expose(help="Display example.com's nginx configuration") + @expose(help="Display Nginx configuration of example.com") def show(self): # TODO Write code for ee site edit command here (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -136,7 +136,7 @@ class EESiteController(CementBaseController): else: Log.error(self, " site {0} does not exists".format(ee_domain)) - @expose(help="change directory to site webroot") + @expose(help="Change directory to site webroot") def cd(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -454,7 +454,7 @@ class EESiteUpdateController(CementBaseController): label = 'update' stacked_on = 'site' stacked_type = 'nested' - description = 'update command manages website configuration with the \ + description = 'Update command manages website configuration with the \ help of the following subcommands' arguments = [ (['site_name'], @@ -480,7 +480,7 @@ class EESiteUpdateController(CementBaseController): dict(help="update to wpsc cache", action='store_true')), ] - @expose(help="update site type or cache") + @expose(help="Update site type or cache") def default(self): (ee_domain, ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) @@ -875,7 +875,7 @@ class EESiteDeleteController(CementBaseController): label = 'delete' stacked_on = 'site' stacked_type = 'nested' - description = 'delete command deletes website' + description = 'To delete website' arguments = [ (['site_name'], dict(help='domain name to be deleted')), @@ -890,7 +890,7 @@ class EESiteDeleteController(CementBaseController): dict(help="delete webroot only", action='store_true')), ] - @expose(help="delete site") + @expose(help="Delete site") def default(self): # TODO Write code for ee site update here (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -999,15 +999,15 @@ class EESiteListController(CementBaseController): label = 'list' stacked_on = 'site' stacked_type = 'nested' - description = 'list websites' + description = 'List websites' arguments = [ (['--enabled'], - dict(help='list enabled sites', action='store_true')), + dict(help='List enabled websites', action='store_true')), (['--disabled'], - dict(help="list disabled sites", action='store_true')), + dict(help="List disabled websites", action='store_true')), ] - @expose(help="delete example.com") + @expose(help="Delete example.com") def default(self): sites = getAllsites(self) if not sites: diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index e47b80eb..1c592e95 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -1,8 +1,3 @@ -import os -import random -import string -import sys -import getpass from ee.cli.plugins.stack import EEStackController from ee.core.fileutils import EEFileUtils from ee.core.mysql import EEMysql @@ -10,6 +5,11 @@ from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables from ee.core.aptget import EEAptGet from ee.core.logging import Log +import os +import random +import string +import sys +import getpass import glob @@ -109,19 +109,19 @@ def setupDatabase(self, data): # create MySQL database Log.info(self, "Setting Up Database ", 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}" .format(ee_db_name)) # Create MySQL User - Log.debug(self, "creating user {0}".format(ee_db_username)) + Log.debug(self, "Creating user {0}".format(ee_db_username)) EEMysql.execute(self, "create user {0}@{1} identified by '{2}'" .format(ee_db_username, ee_mysql_grant_host, ee_db_password)) # Grant permission - Log.debug(self, "setting up user privileges") + Log.debug(self, "Setting up user privileges") EEMysql.execute(self, "grant all privileges on {0}.* to {1}@{2}" .format(ee_db_name, ee_db_username, ee_mysql_grant_host)) @@ -200,14 +200,14 @@ def setupWordpress(self, data): if not ee_wp_user: ee_wp_user = EEVariables.ee_user while not ee_wp_user: - Log.warn(self, "Usernames can have only alphanumeric" + Log.warn(self, "Username can have only alphanumeric" "characters, spaces, underscores, hyphens," "periods and the @ symbol.") try: ee_wp_user = input('Enter WordPress username: ') except EOFError as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to input wp user name") + Log.error(self, "Unable to input WordPress user name") if not ee_wp_pass: ee_wp_pass = ee_random @@ -219,12 +219,12 @@ def setupWordpress(self, data): ee_wp_email = input('Enter WordPress email: ') except EOFError as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to input wp user email") + Log.error(self, "Unable to input WordPress user email") - Log.debug(self, "setting up WordPress Tables") + Log.debug(self, "Setting up WordPress tables") if not data['multisite']: - Log.debug(self, "creating tables for WordPress Single site") + Log.debug(self, "Creating tables for WordPress Single site") EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install " "--url={0} --title={0} --admin_name={1} " .format(data['www_domain'], ee_wp_user) @@ -232,7 +232,7 @@ def setupWordpress(self, data): .format(ee_wp_pass, ee_wp_email), errormsg="Unable to setup WordPress Tables") else: - Log.debug(self, "creating tables for WordPress multisite") + Log.debug(self, "Creating tables for WordPress multisite") EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root " "core multisite-install " "--url={0} --title={0} --admin_name={1} " @@ -306,7 +306,7 @@ def uninstallWP_Plugin(self, plugin_name, data): def SetWebrootPermissions(self, webroot): - Log.debug(self, "Setting Up Permissions...") + Log.debug(self, "Setting up permissions...") EEFileUtils.chown(self, webroot, EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) @@ -316,7 +316,7 @@ def siteBackup(self, data): backup_path = ee_site_webroot + '/backup/{0}'.format(EEVariables.ee_date) if not EEFileUtils.isexist(self, backup_path): EEFileUtils.mkdir(self, backup_path) - Log.info(self, "Backup Location : {0}".format(backup_path)) + Log.info(self, "Backup location : {0}".format(backup_path)) EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}' .format(data['site_name']), backup_path) @@ -331,7 +331,7 @@ def siteBackup(self, data): ee_db_name = (EEFileUtils.grep(self, configfiles[0], 'DB_NAME').split(',')[1] .split(')')[0].strip().replace('\'', '')) - Log.info(self, 'Backing up Database ', end='') + Log.info(self, 'Backing up database ', end='') EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" .format(ee_db_name, backup_path), errormsg="\nFailed: Backup Database") diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index 318beb46..27914562 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -3,9 +3,9 @@ from sqlalchemy import ForeignKey, func from sqlalchemy.orm import relationship, backref from sqlalchemy.ext.declarative import declarative_base from ee.core.logging import Log -import sys from ee.core.database import db_session from ee.core.models import SiteDB +import sys def addNewSite(self, site, stype, cache, path, @@ -60,7 +60,7 @@ def deleteSiteInfo(self, site): q = SiteDB.query.filter(SiteDB.sitename == site).first() except Exception as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to query database :") + Log.error(self, "Unable to query database") try: db_session.delete(q) db_session.commit() @@ -75,4 +75,4 @@ def getAllsites(self): return q except Exception as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to query database :") + Log.error(self, "Unable to query database") diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index b226cddb..a4de41ff 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -9,7 +9,7 @@ class EEStackStatusController(CementBaseController): label = 'stack_services' stacked_on = 'stack' stacked_type = 'embedded' - description = 'stack command manages stack operations' + description = 'Get status of stack' arguments = [ (['--memcache'], dict(help='start/stop/restart stack', action='store_true')), @@ -17,7 +17,7 @@ class EEStackStatusController(CementBaseController): dict(help='start/stop/restart dovecot', action='store_true')), ] - @expose(help="start stack services") + @expose(help="Start stack services") def start(self): services = [] if self.app.pargs.nginx: @@ -44,7 +44,7 @@ class EEStackStatusController(CementBaseController): for service in services: EEService.start_service(self, service) - @expose(help="stop stack services") + @expose(help="Stop stack services") def stop(self): services = [] if self.app.pargs.nginx: @@ -71,7 +71,7 @@ class EEStackStatusController(CementBaseController): for service in services: EEService.stop_service(self, service) - @expose(help="restart stack services") + @expose(help="Restart stack services") def restart(self): services = [] if self.app.pargs.nginx: @@ -98,7 +98,7 @@ class EEStackStatusController(CementBaseController): Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart") EEService.restart_service(self, service) - @expose(help="get stack status") + @expose(help="Get stack status") def status(self): services = [] if self.app.pargs.nginx: @@ -126,7 +126,7 @@ class EEStackStatusController(CementBaseController): if EEService.get_service_status(self, service): Log.info(self, "{0:10}: {1}".format(service, "Running")) - @expose(help="reload stack services") + @expose(help="Reload stack services") def reload(self): services = [] if self.app.pargs.nginx: diff --git a/ee/core/addswap.py b/ee/core/addswap.py index b1727a9a..37291a24 100644 --- a/ee/core/addswap.py +++ b/ee/core/addswap.py @@ -1,3 +1,4 @@ +"""EasyEngine SWAP creation""" from ee.core.variables import EEVariables from ee.core.shellexec import EEShellExec from ee.core.fileutils import EEFileUtils diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index bdf17cfd..9b00fdd4 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -1,6 +1,7 @@ -import os +"""EasyEngine packages repository operations""" from ee.core.shellexec import EEShellExec from ee.core.variables import EEVariables +import os class EERepo(): diff --git a/ee/core/database.py b/ee/core/database.py index 1cac3452..1f06617c 100644 --- a/ee/core/database.py +++ b/ee/core/database.py @@ -1,8 +1,9 @@ +"""EasyEngine generic database creation module""" from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy.ext.declarative import declarative_base -#db_path = self.app.config.get('site', 'db_path') +# db_path = self.app.config.get('site', 'db_path') engine = create_engine('sqlite:////var/lib/ee/ee.sqlite', convert_unicode=True) db_session = scoped_session(sessionmaker(autocommit=False, autoflush=False, diff --git a/ee/core/domainvalidate.py b/ee/core/domainvalidate.py index f110d5ce..2f7eef6a 100644 --- a/ee/core/domainvalidate.py +++ b/ee/core/domainvalidate.py @@ -1,3 +1,4 @@ +"""EasyEngine domain validation module.""" from urllib.parse import urlparse diff --git a/ee/core/git.py b/ee/core/git.py index 3863719f..430a4f3f 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -1,6 +1,7 @@ +"""EasyEngine GIT module""" from sh import git, ErrorReturnCode -import os from ee.core.logging import Log +import os class EEGit: diff --git a/ee/core/logging.py b/ee/core/logging.py index 56847a38..69c2c3bc 100644 --- a/ee/core/logging.py +++ b/ee/core/logging.py @@ -1,3 +1,4 @@ +"""EasyEngine log module""" class Log: diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index ed0d4691..8f16044e 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -1,9 +1,9 @@ """EasyEngine shell executaion functions.""" +from subprocess import Popen +from ee.core.logging import Log import os import sys import subprocess -from subprocess import Popen -from ee.core.logging import Log class EEShellExec(): diff --git a/ee/core/symboliclink.py b/ee/core/symboliclink.py deleted file mode 100644 index 7cacd2d8..00000000 --- a/ee/core/symboliclink.py +++ /dev/null @@ -1,8 +0,0 @@ -"""EasyEngine symbolic link creation module""" - - -class EESymbolicLink(): - """Intialization for symbolic link""" - def ___init__(): - # TODO method for symbolic link - pass From e648e0f8e001e26159f5c6556df217def62638f5 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 15:50:30 +0530 Subject: [PATCH 682/829] fixed web purge --- ee/core/apt_repo.py | 9 ++++----- ee/core/aptget.py | 30 +++++++++++++++--------------- ee/core/variables.py | 4 ++-- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index bdf17cfd..71a0b450 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -11,7 +11,6 @@ class EERepo(): pass def add(self, repo_url=None, ppa=None): - # TODO add repository code if repo_url is not None: repo_file_path = ("/etc/apt/sources.list.d/" @@ -27,10 +26,11 @@ class EERepo(): repofile.close() return True except IOError as e: - print("File I/O error({0}): {1}".format(e.errno, e.strerror)) + Log.debug(self, "{0}".format(e)) + Log.error(self, "File I/O error.") except Exception as e: - print("{error}".format(error=e)) - return False + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to add repo") if ppa is not None: if EEVariables.ee_platform_distro == 'squeeze': print("Cannot add repo for {distro}" @@ -41,7 +41,6 @@ class EERepo(): .format(ppa_name=ppa)) def remove(self, repo_url=None): - # TODO remove repository EEShellExec.cmd_exec(self, "add-apt-repository -y " "--remove '{ppa_name}'" .format(ppa_name=repo_url)) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index cfa7509c..d81cb876 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -59,7 +59,7 @@ class EEAptGet(): .format(space=cache.required_space)) try: # Commit changes in cache (actually install) - cache.commit(fprogress, iprogress) + cache.commit(fprogress, iprogres) except Exception as e: print("package installation failed. [{err}]" .format(err=str(e))) @@ -111,8 +111,8 @@ class EEAptGet(): .format(pkg_install_count=cache.install_count)) print("Need to get {req_download} bytes of archives" .format(req_download=cache.required_download)) - print("After this operation, {space} bytes of" - "additional disk space will be used." + print("After this operation, {space:.2f} MB of" + " additional disk space will be used." .format(space=cache.required_space/1e6)) try: # Commit changes in cache (actually install) @@ -182,16 +182,16 @@ class EEAptGet(): # Mark for deletion the first package, to fire up # auto_removable Purge? - for dep in onelevel: - my_selected_packages.append(dep.name) - try: - if purge: - dep.mark_delete(purge=True) - else: - dep.mark_delete(purge=False) - except SystemError as e: - Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to purge depedencies.") + # for dep in onelevel: + # my_selected_packages.append(dep.name) + # try: + # if purge: + # dep.mark_delete(purge=True) + # else: + # dep.mark_delete(purge=False) + # except SystemError as e: + # Log.debug(self, "{0}".format(e)) + # Log.error(self, "Unable to purge depedencies.") try: if purge: @@ -211,8 +211,8 @@ class EEAptGet(): print("{pkg_remove_count} to remove." .format(pkg_remove_count=cache.delete_count)) # app.log.debug('bytes disk space will be freed') - print("After this operation, {space} bytes disk spac" - "e will be freed.".format(space=cache.required_space)) + print("After this operation, {space:.2f} MB disk space " + "will be freed.".format(space=cache.required_space/1e6)) try: cache.commit(fprogress, iprogress) except Exception as e: diff --git a/ee/core/variables.py b/ee/core/variables.py index 3b0c5cd7..262bf730 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -81,9 +81,9 @@ class EEVariables(): elif ee_platform_codename == 'wheezy': ee_php_repo = ("deb http://packages.dotdeb.org {codename}-php55 all" .format(codename=ee_platform_codename)) - ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-cli", "php5-imap", + ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap", "php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", - "php5-mysql", "memcached"] + "php5-mysql", "php5-cli", "memcached"] # MySQL repo and packages ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main" From 7b3ad70202988c4aea57d321d145d716ef185d12 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 15:52:58 +0530 Subject: [PATCH 683/829] minor change --- ee/core/aptget.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index d81cb876..13bc70d4 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -182,16 +182,16 @@ class EEAptGet(): # Mark for deletion the first package, to fire up # auto_removable Purge? - # for dep in onelevel: - # my_selected_packages.append(dep.name) - # try: - # if purge: - # dep.mark_delete(purge=True) - # else: - # dep.mark_delete(purge=False) - # except SystemError as e: - # Log.debug(self, "{0}".format(e)) - # Log.error(self, "Unable to purge depedencies.") + for dep in onelevel: + my_selected_packages.append(dep.name) + try: + if purge: + dep.mark_delete(purge=True) + else: + dep.mark_delete(purge=False) + except SystemError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to purge depedencies.") try: if purge: From 47f6b87365dd2a222cfcc6f2dec45be038310405 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 16:01:59 +0530 Subject: [PATCH 684/829] modified function name according to pep --- ee/cli/plugins/site.py | 179 +++++++++++++++++-------------- ee/cli/plugins/site_functions.py | 51 ++++----- ee/cli/plugins/sitedb.py | 8 ++ ee/cli/plugins/stack_services.py | 14 +-- ee/core/aptget.py | 1 - ee/core/mysql.py | 8 +- 6 files changed, 147 insertions(+), 114 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index b78de277..e71cbdd8 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -131,7 +131,7 @@ class EESiteController(CementBaseController): .format(ee_domain)) f = open('/etc/nginx/sites-available/{0}'.format(ee_domain), "r") text = f.read() - print(text) + Log.info(self, Log.ENDC + text) f.close() else: Log.error(self, " site {0} does not exists".format(ee_domain)) @@ -156,8 +156,8 @@ class EESiteCreateController(CementBaseController): label = 'create' stacked_on = 'site' stacked_type = 'nested' - description = 'create command manages website configuration with the \ - help of the following subcommands' + description = ('this commands set up configuration and installs ' + 'required files as options are provided') arguments = [ (['site_name'], dict(help='domain name for the site to be created.')), @@ -191,6 +191,7 @@ class EESiteCreateController(CementBaseController): def default(self): # self.app.render((data), 'default.mustache') # Check domain name validation + data = '' (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = EEVariables.ee_webroot + ee_domain @@ -406,10 +407,10 @@ class EESiteCreateController(CementBaseController): # Check rerequired packages are installed or not site_package_check(self, stype) # setup NGINX configuration, and webroot - setupDomain(self, data) + setupdomain(self, data) # Setup database for MySQL site if 'ee_db_name' in data.keys() and not data['wp']: - data = setupDatabase(self, data) + data = setupdatabase(self, data) try: eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), 'w') @@ -430,7 +431,7 @@ class EESiteCreateController(CementBaseController): # Setup WordPress if Wordpress site if data['wp']: - ee_wp_creds = setupWordpress(self, data) + ee_wp_creds = setupwordpress(self, data) # Service Nginx Reload EEService.reload_service(self, 'nginx') @@ -438,11 +439,11 @@ class EESiteCreateController(CementBaseController): msg="{0} created with {1} {2}" .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot - SetWebrootPermissions(self, data['webroot']) + setwebrootpermissions(self, data['webroot']) if data['wp']: - Log.info(self, '\033[94m'+"WordPress Admin User :" - " {0}".format(ee_wp_creds['wp_user'])+'\033[0m') - Log.info(self, "WordPress Admin User Password : {0}" + Log.info(self, Log.ENDC + "WordPress Admin User :" + " {0}".format(ee_wp_creds['wp_user'])) + Log.info(self, Log.ENDC + "WordPress Admin User Password : {0}" .format(ee_wp_creds['wp_pass'])) addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot) Log.info(self, "Successfully created site" @@ -454,11 +455,14 @@ class EESiteUpdateController(CementBaseController): label = 'update' stacked_on = 'site' stacked_type = 'nested' - description = 'update command manages website configuration with the \ - help of the following subcommands' + description = ('this command updates websites configuration to ' + 'another as per the options are provided') arguments = [ (['site_name'], dict(help='domain name for the site to be updated')), + (['--password'], + dict(help="update to password for wordpress site user", + action='store_true')), (['--html'], dict(help="update to html site", action='store_true')), (['--php'], @@ -482,6 +486,7 @@ class EESiteUpdateController(CementBaseController): @expose(help="update site type or cache") def default(self): + data = '' (ee_domain, ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = EEVariables.ee_webroot + ee_domain @@ -494,13 +499,20 @@ class EESiteUpdateController(CementBaseController): oldsitetype = check_site.site_type oldcachetype = check_site.cache_type - print(oldsitetype, oldcachetype) + if (self.app.pargs.password and not (self.app.pargs.html or + self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or + self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc + or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): + + updatewpuserpassword(self, ee_domain, ee_site_webroot) + self.app.close(0) if (self.app.pargs.html and not (self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wp or self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc or self.app.pargs.wpsubdir or self.app.pargs.wpsubdomain)): - pass + Log.error(self, " Cannot update {0} {1} to html" + .format(ee_domain, oldsitetype)) # PHP if (self.app.pargs.php and not (self.app.pargs.html or @@ -549,8 +561,8 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wp and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - if ((oldsitetype in ['html', 'php', 'mysql', 'wp']) - and (oldcachetype not in ['w3tc', 'wpfc', 'wpsc'])): + if ((oldsitetype not in ['html', 'php', 'mysql', 'wp']) + or (oldsitetype is 'wp' and oldcachetype is 'basic')): print(oldsitetype, oldcachetype) Log.error(self, " Cannot update {0}, {1} {2} to wp basic" .format(ee_domain, oldsitetype, oldcachetype)) @@ -568,9 +580,9 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp'] - and oldcachetype not in ['basic', 'wpfc', 'wpsc']): - Log.error(self, " Cannot update {0}, {1} {2}to wp w3tc" + if (oldsitetype not in ['html', 'php', 'mysql', 'wp'] + or (oldsitetype is 'wp' and oldcachetype is 'w3tc')): + Log.error(self, " Cannot update {0}, {1} {2} to wp w3tc" .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -587,8 +599,8 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp'] - and oldcachetype not in ['basic', 'w3tc', 'wpsc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp'] + or (oldsitetype is 'wp' and oldcachetype is 'wpfc')): Log.error(self, "Cannot update {0}, {1} {2} to wp wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -605,8 +617,8 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp'] - and oldcachetype not in ['basic', 'w3tc', 'wpfc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp'] + or (oldsitetype is 'wp' and oldcachetype is 'wpsc')): Log.error(self, "Cannot update {0}, {1} {2} to wp wpsc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -627,8 +639,9 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpsubdir and not (self.app.pargs.w3tc or self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] - and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdir'] + or (oldsitetype is 'wpsubdir' and oldcachetype is 'basic')): Log.error(self, " Cannot update {0}, {1} {2} " "to wpsubdir basic" .format(ee_domain, oldsitetype, oldcachetype)) @@ -646,8 +659,9 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] - and oldcachetype not in ['basic', 'wpfc', 'wpsc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdir'] + or (oldsitetype is 'wpsubdir' and oldcachetype is 'w3tc')): Log.error(self, " Cannot update {0} {1} {2}" "to wpsubdir w3tc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -666,8 +680,9 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] - and oldcachetype not in ['basic', 'w3tc', 'wpsc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdir'] + or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpfc')): Log.error(self, " Cannot update {0} {1} {2}" " to wpsubdir wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -685,8 +700,9 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] - and oldcachetype not in ['basic', 'w3tc', 'wpfc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdir'] + or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpsc')): Log.error(self, " Cannot update {0} {1} {2}" " to wpsubdir wpsc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -705,8 +721,9 @@ class EESiteUpdateController(CementBaseController): self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdir or self.app.pargs.wp)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] - and oldcachetype not in ['w3tc', 'wpfc', 'wpsc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdomain'] + or (oldsitetype is 'wpsubdomain' and oldcachetype is 'basic')): Log.error(self, " Cannot update {0} {1} {2}" " to wpsubdomain basic" .format(ee_domain, oldsitetype, oldcachetype)) @@ -725,9 +742,9 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.w3tc and not (self.app.pargs.wpfc or self.app.pargs.wpsc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp', - 'wpsubdomain'] - and oldcachetype not in ['basic', 'wpfc', 'wpsc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdomain'] or + (oldsitetype is 'wpsubdomain' and oldcachetype is 'w3tc')): Log.error(self, " Cannot update {0}, {1} {2}" " to wpsubdomain w3tc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -746,9 +763,9 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpfc and not (self.app.pargs.wpsc or self.app.pargs.w3tc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp', - 'wpsubdomain'] - and oldcachetype not in ['basic', 'w3tc', 'wpsc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdomain'] or + (oldsitetype is 'wpsubdomain' and oldcachetype is 'wpfc')): Log.error(self, " Cannot update {0}, {1} {2} " "to wpsubdomain wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -767,9 +784,9 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpsc and not (self.app.pargs.w3tc or self.app.pargs.wpfc)): - if (oldsitetype in ['html', 'php', 'mysql', 'wp', - 'wpsubdomain'] - and oldcachetype not in ['basic', 'w3tc', 'wpfc']): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdomain'] or + (oldsitetype is 'wpsubdomain' and oldcachetype is 'wpsc')): Log.error(self, " Cannot update {0}, {1} {2}" " to wpsubdomain wpsc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -786,17 +803,17 @@ class EESiteUpdateController(CementBaseController): cache = 'wpsc' if not data: - Log.error(self, " Cannot update" + Log.error(self, " Cannot update {0}, Invalid Options" .format(ee_domain)) + site_package_check(self, stype) - siteBackup(self, data) - # TODO Check for required packages before update + sitebackup(self, data) # setup NGINX configuration, and webroot - setupDomain(self, data) + setupdomain(self, data) if 'ee_db_name' in data.keys() and not data['wp']: - data = setupDatabase(self, data) + data = setupdatabase(self, data) try: eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot), 'w') @@ -816,45 +833,44 @@ class EESiteUpdateController(CementBaseController): if oldsitetype == 'mysql': config_file = (ee_site_webroot + '/backup/{0}/ee-config.php' .format(EEVariables.ee_date)) - data['ee_db_name'] = EEFileUtils.grep(EEFileUtils - .grep(self, config_file, - 'DB_NAME') - .split(',')[1] - .split(')')[0].strip()) - data['ee_db_user'] = EEFileUtils.grep(EEFileUtils - .grep(self, config_file, - 'DB_USER') - .split(',')[1] - .split(')')[0].strip()) - data['ee_db_pass'] = EEFileUtils.grep(EEFileUtils - .grep(self, config_file, - 'DB_PASSWORD') - .split(',')[1] - .split(')')[0].strip()) + print(config_file, 'DB_NAME') + data['ee_db_name'] = (EEFileUtils.grep(self, config_file, + 'DB_NAME') + .split(',')[1] + .split(')')[0].strip()) + data['ee_db_user'] = (EEFileUtils.grep(self, config_file, + 'DB_USER') + .split(',')[1] + .split(')')[0].strip()) + data['ee_db_pass'] = (EEFileUtils.grep(self, config_file, + 'DB_PASSWORD') + .split(',')[1] + .split(')')[0].strip()) # Setup WordPress if old sites are html/php/mysql sites if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: - ee_wp_creds = setupWordpress(self, data) + ee_wp_creds = setupwordpress(self, data) # Uninstall unnecessary plugins if oldsitetype in ['wp', 'wpsubdir', 'wpsubdomain']: # Setup WordPress Network if update option is multisite # and oldsite is WordPress single site if data['multisite'] and oldsitetype == 'wp': - setupWordpressNetwork(self, data) + setupwordpressnetwork(self, data) if (oldcachetype == 'w3tc' or oldcachetype == 'wpfc' and - not data['w3tc', 'wpfc']): - uninstallWP_Plugin(self, 'w3-total-cache', data) + not (data['w3tc'] or data['wpfc'])): + uninstallwp_plugin(self, 'w3-total-cache', data) if oldcachetype == 'wpsc' and not data['wpsc']: - uninstallWP_Plugin(self, 'wp-super-cache', data) + uninstallwp_plugin(self, 'wp-super-cache', data) - if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and data['w3tc']: - installWP_Plugin(self, 'w3-total-cache', data) + if (oldcachetype != 'w3tc' or oldcachetype != 'wpfc') and (data['w3tc'] + or data['wpfc']): + installwp_plugin(self, 'w3-total-cache', data) if oldcachetype != 'wpsc' and data['wpsc']: - installWP_Plugin(self, 'wp-super-cache', data) + installwp_plugin(self, 'wp-super-cache', data) # Service Nginx Reload EEService.reload_service(self, 'nginx') @@ -863,7 +879,13 @@ class EESiteUpdateController(CementBaseController): msg="{0} updated with {1} {2}" .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot - # SetWebrootPermissions(self, data['webroot']) + # setwebrootpermissions(self, data['webroot']) + + if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: + Log.info(self, Log.ENDC + "WordPress Admin User :" + " {0}".format(ee_wp_creds['wp_user'])) + Log.info(self, Log.ENDC + "WordPress Admin User Password : {0}" + .format(ee_wp_creds['wp_pass'])) updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) Log.info(self, "Successfully updated site" @@ -890,12 +912,13 @@ class EESiteDeleteController(CementBaseController): dict(help="delete webroot only", action='store_true')), ] - @expose(help="delete site") + @expose(help="delete website configuration and files") def default(self): # TODO Write code for ee site update here (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_db_name = '' ee_prompt = '' + ee_nginx_prompt = '' if ((not self.app.pargs.db) and (not self.app.pargs.files) and (not self.app.pargs.all)): @@ -914,7 +937,7 @@ class EESiteDeleteController(CementBaseController): '[Y/N]: ') else: ee_db_prompt = 'Y' - ee_nginx_prompt = 'Y' + if ee_db_prompt == 'Y' or ee_db_prompt == 'y': self.deleteDB(ee_site_webroot) @@ -924,7 +947,6 @@ class EESiteDeleteController(CementBaseController): '[Y/N]: ') else: ee_web_prompt = 'Y' - ee_nginx_prompt = 'Y' if ee_web_prompt == 'Y' or ee_web_prompt == 'y': self.deleteWebRoot(ee_site_webroot) @@ -949,9 +971,10 @@ class EESiteDeleteController(CementBaseController): self.deleteWebRoot(ee_site_webroot) if (ee_nginx_prompt == 'Y' or ee_nginx_prompt == 'y'): + Log.debug(self, "Removing Nginx configuration") EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}' .format(ee_domain)) - deleteSiteInfo(self, ee_domain) + deleteSiteInfo(self, ee_domain) Log.info(self, "Deleted site {0}".format(ee_domain)) else: Log.error(self, " site {0} does not exists".format(ee_domain)) @@ -1002,12 +1025,12 @@ class EESiteListController(CementBaseController): description = 'list websites' arguments = [ (['--enabled'], - dict(help='list enabled sites', action='store_true')), + dict(help='list enabled websites', action='store_true')), (['--disabled'], - dict(help="list disabled sites", action='store_true')), + dict(help="list disabled websites", action='store_true')), ] - @expose(help="delete example.com") + @expose(help="Lists websites") def default(self): sites = getAllsites(self) if not sites: diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index e47b80eb..e9b9ec6c 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -13,11 +13,11 @@ from ee.core.logging import Log import glob -def setupDomain(self, data): +def setupdomain(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] - Log.info(self, "Setting up NGINX configuration ", end='') + Log.info(self, "Setting up NGINX configuration \t\t", end='') # write nginx config for file try: ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}' @@ -41,7 +41,7 @@ def setupDomain(self, data): .format(ee_domain_name)]) # Creating htdocs & logs directory - Log.info(self, "Setting up webroot ", end='') + Log.info(self, "Setting up webroot \t\t", end='') try: if not os.path.exists('{0}/htdocs'.format(ee_site_webroot)): os.makedirs('{0}/htdocs'.format(ee_site_webroot)) @@ -62,7 +62,7 @@ def setupDomain(self, data): Log.info(self, "[Done]") -def setupDatabase(self, data): +def setupdatabase(self, data): ee_domain_name = data['site_name'] ee_random = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 15))) @@ -89,8 +89,9 @@ def setupDatabase(self, data): try: ee_db_username = input('Enter the MySQL database user name [{0}]: ' .format(ee_replace_dot)) - ee_db_password = input('Enter the MySQL database password [{0}]: ' - .format(ee_random)) + ee_db_password = getpass.getpass(prompt='Enter the MySQL database' + ' password [{0}]: ' + .format(ee_random)) except EOFError as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to input database credentials") @@ -102,13 +103,13 @@ def setupDatabase(self, data): if len(ee_db_username) > 16: Log.info(self, 'Autofix MySQL username (ERROR 1470 (HY000)),' - ' please wait...') + ' please wait') ee_random10 = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 10))) ee_db_name = (ee_db_name[0:6] + ee_random10) # create MySQL database - Log.info(self, "Setting Up Database ", end='') + 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}" .format(ee_db_name)) @@ -134,7 +135,7 @@ def setupDatabase(self, data): return(data) -def setupWordpress(self, data): +def setupwordpress(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] prompt_wpprefix = self.app.config.get('wordpress', 'prefix') @@ -148,13 +149,13 @@ def setupWordpress(self, data): ee_wp_user = '' ee_wp_pass = '' - Log.info(self, "Downloading Wordpress ", end='') + Log.info(self, "Downloading Wordpress \t\t", end='') EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") Log.info(self, "[Done]") if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']): - data = setupDatabase(self, data) + data = setupdatabase(self, data) if prompt_wpprefix == 'True' or prompt_wpprefix == 'true': try: ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' @@ -251,15 +252,15 @@ def setupWordpress(self, data): errormsg="Unable to Update WordPress permalink") """Install nginx-helper plugin """ - installWP_Plugin(self, 'nginx-helper', data) + installwp_plugin(self, 'nginx-helper', data) """Install Wp Super Cache""" if data['wpsc']: - installWP_Plugin(self, 'wp-super-cache', data) + installwp_plugin(self, 'wp-super-cache', data) """Install W3 Total Cache""" if data['w3tc'] or data['wpfc']: - installWP_Plugin(self, 'w3-total-cache', data) + installwp_plugin(self, 'w3-total-cache', data) wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass, wp_email=ee_wp_email) @@ -267,10 +268,10 @@ def setupWordpress(self, data): return(wp_creds) -def setupWordpressNetwork(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 ", end='') + Log.info(self, "Setting up WordPress Network \t\t", end='') EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert' ' --title={0} {subdomains}' .format(data['www_domain'], subdomains='--subdomains' @@ -278,7 +279,7 @@ def setupWordpressNetwork(self, data): Log.info(self, "Done") -def installWP_Plugin(self, plugin_name, data): +def installwp_plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] Log.debug(self, "Installing plugin {0}".format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) @@ -295,7 +296,7 @@ def installWP_Plugin(self, plugin_name, data): .format(plugin_name)) -def uninstallWP_Plugin(self, plugin_name, data): +def uninstallwp_plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] Log.debug(self, "Uninstalling plugin {0}".format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) @@ -305,13 +306,13 @@ def uninstallWP_Plugin(self, plugin_name, data): .format(plugin_name)) -def SetWebrootPermissions(self, webroot): - Log.debug(self, "Setting Up Permissions...") +def setwebrootpermissions(self, webroot): + Log.debug(self, "Setting Up Permissions") EEFileUtils.chown(self, webroot, EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) -def siteBackup(self, data): +def sitebackup(self, data): ee_site_webroot = data['webroot'] backup_path = ee_site_webroot + '/backup/{0}'.format(EEVariables.ee_date) if not EEFileUtils.isexist(self, backup_path): @@ -321,7 +322,7 @@ def siteBackup(self, data): .format(data['site_name']), backup_path) if data['currsitetype'] in ['html', 'php', 'mysql']: - Log.info(self, "Backing up Webroot ", end='') + Log.info(self, "Backing up Webroot \t\t", end='') EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path) Log.info(self, "[Done]") @@ -331,7 +332,7 @@ def siteBackup(self, data): ee_db_name = (EEFileUtils.grep(self, configfiles[0], 'DB_NAME').split(',')[1] .split(')')[0].strip().replace('\'', '')) - Log.info(self, 'Backing up Database ', end='') + Log.info(self, 'Backing up Database \t\t', end='') EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" .format(ee_db_name, backup_path), errormsg="\nFailed: Backup Database") @@ -378,7 +379,7 @@ def site_package_check(self, stype): stack.install(apt_packages=apt_packages, packages=packages) -def updateWPuserPassword(self, ee_domain, ee_site_webroot): +def updatewpuserpassword(self, ee_domain, ee_site_webroot): ee_wp_user = '' ee_wp_pass = '' @@ -412,7 +413,7 @@ def updateWPuserPassword(self, ee_domain, ee_site_webroot): if is_user_exist: ee_wp_pass = input("Provide password for {0} user: " .format(ee_wp_user)) - if len(ee_wp_pass) < 8: + if len(ee_wp_pass) > 8: EEShellExec.cmd_exec(self, "wp --allow-root user update {0}" " --user_pass={1}" .format(ee_wp_user, ee_wp_pass)) diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index 318beb46..77e11752 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -35,6 +35,10 @@ def updateSiteInfo(self, site, stype='', cache='', except Exception as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to query database for site info") + + if not q: + Log.error(self, "{0} does not exist in database".format(site)) + if stype and q.site_type != stype: q.site_type = stype @@ -61,6 +65,10 @@ def deleteSiteInfo(self, site): except Exception as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to query database :") + + if not q: + Log.error(self, "{0} does not exist in database".format(site)) + try: db_session.delete(q) db_session.commit() diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index b226cddb..062850a2 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -130,25 +130,25 @@ class EEStackStatusController(CementBaseController): def reload(self): services = [] if self.app.pargs.nginx: - Log.debug(self, "nginx service restart") + Log.debug(self, "nginx service reload") services = services + ['nginx'] elif self.app.pargs.php: - Log.debug(self, "php5-fpm service restart") + Log.debug(self, "php5-fpm service reload") services = services + ['php5-fpm'] elif self.app.pargs.mysql: - Log.debug(self, "mysql service restart") + Log.debug(self, "mysql service reload") services = services + ['mysql'] elif self.app.pargs.postfix: - Log.debug(self, "postfix service restart") + Log.debug(self, "postfix service reload") services = services + ['postfix'] elif self.app.pargs.memcache: - Log.debug(self, "memcached service restart") + Log.debug(self, "memcached service reload") services = services + ['memcached'] elif self.app.pargs.dovecot: - Log.debug(self, "dovecot service restart") + Log.debug(self, "dovecot service reload") services = services + ['dovecot'] else: services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: - Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart") + Log.debug(self, "nginx,php5-fpm,mysql,postfix services reload") EEService.reload_service(self, service) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 13bc70d4..002e1ef3 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -170,7 +170,6 @@ class EEAptGet(): .format(package_name=pkg.name)) continue my_selected_packages.append(pkg.name) - print(my_selected_packages) # How logic works: # 1) We loop trough dependencies's dependencies and add them to # the list. diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 61cdc092..3b250c74 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -44,11 +44,13 @@ class EEMysql(): try: cur.execute(statement) except Exception as e: - Log.error(self, 'Unable to execute statement:') - Lod.debug(self, "{0}".format(e)) cur.close() conn.close() - sys.exit(1) + Log.debug(self, "{0}".format(e)) + if not errormsg: + Log.error(self, 'Unable to execute statement') + else: + Log.error(self, '{0}'.format(errormsg)) cur.close() conn.close() From 84844b93dc090375d8ad15d4e13cb9d660b47a68 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 16:40:56 +0530 Subject: [PATCH 685/829] ee debug autocompletion improved --- config/bash_completion.d/ee_auto.py | 47 ++++++++++------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/config/bash_completion.d/ee_auto.py b/config/bash_completion.d/ee_auto.py index e0bf09ca..dfd7a300 100644 --- a/config/bash_completion.d/ee_auto.py +++ b/config/bash_completion.d/ee_auto.py @@ -1,15 +1,3 @@ -function ee_single() -{ - for (( j=0; j<${#COMP_WORDS[@]}; j++ )); do - for (( i=0; i<${#COMPREPLY[@]}; i++ )); do - if [[ ${COMP_WORDS[COMP_CWORD-j]} == ${COMPREPLY[i]} ]]; then - rem=( ${COMP_WORDS[COMP_CWORD-j]} ); - COMPREPLY=( "${COMPREPLY[@]/$rem}" ) - fi - done - done -} - _ee_complete() { local cur prev BASE_LEVEL @@ -41,7 +29,7 @@ _ee_complete() # IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE "debug") COMPREPLY=( $(compgen \ - -W "--start --nginx --php --fpm --mysql -i --interactive" \ + -W "--start --nginx --php --fpm --mysql -i --interactive --stop " \ -- $cur) ) ;; @@ -90,7 +78,7 @@ _ee_complete() -- $cur) ) ;; - "edit" | "enable" | "info" | "log" | "show" | "cd" | "update") + "edit" | "enable" | "info" | "log" | "show" | "cd" | "update" | "delete") COMPREPLY=( $(compgen \ -W "$(find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)" \ -- $cur) ) @@ -105,17 +93,13 @@ _ee_complete() *) ;; esac - - # case "$mprev" in - # "debug") - # COMPREPLY=( $(compgen \ - # -W "--wp --nginx --rewrite --start --stop -i --interactive" \ - # -- $cur) ) - # ;; - # - # *) - # ;; - # esac + if [[ ${COMP_WORDS[1]} == "debug" ]] && [ "$prev" != "--start" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]; then + retlist="--start --stop --wp --rewrite -i" + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) + fi elif [ $COMP_CWORD -eq 4 ]; then case "$mprev" in @@ -131,7 +115,6 @@ _ee_complete() -W "--db --files --all" \ -- $cur) ) - esac fi @@ -143,13 +126,15 @@ _ee_complete() ;; "--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot") - if [[ $COMP_WORDS =~ "stack" ]]; then + if [[ ${COMP_WORDS[1]} == "stack" ]]; then retlist="--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot" - ret="${retlist[@]/$prev}" - COMPREPLY=( $(compgen \ - -W "$(echo $ret)" \ - -- $cur) ) + elif [[ ${COMP_WORDS[1]} == "debug" ]]; then + retlist="--start --nginx --php --fpm --mysql -i --interactive --stop" fi + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) ;; "--db" | "--files" | "--all") From 24500e891ea8b0d44f52dfdbee859aa9b51b09c3 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 17:06:55 +0530 Subject: [PATCH 686/829] final autocompletion --- config/bash_completion.d/{ee_auto.py => ee_auto.rc} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/bash_completion.d/{ee_auto.py => ee_auto.rc} (100%) diff --git a/config/bash_completion.d/ee_auto.py b/config/bash_completion.d/ee_auto.rc similarity index 100% rename from config/bash_completion.d/ee_auto.py rename to config/bash_completion.d/ee_auto.rc From f44caecadedefad46958807ac0c98b2e444d6632 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 20 Jan 2015 17:32:54 +0530 Subject: [PATCH 687/829] Added autocompletion, Git user into installation --- ee/core/variables.py | 4 ++-- setup.py | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 483ded64..d911d703 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -10,8 +10,6 @@ import datetime class EEVariables(): """Intialization of core variables""" - config = configparser.ConfigParser() - config.read(os.path.expanduser("~")+'/.gitconfig') # EasyEngine version ee_version = "3.0.0" @@ -40,6 +38,8 @@ class EEVariables(): ee_php_user = 'www-data' # Get git user name and EMail + config = configparser.ConfigParser() + config.read(os.path.expanduser("~")+'/.gitconfig') try: ee_user = config['user']['name'] ee_email = config['user']['email'] diff --git a/setup.py b/setup.py index 001b2fe6..eeacb4a2 100644 --- a/setup.py +++ b/setup.py @@ -3,12 +3,13 @@ from setuptools import setup, find_packages import sys import os import glob +import configparser conf = [] templates = [] long_description = '''EasyEngine is the commandline tool to manage your - Websites based on WordPress and NGINX with easy to use + Websites based on WordPress and Nginx with easy to use commands''' for name in glob.glob('config/plugins.d/*.conf'): @@ -23,6 +24,24 @@ if not os.path.exists('/var/log/ee/'): if not os.path.exists('/var/lib/ee/'): os.makedirs('/var/lib/ee/') +# EasyEngine git function +config = configparser.ConfigParser() +config.read(os.path.expanduser("~")+'/.gitconfig') +try: + ee_user = config['user']['name'] + ee_email = config['user']['email'] +except Exception as e: + print("EasyEngine (ee) required your name & email address to track" + " changes you made under the Git version control") + print("EasyEngine (ee) will be able to send you daily reports & alerts in " + "upcoming version") + print("EasyEngine (ee) will NEVER send your information across") + + ee_user = input("Enter username for Git:") + ee_email = input("Enter email for Git:") + os.system("git config --global user.name {0}".format(ee_user)) + os.system("git config --global user.email {0}".format(ee_email)) + setup(name='ee', version='3.0', description=long_description, @@ -56,7 +75,9 @@ setup(name='ee', ], data_files=[('/etc/ee', ['config/ee.conf']), ('/etc/ee/plugins.d', conf), - ('/usr/lib/ee/templates', templates)], + ('/usr/lib/ee/templates', templates), + ('/etc/bash_completion.d/', + ['config/bash_completion.d/ee_auto.rc'])], setup_requires=[], entry_points=""" [console_scripts] From 56eb2d20cb60eaf1ff4330c3b8c713f36941b39d Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 20 Jan 2015 17:55:03 +0530 Subject: [PATCH 688/829] updated log messages --- config/ee.conf | 2 +- ee/cli/plugins/secure.py | 1 - ee/cli/plugins/site_functions.py | 4 +- ee/cli/plugins/stack.py | 176 +++++++++++++++---------------- ee/cli/plugins/stack_services.py | 10 +- ee/core/download.py | 3 +- ee/core/fileutils.py | 6 +- tests/cli/97_test_site_update.py | 11 +- 8 files changed, 105 insertions(+), 108 deletions(-) diff --git a/config/ee.conf b/config/ee.conf index d3d8aafb..ce68b3e5 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -27,7 +27,7 @@ file = /var/log/ee/ee.log level = debug ### Whether or not to log to console -to_console = true +to_console = false ### Whether or not to rotate the log file when it reaches `max_bytes` rotate = true diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index fc336e77..8ed6d565 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -98,7 +98,6 @@ class EEsecureController(CementBaseController): ip = ['127.0.0.1'] self.app.config.set('mysql', 'grant-host', "hello") exist_ip_list = self.app.config.get('stack', 'ip-address').split() - print(exist_ip_list) for check_ip in user_list_ip: if check_ip not in exist_ip_list: newlist.extend(exist_ip_list) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 26659719..6edfbee4 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -363,12 +363,12 @@ def site_package_check(self, stype): apt_packages = apt_packages + EEVariables.ee_mysql if stype in ['php', 'mysql', 'wp', 'wpsubdir', 'wpsubdomain']: - Log.debug(self, "Setting apt_packages variable for PostFix") + Log.debug(self, "Setting apt_packages variable for Postfix") if not EEAptGet.is_installed(self, 'postfix'): apt_packages = apt_packages + EEVariables.ee_postfix if stype in ['wp', 'wpsubdir', 'wpsubdomain']: - Log.debug(self, "Setting packages variable for WPCLI") + 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/" diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 5c70d859..f93abb96 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -62,20 +62,15 @@ class EEStackController(CementBaseController): dict(help='Install Utils stack', action='store_true')), ] - @expose(hide=True) - def package_check(self, packages=[]): - # Function for packages check - pass - @expose(hide=True) def default(self): # TODO Default action for ee stack command - Log.info(self, "Inside EEStackController.default().") + self.app.args.print_help() @expose(hide=True) def pre_pref(self, apt_packages): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): - Log.info(self, "Pre-seeding postfix variables ... ") + Log.info(self, "Pre-seeding Postfix") EEShellExec.cmd_exec(self, "echo \"postfix postfix" "/main_mailer_type string \'Internet Site\'\"" " | debconf-set-selections") @@ -83,12 +78,13 @@ class EEStackController(CementBaseController): " $(hostname -f)\" | debconf-set-selections") if set(EEVariables.ee_mysql).issubset(set(apt_packages)): - Log.info(self, "Adding repository for MySQL ... ") + Log.info(self, "Adding repository for MySQL") EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) - Log.debug(self, 'Adding key of MySQL.') + Log.debug(self, 'Adding key for {0}' + .format(EEVariables.ee_mysql_repo)) EERepo.add_key(self, '1C4CBDCDCD2EFD2A') chars = ''.join(random.sample(string.ascii_letters, 8)) - Log.info(self, "Pre-seeding MySQL variables ... ") + Log.info(self, "Pre-seeding MySQL") EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " "percona-server-server/root_password " "password {chars}\" | " @@ -104,25 +100,25 @@ class EEStackController(CementBaseController): """.format(chars=chars) config = configparser.ConfigParser() config.read_string(mysql_config) - Log.debug(self, 'writting configartion into MySQL file.') + Log.debug(self, 'Writting configuration into MySQL file') with open(os.path.expanduser("~")+'/.my.cnf', 'w') as configfile: config.write(configfile) if set(EEVariables.ee_nginx).issubset(set(apt_packages)): - Log.info(self, "Adding repository for Nginx ... ") + Log.info(self, "Adding repository for Nginx") if EEVariables.ee_platform_distro == 'Debian': Log.debug(self, 'Adding Dotdeb/nginx GPG key') EERepo.add(self, repo_url=EEVariables.ee_nginx_repo) else: - Log.debug(self, 'Adding ppa of Nginx') EERepo.add(self, ppa=EEVariables.ee_nginx_repo) + Log.debug(self, 'Adding ppa of Nginx') if set(EEVariables.ee_php).issubset(set(apt_packages)): - Log.info(self, "Adding repository for PHP ... ") + Log.info(self, "Adding repository for PHP") if EEVariables.ee_platform_distro == 'Debian': Log.debug(self, 'Adding repo_url of php for Debian') EERepo.add(self, repo_url=EEVariables.ee_php_repo) - Log.debug(self, 'Adding Dotdeb/php GPG key') + Log.debug(self, 'Adding Dotdeb/php GPG key') EERepo.add_key(self, '89DF5277') else: Log.debug(self, 'Adding ppa for PHP') @@ -130,7 +126,7 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_mail).issubset(set(apt_packages)): if EEVariables.ee_platform_codename == 'squeeze': - Log.info(self, "Adding repository for dovecot ... ") + Log.info(self, "Adding repository for dovecot ") EERepo.add(self, repo_url=EEVariables.ee_dovecot_repo) Log.debug(self, 'Executing the command debconf-set-selections.') EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/" @@ -161,13 +157,13 @@ class EEStackController(CementBaseController): [('worker_connections', '4096'), ('multi_accept', 'on')]}, position=4) nc.set([('http',), 'keepalive_timeout'], '30') - Log.debug(self, "Writting nginx configration to " + Log.debug(self, "Writting nginx configuration to " "file /etc/nginx/nginx.conf ") nc.savef('/etc/nginx/nginx.conf') # Custom Nginx configuration by EasyEngine data = dict(version=EEVariables.ee_version) - Log.debug(self, 'writting the nginx configration to ' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/conf.d/ee-nginx.conf ') ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w') self.app.render((data), 'nginx-core.mustache', @@ -175,20 +171,20 @@ class EEStackController(CementBaseController): ee_nginx.close() data = dict() - Log.debug(self, 'writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/conf.d/blockips.conf') ee_nginx = open('/etc/nginx/conf.d/blockips.conf', 'w') self.app.render((data), 'blockips.mustache', out=ee_nginx) ee_nginx.close() - Log.debug(self, 'writting the nginx configration to' - ' file /etc/nginx/conf.d/fastcgi.conf') + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/conf.d/fastcgi.conf') ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf', 'w') self.app.render((data), 'fastcgi.mustache', out=ee_nginx) ee_nginx.close() data = dict(php="9000", debug="9001") - Log.debug(self, 'writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) @@ -201,56 +197,56 @@ class EEStackController(CementBaseController): os.makedirs('/etc/nginx/common') data = dict() - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/acl.conf') ee_nginx = open('/etc/nginx/common/acl.conf', 'w') self.app.render((data), 'acl.mustache', out=ee_nginx) ee_nginx.close() - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/locations.conf') ee_nginx = open('/etc/nginx/common/locations.conf', 'w') self.app.render((data), 'locations.mustache', out=ee_nginx) ee_nginx.close() - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/ php.conf') ee_nginx = open('/etc/nginx/common/php.conf', 'w') self.app.render((data), 'php.mustache', out=ee_nginx) ee_nginx.close() - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/w3tc.conf') ee_nginx = open('/etc/nginx/common/w3tc.conf', 'w') self.app.render((data), 'w3tc.mustache', out=ee_nginx) ee_nginx.close() - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/wpcommon.conf') ee_nginx = open('/etc/nginx/common/wpcommon.conf', 'w') self.app.render((data), 'wpcommon.mustache', out=ee_nginx) ee_nginx.close() - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/wpfc.conf') ee_nginx = open('/etc/nginx/common/wpfc.conf', 'w') self.app.render((data), 'wpfc.mustache', out=ee_nginx) ee_nginx.close() - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/wpsc.conf') ee_nginx = open('/etc/nginx/common/wpsc.conf', 'w') self.app.render((data), 'wpsc.mustache', out=ee_nginx) ee_nginx.close() - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/wpsubdir.conf') ee_nginx = open('/etc/nginx/common/wpsubdir.conf', 'w') self.app.render((data), 'wpsubdir.mustache', @@ -258,7 +254,7 @@ class EEStackController(CementBaseController): ee_nginx.close() # 22222 port settings - Log.debug(self, 'Writting the nginx configration to' + Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/sites-available/' '22222.conf') ee_nginx = open('/etc/nginx/sites-available/22222.conf', @@ -285,9 +281,13 @@ class EEStackController(CementBaseController): '22222.conf']) # Create log and cert folder and softlinks if not os.path.exists('/var/www/22222/logs'): + Log.debug(self, "Creating directory " + "/var/www/22222/logs ") os.makedirs('/var/www/22222/logs') if not os.path.exists('/var/www/22222/cert'): + Log.debug(self, "Creating directory " + "/var/www/22222/cert") os.makedirs('/var/www/22222/cert') EEFileUtils.create_symlink(self, ['/var/log/nginx/' @@ -327,7 +327,7 @@ class EEStackController(CementBaseController): ["/etc/nginx"], msg="Adding Nginx into Git") EEService.reload_service(self, 'nginx') self.msg = (self.msg + ["HTTP Auth User Name: easyengine"] - + ["HTTP Auth Password: {0}".format(passwd)]) + + ["HTTP Auth Password : {0}".format(passwd)]) if set(EEVariables.ee_php).issubset(set(apt_packages)): # Create log directories @@ -337,7 +337,7 @@ class EEStackController(CementBaseController): # Parse etc/php5/fpm/php.ini config = configparser.ConfigParser() - Log.debug(self, "configring php file /etc/php5/fpm/php.ini") + Log.debug(self, "configuring php file /etc/php5/fpm/php.ini") config.read('/etc/php5/fpm/php.ini') config['PHP']['expose_php'] = 'Off' config['PHP']['post_max_size'] = '100M' @@ -345,8 +345,8 @@ class EEStackController(CementBaseController): config['PHP']['max_execution_time'] = '300' config['PHP']['date.timezone'] = time.tzname[time.daylight] with open('/etc/php5/fpm/php.ini', 'w') as configfile: - Log.debug(self, "writting configration of php in to" - "file /etc/php5/fpm/php.ini") + Log.debug(self, "Writting php configuration into " + "/etc/php5/fpm/php.ini") config.write(configfile) # Prase /etc/php5/fpm/php-fpm.conf @@ -354,8 +354,8 @@ class EEStackController(CementBaseController): config.read('/etc/php5/fpm/php-fpm.conf') config['global']['error_log'] = '/var/log/php5/fpm.log' with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: - Log.debug(self, "writting php5 configartion into " - " /etc/php5/fpm/php-fpm.conf") + Log.debug(self, "writting php5 configuration into " + "/etc/php5/fpm/php-fpm.conf") config.write(configfile) # Parse /etc/php5/fpm/pool.d/www.conf @@ -372,8 +372,8 @@ class EEStackController(CementBaseController): config['www']['pm'] = 'ondemand' config['www']['listen'] = '127.0.0.1:9000' with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile: - Log.debug(self, "writting PHP5 configartion into " - " /etc/php5/fpm/pool.d/www.conf") + Log.debug(self, "writting PHP5 configuration into " + "/etc/php5/fpm/pool.d/www.conf") config.write(configfile) # Generate /etc/php5/fpm/pool.d/debug.conf @@ -385,8 +385,8 @@ class EEStackController(CementBaseController): config.read('/etc/php5/fpm/pool.d/debug.conf') config['debug']['listen'] = '127.0.0.1:9001' with open('/etc/php5/fpm/pool.d/debug.conf', 'w') as confifile: - Log.debug(self, "writting PHP5 configartion into " - " /etc/php5/fpm/pool.d/debug.conf") + Log.debug(self, "writting PHP5 configuration into " + "/etc/php5/fpm/pool.d/debug.conf") config.write(confifile) with open("/etc/php5/fpm/pool.d/debug.conf", "a") as myfile: @@ -425,7 +425,7 @@ class EEStackController(CementBaseController): EEService.reload_service(self, 'mysql') if set(EEVariables.ee_mail).issubset(set(apt_packages)): - Log.debug(self, "Executing mail commands") + Log.debug(self, "Adding user") EEShellExec.cmd_exec(self, "adduser --uid 5000 --home /var" "/vmail --disabled-password --gecos ''" " vmail") @@ -436,14 +436,14 @@ class EEStackController(CementBaseController): "pem -keyout /etc/ssl/private/dovecot.pem" .format(HOSTNAME=EEVariables.ee_fqdn, EMAIL=EEVariables.ee_email)) - Log.debug(self, "Adding Privillages to file " - "/etc/ssl/private/dovecot.pem ") + Log.debug(self, "Setting Privileges to " + "/etc/ssl/private/dovecot.pem file ") EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private" "/dovecot.pem") # Custom Dovecot configuration by EasyEngine data = dict() - Log.debug(self, "Writting configration into file" + Log.debug(self, "Writting configuration into file" "/etc/dovecot/conf.d/99-ee.conf ") ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf', 'w') self.app.render((data), 'dovecot.mustache', out=ee_dovecot) @@ -514,13 +514,13 @@ class EEStackController(CementBaseController): # Sieve configuration if not os.path.exists('/var/lib/dovecot/sieve/'): - Log.debug(self, 'Creating directory' + Log.debug(self, 'Creating directory ' '/var/lib/dovecot/sieve/ ') os.makedirs('/var/lib/dovecot/sieve/') # Custom sieve configuration by EasyEngine data = dict() - Log.debug(self, "Writting configaration of EasyEngine into" + Log.debug(self, "Writting configuration of EasyEngine into " "file /var/lib/dovecot/sieve/default.sieve") ee_sieve = open('/var/lib/dovecot/sieve/default.sieve', 'w') self.app.render((data), 'default-sieve.mustache', @@ -528,7 +528,7 @@ class EEStackController(CementBaseController): ee_sieve.close() # Compile sieve rules - Log.debug(self, "Privillages to dovecot ") + Log.debug(self, "Setting Privileges to dovecot ") # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" # "/dovecot") EEFileUtils.chown(self, "/var/lig/dovecot", "vmail", "vmail", @@ -565,13 +565,13 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec(self, "adduser clamav amavis") Log.debug(self, "Adding new user amavis clamav") EEShellExec.cmd_exec(self, "adduser amavis clamav") - Log.debug(self, "Privillages to file /var/lib/amavis/tmp ") + Log.debug(self, "Setting Privileges to /var/lib/amavis/tmp ") EEShellExec.cmd_exec(self, "chmod -R 775 /var/lib/amavis/tmp") # Update ClamAV database Log.debug(self, "Updating database") EEShellExec.cmd_exec(self, "freshclam") - Log.debug(self, "Restarting service clamav-daemon") + Log.debug(self, "Restarting clamav-daemon service") EEShellExec.cmd_exec(self, "service clamav-daemon restart") EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git") EEService.reload_service(self, 'dovecot') @@ -580,7 +580,7 @@ class EEStackController(CementBaseController): if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): - Log.debug(self, "Privillages to /usr/bin/wp ") + Log.debug(self, "Setting Privileges to /usr/bin/wp file ") EEShellExec.cmd_exec(self, "chmod +x /usr/bin/wp") if any('/tmp/pma.tar.gz' == x[1] for x in packages): @@ -593,8 +593,8 @@ class EEStackController(CementBaseController): os.makedirs('/var/www/22222/htdocs/db') shutil.move('/tmp/phpmyadmin-STABLE/', '/var/www/22222/htdocs/db/pma/') - Log.debug(self, 'Privillages to www-data:www-data ' - '/var/www/22222/htdocs/db/pma ') + Log.debug(self, 'Setting Privileges of www-data:www-data to ' + '/var/www/22222/htdocs/db/pma file ') # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/db/pma') EEFileUtils.chown(self, '/var/www/22222', @@ -606,8 +606,8 @@ class EEStackController(CementBaseController): " /var/www/22222/htdocs/cache/memcache ") EEExtract.extract(self, '/tmp/memcache.tar.gz', '/var/www/22222/htdocs/cache/memcache') - Log.debug(self, "Privillages to" - " /var/www/22222/htdocs/cache/memcache") + Log.debug(self, "Setting Privileges to " + "/var/www/22222/htdocs/cache/memcache file") # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/cache/memcache') EEFileUtils.chown(self, '/var/www/22222', @@ -625,8 +625,8 @@ class EEStackController(CementBaseController): os.makedirs('/var/www/22222/htdocs/php') shutil.move('/tmp/webgrind-master/', '/var/www/22222/htdocs/php/webgrind') - Log.debug(self, "Privillages www-data:www-data " - "/var/www/22222/htdocs/php/webgrind/ ") + Log.debug(self, "Setting Privileges of www-data:www-data to " + "/var/www/22222/htdocs/php/webgrind/ file ") # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/php/webgrind/') EEFileUtils.chown(self, '/var/www/22222', @@ -677,7 +677,7 @@ class EEStackController(CementBaseController): EEExtract.extract(self, '/tmp/vimbadmin.tar.gz', '/tmp/') if not os.path.exists('/var/www/22222/htdocs/'): Log.debug(self, "Creating directory " - " /var/www/22222/htdocs/") + "/var/www/22222/htdocs/") os.makedirs('/var/www/22222/htdocs/') shutil.move('/tmp/ViMbAdmin-3.0.10/', '/var/www/22222/htdocs/vimbadmin/') @@ -739,7 +739,7 @@ class EEStackController(CementBaseController): string.ascii_letters, 64))) config['user']['defaults.mailbox.' 'password_salt'] = vm_salt - Log.debug(self, "Writting configration to file " + Log.debug(self, "Writting configuration to file " "/var/www/22222/htdocs/vimbadmin" "/application/configs/application.ini ") with open('/var/www/22222/htdocs/vimbadmin/application' @@ -776,25 +776,26 @@ class EEStackController(CementBaseController): out=vm_config) vm_config.close() - Log.debug(self, "Configration of file " + Log.debug(self, "Writting configuration to " "/etc/postfix/mysql" - "/virtual_domains_maps.cf") + "/virtual_domains_maps.cf file") vm_config = open('/etc/postfix/mysql/virtual_domains_maps.cf', 'w') self.app.render((data), 'virtual_domains_maps.mustache', out=vm_config) vm_config.close() - Log.debug(self, "Configation of file " + Log.debug(self, "Writting configuration to " "/etc/postfix/mysql" - "/virtual_mailbox_maps.cf ") + "/virtual_mailbox_maps.cf file") vm_config = open('/etc/postfix/mysql/virtual_mailbox_maps.cf', 'w') self.app.render((data), 'virtual_mailbox_maps.mustache', out=vm_config) vm_config.close() - Log.debug(self, "Configration of file ") + Log.debug(self, "Writting configration" + " to /etc/dovecot/dovecot-sql.conf.ext file ") vm_config = open('/etc/dovecot/dovecot-sql.conf.ext', 'w') self.app.render((data), 'dovecot-sql-conf.mustache', @@ -876,8 +877,8 @@ class EEStackController(CementBaseController): ee_db_user='', ee_db_pass='', ee_db_host='', rc=True) - Log.debug(self, 'Writting the nginx configration for' - ' RoundCubemail') + Log.debug(self, 'Writting the nginx configuration for ' + 'RoundCubemail') ee_rc = open('/etc/nginx/sites-available/webmail.conf', 'w') self.app.render((data), 'virtualconf.mustache', out=ee_rc) @@ -909,7 +910,7 @@ class EEStackController(CementBaseController): EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) - @expose() + @expose(help="Install packages") def install(self, packages=[], apt_packages=[]): self.msg = [] try: @@ -964,43 +965,43 @@ class EEStackController(CementBaseController): apt_packages = (apt_packages + EEVariables.ee_mailscanner) else: - Log.info(self, "Mail server is allready installed") + Log.info(self, "Mail server is already installed") if self.app.pargs.nginx: Log.debug(self, "Setting apt_packages variable for Nginx") if not EEAptGet.is_installed(self, 'nginx-common'): apt_packages = apt_packages + EEVariables.ee_nginx else: - Log.info(self, "Nginx allready installed") + Log.debug(self, "Nginx already installed") if self.app.pargs.php: Log.debug(self, "Setting apt_packages variable for PHP") if not EEAptGet.is_installed(self, 'php5-fpm'): apt_packages = apt_packages + EEVariables.ee_php else: - Log.info(self, "PHP allready installed") + Log.debug(self, "PHP already installed") if self.app.pargs.mysql: Log.debug(self, "Setting apt_packages variable for MySQL") if not EEShellExec.cmd_exec(self, "mysqladmin ping"): apt_packages = apt_packages + EEVariables.ee_mysql else: - Log.info(self, "MySQL connection is allready alive") + Log.debug(self, "MySQL connection is already alive") if self.app.pargs.postfix: - Log.debug(self, "Setting apt_packages variable for PostFix") + Log.debug(self, "Setting apt_packages variable for Postfix") if not EEAptGet.is_installed(self, 'postfix'): apt_packages = apt_packages + EEVariables.ee_postfix else: - Log.info(self, "Postfix is allready installed") + Log.debug(self, "Postfix is already installed") if self.app.pargs.wpcli: - Log.debug(self, "Setting packages variable for WPCLI") + 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/v{0}/" "wp-cli-{0}.phar" "".format(EEVariables.ee_wp_cli), "/usr/bin/wp", - "WP_CLI"]] + "WP-CLI"]] else: - Log.info(self, "WP-CLI is allready installed") + Log.debug(self, "WP-CLI is already installed") if self.app.pargs.phpmyadmin: Log.debug(self, "Setting packages varible for phpMyAdmin ") packages = packages + [["https://github.com/phpmyadmin/" @@ -1035,12 +1036,12 @@ class EEStackController(CementBaseController): "opcache-gui/master/index.php", "/var/www/22222/htdocs/" "cache/opcache/opgui.php", - "index.php"], + "Opgui"], ["https://gist.github.com/ck-on/4959032" "/raw/0b871b345fd6cfcd6d2be030c1f33d1" "ad6a475cb/ocp.php", "/var/www/22222/htdocs/cache/" - "opcache/ocp.php", "ocp.php"], + "opcache/ocp.php", "OCP.php"], ["https://github.com/jokkedk/webgrind/" "archive/master.tar.gz", '/tmp/webgrind.tar.gz', 'Webgrind'], @@ -1050,7 +1051,7 @@ class EEStackController(CementBaseController): "20110624220137-or26tn4" "expb9ul2a-16/pt-query-digest", "/usr/bin/pt-query-advisor", - "pt-query-digest"], + "pt-query-advisor"], ["https://github.com/box/Anemometer/" "archive/master.tar.gz", '/tmp/anemometer.tar.gz', 'Anemometer'] @@ -1059,15 +1060,12 @@ class EEStackController(CementBaseController): pass if len(apt_packages) or len(packages): - Log.debug(self, "Calling pre_pref ") + Log.debug(self, "Calling pre_pref") self.pre_pref(apt_packages) if len(apt_packages): EESwap.add(self) Log.debug(self, "Updating apt-cache") EEAptGet.update(self) - Log.debug(self, "Installing following: {0}" - .format(apt_packages)) - print(apt_packages) EEAptGet.install(self, apt_packages) if len(packages): Log.debug(self, "Downloading following: {0}".format(packages)) @@ -1079,7 +1077,7 @@ class EEStackController(CementBaseController): Log.info(self, msg) Log.info(self, "Successfully installed packages") - @expose() + @expose(help="Remove packages") def remove(self): apt_packages = [] packages = [] @@ -1135,16 +1133,16 @@ class EEStackController(CementBaseController): packages = packages + ['/var/www/22222/htdocs/db/pma'] if self.app.pargs.adminer: Log.debug(self, "Removing package variable of Adminer ") - packages = packages + ['/var/www/22222/htdocs/db/adminer'] + packages = packages + ['/var/www/22222/htdocs/db/Adminer'] if self.app.pargs.utils: Log.debug(self, "Removing package variable of utils ") packages = packages + ['/var/www/22222/htdocs/php/webgrind/', '/var/www/22222/htdocs/cache/opcache', - '/var/www/22222/htdocs/cache/nginx/' + '/var/www/22222/htdocs/cache/Nginx/' 'clean.php', - '/var/www/22222/htdocs/cache/memcache', + '/var/www/22222/htdocs/cache/Memcache', '/usr/bin/pt-query-advisor', - '/var/www/22222/htdocs/db/anemometer'] + '/var/www/22222/htdocs/db/Anemometer'] if len(apt_packages): Log.debug(self, "Removing apt_packages") @@ -1153,7 +1151,7 @@ class EEStackController(CementBaseController): EEFileUtils.remove(self, packages) Log.info(self, "Successfully removed packages") - @expose() + @expose(help="Purge packages") def purge(self): apt_packages = [] packages = [] diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index b226cddb..562a9930 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -17,7 +17,7 @@ class EEStackStatusController(CementBaseController): dict(help='start/stop/restart dovecot', action='store_true')), ] - @expose(help="start stack services") + @expose(help="Start stack services") def start(self): services = [] if self.app.pargs.nginx: @@ -44,7 +44,7 @@ class EEStackStatusController(CementBaseController): for service in services: EEService.start_service(self, service) - @expose(help="stop stack services") + @expose(help="Stop stack services") def stop(self): services = [] if self.app.pargs.nginx: @@ -71,7 +71,7 @@ class EEStackStatusController(CementBaseController): for service in services: EEService.stop_service(self, service) - @expose(help="restart stack services") + @expose(help="Restart stack services") def restart(self): services = [] if self.app.pargs.nginx: @@ -98,7 +98,7 @@ class EEStackStatusController(CementBaseController): Log.debug(self, "nginx,php5-fpm,mysql,postfix services restart") EEService.restart_service(self, service) - @expose(help="get stack status") + @expose(help="Get stack status") def status(self): services = [] if self.app.pargs.nginx: @@ -126,7 +126,7 @@ class EEStackStatusController(CementBaseController): if EEService.get_service_status(self, service): Log.info(self, "{0:10}: {1}".format(service, "Running")) - @expose(help="reload stack services") + @expose(help="Reload stack services") def reload(self): services = [] if self.app.pargs.nginx: diff --git a/ee/core/download.py b/ee/core/download.py index a4bc97a0..5469a593 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -19,8 +19,9 @@ class EEDownload(): directory = os.path.dirname(filename) if not os.path.exists(directory): os.makedirs(directory) - Log.info(self, "Downloading "+pkg_name+" ...") + Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ') urllib.request.urlretrieve(url, filename) + Log.info(self, "{0}".format("[ Done ]")) except urllib.error.URLError as e: Log.debug(self, "[{err}]".format(err=str(e.reason))) Log.error(self, "Unable to donwload file, {0}" diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index d67bd3a3..5cb3b5d0 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -16,13 +16,15 @@ class EEFileUtils(): def remove(self, filelist): for file in filelist: if os.path.isfile(file): - Log.info(self, "Removing "+os.path.basename(file)+" ...") + Log.info(self, "Removing {0:65}".format(file), end=' ') os.remove(file) + Log.info(self, "{0}".format("[Done]")) Log.debug(self, 'file Removed') if os.path.isdir(file): try: - Log.info(self, "Removing "+os.path.basename(file)+"...") + Log.info(self, "Removing {0:65}".format(file), end=' ') shutil.rmtree(file) + Log.info(self, "{0}".format("[Done]")) except shutil.Error as e: Log.debug(self, "{err}".format(err=str(e.reason))) Log.error(self, 'Unable to Remove file ') diff --git a/tests/cli/97_test_site_update.py b/tests/cli/97_test_site_update.py index 538b5b15..b2135e0a 100644 --- a/tests/cli/97_test_site_update.py +++ b/tests/cli/97_test_site_update.py @@ -1,5 +1,5 @@ from ee.utils import test -from ee.cli.main import get_test_app +from ee.cli.plugins.site import EESiteUpdateController class CliTestCaseSite(test.EETestCase): @@ -10,15 +10,13 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_update(self): - self.app = get_test_app(argv=['site', 'update', 'example5.com', - '--password']) + self.ok(self.config.has_key('EESiteUpdateController', 'debug')) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_html(self): - self.app = get_test_app(argv=['site', 'update', 'example2.com', - '--html']) + self.ok(self.config.has_key('EESiteUpdateController', 'debug')) self.app.setup() self.app.run() self.app.close() @@ -38,8 +36,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_update_wp(self): - self.app = get_test_app(argv=['site', 'update', 'example5.com', - '--wp']) + self.ok(self.config.has_key('EESiteUpdateController', 'debug')) self.app.setup() self.app.run() self.app.close() From 50d60c17caffd5f80b71378f34f9f29a178a46d5 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 18:51:56 +0530 Subject: [PATCH 689/829] minor fix --- ee/cli/plugins/site.py | 17 ++++++++++------- ee/cli/plugins/site_functions.py | 5 +++-- ee/cli/plugins/stack.py | 13 ++++++++----- ee/core/aptget.py | 4 ++-- ee/core/fileutils.py | 2 +- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 1cbbdcab..233caf78 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -26,8 +26,7 @@ class EESiteController(CementBaseController): label = 'site' stacked_on = 'base' stacked_type = 'nested' - description = ('Site command manages website configuration' - ' with the help of the following subcommands') + description = ('Performs website specific operations') arguments = [ (['site_name'], dict(help='Website name')), @@ -405,7 +404,7 @@ class EESiteCreateController(CementBaseController): self.app.close(1) # Check rerequired packages are installed or not - site_package_check(self, stype) + ee_auth = site_package_check(self, stype) # setup NGINX configuration, and webroot setupdomain(self, data) # Setup database for MySQL site @@ -440,10 +439,14 @@ class EESiteCreateController(CementBaseController): .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot setwebrootpermissions(self, data['webroot']) + if len(ee_auth): + for msg in ee_auth: + Log.info(self, Log.ENDC + msg) + if data['wp']: - Log.info(self, Log.ENDC + "WordPress Admin User :" + Log.info(self, Log.ENDC + "WordPress admin user :" " {0}".format(ee_wp_creds['wp_user'])) - Log.info(self, Log.ENDC + "WordPress Admin User Password : {0}" + Log.info(self, Log.ENDC + "WordPress admin user password : {0}" .format(ee_wp_creds['wp_pass'])) addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot) Log.info(self, "Successfully created site" @@ -882,9 +885,9 @@ class EESiteUpdateController(CementBaseController): # setwebrootpermissions(self, data['webroot']) if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: - Log.info(self, Log.ENDC + "WordPress Admin User :" + Log.info(self, Log.ENDC + "WordPress admin user :" " {0}".format(ee_wp_creds['wp_user'])) - Log.info(self, Log.ENDC + "WordPress Admin User Password : {0}" + Log.info(self, Log.ENDC + "WordPress admin password : {0}" .format(ee_wp_creds['wp_pass'])) updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index a80e6d6f..aebe3272 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -17,7 +17,7 @@ def setupdomain(self, data): ee_domain_name = data['site_name'] ee_site_webroot = data['webroot'] - Log.info(self, "Setting up NGINX configuration \t\t", end='') + Log.info(self, "Setting up NGINX configuration \t", end='') # write nginx config for file try: ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}' @@ -376,7 +376,8 @@ def site_package_check(self, stype): "releases/download/v0.17.1/" "wp-cli.phar", "/usr/bin/wp", "WP_CLI"]] - stack.install(apt_packages=apt_packages, packages=packages) + return(stack.install(apt_packages=apt_packages, packages=packages, + disp_msg=False)) def updatewpuserpassword(self, ee_domain, ee_site_webroot): diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index ffc0aa34..8cb14dc6 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -911,7 +911,7 @@ class EEStackController(CementBaseController): EEVariables.ee_php_user, recursive=True) @expose(help="Install packages") - def install(self, packages=[], apt_packages=[]): + def install(self, packages=[], apt_packages=[], disp_msg=True): self.msg = [] try: # Default action for stack installation @@ -1072,10 +1072,13 @@ class EEStackController(CementBaseController): EEDownload.download(self, packages) Log.debug(self, "Calling post_pref") self.post_pref(apt_packages, packages) - if len(self.msg): - for msg in self.msg: - Log.info(self, msg) - Log.info(self, "Successfully installed packages") + if disp_msg: + if len(self.msg): + for msg in self.msg: + Log.info(self, Log.ENDC + msg) + Log.info(self, "Successfully installed packages") + else: + return self.msg @expose(help="Remove packages") def remove(self): diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 002e1ef3..57eaa7b8 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -15,7 +15,7 @@ class EEAptGet(): cache = apt.Cache() fprogress = apt.progress.text.AcquireProgress() iprogress = apt.progress.base.InstallProgress() - cache.update(fprogress) + cache.update() cache.close() def upgrade(self, packages): @@ -116,7 +116,7 @@ class EEAptGet(): .format(space=cache.required_space/1e6)) try: # Commit changes in cache (actually install) - cache.commit(fprogress, iprogress) + cache.commit() except Exception as e: print("package installation failed. [{err}]" .format(err=str(e))) diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 5cb3b5d0..b0c37f98 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -74,7 +74,7 @@ class EEFileUtils(): try: shutil.move(src, dst) except shutil.Error as e: - Log.debug(self, "{err}".format(err=str(e.reason))) + Log.debug(self, "{err}".format(err=e)) Log.error(self, 'Unable to move file from {0} to {1}' .format(src, dst)) From b7881c7a120e9ad73617f214ebe78b0557ae7985 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 20 Jan 2015 18:57:54 +0530 Subject: [PATCH 690/829] updated log messages --- ee/cli/plugins/secure.py | 3 +-- ee/cli/plugins/site_functions.py | 2 +- ee/cli/plugins/stack.py | 2 +- tests/cli/97_test_site_update.py | 11 +++++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index a578b4b7..3032e4ca 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -20,8 +20,7 @@ class EESecureController(CementBaseController): label = 'secure' stacked_on = 'base' stacked_type = 'nested' - description = ('clean command cleans different cache with following ' - 'options') + description = ('clean command cleans different cache ') arguments = [ (['--auth'], dict(help='secure auth', action='store_true')), diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index a80e6d6f..41374cd2 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -375,7 +375,7 @@ def site_package_check(self, stype): packages = packages + [["https://github.com/wp-cli/wp-cli/" "releases/download/v0.17.1/" "wp-cli.phar", "/usr/bin/wp", - "WP_CLI"]] + "WP-CLI"]] stack.install(apt_packages=apt_packages, packages=packages) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index ffc0aa34..f0e43039 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -36,7 +36,7 @@ class EEStackController(CementBaseController): label = 'stack' stacked_on = 'base' stacked_type = 'nested' - description = 'stack command manages stack operations' + description = 'Stack command manages stack operations' arguments = [ (['--web'], dict(help='Install web stack', action='store_true')), diff --git a/tests/cli/97_test_site_update.py b/tests/cli/97_test_site_update.py index b2135e0a..4e4e1acf 100644 --- a/tests/cli/97_test_site_update.py +++ b/tests/cli/97_test_site_update.py @@ -1,5 +1,5 @@ from ee.utils import test -from ee.cli.plugins.site import EESiteUpdateController +from ee.cli.main import get_test_app class CliTestCaseSite(test.EETestCase): @@ -10,13 +10,15 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_update(self): - self.ok(self.config.has_key('EESiteUpdateController', 'debug')) + self.app = get_test_app(argv=['site', 'update', 'example3.com', + '--password']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_html(self): - self.ok(self.config.has_key('EESiteUpdateController', 'debug')) + self.app = get_test_app(argv=['site', 'update', 'example4.com', + '--php']) self.app.setup() self.app.run() self.app.close() @@ -36,7 +38,8 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_update_wp(self): - self.ok(self.config.has_key('EESiteUpdateController', 'debug')) + self.app = get_test_app(argv=['site', 'update', 'example4.com', + '--mysql']) self.app.setup() self.app.run() self.app.close() From e9c0c7a8d1d59a4ee91d3937a11e4e6f6c77e0e0 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 20 Jan 2015 19:03:35 +0530 Subject: [PATCH 691/829] added log messages to download.py file --- ee/core/download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/download.py b/ee/core/download.py index 5469a593..e12b66be 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -21,7 +21,7 @@ class EEDownload(): os.makedirs(directory) Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ') urllib.request.urlretrieve(url, filename) - Log.info(self, "{0}".format("[ Done ]")) + Log.info(self, "{0}".format("[Done]")) except urllib.error.URLError as e: Log.debug(self, "[{err}]".format(err=str(e.reason))) Log.error(self, "Unable to donwload file, {0}" From bfb64b18599adb3b4b2882dd04a971d4f9f6a6c0 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 19:22:09 +0530 Subject: [PATCH 692/829] ee auth msg position --- ee/cli/plugins/site.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 233caf78..6c18e451 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -439,7 +439,7 @@ class EESiteCreateController(CementBaseController): .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot setwebrootpermissions(self, data['webroot']) - if len(ee_auth): + if ee_auth and len(ee_auth): for msg in ee_auth: Log.info(self, Log.ENDC + msg) @@ -809,7 +809,7 @@ class EESiteUpdateController(CementBaseController): Log.error(self, " Cannot update {0}, Invalid Options" .format(ee_domain)) - site_package_check(self, stype) + ee_auth = site_package_check(self, stype) sitebackup(self, data) # setup NGINX configuration, and webroot @@ -883,12 +883,15 @@ class EESiteUpdateController(CementBaseController): .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot # setwebrootpermissions(self, data['webroot']) + if ee_auth and len(ee_auth): + for msg in ee_auth: + Log.info(self, Log.ENDC + msg) if data['wp'] and oldsitetype in ['html', 'php', 'mysql']: - Log.info(self, Log.ENDC + "WordPress admin user :" + Log.info(self, "\n\n" + Log.ENDC + "WordPress admin user :" " {0}".format(ee_wp_creds['wp_user'])) Log.info(self, Log.ENDC + "WordPress admin password : {0}" - .format(ee_wp_creds['wp_pass'])) + .format(ee_wp_creds['wp_pass']) + "\n\n") updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) Log.info(self, "Successfully updated site" From ce037de1fb62a18a375545c5a9d261e467f91690 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 19:48:31 +0530 Subject: [PATCH 693/829] changed messages --- ee/cli/plugins/site_functions.py | 12 ++++++------ ee/core/download.py | 2 +- ee/core/fileutils.py | 4 ++-- ee/core/services.py | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 9577cfde..aac9c479 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -32,7 +32,7 @@ def setupdomain(self, data): except Exception as e: Log.debug(self, "{0}".format(e)) Log.error(self, "\nUnable to create NGINX configuration") - Log.info(self, "[Done]") + Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") # create symbolic link for EEFileUtils.create_symlink(self, ['/etc/nginx/sites-available/{0}' @@ -59,7 +59,7 @@ def setupdomain(self, data): .format(ee_domain_name), '{0}/logs/error.log' .format(ee_site_webroot)]) - Log.info(self, "[Done]") + Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") def setupdatabase(self, data): @@ -126,7 +126,7 @@ def setupdatabase(self, data): EEMysql.execute(self, "grant all privileges on {0}.* to {1}@{2}" .format(ee_db_name, ee_db_username, ee_mysql_grant_host)) - Log.info(self, "[Done]") + Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") data['ee_db_name'] = ee_db_name data['ee_db_user'] = ee_db_username @@ -152,7 +152,7 @@ def setupwordpress(self, data): Log.info(self, "Downloading Wordpress \t\t", end='') EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "wp --allow-root core download") - Log.info(self, "[Done]") + Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']): data = setupdatabase(self, data) @@ -324,7 +324,7 @@ def sitebackup(self, data): if data['currsitetype'] in ['html', 'php', 'mysql']: Log.info(self, "Backing up Webroot \t\t", end='') EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path) - Log.info(self, "[Done]") + Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") configfiles = glob.glob(ee_site_webroot + '/*-config.php') @@ -336,7 +336,7 @@ def sitebackup(self, data): EEShellExec.cmd_exec(self, "mysqldump {0} > {1}/{0}.sql" .format(ee_db_name, backup_path), errormsg="\nFailed: Backup Database") - Log.info(self, "[Done]") + Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") # move wp-config.php/ee-config.php to backup if data['currsitetype'] in ['mysql']: EEFileUtils.mvfile(self, configfiles[0], backup_path) diff --git a/ee/core/download.py b/ee/core/download.py index e12b66be..90e70544 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -21,7 +21,7 @@ class EEDownload(): os.makedirs(directory) Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ') urllib.request.urlretrieve(url, filename) - Log.info(self, "{0}".format("[Done]")) + Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + Log.OKBLUE + "]")) except urllib.error.URLError as e: Log.debug(self, "[{err}]".format(err=str(e.reason))) Log.error(self, "Unable to donwload file, {0}" diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index b0c37f98..17bab3a9 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -18,13 +18,13 @@ class EEFileUtils(): if os.path.isfile(file): Log.info(self, "Removing {0:65}".format(file), end=' ') os.remove(file) - Log.info(self, "{0}".format("[Done]")) + Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + Log.OKBLUE + "]")) Log.debug(self, 'file Removed') if os.path.isdir(file): try: Log.info(self, "Removing {0:65}".format(file), end=' ') shutil.rmtree(file) - Log.info(self, "{0}".format("[Done]")) + Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + Log.OKBLUE + "]")) except shutil.Error as e: Log.debug(self, "{err}".format(err=str(e.reason))) Log.error(self, 'Unable to Remove file ') diff --git a/ee/core/services.py b/ee/core/services.py index bf533e9f..6ecfded1 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -18,7 +18,7 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} start' .format(service_name)) if retcode[0] == 0: - Log.info(self, "[OK]") + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") return True else: Log.debug(self, "{0}".format(retcode[1])) @@ -35,7 +35,7 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} stop' .format(service_name)) if retcode[0] == 0: - Log.info(self, "[OK]") + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") return True else: Log.debug(self, "{0}".format(retcode[1])) @@ -52,7 +52,7 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} restart' .format(service_name)) if retcode[0] == 0: - Log.info(self, "[OK]") + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") return True else: Log.debug(self, "{0}".format(retcode[1])) @@ -75,7 +75,7 @@ class EEService(): # print(retcode[0]) # subprocess.getstatusoutput('service {0} reload' # .format(service_name)) - Log.info(self, "[OK]") + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") return True else: Log.debug(self, "{0}".format(retcode[1])) @@ -87,7 +87,7 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: - Log.info(self, "[OK]") + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") return True else: Log.debug(self, "{0}".format(retcode[1])) From 515a7628367d3bd96c9ff5e0635ad52a9b375f97 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 20:19:19 +0530 Subject: [PATCH 694/829] updated travis.yml --- .travis.yml | 138 ++++++++++++++++++++++++++-------------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/.travis.yml b/.travis.yml index a2b1ae4c..8f6b7dc8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,15 +16,15 @@ before_script: - sudo apt-get -qq autoremove script: - - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig - - sudo echo "Travis Banch = $TRAVIS_BRANCH" - - sudo apt-get install git python3-setuptools python3-dev python3-apt - - sudo python3 setup.py install - - sudo ee --help - - sudo ee stack install - - sudo ee stack install --web - - sudo ee stack install --admin - - sudo ee site create html.com + # - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig + # - sudo echo "Travis Banch = $TRAVIS_BRANCH" + # - sudo apt-get install git python3-setuptools python3-dev python3-apt + # - sudo python3 setup.py install + # - sudo ee --help + # - sudo ee stack install + # - sudo ee stack install --web + # - sudo ee stack install --admin + # - sudo ee site create html.com - sudo ee site create html.net --html - sudo ee site create php.com --php - sudo ee site create mysql.com --mysql @@ -43,63 +43,63 @@ script: - sudo ee site create site4.net --wp --wpfc - sudo ee site create site4.org --wpfc --wp - sudo ee site create site5.com --wpsubdir - - sudo ee site create site5.net --wpsubdir --basic - - sudo ee site create site5.org --basic --wpsubdir - - sudo ee site create site5.in --wpsubdirectory - - sudo ee site create site5.co --wpsubdirectory --basic - - sudo ee site create site5.co.in --basic --wpsubdirector - - sudo ee site create site6.com --wpsubdir --wpsc - - sudo ee site create site6.net --wpsc --wpsubdir - - sudo ee site create site6.org --wpsubdirectory --wpsc - - sudo ee site create site6.in --wpsc --wpsubdirectory - - sudo ee site create site7.com --wpsubdir --w3tc - - sudo ee site create site7.net --w3tc --wpsubdir - - sudo ee site create site7.org --wpsubdirectory --w3tc - - sudo ee site create site7.in --w3tc --wpsubdirectory - - sudo ee site create site8.com --wpsubdir --wpfc - - sudo ee site create site8.net --wpfc --wpsubdir - - sudo ee site create site8.org --wpsubdirectory --wpfc - - sudo ee site create site8.in --wpfc --wpsubdirectory - - sudo ee site create site9.com --wpsubdom - - sudo ee site create site9.net --wpsubdom --basic - - sudo ee site create site9.org --basic --wpsubdom - - sudo ee site create site9.in --wpsubdomain - - sudo ee site create site9.co --wpsubdomain --basic - - sudo ee site create site9.co.in --basic --wpsubdomain - - sudo ee site create site10.com --wpsubdom --wpsc - - sudo ee site create site10.net --wpsc --wpsubdom - - sudo ee site create site10.org --wpsubdomain --wpsc - - sudo ee site create site10.in --wpsc --wpsubdomain - - sudo ee site create site11.com --wpsubdom --w3tc - - sudo ee site create site11.net --w3tc --wpsubdom - - sudo ee site create site11.org --wpsubdomain --w3tc - - sudo ee site create site11.in --w3tc --wpsubdomain - - sudo ee site create site12.com --wpsubdom --wpfc - - sudo ee site create site12.net --wpfc --wpsubdom - - sudo ee site create site12.org --wpsubdomain --wpfc - - sudo ee site create site12.in --wpfc --wpsubdomain - - - sudo ee debug - - sudo ee debug --stop - - sudo ee site create 1.com --html - - sudo ee site create 2.com --php - - sudo ee site create 3.com --mysql - - sudo ee site update 1.com --wp - - sudo ee site update 2.com --wpsubdir - - sudo ee site update 3.com --wpsubdomain - - sudo ee site update site1.com --wp --wpfc - - sudo ee site update site1.com --wp --w3tc - - sudo ee site update site1.com --wp --wpsc - - sudo ee site update site5.com --wpsubdir --wpfc - - sudo ee site update site5.com --wpsubdir --w3tc - - sudo ee site update site5.com --wpsubdir --wpsc - - sudo ee site update site9.com --wpsubdom --wpfc - - sudo ee site update site9.com --wpsubdom --w3tc - - sudo ee site update site9.com --wpsubdom --wpsc - - sudo ee site delete site12.com --no-prompt - - sudo ee site delete site12.net --no-prompt - - sudo ee site delete site12.org --no-prompt - - - sudo ee stack install --mail - - sudo ls /var/www/ - - sudo wp --allow-root --info + # - sudo ee site create site5.net --wpsubdir --basic + # - sudo ee site create site5.org --basic --wpsubdir + # - sudo ee site create site5.in --wpsubdirectory + # - sudo ee site create site5.co --wpsubdirectory --basic + # - sudo ee site create site5.co.in --basic --wpsubdirector + # - sudo ee site create site6.com --wpsubdir --wpsc + # - sudo ee site create site6.net --wpsc --wpsubdir + # - sudo ee site create site6.org --wpsubdirectory --wpsc + # - sudo ee site create site6.in --wpsc --wpsubdirectory + # - sudo ee site create site7.com --wpsubdir --w3tc + # - sudo ee site create site7.net --w3tc --wpsubdir + # - sudo ee site create site7.org --wpsubdirectory --w3tc + # - sudo ee site create site7.in --w3tc --wpsubdirectory + # - sudo ee site create site8.com --wpsubdir --wpfc + # - sudo ee site create site8.net --wpfc --wpsubdir + # - sudo ee site create site8.org --wpsubdirectory --wpfc + # - sudo ee site create site8.in --wpfc --wpsubdirectory + # - sudo ee site create site9.com --wpsubdom + # - sudo ee site create site9.net --wpsubdom --basic + # - sudo ee site create site9.org --basic --wpsubdom + # - sudo ee site create site9.in --wpsubdomain + # - sudo ee site create site9.co --wpsubdomain --basic + # - sudo ee site create site9.co.in --basic --wpsubdomain + # - sudo ee site create site10.com --wpsubdom --wpsc + # - sudo ee site create site10.net --wpsc --wpsubdom + # - sudo ee site create site10.org --wpsubdomain --wpsc + # - sudo ee site create site10.in --wpsc --wpsubdomain + # - sudo ee site create site11.com --wpsubdom --w3tc + # - sudo ee site create site11.net --w3tc --wpsubdom + # - sudo ee site create site11.org --wpsubdomain --w3tc + # - sudo ee site create site11.in --w3tc --wpsubdomain + # - sudo ee site create site12.com --wpsubdom --wpfc + # - sudo ee site create site12.net --wpfc --wpsubdom + # - sudo ee site create site12.org --wpsubdomain --wpfc + # - sudo ee site create site12.in --wpfc --wpsubdomain + # + # - sudo ee debug + # - sudo ee debug --stop + # - sudo ee site create 1.com --html + # - sudo ee site create 2.com --php + # - sudo ee site create 3.com --mysql + # - sudo ee site update 1.com --wp + # - sudo ee site update 2.com --wpsubdir + # - sudo ee site update 3.com --wpsubdomain + # - sudo ee site update site1.com --wp --wpfc + # - sudo ee site update site1.com --wp --w3tc + # - sudo ee site update site1.com --wp --wpsc + # - sudo ee site update site5.com --wpsubdir --wpfc + # - sudo ee site update site5.com --wpsubdir --w3tc + # - sudo ee site update site5.com --wpsubdir --wpsc + # - sudo ee site update site9.com --wpsubdom --wpfc + # - sudo ee site update site9.com --wpsubdom --w3tc + # - sudo ee site update site9.com --wpsubdom --wpsc + # - sudo ee site delete site12.com --no-prompt + # - sudo ee site delete site12.net --no-prompt + # - sudo ee site delete site12.org --no-prompt + # + # - sudo ee stack install --mail + # - sudo ls /var/www/ + # - sudo wp --allow-root --info From b45907faa81abf5918b87c9f82e3e321bbd59547 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 20:21:26 +0530 Subject: [PATCH 695/829] updated travis.yml --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8f6b7dc8..8bc28c43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,11 +16,11 @@ before_script: - sudo apt-get -qq autoremove script: - # - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig - # - sudo echo "Travis Banch = $TRAVIS_BRANCH" - # - sudo apt-get install git python3-setuptools python3-dev python3-apt - # - sudo python3 setup.py install - # - sudo ee --help + - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig + - sudo echo "Travis Banch = $TRAVIS_BRANCH" + - sudo apt-get install git python3-setuptools python3-dev python3-apt + - sudo python3 setup.py install + - sudo ee --help # - sudo ee stack install # - sudo ee stack install --web # - sudo ee stack install --admin From dcd9d79085080f612a119cc58466700571af44f9 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 20 Jan 2015 20:27:06 +0530 Subject: [PATCH 696/829] updated travis.yml --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8bc28c43..3a646cde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,9 +21,9 @@ script: - sudo apt-get install git python3-setuptools python3-dev python3-apt - sudo python3 setup.py install - sudo ee --help - # - sudo ee stack install - # - sudo ee stack install --web - # - sudo ee stack install --admin + - sudo ee stack install + - sudo ee stack install --web + - sudo ee stack install --admin # - sudo ee site create html.com - sudo ee site create html.net --html - sudo ee site create php.com --php @@ -43,7 +43,7 @@ script: - sudo ee site create site4.net --wp --wpfc - sudo ee site create site4.org --wpfc --wp - sudo ee site create site5.com --wpsubdir - # - sudo ee site create site5.net --wpsubdir --basic + # - sudo ee site create site5.net --wpsubdir # - sudo ee site create site5.org --basic --wpsubdir # - sudo ee site create site5.in --wpsubdirectory # - sudo ee site create site5.co --wpsubdirectory --basic From 31660c8f20cf253fc788b143195ab58f8a2afd86 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 21 Jan 2015 11:09:48 +0530 Subject: [PATCH 697/829] added test.py --- ee/utils/test.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ee/utils/test.py diff --git a/ee/utils/test.py b/ee/utils/test.py new file mode 100644 index 00000000..1d3371ed --- /dev/null +++ b/ee/utils/test.py @@ -0,0 +1,15 @@ +"""Testing utilities for EasyEngine.""" +from ee.cli.main import EETestApp +from cement.utils.test import * + + +class EETestCase(CementTestCase): + app_class = EETestApp + + def setUp(self): + """Override setup actions (for every test).""" + super(EETestCase, self).setUp() + + def tearDown(self): + """Override teardown actions (for every test).""" + super(EETestCase, self).tearDown() From 7994f0738eb236e6e5cd5c0d62583c5b091ede60 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 21 Jan 2015 12:22:26 +0530 Subject: [PATCH 698/829] replace shutil.chown with os.chown --- .travis.yml | 108 ++++++++++++------------------- ee/cli/plugins/site_functions.py | 5 +- ee/cli/plugins/stack.py | 29 +++++---- ee/core/addswap.py | 5 +- ee/core/fileutils.py | 18 +++--- 5 files changed, 78 insertions(+), 87 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a646cde..507202aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,15 +24,12 @@ script: - sudo ee stack install - sudo ee stack install --web - sudo ee stack install --admin - # - sudo ee site create html.com + - sudo ee site create html.net --html - sudo ee site create php.com --php - sudo ee site create mysql.com --mysql - sudo ee site create site1.com --wp - - sudo ee site create site1.net --basic - - sudo ee site create site1.org --wp --basic - - sudo ee site create site1.in --basic --wp - - sudo ee site create subdomain.site1.in --basic --wp + - sudo ee site create site2.com --wpsc - sudo ee site create site2.net --wp --wpsc - sudo ee site create site2.org --wpsc --wp @@ -43,63 +40,44 @@ script: - sudo ee site create site4.net --wp --wpfc - sudo ee site create site4.org --wpfc --wp - sudo ee site create site5.com --wpsubdir - # - sudo ee site create site5.net --wpsubdir - # - sudo ee site create site5.org --basic --wpsubdir - # - sudo ee site create site5.in --wpsubdirectory - # - sudo ee site create site5.co --wpsubdirectory --basic - # - sudo ee site create site5.co.in --basic --wpsubdirector - # - sudo ee site create site6.com --wpsubdir --wpsc - # - sudo ee site create site6.net --wpsc --wpsubdir - # - sudo ee site create site6.org --wpsubdirectory --wpsc - # - sudo ee site create site6.in --wpsc --wpsubdirectory - # - sudo ee site create site7.com --wpsubdir --w3tc - # - sudo ee site create site7.net --w3tc --wpsubdir - # - sudo ee site create site7.org --wpsubdirectory --w3tc - # - sudo ee site create site7.in --w3tc --wpsubdirectory - # - sudo ee site create site8.com --wpsubdir --wpfc - # - sudo ee site create site8.net --wpfc --wpsubdir - # - sudo ee site create site8.org --wpsubdirectory --wpfc - # - sudo ee site create site8.in --wpfc --wpsubdirectory - # - sudo ee site create site9.com --wpsubdom - # - sudo ee site create site9.net --wpsubdom --basic - # - sudo ee site create site9.org --basic --wpsubdom - # - sudo ee site create site9.in --wpsubdomain - # - sudo ee site create site9.co --wpsubdomain --basic - # - sudo ee site create site9.co.in --basic --wpsubdomain - # - sudo ee site create site10.com --wpsubdom --wpsc - # - sudo ee site create site10.net --wpsc --wpsubdom - # - sudo ee site create site10.org --wpsubdomain --wpsc - # - sudo ee site create site10.in --wpsc --wpsubdomain - # - sudo ee site create site11.com --wpsubdom --w3tc - # - sudo ee site create site11.net --w3tc --wpsubdom - # - sudo ee site create site11.org --wpsubdomain --w3tc - # - sudo ee site create site11.in --w3tc --wpsubdomain - # - sudo ee site create site12.com --wpsubdom --wpfc - # - sudo ee site create site12.net --wpfc --wpsubdom - # - sudo ee site create site12.org --wpsubdomain --wpfc - # - sudo ee site create site12.in --wpfc --wpsubdomain - # - # - sudo ee debug - # - sudo ee debug --stop - # - sudo ee site create 1.com --html - # - sudo ee site create 2.com --php - # - sudo ee site create 3.com --mysql - # - sudo ee site update 1.com --wp - # - sudo ee site update 2.com --wpsubdir - # - sudo ee site update 3.com --wpsubdomain - # - sudo ee site update site1.com --wp --wpfc - # - sudo ee site update site1.com --wp --w3tc - # - sudo ee site update site1.com --wp --wpsc - # - sudo ee site update site5.com --wpsubdir --wpfc - # - sudo ee site update site5.com --wpsubdir --w3tc - # - sudo ee site update site5.com --wpsubdir --wpsc - # - sudo ee site update site9.com --wpsubdom --wpfc - # - sudo ee site update site9.com --wpsubdom --w3tc - # - sudo ee site update site9.com --wpsubdom --wpsc - # - sudo ee site delete site12.com --no-prompt - # - sudo ee site delete site12.net --no-prompt - # - sudo ee site delete site12.org --no-prompt - # - # - sudo ee stack install --mail - # - sudo ls /var/www/ - # - sudo wp --allow-root --info + - sudo ee site create site5.net --wpsubdir + + - sudo ee site create site6.com --wpsubdir --wpsc + - sudo ee site create site6.net --wpsc --wpsubdir + - sudo ee site create site7.com --wpsubdir --w3tc + - sudo ee site create site7.net --w3tc --wpsubdir + - sudo ee site create site8.com --wpsubdir --wpfc + - sudo ee site create site8.net --wpfc --wpsubdir + - sudo ee site create site9.in --wpsubdomain + + - sudo ee site create site10.org --wpsubdomain --wpsc + - sudo ee site create site10.in --wpsc --wpsubdomain + - sudo ee site create site11.org --wpsubdomain --w3tc + - sudo ee site create site11.in --w3tc --wpsubdomain + - sudo ee site create site12.org --wpsubdomain --wpfc + - sudo ee site create site12.in --wpfc --wpsubdomain + + - sudo ee debug + - sudo ee debug --stop + - sudo ee site create 1.com --html + - sudo ee site create 2.com --php + - sudo ee site create 3.com --mysql + - sudo ee site update 1.com --wp + - sudo ee site update 2.com --wpsubdir + - sudo ee site update 3.com --wpsubdomain + - sudo ee site update site1.com --wp --wpfc + - sudo ee site update site1.com --wp --w3tc + - sudo ee site update site1.com --wp --wpsc + - sudo ee site update site5.com --wpsubdir --wpfc + - sudo ee site update site5.com --wpsubdir --w3tc + - sudo ee site update site5.com --wpsubdir --wpsc + - sudo ee site update site9.com --wpsubdom --wpfc + - sudo ee site update site9.com --wpsubdom --w3tc + - sudo ee site update site9.com --wpsubdom --wpsc + - sudo ee site delete site12.com --no-prompt + - sudo ee site delete site12.net --no-prompt + - sudo ee site delete site12.org --no-prompt + + - sudo ee stack install --mail + - sudo ls /var/www/ + - sudo wp --allow-root --info diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index aac9c479..6da34f70 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -11,6 +11,7 @@ import string import sys import getpass import glob +import pwd def setupdomain(self, data): @@ -308,8 +309,8 @@ def uninstallwp_plugin(self, plugin_name, data): def setwebrootpermissions(self, webroot): Log.debug(self, "Setting up permissions") - EEFileUtils.chown(self, webroot, EEVariables.ee_php_user, - EEVariables.ee_php_user, recursive=True) + EEFileUtils.chown(self, webroot, pwd.getpwnam(EEVariables.ee_php_user)[2], + pwd.getpwnam(EEVariables.ee_php_user)[3], recursive=True) def sitebackup(self, data): diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 2fb45386..ae51d72d 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -531,7 +531,9 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting Privileges to dovecot ") # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" # "/dovecot") - EEFileUtils.chown(self, "/var/lig/dovecot", "vmail", "vmail", + EEFileUtils.chown(self, "/var/lig/dovecot", + pwd.getpwnam('vmail')[2], + pwd.getpwnam('vmail')[3], recursive=True) EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/" "default.sieve") @@ -598,8 +600,9 @@ class EEStackController(CementBaseController): # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/db/pma') EEFileUtils.chown(self, '/var/www/22222', - EEVariables.ee_php_user, - EEVariables.ee_php_user, recursive=True) + pwd.getpwnam(EEVariables.ee_php_user)[2], + pwd.getpwnam(EEVariables.ee_php_user)[3], + recursive=True) if any('/tmp/memcache.tar.gz' == x[1] for x in packages): Log.debug(self, "Extracting memcache.tar.gz to location" @@ -611,8 +614,9 @@ class EEStackController(CementBaseController): # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/cache/memcache') EEFileUtils.chown(self, '/var/www/22222', - EEVariables.ee_php_user, - EEVariables.ee_php_user, recursive=True) + pwd.getpwnam(EEVariables.ee_php_user)[2], + pwd.getpwnam(EEVariables.ee_php_user)[3], + recursive=True) if any('/tmp/webgrind.tar.gz' == x[1] for x in packages): @@ -630,8 +634,9 @@ class EEStackController(CementBaseController): # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/php/webgrind/') EEFileUtils.chown(self, '/var/www/22222', - EEVariables.ee_php_user, - EEVariables.ee_php_user, recursive=True) + pwd.getpwnam(EEVariables.ee_php_user)[2], + pwd.getpwnam(EEVariables.ee_php_user)[3], + recursive=True) if any('/tmp/anemometer.tar.gz' == x[1] for x in packages): @@ -759,8 +764,9 @@ class EEStackController(CementBaseController): "create") EEFileUtils.chown(self, '/var/www/22222', - EEVariables.ee_php_user, - EEVariables.ee_php_user, recursive=True) + pwd.getpwnam(EEVariables.ee_php_user)[2], + pwd.getpwnam(EEVariables.ee_php_user)[3], + recursive=True) # Copy Dovecot and Postfix templates which are depednet on # Vimbadmin @@ -907,8 +913,9 @@ class EEStackController(CementBaseController): EEFileUtils.remove(self, ["/var/www/roundcubemail" "/htdocs/installer"]) EEFileUtils.chown(self, '/var/www/roundcubemail', - EEVariables.ee_php_user, - EEVariables.ee_php_user, recursive=True) + pwd.getpwnam(EEVariables.ee_php_user)[2], + pwd.getpwnam(EEVariables.ee_php_user)[3], + recursive=True) @expose(help="Install packages") def install(self, packages=[], apt_packages=[], disp_msg=True): diff --git a/ee/core/addswap.py b/ee/core/addswap.py index 37291a24..ed3cfcd8 100644 --- a/ee/core/addswap.py +++ b/ee/core/addswap.py @@ -3,6 +3,7 @@ from ee.core.variables import EEVariables from ee.core.shellexec import EEShellExec from ee.core.fileutils import EEFileUtils from ee.core.logging import Log +import pwd class EESwap(): @@ -19,7 +20,9 @@ class EESwap(): EEShellExec.cmd_exec(self, "dd if=/dev/zero of=/ee-swapfile " "bs=1024 count=1048k") EEShellExec.cmd_exec(self, "mkswap /ee-swapfile") - EEFileUtils.chown(self, "/ee-swapfile", "root", "root") + EEFileUtils.chown(self, "/ee-swapfile", + pwd.getpwnam("root")[2], + pwd.getpwnam("root")[3]) EEFileUtils.chmod(self, "/ee-swapfile", 0o600) EEShellExec.cmd_exec(self, "swapon /ee-swapfile") with open("/etc/fstab", "a") as swap_file: diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 17bab3a9..a44f2781 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -18,13 +18,15 @@ class EEFileUtils(): if os.path.isfile(file): Log.info(self, "Removing {0:65}".format(file), end=' ') os.remove(file) - Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + Log.OKBLUE + "]")) + Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + + Log.OKBLUE + "]")) Log.debug(self, 'file Removed') if os.path.isdir(file): try: Log.info(self, "Removing {0:65}".format(file), end=' ') shutil.rmtree(file) - Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + Log.OKBLUE + "]")) + Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + + Log.OKBLUE + "]")) except shutil.Error as e: Log.debug(self, "{err}".format(err=str(e.reason))) Log.error(self, 'Unable to Remove file ') @@ -85,18 +87,18 @@ class EEFileUtils(): Log.debug(self, "{err}".format(err=e.strerror)) Log.error(self, 'Unable to Change Directory {0}'.format(path)) - def chown(self, path, user, group, recursive=False): + def chown(self, path, userid, groupid, recursive=False): try: if recursive: for root, dirs, files in os.walk(path): for d in dirs: - shutil.chown(os.path.join(root, d), user=user, - group=group) + os.chown(os.path.join(root, d), userid, + groupid) for f in files: - shutil.chown(os.path.join(root, f), user=user, - group=group) + os.chown(os.path.join(root, f), userid, + groupid) else: - shutil.chown(path, user=user, group=group) + os.chown(path, userid, groupid) except shutil.Error as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to change owner : {0}".format(path)) From aac18a6d65502f372836db933b03e5ca7377afcb Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 21 Jan 2015 14:02:08 +0530 Subject: [PATCH 699/829] Fix error of file clean.py and secure.py and added test cases --- ee/cli/plugins/clean.py | 2 +- ee/cli/plugins/secure.py | 6 +---- .../cli/{1_test_stack.py => 13_test_stack.py} | 0 tests/cli/2_test_stack_services_start.py | 4 +-- tests/cli/3_test_stack_services_status.py | 4 +-- tests/cli/4_test_stack_services_stop.py | 4 +-- tests/cli/5_test_stack_services_restart.py | 4 +-- tests/cli/92_test_site_cd.py | 16 ------------ tests/cli/97_test_site_update.py | 25 +++++++------------ tests/cli/{52_test_clean.py => test_clean.py} | 0 tests/cli/test_debug.py | 6 ----- .../cli/{51_test_secure.py => test_secure.py} | 0 12 files changed, 19 insertions(+), 52 deletions(-) rename tests/cli/{1_test_stack.py => 13_test_stack.py} (100%) delete mode 100644 tests/cli/92_test_site_cd.py rename tests/cli/{52_test_clean.py => test_clean.py} (100%) rename tests/cli/{51_test_secure.py => test_secure.py} (100%) diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index 2d6ab8dd..de5ba83a 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -51,7 +51,7 @@ class EECleanController(CementBaseController): @expose(hide=True) def clean_memcache(self): try: - if(EEAptGet.is_installed("memcached")): + if(EEAptGet.is_installed(self, "memcached")): EEService.restart_service(self, "memcached") Log.info(self, "Cleaning MemCache") else: diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 3032e4ca..932087f3 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -71,17 +71,13 @@ class EESecureController(CementBaseController): if EEVariables.ee_platform_distro == 'Ubuntu': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl spdy;/\" " - "/etc/nginx/sites-available/22222" + "/etc/nginx/sites-available/22222.conf" .format(port=port)) - else: - Log.error(self, "Unable to change EasyEngine admin port") if EEVariables.ee_platform_distro == 'Debian': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl;/\" " "/etc/nginx/sites-available/22222" .format(port=port)) - else: - Log.error(self, "Unable to change EasyEngine admin port") @expose(hide=True) def secure_ip(self): diff --git a/tests/cli/1_test_stack.py b/tests/cli/13_test_stack.py similarity index 100% rename from tests/cli/1_test_stack.py rename to tests/cli/13_test_stack.py diff --git a/tests/cli/2_test_stack_services_start.py b/tests/cli/2_test_stack_services_start.py index d37519ee..de874afe 100644 --- a/tests/cli/2_test_stack_services_start.py +++ b/tests/cli/2_test_stack_services_start.py @@ -16,7 +16,7 @@ class CliTestCaseStack(test.EETestCase): self.app.close() def test_ee_cli_stack_services_start_php5_fpm(self): - self.app = get_test_app(argv=['stack', 'start', '--php5-fpm']) + self.app = get_test_app(argv=['stack', 'start', '--php']) self.app.setup() self.app.run() self.app.close() @@ -34,7 +34,7 @@ class CliTestCaseStack(test.EETestCase): self.app.close() def test_ee_cli_stack_services_start_memcached(self): - self.app = get_test_app(argv=['stack', 'start', '--memcached']) + self.app = get_test_app(argv=['stack', 'start', '--memcache']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/3_test_stack_services_status.py b/tests/cli/3_test_stack_services_status.py index acf73ca3..42bd65a8 100644 --- a/tests/cli/3_test_stack_services_status.py +++ b/tests/cli/3_test_stack_services_status.py @@ -16,7 +16,7 @@ class CliTestCaseStack(test.EETestCase): self.app.close() def test_ee_cli_stack_services_status_php5_fpm(self): - self.app = get_test_app(argv=['stack', 'status', '--php5-fpm']) + self.app = get_test_app(argv=['stack', 'status', '--php']) self.app.setup() self.app.run() self.app.close() @@ -34,7 +34,7 @@ class CliTestCaseStack(test.EETestCase): self.app.close() def test_ee_cli_stack_services_status_memcached(self): - self.app = get_test_app(argv=['stack', 'status', '--memcached']) + self.app = get_test_app(argv=['stack', 'status', '--memcache']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/4_test_stack_services_stop.py b/tests/cli/4_test_stack_services_stop.py index 0eaef4e8..9b6ece4b 100644 --- a/tests/cli/4_test_stack_services_stop.py +++ b/tests/cli/4_test_stack_services_stop.py @@ -16,7 +16,7 @@ class CliTestCaseStack(test.EETestCase): self.app.close() def test_ee_cli_stack_services_stop_php5_fpm(self): - self.app = get_test_app(argv=['stack', 'stop', '--php5-fpm']) + self.app = get_test_app(argv=['stack', 'stop', '--php']) self.app.setup() self.app.run() self.app.close() @@ -34,7 +34,7 @@ class CliTestCaseStack(test.EETestCase): self.app.close() def test_ee_cli_stack_services_stop_memcached(self): - self.app = get_test_app(argv=['stack', 'stop', '--memcached']) + self.app = get_test_app(argv=['stack', 'stop', '--memcache']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/5_test_stack_services_restart.py b/tests/cli/5_test_stack_services_restart.py index dfe24081..39d8825c 100644 --- a/tests/cli/5_test_stack_services_restart.py +++ b/tests/cli/5_test_stack_services_restart.py @@ -16,7 +16,7 @@ class CliTestCaseStack(test.EETestCase): self.app.close() def test_ee_cli_stack_services_restart_php5_fpm(self): - self.app = get_test_app(argv=['stack', 'restart', '--php5-fpm']) + self.app = get_test_app(argv=['stack', 'restart', '--php']) self.app.setup() self.app.run() self.app.close() @@ -34,7 +34,7 @@ class CliTestCaseStack(test.EETestCase): self.app.close() def test_ee_cli_stack_services_restart_memcached(self): - self.app = get_test_app(argv=['stack', 'restart', '--memcached']) + self.app = get_test_app(argv=['stack', 'restart', '--memcache']) self.app.setup() self.app.run() self.app.close() diff --git a/tests/cli/92_test_site_cd.py b/tests/cli/92_test_site_cd.py deleted file mode 100644 index 51d55bec..00000000 --- a/tests/cli/92_test_site_cd.py +++ /dev/null @@ -1,16 +0,0 @@ -from ee.utils import test -from ee.cli.main import get_test_app - - -class CliTestCaseSite(test.EETestCase): - - def test_ee_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_show_cd(self): - self.app = get_test_app(argv=['site', 'cd', 'example.com']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/97_test_site_update.py b/tests/cli/97_test_site_update.py index 4e4e1acf..38b0c0ab 100644 --- a/tests/cli/97_test_site_update.py +++ b/tests/cli/97_test_site_update.py @@ -9,43 +9,36 @@ class CliTestCaseSite(test.EETestCase): self.app.run() self.app.close() - def test_ee_cli_site_update(self): - self.app = get_test_app(argv=['site', 'update', 'example3.com', - '--password']) - self.app.setup() - self.app.run() - self.app.close() - def test_ee_cli_site_update_html(self): - self.app = get_test_app(argv=['site', 'update', 'example4.com', - '--php']) + self.app = get_test_app(argv=['site', 'update', 'example2.com', + '--html']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_php(self): - self.app = get_test_app(argv=['site', 'update', 'example3.com', + self.app = get_test_app(argv=['site', 'update', 'example1.com', '--php']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_mysql(self): - self.app = get_test_app(argv=['site', 'update', 'example4.com', - '--mysql']) + self.app = get_test_app(argv=['site', 'update', 'example1.com', + '--html']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wp(self): - self.app = get_test_app(argv=['site', 'update', 'example4.com', - '--mysql']) + self.app = get_test_app(argv=['site', 'update', 'example5.com', + '--wp']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_update_wpsubdir(self): - self.app = get_test_app(argv=['site', 'update', 'example6.com', + self.app = get_test_app(argv=['site', 'update', 'example4.com', '--wpsubdir']) self.app.setup() self.app.run() @@ -73,7 +66,7 @@ class CliTestCaseSite(test.EETestCase): self.app.close() def test_ee_cli_site_update_wpsc(self): - self.app = get_test_app(argv=['site', 'update', 'example1.com', + self.app = get_test_app(argv=['site', 'update', 'example6.com', '--wpsc']) self.app.setup() self.app.run() diff --git a/tests/cli/52_test_clean.py b/tests/cli/test_clean.py similarity index 100% rename from tests/cli/52_test_clean.py rename to tests/cli/test_clean.py diff --git a/tests/cli/test_debug.py b/tests/cli/test_debug.py index 643b34ec..ba071001 100644 --- a/tests/cli/test_debug.py +++ b/tests/cli/test_debug.py @@ -93,9 +93,3 @@ class CliTestCaseDebug(test.EETestCase): self.app.setup() self.app.run() self.app.close() - - def test_ee_cli_debug(self): - self.app = get_test_app(argv=['debug']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/51_test_secure.py b/tests/cli/test_secure.py similarity index 100% rename from tests/cli/51_test_secure.py rename to tests/cli/test_secure.py From e33422970a99a89c1e132005746566f55e6bc266 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 21 Jan 2015 14:03:30 +0530 Subject: [PATCH 700/829] shutil absolute path provided while creating wpsubdir site --- ee/cli/plugins/site_functions.py | 8 ++++---- ee/cli/plugins/stack.py | 24 +++++++++++------------- ee/core/addswap.py | 5 +---- ee/core/fileutils.py | 8 ++++++-- ee/core/shellexec.py | 9 ++++++++- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 6da34f70..89484fa5 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -11,7 +11,6 @@ import string import sys import getpass import glob -import pwd def setupdomain(self, data): @@ -197,7 +196,8 @@ def setupwordpress(self, data): var2="" "\n define('WPMU_ACCEL_REDIRECT', true);") ) - EEFileUtils.mvfile(self, './wp-config.php', '../') + EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php', + os.path.abspath(os.path.join(os.getcwd(), os.pardir))) if not ee_wp_user: ee_wp_user = EEVariables.ee_user @@ -309,8 +309,8 @@ def uninstallwp_plugin(self, plugin_name, data): def setwebrootpermissions(self, webroot): Log.debug(self, "Setting up permissions") - EEFileUtils.chown(self, webroot, pwd.getpwnam(EEVariables.ee_php_user)[2], - pwd.getpwnam(EEVariables.ee_php_user)[3], recursive=True) + EEFileUtils.chown(self, webroot, EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) def sitebackup(self, data): diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index ae51d72d..b7f9dc24 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -531,9 +531,7 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting Privileges to dovecot ") # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" # "/dovecot") - EEFileUtils.chown(self, "/var/lig/dovecot", - pwd.getpwnam('vmail')[2], - pwd.getpwnam('vmail')[3], + EEFileUtils.chown(self, "/var/lig/dovecot", 'vmail', 'vmail', recursive=True) EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/" "default.sieve") @@ -600,8 +598,8 @@ class EEStackController(CementBaseController): # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/db/pma') EEFileUtils.chown(self, '/var/www/22222', - pwd.getpwnam(EEVariables.ee_php_user)[2], - pwd.getpwnam(EEVariables.ee_php_user)[3], + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) if any('/tmp/memcache.tar.gz' == x[1] for x in packages): @@ -614,8 +612,8 @@ class EEStackController(CementBaseController): # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/cache/memcache') EEFileUtils.chown(self, '/var/www/22222', - pwd.getpwnam(EEVariables.ee_php_user)[2], - pwd.getpwnam(EEVariables.ee_php_user)[3], + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) if any('/tmp/webgrind.tar.gz' == x[1] @@ -634,8 +632,8 @@ class EEStackController(CementBaseController): # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/php/webgrind/') EEFileUtils.chown(self, '/var/www/22222', - pwd.getpwnam(EEVariables.ee_php_user)[2], - pwd.getpwnam(EEVariables.ee_php_user)[3], + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) if any('/tmp/anemometer.tar.gz' == x[1] @@ -764,8 +762,8 @@ class EEStackController(CementBaseController): "create") EEFileUtils.chown(self, '/var/www/22222', - pwd.getpwnam(EEVariables.ee_php_user)[2], - pwd.getpwnam(EEVariables.ee_php_user)[3], + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) # Copy Dovecot and Postfix templates which are depednet on @@ -913,8 +911,8 @@ class EEStackController(CementBaseController): EEFileUtils.remove(self, ["/var/www/roundcubemail" "/htdocs/installer"]) EEFileUtils.chown(self, '/var/www/roundcubemail', - pwd.getpwnam(EEVariables.ee_php_user)[2], - pwd.getpwnam(EEVariables.ee_php_user)[3], + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) @expose(help="Install packages") diff --git a/ee/core/addswap.py b/ee/core/addswap.py index ed3cfcd8..37291a24 100644 --- a/ee/core/addswap.py +++ b/ee/core/addswap.py @@ -3,7 +3,6 @@ from ee.core.variables import EEVariables from ee.core.shellexec import EEShellExec from ee.core.fileutils import EEFileUtils from ee.core.logging import Log -import pwd class EESwap(): @@ -20,9 +19,7 @@ class EESwap(): EEShellExec.cmd_exec(self, "dd if=/dev/zero of=/ee-swapfile " "bs=1024 count=1048k") EEShellExec.cmd_exec(self, "mkswap /ee-swapfile") - EEFileUtils.chown(self, "/ee-swapfile", - pwd.getpwnam("root")[2], - pwd.getpwnam("root")[3]) + EEFileUtils.chown(self, "/ee-swapfile", "root", "root") EEFileUtils.chmod(self, "/ee-swapfile", 0o600) EEShellExec.cmd_exec(self, "swapon /ee-swapfile") with open("/etc/fstab", "a") as swap_file: diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index a44f2781..ccf576fb 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -4,6 +4,7 @@ import os import sys import glob import shutil +import pwd import fileinput from ee.core.logging import Log @@ -74,8 +75,9 @@ class EEFileUtils(): def mvfile(self, src, dst): try: + Log.debug(self, "Moving file from {0} to {1}".format(src, dst)) shutil.move(src, dst) - except shutil.Error as e: + except Exception as e: Log.debug(self, "{err}".format(err=e)) Log.error(self, 'Unable to move file from {0} to {1}' .format(src, dst)) @@ -87,7 +89,9 @@ class EEFileUtils(): Log.debug(self, "{err}".format(err=e.strerror)) Log.error(self, 'Unable to Change Directory {0}'.format(path)) - def chown(self, path, userid, groupid, recursive=False): + def chown(self, path, user, group, recursive=False): + userid = pwd.getpwnam(user)[2] + groupid = pwd.getpwnam(user)[3] try: if recursive: for root, dirs, files in os.walk(path): diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 8f16044e..eabb4262 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -24,7 +24,14 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to execute command {0}" + .format(command)) + except Exception as e: + if errormsg: + Log.error(self, errormsg) + else: + Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to execute command {0}" .format(command)) From b4ac28ce8b283467e1eab02b734b20e102bf4a75 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 21 Jan 2015 14:36:18 +0530 Subject: [PATCH 701/829] minor commit --- .travis.yml | 19 +++++++++++++------ config/bash_completion.d/ee_auto.rc | 2 +- ee/cli/plugins/site_functions.py | 5 +++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 507202aa..f3212df9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ script: - sudo ee site create site7.net --w3tc --wpsubdir - sudo ee site create site8.com --wpsubdir --wpfc - sudo ee site create site8.net --wpfc --wpsubdir - - sudo ee site create site9.in --wpsubdomain + - sudo ee site create site9.com --wpsubdomain - sudo ee site create site10.org --wpsubdomain --wpsc - sudo ee site create site10.in --wpsc --wpsubdomain @@ -56,25 +56,32 @@ script: - sudo ee site create site11.in --w3tc --wpsubdomain - sudo ee site create site12.org --wpsubdomain --wpfc - sudo ee site create site12.in --wpfc --wpsubdomain - + - sudo ee site create site12.net --wpfc --wpsubdomain + - sudo ee site create site12.org --wpfc --wpsubdomain + - sudo ee debug - sudo ee debug --stop - sudo ee site create 1.com --html - sudo ee site create 2.com --php - sudo ee site create 3.com --mysql + - sudo ee site update 1.com --wp - sudo ee site update 2.com --wpsubdir - sudo ee site update 3.com --wpsubdomain + - sudo ee site update site1.com --wp --wpfc - sudo ee site update site1.com --wp --w3tc - sudo ee site update site1.com --wp --wpsc + - sudo ee site update site5.com --wpsubdir --wpfc - sudo ee site update site5.com --wpsubdir --w3tc - sudo ee site update site5.com --wpsubdir --wpsc - - sudo ee site update site9.com --wpsubdom --wpfc - - sudo ee site update site9.com --wpsubdom --w3tc - - sudo ee site update site9.com --wpsubdom --wpsc - - sudo ee site delete site12.com --no-prompt + + - sudo ee site update site9.com --wpsubdomain --wpfc + - sudo ee site update site9.com --wpsubdomain --w3tc + - sudo ee site update site9.com --wpsubdomain --wpsc + + - sudo ee site delete site12.com --all --no-prompt - sudo ee site delete site12.net --no-prompt - sudo ee site delete site12.org --no-prompt diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index dfd7a300..062548bf 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -41,7 +41,7 @@ _ee_complete() "site") COMPREPLY=( $(compgen \ - -W "create delete disable edit enable info list log show update" \ + -W "cd create delete disable edit enable info list log show update" \ -- $cur) ) ;; diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 89484fa5..26d05ccf 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -185,11 +185,12 @@ def setupwordpress(self, data): + "--dbpass={0}".format(data['ee_db_pass'])) else: Log.debug(self, "Generating wp-config for WordPress multisite") - EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core config " + EEShellExec.cmd_exec(self, "bash -c \'php /usr/bin/wp --allow-root " + + "core config " + "--dbname={0} --dbprefix={1} " .format(data['ee_db_name'], ee_wp_prefix) + "--dbuser={0} --dbpass={1} " - "--extra-php< Date: Wed, 21 Jan 2015 14:58:52 +0530 Subject: [PATCH 702/829] Fixed debug options --- ee/cli/plugins/debug.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 930cf496..a76c2eae 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -372,11 +372,19 @@ class EEDebugController(CementBaseController): if ((not self.app.pargs.nginx) and (not self.app.pargs.php) and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) - and (not self.app.pargs.wp) and (not self.app.pargs.rewrite)): + and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) + and (not self.app.pargs.site_name)): self.debug_nginx() self.debug_php() self.debug_fpm() self.debug_mysql() + self.debug_rewrite() + + if ((not self.app.pargs.nginx) and (not self.app.pargs.php) + and (not self.app.pargs.fpm) and (not self.app.pargs.mysql) + and (not self.app.pargs.wp) and (not self.app.pargs.rewrite) + and self.app.pargs.site_name): + self.debug_nginx() self.debug_wp() self.debug_rewrite() From 06efab9579b1d0fdcfead40e4ebcc6ac69510239 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 21 Jan 2015 15:19:27 +0530 Subject: [PATCH 703/829] updated travis --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3212df9..61ef8c08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,10 +57,11 @@ script: - sudo ee site create site12.org --wpsubdomain --wpfc - sudo ee site create site12.in --wpfc --wpsubdomain - sudo ee site create site12.net --wpfc --wpsubdomain - - sudo ee site create site12.org --wpfc --wpsubdomain - sudo ee debug - sudo ee debug --stop + - sudo ee debug site12.net + - sudo ee debug site12.net --stop - sudo ee site create 1.com --html - sudo ee site create 2.com --php - sudo ee site create 3.com --mysql @@ -81,7 +82,7 @@ script: - sudo ee site update site9.com --wpsubdomain --w3tc - sudo ee site update site9.com --wpsubdomain --wpsc - - sudo ee site delete site12.com --all --no-prompt + - sudo ee site delete site12.in --all --no-prompt - sudo ee site delete site12.net --no-prompt - sudo ee site delete site12.org --no-prompt From 3bc459d083517643f604d9153b8bb93944ca6773 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 21 Jan 2015 15:36:29 +0530 Subject: [PATCH 704/829] Fixed missing self variables --- ee/cli/plugins/debug.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index a76c2eae..7d585d44 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -86,11 +86,12 @@ class EEDebugController(CementBaseController): config_path = ("/etc/nginx/sites-available/{0}" .format(self.app.pargs.site_name)) if os.path.isfile(config_path): - if not EEShellExec.cmd_exec("grep \"error.log debug\" {0}" - .format(config_path)): + if not EEShellExec.cmd_exec(self, "grep \"error.log debug\" " + "{0}".format(config_path)): Log.info(self, "Starting NGINX debug connection for " "{0}".format(self.app.pargs.site_name)) - EEShellExec.cmd_exec("sed -i \"s/error.log;/error.log " + EEShellExec.cmd_exec(self, "sed -i \"s/error.log;/" + "error.log " "debug;/\" {0}".format(config_path)) self.trigger_nginx = True @@ -109,11 +110,11 @@ class EEDebugController(CementBaseController): config_path = ("/etc/nginx/sites-available/{0}" .format(self.app.pargs.site_name)) if os.path.isfile(config_path): - if EEShellExec.cmd_exec("grep \"error.log debug\" {0}" + if EEShellExec.cmd_exec(self, "grep \"error.log debug\" {0}" .format(config_path)): Log.info(self, "Stoping NGINX debug connection for {0}" .format(self.app.pargs.site_name)) - EEShellExec.cmd_exec("sed -i \"s/error.log debug;/" + EEShellExec.cmd_exec(self, "sed -i \"s/error.log debug;/" "error.log;/\" {0}" .format(config_path)) self.trigger_nginx = True @@ -286,7 +287,7 @@ class EEDebugController(CementBaseController): EEShellExec.cmd_exec(self, "sed -i \"/define(\'" "WP_DEBUG_LOG\', true);/d\" {0}" .format(wp_config)) - EEShellExec.cmd_exec("sed -i \"/define(\'" + EEShellExec.cmd_exec(self, "sed -i \"/define(\'" "SAVEQUERIES\', " "true);/d\" {0}".format(wp_config)) else: From debee26018e712d1ef8e3b12409cc4ecc97e32a4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 21 Jan 2015 18:14:30 +0530 Subject: [PATCH 705/829] Add 301, 302, 404 per http://community.rtcamp.com/t/fascgi-cache-caching-error-pages/3847 --- ee/cli/templates/fastcgi.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/templates/fastcgi.mustache b/ee/cli/templates/fastcgi.mustache index 37f06e0f..db82c459 100644 --- a/ee/cli/templates/fastcgi.mustache +++ b/ee/cli/templates/fastcgi.mustache @@ -2,7 +2,7 @@ fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:50m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503; -fastcgi_cache_valid any 1h; +fastcgi_cache_valid 200 301 302 404 1h; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_param SERVER_NAME $http_host; From a740dfba1383195aa4be4158416a20266da9d6db Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 21 Jan 2015 18:40:44 +0530 Subject: [PATCH 706/829] fixed dependenc purge problem in mail stack --- ee/cli/plugins/site.py | 1 - ee/core/aptget.py | 32 ++++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 6c18e451..8b165fb4 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -836,7 +836,6 @@ class EESiteUpdateController(CementBaseController): if oldsitetype == 'mysql': config_file = (ee_site_webroot + '/backup/{0}/ee-config.php' .format(EEVariables.ee_date)) - print(config_file, 'DB_NAME') data['ee_db_name'] = (EEFileUtils.grep(self, config_file, 'DB_NAME') .split(',')[1] diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 57eaa7b8..b1adc51b 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -151,6 +151,8 @@ class EEAptGet(): fprogress = apt.progress.text.AcquireProgress() iprogress = apt.progress.base.InstallProgress() + onelevel = [] + my_selected_packages = [] # Cache Initialization if not cache: @@ -176,22 +178,11 @@ class EEAptGet(): # 2) We sequentially remove every package in list # - via is_auto_installed we check if we can safely remove it deplist = [] - onelevel = __dependencies_loop(cache, deplist, pkg, - onelevel=True) + onelevel = onelevel + __dependencies_loop(cache, deplist, pkg, + onelevel=True) # Mark for deletion the first package, to fire up # auto_removable Purge? - for dep in onelevel: - my_selected_packages.append(dep.name) - try: - if purge: - dep.mark_delete(purge=True) - else: - dep.mark_delete(purge=False) - except SystemError as e: - Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to purge depedencies.") - try: if purge: pkg.mark_delete(purge=True) @@ -199,7 +190,20 @@ class EEAptGet(): pkg.mark_delete(purge=False) except SystemError as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to purge packages.") + apt.ProblemResolver(cache).remove(pkg) + # print(pkg.inst_state) + # Log.error(self, "Unable to purge packages.") + + for dep in onelevel: + my_selected_packages.append(dep.name) + try: + if purge: + dep.mark_delete(purge=True) + else: + dep.mark_delete(purge=False) + except SystemError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to purge depedencies.") # Check if packages available for remove/update. if cache.delete_count > 0: From aefccc5502220db19e96508b7785d1bfc1688813 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 22 Jan 2015 10:52:10 +0530 Subject: [PATCH 707/829] Updated ViMbAdmin version --- ee/core/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index d911d703..477b3a85 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -18,7 +18,7 @@ class EEVariables(): ee_wp_cli = "0.18.0" ee_adminer = "4.1.0" ee_roundcube = "1.0.4" - ee_vimbadmin = "3.0.10" + ee_vimbadmin = "3.0.11" # Current date and time of System ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S') From d4c06228d2dea6d49ba5d98c8c48bbe6c9b4ae8f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 22 Jan 2015 11:08:46 +0530 Subject: [PATCH 708/829] Removed ViMbAdmin hardcoded version --- ee/cli/plugins/stack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index b7f9dc24..ccfa6f3c 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -682,7 +682,8 @@ class EEStackController(CementBaseController): Log.debug(self, "Creating directory " "/var/www/22222/htdocs/") os.makedirs('/var/www/22222/htdocs/') - shutil.move('/tmp/ViMbAdmin-3.0.10/', + shutil.move('/tmp/ViMbAdmin-{0}/' + .format(EEVariables.ee_vimbadmin), '/var/www/22222/htdocs/vimbadmin/') # Donwload composer and install ViMbAdmin From 12967f57937242bdf2ec55df805c7ee3b5f46f08 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Thu, 22 Jan 2015 12:34:14 +0530 Subject: [PATCH 709/829] Done changes in stack_services.py and secure.py --- ee/cli/plugins/secure.py | 97 ++++++++++++++++++-------------- ee/cli/plugins/stack_services.py | 2 +- tests/cli/94_test_site_edit.py | 16 ------ tests/cli/test_site_delete.py | 6 +- 4 files changed, 60 insertions(+), 61 deletions(-) delete mode 100644 tests/cli/94_test_site_edit.py diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 932087f3..59cdf4f7 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -27,8 +27,11 @@ class EESecureController(CementBaseController): (['--port'], dict(help='secure port', action='store_true')), (['--ip'], - dict(help='secure ip', action='store_true')) - ] + dict(help='secure ip', action='store_true')), + (['user_input'], + dict(help='user input', nargs='?', default=None)), + (['user_pass'], + dict(help='user pass', nargs='?', default=None))] @expose(hide=True) def default(self): @@ -44,65 +47,77 @@ class EESecureController(CementBaseController): passwd = ''.join([random.choice (string.ascii_letters + string.digits) for n in range(6)]) - username = input("Provide HTTP authentication user " - "name [{0}] :".format(EEVariables.ee_user)) - password = input("Provide HTTP authentication " - "password [{0}]".format(passwd)) - if username == "": - username = EEVariables.ee_user - Log.info(self, "HTTP authentication username:{username}" - .format(username=username)) - if password == "": - password = passwd - Log.info(self, "HTTP authentication password:{password}" - .format(password=password)) + if not self.app.pargs.user_input: + username = input("Provide HTTP authentication user " + "name [{0}] :".format(EEVariables.ee_user)) + self.app.pargs.user_input = username + 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)) + self.app.pargs.user_pass = password + if password == "": + self.app.pargs.user_pass = passwd EEShellExec.cmd_exec(self, "printf \"{username}:" "$(openssl passwd -crypt " "{password} 2> /dev/null)\n\"" "> /etc/nginx/htpasswd-ee 2>/dev/null" - .format(username=username, - password=password)) + .format(username=self.app.pargs.user_input, + password=self.app.pargs.user_pass)) + Log.info(self, "Successfully changed HTTP authentication" + " username:{username}" + .format(username=self.app.pargs.user_input)) + Log.info(self, "Successfully changed HTTP authentication" + " password:{password}" + .format(password=self.app.pargs.user_pass)) @expose(hide=True) def secure_port(self): - port = input("EasyEngine admin port [22222]:") - if port == "": - port = 22222 + 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 == "": + self.app.pargs.user_input = 22222 + while not port.isdigit() and port != "": + Log.info(self, "Please Enter valid port number :") + port = input("EasyEngine admin port [22222]:") + self.app.pargs.user_input = port if EEVariables.ee_platform_distro == 'Ubuntu': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl spdy;/\" " "/etc/nginx/sites-available/22222.conf" - .format(port=port)) + .format(port=self.app.pargs.user_input)) if EEVariables.ee_platform_distro == 'Debian': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl;/\" " - "/etc/nginx/sites-available/22222" - .format(port=port)) + "/etc/nginx/sites-available/22222.conf" + .format(port=self.app.pargs.user_input)) + Log.info(self, "Successfully port changed {port}" + .format(port=self.app.pargs.user_input)) @expose(hide=True) def secure_ip(self): - # TODO:remaining with ee.conf updation in file + # TODO:remaining with ee.conf updation in file newlist = [] - ip = input("Enter the comma separated IP addresses " - "to white list [127.0.0.1]:") + if not self.app.pargs.user_input: + ip = input("Enter the comma separated IP addresses " + "to white list [127.0.0.1]:") + self.app.pargs.user_input = ip try: - user_list_ip = ip.split(',') + user_ip = self.app.pargs.user_input.split(',') except Exception as e: - ip = ['127.0.0.1'] - self.app.config.set('mysql', 'grant-host', "hello") - exist_ip_list = self.app.config.get('stack', 'ip-address').split() - for check_ip in user_list_ip: - if check_ip not in exist_ip_list: - newlist.extend(exist_ip_list) - # changes in acl.conf file - if len(newlist) != 0: - EEShellExec.cmd_exec(self, "sed -i \"/allow.*/d\" /etc/nginx" - "/common/acl.conf") - for whitelist_adre in newlist: - EEShellExec.cmd_exec(self, "sed -i \"/deny/i " - "echo allow {whitelist_adre}\\;\" " - "/etc/nginx/common/acl.conf" - .format(whitelist_adre=whitelist_adre)) + user_ip = ['127.0.0.1'] + for ip_addr in user_ip: + if not ("exist_ip_address "+ip_addr in open('/etc/nginx/common/' + 'acl.conf').read()): + EEShellExec.cmd_exec(self, "sed -i " + "\"/deny/i allow {whitelist_adre}\;\"" + " /etc/nginx/common/acl.conf" + .format(whitelist_adre=ip_addr)) + Log.info(self, "Successfully added IP address in acl.conf file") def load(app): diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index 4ab826f7..31d46e13 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -12,7 +12,7 @@ class EEStackStatusController(CementBaseController): description = 'Get status of stack' arguments = [ (['--memcache'], - dict(help='start/stop/restart stack', action='store_true')), + dict(help='start/stop/restart memcache', action='store_true')), (['--dovecot'], dict(help='start/stop/restart dovecot', action='store_true')), ] diff --git a/tests/cli/94_test_site_edit.py b/tests/cli/94_test_site_edit.py deleted file mode 100644 index ebeee4f5..00000000 --- a/tests/cli/94_test_site_edit.py +++ /dev/null @@ -1,16 +0,0 @@ -from ee.utils import test -from ee.cli.main import get_test_app - - -class CliTestCaseSite(test.EETestCase): - - def test_ee_cli(self): - self.app.setup() - self.app.run() - self.app.close() - - def test_ee_cli_site_edit(self): - self.app = get_test_app(argv=['site', 'edit', 'example1.com']) - self.app.setup() - self.app.run() - self.app.close() diff --git a/tests/cli/test_site_delete.py b/tests/cli/test_site_delete.py index 2a2dfe8d..b9f204ea 100644 --- a/tests/cli/test_site_delete.py +++ b/tests/cli/test_site_delete.py @@ -18,21 +18,21 @@ class CliTestCaseSite(test.EETestCase): def test_ee_cli_site_detele_all(self): self.app = get_test_app(argv=['site', 'delete', 'example2.com', - '--all']) + '--all', '--no-prompt']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_detele_db(self): self.app = get_test_app(argv=['site', 'delete', 'example3.com', - '--db']) + '--db', '--no-prompt']) self.app.setup() self.app.run() self.app.close() def test_ee_cli_site_detele_files(self): self.app = get_test_app(argv=['site', 'delete', 'example4.com', - '--files']) + '--files', '--no-prompt']) self.app.setup() self.app.run() self.app.close() From 1d2857ea8c24403a87c948a1941926637a0b45c7 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Thu, 22 Jan 2015 13:04:52 +0530 Subject: [PATCH 710/829] completed ee --version command --- ee/cli/controllers/base.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index 95118c6e..3c2354ab 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -1,6 +1,13 @@ """EasyEngine base controller.""" from cement.core.controller import CementBaseController, expose +from ee.core.variables import EEVariables +VERSION = EEVariables.ee_version + +BANNER = """ +EasyEngine v%s +Copyright (c) 2015 rtCamp Solutions Pvt. Ltd. +""" % VERSION class EEBaseController(CementBaseController): @@ -9,6 +16,9 @@ class EEBaseController(CementBaseController): description = ("EasyEngine is the commandline tool to manage your" " websites based on WordPress and Nginx with easy to" " use commands") + arguments = [ + (['-v', '--version'], dict(action='version', version=BANNER)), + ] @expose(hide=True) def default(self): From 65c80631fa1e942ac77c3675ea82ccef958558c7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 22 Jan 2015 16:33:37 +0530 Subject: [PATCH 711/829] Fixed PHP/Debug pool status and info.php --- ee/cli/plugins/stack.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index ccfa6f3c..9dfb1f68 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -396,6 +396,27 @@ class EEStackController(CementBaseController): "\nphp_admin_flag[xdebug.profiler_enable" "_trigger] = on \nphp_admin_flag[xdebug." "profiler_enable] = off\n") + + # PHP and Debug pull configuration + if not os.path.exists('/var/www/22222/htdocs/fpm/status/'): + Log.debug(self, 'Creating directory ' + '/var/www/22222/htdocs/fpm/status/ ') + os.makedirs('/var/www/22222/htdocs/fpm/status/') + open('/var/www/22222/htdocs/fpm/status/debug', 'a').close() + open('/var/www/22222/htdocs/fpm/status/php', 'a').close() + + # Write info.php + if not os.path.exists('/var/www/22222/htdocs/php/'): + Log.debug(self, 'Creating directory ' + '/var/www/22222/htdocs/php/ ') + os.makedirs('/var/www/22222/htdocs/php') + + with open("/var/www/22222/htdocs/php/info.php", "w") as myfile: + myfile.write("") + + EEFileUtils.chown(self, "/var/www/22222", 'www-data', + 'www-data', recursive=True) + EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") EEService.reload_service(self, 'php5-fpm') From 13f7a050885181f0b5edde9bee024aef3ae0751c Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 22 Jan 2015 16:42:59 +0530 Subject: [PATCH 712/829] Fixed memcache not working issue --- ee/core/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 477b3a85..66902be3 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -83,7 +83,7 @@ class EEVariables(): .format(codename=ee_platform_codename)) ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap", "php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", - "php5-mysql", "php5-cli", "memcached"] + "php5-mysql", "php5-cli", "php5-memcache", "memcached"] # MySQL repo and packages ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main" From fde03958b02c6417a5107a1119d621ecf72b0132 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 22 Jan 2015 18:22:44 +0530 Subject: [PATCH 713/829] Fixed Debian codename --- ee/cli/plugins/secure.py | 4 ++-- ee/cli/plugins/stack.py | 6 +++--- ee/core/variables.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 59cdf4f7..49fed63c 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -90,7 +90,7 @@ class EESecureController(CementBaseController): "{port} default_server ssl spdy;/\" " "/etc/nginx/sites-available/22222.conf" .format(port=self.app.pargs.user_input)) - if EEVariables.ee_platform_distro == 'Debian': + if EEVariables.ee_platform_distro == 'debian': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl;/\" " "/etc/nginx/sites-available/22222.conf" @@ -100,7 +100,7 @@ class EESecureController(CementBaseController): @expose(hide=True) def secure_ip(self): - # TODO:remaining with ee.conf updation in file + # TODO:remaining with ee.conf updation in file newlist = [] if not self.app.pargs.user_input: ip = input("Enter the comma separated IP addresses " diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9dfb1f68..356d7f7a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -106,7 +106,7 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_nginx).issubset(set(apt_packages)): Log.info(self, "Adding repository for Nginx") - if EEVariables.ee_platform_distro == 'Debian': + if EEVariables.ee_platform_distro == 'debian': Log.debug(self, 'Adding Dotdeb/nginx GPG key') EERepo.add(self, repo_url=EEVariables.ee_nginx_repo) else: @@ -115,8 +115,8 @@ class EEStackController(CementBaseController): if set(EEVariables.ee_php).issubset(set(apt_packages)): Log.info(self, "Adding repository for PHP") - if EEVariables.ee_platform_distro == 'Debian': - Log.debug(self, 'Adding repo_url of php for Debian') + if EEVariables.ee_platform_distro == 'debian': + Log.debug(self, 'Adding repo_url of php for debian') EERepo.add(self, repo_url=EEVariables.ee_php_repo) Log.debug(self, 'Adding Dotdeb/php GPG key') EERepo.add_key(self, '89DF5277') diff --git a/ee/core/variables.py b/ee/core/variables.py index 66902be3..1e524ec9 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -67,7 +67,7 @@ class EEVariables(): # Nginx repo and packages if ee_platform_distro == 'Ubuntu': ee_nginx_repo = "ppa:rtcamp/nginx" - elif ee_platform_distro == 'Debian': + elif ee_platform_distro == 'debian': ee_nginx_repo = ("deb http://packages.dotdeb.org {codename} all" .format(codename=ee_platform_codename)) ee_nginx = ["nginx-custom"] From 3b3f76fdb35a17c83d36f97908da59745d0698af Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 22 Jan 2015 19:02:07 +0530 Subject: [PATCH 714/829] Fixed codename issue for debian --- ee/core/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 1e524ec9..6efa0bef 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -26,7 +26,7 @@ class EEVariables(): # EasyEngine core variables ee_platform_distro = platform.linux_distribution()[0] ee_platform_version = platform.linux_distribution()[1] - ee_platform_codename = platform.linux_distribution()[2] + ee_platform_codename = os.popen("lsb_release -sc | tr -d \'\\n\'").read() # Get FQDN of system ee_fqdn = socket.getfqdn() From 2eef5bc64258bdacf0d5ef2e682f846e9ba6476d Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 22 Jan 2015 19:24:46 +0530 Subject: [PATCH 715/829] Fixed cache.close() debian dependecy --- ee/core/aptget.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index b1adc51b..a7213cae 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -16,7 +16,6 @@ class EEAptGet(): fprogress = apt.progress.text.AcquireProgress() iprogress = apt.progress.base.InstallProgress() cache.update() - cache.close() def upgrade(self, packages): """Similar to apt-get update""" @@ -121,8 +120,6 @@ class EEAptGet(): print("package installation failed. [{err}]" .format(err=str(e))) return(False) - cache.close() - cache.close() return(True) def remove(self, packages, auto=False, purge=False): @@ -222,9 +219,7 @@ class EEAptGet(): # app.log.error('Sorry, package installation failed ') print("Sorry, package installation failed [{err}]" .format(err=str(e))) - cache.close() return(False) - cache.close() return(True) def is_installed(self, package): @@ -241,13 +236,10 @@ class EEAptGet(): pkg = cache[package] # Check Package Installed if pkg.is_installed: - cache.close() return True else: - cache.close() return False except KeyError as e: Log.debug(self, "{0}".format(e)) except Exception as e: - cache.close() return False From c5c93a19dea5c2c8f523f86867c96f8dc5609abc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 22 Jan 2015 19:52:08 +0530 Subject: [PATCH 716/829] Fixed repo writing debian --- ee/core/apt_repo.py | 2 ++ ee/core/variables.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index b9f93e5c..4a71a6fb 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -20,10 +20,12 @@ class EERepo(): if not os.path.isfile(repo_file_path): with open(repo_file_path, "a") as repofile: repofile.write(repo_url) + repofile.write('\n') repofile.close() elif repo_url not in open(repo_file_path).read(): with open(repo_file_path, "a") as repofile: repofile.write(repo_url) + repofile.write('\n') repofile.close() return True except IOError as e: diff --git a/ee/core/variables.py b/ee/core/variables.py index 6efa0bef..986d4f9c 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -67,10 +67,11 @@ class EEVariables(): # Nginx repo and packages if ee_platform_distro == 'Ubuntu': ee_nginx_repo = "ppa:rtcamp/nginx" + ee_nginx = ["nginx-custom"] elif ee_platform_distro == 'debian': ee_nginx_repo = ("deb http://packages.dotdeb.org {codename} all" .format(codename=ee_platform_codename)) - ee_nginx = ["nginx-custom"] + ee_nginx = ["nginx-full"] # PHP repo and packages if ee_platform_distro == 'Ubuntu': From 8df680ad1dc709f48ddfeab6d1194bb6497cc870 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 23 Jan 2015 12:26:43 +0530 Subject: [PATCH 717/829] Fixed service not reloading after debug --- ee/cli/plugins/debug.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 7d585d44..05f8369d 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -407,10 +407,10 @@ class EEDebugController(CementBaseController): # Reload Nginx if self.trigger_nginx: - EEService.reload_service(self, ['nginx']) + EEService.reload_service(self, 'nginx') # Reload PHP if self.trigger_php: - EEService.reload_service(self, ['php5-fpm']) + EEService.reload_service(self, 'php5-fpm') # # if len(self.msg) > 0: # self.app.log.info("Use following command to check debug logs:" From 594febe7d4b900b155393edf9458a28e7b3329c3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 23 Jan 2015 12:37:54 +0530 Subject: [PATCH 718/829] Fixed EasyEngine site header --- ee/cli/templates/nginx-core.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/templates/nginx-core.mustache b/ee/cli/templates/nginx-core.mustache index a3442847..6c90e51b 100644 --- a/ee/cli/templates/nginx-core.mustache +++ b/ee/cli/templates/nginx-core.mustache @@ -4,7 +4,7 @@ server_tokens off; reset_timedout_connection on; -add_header X-Powered-By "{{version}}"; +add_header X-Powered-By "EasyEngine {{version}}"; add_header rt-Fastcgi-Cache $upstream_cache_status; # Limit Request From 8f01acec6c13017bdbf1a3f56ac261cbaf709843 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 23 Jan 2015 12:51:21 +0530 Subject: [PATCH 719/829] Fixed debug connection now working on 12.04 --- ee/cli/plugins/debug.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 05f8369d..0e568f99 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -326,7 +326,7 @@ class EEDebugController(CementBaseController): Log.info(self, "Nginx rewrite logs already disabled") # Start Nginx rewrite for site elif self.start and self.app.pargs.site_name: - config_path = ("/etc/nginx/sites-available/{0}.conf" + config_path = ("/etc/nginx/sites-available/{0}" .format(self.app.pargs.site_name)) if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" .format(config_path)): @@ -347,7 +347,7 @@ class EEDebugController(CementBaseController): # Stop Nginx rewrite for site elif not self.start and self.app.pargs.site_name: - config_path = ("/etc/nginx/sites-available/{0}.conf" + config_path = ("/etc/nginx/sites-available/{0}" .format(self.app.pargs.site_name)) if EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" {0}" .format(config_path)): From a06fbdb4c60d8e85c708bec277ac81e882349558 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 23 Jan 2015 13:02:04 +0530 Subject: [PATCH 720/829] Added define('WP_DEBUG', false); to wp-config.php for WordPress site --- ee/cli/plugins/site_functions.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 26d05ccf..bbd1823d 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -182,20 +182,23 @@ def setupwordpress(self, data): + "--dbname={0} --dbprefix={1} --dbuser={2} " .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_user']) - + "--dbpass={0}".format(data['ee_db_pass'])) - else: + + "--dbpass={0}" + "--extra-php< Date: Fri, 23 Jan 2015 13:09:25 +0530 Subject: [PATCH 721/829] Fixed sh error on Ubuntu 12.04 --- ee/cli/plugins/site_functions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index bbd1823d..3f1bf6ab 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -178,7 +178,8 @@ def setupwordpress(self, data): Log.debug(self, "Setting up wp-config file") if not data['multisite']: Log.debug(self, "Generating wp-config for WordPress Single site") - EEShellExec.cmd_exec(self, "wp --allow-root core config " + EEShellExec.cmd_exec(self, "bash -c \'php /usr/bin/wp --allow-root " + + "core config " + "--dbname={0} --dbprefix={1} --dbuser={2} " .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_user']) From dd520cd5f29f932bb341eccdf219d30e649d81ea Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 23 Jan 2015 13:21:54 +0530 Subject: [PATCH 722/829] Fixed travis --- ee/cli/plugins/site_functions.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 3f1bf6ab..45bc914e 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -186,9 +186,9 @@ def setupwordpress(self, data): + "--dbpass={0}" "--extra-php< Date: Fri, 23 Jan 2015 13:26:14 +0530 Subject: [PATCH 723/829] Fixed missing single quote in wp-config.php file --- ee/cli/plugins/site_functions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 45bc914e..52af5b1b 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -186,7 +186,7 @@ def setupwordpress(self, data): + "--dbpass={0}" "--extra-php< Date: Fri, 23 Jan 2015 14:52:03 +0530 Subject: [PATCH 724/829] Fixed wpconfig generation --- ee/cli/plugins/site_functions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 52af5b1b..8db0aec9 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -178,24 +178,24 @@ def setupwordpress(self, data): Log.debug(self, "Setting up wp-config file") if not data['multisite']: Log.debug(self, "Generating wp-config for WordPress Single site") - EEShellExec.cmd_exec(self, "bash -c \'php /usr/bin/wp --allow-root " + EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root " + "core config " + "--dbname={0} --dbprefix={1} --dbuser={2} " .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_user']) - + "--dbpass={0}" - "--extra-php< Date: Fri, 23 Jan 2015 14:55:39 +0530 Subject: [PATCH 725/829] Removed extra slashes --- ee/cli/plugins/site_functions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 8db0aec9..92780c92 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -186,7 +186,7 @@ def setupwordpress(self, data): + "--dbpass={0} " "--extra-php< Date: Fri, 23 Jan 2015 15:08:19 +0530 Subject: [PATCH 726/829] ee stack purge --web solved --- ee/cli/plugins/stack.py | 4 + ee/core/aptget.py | 322 +++++++++++++--------------------------- ee/core/services.py | 3 +- 3 files changed, 109 insertions(+), 220 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 356d7f7a..f6958e0c 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -1177,8 +1177,10 @@ class EEStackController(CementBaseController): if len(apt_packages): Log.debug(self, "Removing apt_packages") EEAptGet.remove(self, apt_packages) + EEAptGet.auto_remove(self) if len(packages): EEFileUtils.remove(self, packages) + EEAptGet.auto_remove(self) Log.info(self, "Successfully removed packages") @expose(help="Purge packages") @@ -1251,8 +1253,10 @@ class EEStackController(CementBaseController): if len(apt_packages): EEAptGet.remove(self, apt_packages, purge=True) + EEAptGet.auto_remove(self) if len(packages): EEFileUtils.remove(self, packages) + EEAptGet.auto_remove(self) Log.info(self, "Successfully purged packages") diff --git a/ee/core/aptget.py b/ee/core/aptget.py index a7213cae..15b2d928 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -3,243 +3,127 @@ import apt import apt_pkg import sys from ee.core.logging import Log +from sh import apt_get class EEAptGet(): """Generic apt-get intialisation""" def update(self): - """Similar to apt-get update""" - - # app.log.debug("Update cache") - cache = apt.Cache() - fprogress = apt.progress.text.AcquireProgress() - iprogress = apt.progress.base.InstallProgress() - cache.update() - - def upgrade(self, packages): - """Similar to apt-get update""" - cache = apt.Cache() - fprogress = apt.progress.text.AcquireProgress() - iprogress = apt.progress.base.InstallProgress() - my_selected_packages = [] - # Cache Initialization - if not cache: - cache = apt.Cache() - # Cache Read - cache.open() - for package in packages: - pkg = cache[package] - # Check Package Installed - if pkg.is_installed: - # Check Package is Upgradeble - if pkg.is_upgradable: - with cache.actiongroup(): - # Mark Package for Upgrade - pkg.mark_upgrade() - my_selected_packages.append(pkg.installed) - else: - print("\'{package_name}-{package_ver.version}\'" - "already the newest version" - .format(package_name=pkg.name, - package_ver=pkg.installed)) - - # Check if packages available for install. - if len(my_selected_packages) > 0: - print("The following packages will be upgraded:" - "\n {pkg_name}" - .format(pkg_name=my_selected_packages)) - print("{pkg_install_count} newly installed." - .format(pkg_upgrade_count=len(my_selected_packages))) - print("Need to get {req_download} bytes of archives" - .format(req_download=cache.required_download)) - print("After this operation, {space} bytes of" - "additional disk space will be used." - .format(space=cache.required_space)) - try: - # Commit changes in cache (actually install) - cache.commit(fprogress, iprogres) - except Exception as e: - print("package installation failed. [{err}]" - .format(err=str(e))) - return(False) - return(True) + try: + apt_cache = apt.cache.Cache() + apt_cache.update() + success = (apt_cache.commit( + apt.progress.text.AcquireProgress(), + apt.progress.base.InstallProgress())) + #apt_cache.close() + return success + except AttributeError as e: + Log.error(self, 'AttributeError: ' + str(e)) + + def dist_upgrade(): + apt_cache = apt.cache.Cache() + apt_cache.update() + apt_cache.open(None) + apt_cache.upgrade(True) + success = (apt_cache.commit( + apt.progress.text.AcquireProgress(), + apt.progress.base.InstallProgress())) + #apt_cache.close() + return success def install(self, packages): """Installation of packages""" - cache = apt.Cache() - fprogress = apt.progress.text.AcquireProgress() - iprogress = apt.progress.base.InstallProgress() - my_selected_packages = [] - # Cache Initialization - if not cache: - cache = apt.Cache() - # Cache Read - cache.open() - - for package in packages: - try: - pkg = cache[package] - except KeyError as e: - continue - # Check Package Installed - if pkg.is_installed or pkg.marked_install: - # Check Package is Upgradeble - if pkg.is_upgradable: - print("latest version of \'{package_name}\' available." - .format(package_name=pkg.installed)) + def install_package(self, package_name): + apt_pkg.init() + # #apt_pkg.PkgSystemLock() + apt_cache = apt.cache.Cache() + pkg = apt_cache[package_name.strip()] + if package_name.strip() in apt_cache: + if pkg.is_installed: + #apt_pkg.PkgSystemUnLock() + Log.info(self, 'Trying to install a package that ' + 'is already installed (' + + package_name.strip() + ')') + #apt_cache.close() + return False else: - # Check if package already marked for install - if not pkg.marked_install: - print("\'{package_name}-{package_ver}\'" - "already the newest version" - .format(package_name=pkg.shortname, - package_ver=pkg.installed)) - else: - with cache.actiongroup(): - # Mark Package for Installation pkg.mark_install() - my_selected_packages.append(pkg.name) - - # Check if packages available for install. - if cache.install_count > 0: - print("The following NEW packages will be installed:" - "\n {pkg_name}" - .format(pkg_name=my_selected_packages)) - print("{pkg_install_count} newly installed." - .format(pkg_install_count=cache.install_count)) - print("Need to get {req_download} bytes of archives" - .format(req_download=cache.required_download)) - print("After this operation, {space:.2f} MB of" - " additional disk space will be used." - .format(space=cache.required_space/1e6)) - try: - # Commit changes in cache (actually install) - cache.commit() - except Exception as e: - print("package installation failed. [{err}]" - .format(err=str(e))) - return(False) - return(True) - - def remove(self, packages, auto=False, purge=False): - def __dependencies_loop(cache, deplist, pkg, onelevel=True): - """ Loops through pkg's dependencies. - Returns a list with every package found. """ - if onelevel: - onelevellist = [] - if not pkg.is_installed: - return - for depf in pkg.installed.dependencies: - for dep in depf: - # if (dep.name in cache and not cache[dep.name] - # in deplist): - # deplist.append(cache[dep.name]) - # __dependencies_loop(cache, deplist, cache[dep.name]) - # if onelevel: - if dep.name in cache: - if (cache[dep.name].is_installed and - cache[dep.name].is_auto_installed): - onelevellist.append(cache[dep.name]) - # if onelevel: - return onelevellist - - cache = apt.Cache() - fprogress = apt.progress.text.AcquireProgress() - iprogress = apt.progress.base.InstallProgress() - - onelevel = [] + try: + #apt_pkg.PkgSystemUnLock() + result = apt_cache.commit() + #apt_cache.close() + return result + except SystemError as e: + Log.error(self, 'SystemError: ' + str(e)) + #apt_cache.close() + else: + #apt_cache.close() + Log.error(self, 'Unknown package selected (' + + package_name.strip() + ')') - my_selected_packages = [] - # Cache Initialization - if not cache: - cache = apt.Cache() - # Cache Read - cache.open() for package in packages: - print("processing", package) - try: - pkg = cache[package] - except KeyError as e: - Log.debug(self, "{0}".format(e)) - continue - if not pkg.is_installed: - Log.info(self, "Package '{package_name}' is not installed," - " so not removed." - .format(package_name=pkg.name)) + if not install_package(self, package): continue - my_selected_packages.append(pkg.name) - # How logic works: - # 1) We loop trough dependencies's dependencies and add them to - # the list. - # 2) We sequentially remove every package in list - # - via is_auto_installed we check if we can safely remove it - deplist = [] - onelevel = onelevel + __dependencies_loop(cache, deplist, pkg, - onelevel=True) - # Mark for deletion the first package, to fire up - # auto_removable Purge? - try: - if purge: - pkg.mark_delete(purge=True) - else: - pkg.mark_delete(purge=False) - except SystemError as e: - Log.debug(self, "{0}".format(e)) - apt.ProblemResolver(cache).remove(pkg) - # print(pkg.inst_state) - # Log.error(self, "Unable to purge packages.") - - for dep in onelevel: - my_selected_packages.append(dep.name) - try: - if purge: - dep.mark_delete(purge=True) + def remove(self, packages, auto=False, purge=False): + def remove_package(self, package_name, purge=False): + apt_pkg.init() + #apt_pkg.PkgSystemLock() + apt_cache = apt.cache.Cache() + pkg = apt_cache[package_name.strip()] + if package_name.strip() in apt_cache: + if not pkg.is_installed: + #apt_pkg.PkgSystemUnLock() + Log.info(self, 'Trying to uninstall a package ' + 'that is not installed (' + + package_name.strip() + ')') + return False else: - dep.mark_delete(purge=False) - except SystemError as e: - Log.debug(self, "{0}".format(e)) - Log.error(self, "Unable to purge depedencies.") + try: + pkg.mark_delete(purge) + except SystemError as e: + Log.debug(self, 'SystemError: ' + str(e)) + return False + try: + #apt_pkg.PkgSystemUnLock() + result = apt_cache.commit() + #apt_cache.close() + return result + except SystemError as e: + Log.debug(self, 'SystemError: ' + str(e)) + return False + #apt_cache.close() + else: + #apt_cache.close() + Log.error(self, 'Unknown package selected (' + + package_name.strip() + ')') - # Check if packages available for remove/update. - if cache.delete_count > 0: - # app.log.debug('packages will be REMOVED ') - print("The following packages will be REMOVED:" - "\n {pkg_name}" - .format(pkg_name=my_selected_packages)) - print("{pkg_remove_count} to remove." - .format(pkg_remove_count=cache.delete_count)) - # app.log.debug('bytes disk space will be freed') - print("After this operation, {space:.2f} MB disk space " - "will be freed.".format(space=cache.required_space/1e6)) - try: - cache.commit(fprogress, iprogress) - except Exception as e: - # app.log.error('Sorry, package installation failed ') - print("Sorry, package installation failed [{err}]" - .format(err=str(e))) - return(False) - return(True) + for package in packages: + if not remove_package(self, package, purge=purge): + continue - def is_installed(self, package): - cache = apt.Cache() - fprogress = apt.progress.text.AcquireProgress() - iprogress = apt.progress.base.InstallProgress() + def auto_clean(self): + try: + apt_get.autoclean("-y") + except ErrorReturnCode as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to apt-get autoclean") - # Cache Initialization - if not cache: - cache = apt.Cache() - # Cache Read - cache.open() + def auto_remove(self): try: - pkg = cache[package] - # Check Package Installed - if pkg.is_installed: - return True - else: - return False - except KeyError as e: + Log.debug(self, "Running apt-get autoremove") + apt_get.autoremove("-y") + except ErrorReturnCode as e: Log.debug(self, "{0}".format(e)) - except Exception as e: - return False + Log.error(self, "Unable to apt-get autoremove") + + def is_installed(self, package_name): + apt_cache = apt.cache.Cache() + apt_cache.open() + if (package_name.strip() in apt_cache and + apt_cache[package_name.strip()].is_installed): + apt_cache.close() + return True + #apt_cache.close() + return False diff --git a/ee/core/services.py b/ee/core/services.py index 6ecfded1..20c9c09a 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -75,7 +75,8 @@ class EEService(): # print(retcode[0]) # subprocess.getstatusoutput('service {0} reload' # .format(service_name)) - Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + + "]") return True else: Log.debug(self, "{0}".format(retcode[1])) From 4196153ebad9d90b44ab2094371593fbfa359cbc Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 23 Jan 2015 15:08:42 +0530 Subject: [PATCH 727/829] Fixed PHP debug log in Ubuntu 12.04 --- ee/cli/plugins/debug.py | 22 ++++++++++++++++------ ee/cli/plugins/stack.py | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 0e568f99..eaa1b31f 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -7,6 +7,7 @@ from ee.core.mysql import EEMysql from ee.core.services import EEService from ee.core.logging import Log import os +import configparser def debug_plugin_hook(app): @@ -170,9 +171,13 @@ class EEDebugController(CementBaseController): if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): Log.info(self, "Setting up PHP5-FPM log_level = debug") - EEShellExec.cmd_exec(self, "sed -i \"s\';log_level.*\'log_" - "level = debug\'\" /etc/php5/fpm" - "/php-fpm.conf") + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/php-fpm.conf') + config['global']['log_level'] = 'debug' + with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: + Log.debug(self, "writting php5 configuration into " + "/etc/php5/fpm/php-fpm.conf") + config.write(configfile) self.trigger_php = True else: Log.info(self, "PHP5-FPM log_level = debug already setup") @@ -183,9 +188,14 @@ class EEDebugController(CementBaseController): if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " "/etc/php5/fpm/php-fpm.conf"): Log.info(self, "Disabling PHP5-FPM log_level = debug") - EEShellExec.cmd_exec(self, "sed -i \"s\'log_level.*\';log_" - "level = notice\'\" /etc/php5/fpm" - "/php-fpm.conf") + config = configparser.ConfigParser() + config.read('/etc/php5/fpm/php-fpm.conf') + config['global']['log_level'] = 'notice' + with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: + Log.debug(self, "writting php5 configuration into " + "/etc/php5/fpm/php-fpm.conf") + config.write(configfile) + self.trigger_php = True else: Log.info(self, "PHP5-FPM log_level = debug already disabled") diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 356d7f7a..bdca97d8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -353,6 +353,7 @@ class EEStackController(CementBaseController): config = configparser.ConfigParser() config.read('/etc/php5/fpm/php-fpm.conf') config['global']['error_log'] = '/var/log/php5/fpm.log' + config['global']['log_level'] = 'notice' with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: Log.debug(self, "writting php5 configuration into " "/etc/php5/fpm/php-fpm.conf") From d8c9f4a6e738c7b74af7e6218e6b28a4a8eb1b7f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 23 Jan 2015 15:37:57 +0530 Subject: [PATCH 728/829] Fixed PHP5-FPM configuration issue, which leads to 502 badgateway --- ee/cli/plugins/debug.py | 10 +++++++--- ee/cli/plugins/stack.py | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index eaa1b31f..9734f82f 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -155,8 +155,8 @@ class EEDebugController(CementBaseController): "| grep 9001"): Log.info(self, "Disabling PHP debug") data = dict(php="9000", debug="9001") - Log.info(self, 'Writting the Nginx debug configration to file ' - '/etc/nginx/conf.d/upstream.conf ') + Log.debug(self, 'Writting the Nginx debug configration to file' + ' /etc/nginx/conf.d/upstream.conf ') ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w') self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() @@ -173,9 +173,11 @@ class EEDebugController(CementBaseController): Log.info(self, "Setting up PHP5-FPM log_level = debug") config = configparser.ConfigParser() config.read('/etc/php5/fpm/php-fpm.conf') + config.remove_option('global', 'include') config['global']['log_level'] = 'debug' + config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf' with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: - Log.debug(self, "writting php5 configuration into " + Log.debug(self, "Writting php5-FPM configuration into " "/etc/php5/fpm/php-fpm.conf") config.write(configfile) self.trigger_php = True @@ -190,7 +192,9 @@ class EEDebugController(CementBaseController): Log.info(self, "Disabling PHP5-FPM log_level = debug") config = configparser.ConfigParser() config.read('/etc/php5/fpm/php-fpm.conf') + config.remove_option('global', 'include') config['global']['log_level'] = 'notice' + config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf' with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: Log.debug(self, "writting php5 configuration into " "/etc/php5/fpm/php-fpm.conf") diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index bdca97d8..9e101b37 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -353,7 +353,9 @@ class EEStackController(CementBaseController): config = configparser.ConfigParser() config.read('/etc/php5/fpm/php-fpm.conf') config['global']['error_log'] = '/var/log/php5/fpm.log' + config.remove_option('global', 'include') config['global']['log_level'] = 'notice' + config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf' with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile: Log.debug(self, "writting php5 configuration into " "/etc/php5/fpm/php-fpm.conf") From e9553ba43e9a83ec286f1bc405db378cb65dda52 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 23 Jan 2015 15:58:40 +0530 Subject: [PATCH 729/829] added messages for site enable|disable commands --- ee/cli/plugins/site.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 8b165fb4..91b00827 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -39,6 +39,7 @@ class EESiteController(CementBaseController): @expose(help="Enable site example.com") def enable(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + Log.info(self, "Enable domain {0:10}".format(ee_domain), end='') if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): EEFileUtils.create_symlink(self, @@ -47,18 +48,26 @@ class EESiteController(CementBaseController): '/etc/nginx/sites-enabled/{0}' .format(ee_domain)]) updateSiteInfo(self, ee_domain, enabled=True) + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") else: Log.error(self, " site {0} does not exists".format(ee_domain)) @expose(help="Disable site example.com") def disable(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + Log.info(self, "Disable domain {0:10}".format(ee_domain), end='') if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): - EEFileUtils.remove_symlink(self, - '/etc/nginx/sites-enabled/{0}' - .format(ee_domain)) - updateSiteInfo(self, ee_domain, enabled=False) + if not os.path.isfile('/etc/nginx/sites-enabled/{0}' + .format(ee_domain)): + Log.debug(self, "Site {0} already disabled" + ee_domain) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") + else: + EEFileUtils.remove_symlink(self, + '/etc/nginx/sites-enabled/{0}' + .format(ee_domain)) + updateSiteInfo(self, ee_domain, enabled=False) + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") else: Log.error(self, " site {0} does not exists".format(ee_domain)) From 8981f1e11f075168b64f154ce3ceca1d5204455c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 23 Jan 2015 16:34:04 +0530 Subject: [PATCH 730/829] removed problem causing apt.Cache.close() --- ee/core/aptget.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 15b2d928..87df5f09 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -69,12 +69,12 @@ class EEAptGet(): def remove(self, packages, auto=False, purge=False): def remove_package(self, package_name, purge=False): apt_pkg.init() - #apt_pkg.PkgSystemLock() + # apt_pkg.PkgSystemLock() apt_cache = apt.cache.Cache() pkg = apt_cache[package_name.strip()] if package_name.strip() in apt_cache: if not pkg.is_installed: - #apt_pkg.PkgSystemUnLock() + # apt_pkg.PkgSystemUnLock() Log.info(self, 'Trying to uninstall a package ' 'that is not installed (' + package_name.strip() + ')') @@ -86,16 +86,16 @@ class EEAptGet(): Log.debug(self, 'SystemError: ' + str(e)) return False try: - #apt_pkg.PkgSystemUnLock() + # apt_pkg.PkgSystemUnLock() result = apt_cache.commit() - #apt_cache.close() + # apt_cache.close() return result except SystemError as e: Log.debug(self, 'SystemError: ' + str(e)) return False - #apt_cache.close() + # apt_cache.close() else: - #apt_cache.close() + # apt_cache.close() Log.error(self, 'Unknown package selected (' + package_name.strip() + ')') @@ -123,7 +123,7 @@ class EEAptGet(): apt_cache.open() if (package_name.strip() in apt_cache and apt_cache[package_name.strip()].is_installed): - apt_cache.close() + # apt_cache.close() return True - #apt_cache.close() + # apt_cache.close() return False From 0fe8026bad7cead6788612d67bde5ca93b7ba12b Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 23 Jan 2015 17:32:32 +0530 Subject: [PATCH 731/829] apt-get unable to fork bug solved --- ee/core/aptget.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 87df5f09..7cfa0e17 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -34,17 +34,19 @@ class EEAptGet(): def install(self, packages): """Installation of packages""" + apt_pkg.init() + # #apt_pkg.PkgSystemLock() + apt_cache = apt.cache.Cache() + def install_package(self, package_name): - apt_pkg.init() - # #apt_pkg.PkgSystemLock() - apt_cache = apt.cache.Cache() + global apt_cache pkg = apt_cache[package_name.strip()] if package_name.strip() in apt_cache: if pkg.is_installed: #apt_pkg.PkgSystemUnLock() - Log.info(self, 'Trying to install a package that ' - 'is already installed (' + - package_name.strip() + ')') + Log.debug(self, 'Trying to install a package that ' + 'is already installed (' + + package_name.strip() + ')') #apt_cache.close() return False else: @@ -67,17 +69,19 @@ class EEAptGet(): continue def remove(self, packages, auto=False, purge=False): + apt_pkg.init() + # apt_pkg.PkgSystemLock() + apt_cache = apt.cache.Cache() + def remove_package(self, package_name, purge=False): - apt_pkg.init() - # apt_pkg.PkgSystemLock() - apt_cache = apt.cache.Cache() + global apt_cache pkg = apt_cache[package_name.strip()] if package_name.strip() in apt_cache: if not pkg.is_installed: # apt_pkg.PkgSystemUnLock() - Log.info(self, 'Trying to uninstall a package ' - 'that is not installed (' + - package_name.strip() + ')') + Log.debug(self, 'Trying to uninstall a package ' + 'that is not installed (' + + package_name.strip() + ')') return False else: try: From dbbb380304314401fe39b42ae1d71c012534b124 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 23 Jan 2015 17:47:21 +0530 Subject: [PATCH 732/829] Minor fix --- ee/core/aptget.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 7cfa0e17..2e533e19 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -36,10 +36,10 @@ class EEAptGet(): """Installation of packages""" apt_pkg.init() # #apt_pkg.PkgSystemLock() + global apt_cache apt_cache = apt.cache.Cache() def install_package(self, package_name): - global apt_cache pkg = apt_cache[package_name.strip()] if package_name.strip() in apt_cache: if pkg.is_installed: @@ -71,10 +71,10 @@ class EEAptGet(): def remove(self, packages, auto=False, purge=False): apt_pkg.init() # apt_pkg.PkgSystemLock() + global apt_cache apt_cache = apt.cache.Cache() def remove_package(self, package_name, purge=False): - global apt_cache pkg = apt_cache[package_name.strip()] if package_name.strip() in apt_cache: if not pkg.is_installed: From 1ad3cc6219151e81e38057054edb2ce4ab96a4b3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 23 Jan 2015 18:14:43 +0530 Subject: [PATCH 733/829] Fixed Nginx common dependencies --- ee/core/variables.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 986d4f9c..d00b5c5d 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -67,11 +67,11 @@ class EEVariables(): # Nginx repo and packages if ee_platform_distro == 'Ubuntu': ee_nginx_repo = "ppa:rtcamp/nginx" - ee_nginx = ["nginx-custom"] + ee_nginx = ["nginx-custom", "nginx-common"] elif ee_platform_distro == 'debian': ee_nginx_repo = ("deb http://packages.dotdeb.org {codename} all" .format(codename=ee_platform_codename)) - ee_nginx = ["nginx-full"] + ee_nginx = ["nginx-full", "nginx-common"] # PHP repo and packages if ee_platform_distro == 'Ubuntu': From 83afa894b7ca2fc14387d1721ec212125b479596 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 27 Jan 2015 10:20:47 +0530 Subject: [PATCH 734/829] Updated Roundcube version to 1.0.5 --- ee/core/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index d00b5c5d..3c5e42d9 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -17,7 +17,7 @@ class EEVariables(): # EasyEngine packages versions ee_wp_cli = "0.18.0" ee_adminer = "4.1.0" - ee_roundcube = "1.0.4" + ee_roundcube = "1.0.5" ee_vimbadmin = "3.0.11" # Current date and time of System From ecfba9e29d68768ea924268b11b699975cd0b4a6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 27 Jan 2015 13:55:59 +0530 Subject: [PATCH 735/829] Removed hardcoded roundcube version --- ee/cli/plugins/stack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index cb7b37de..b431e1a8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -855,7 +855,8 @@ class EEStackController(CementBaseController): Log.debug(self, "Creating new directory " " /var/www/roundcubemail/") os.makedirs('/var/www/roundcubemail/') - shutil.move('/tmp/roundcubemail-1.0.4/', + shutil.move('/tmp/roundcubemail-{0}/' + .format(EEVariables.ee_roundcube), '/var/www/roundcubemail/htdocs') # Configure roundcube database From e380f2846fc41c12655736d51153e846dc6f9e7f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 27 Jan 2015 14:35:54 +0530 Subject: [PATCH 736/829] Added Travis integration to slack --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 61ef8c08..bcd2a8d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ notifications: + slack: rtcamp:MGteQ7CA6kFIsNbMIarkeWxa webhooks: urls: - https://webhooks.gitter.im/e/bd77a26eab56de803949 From 89840c44733303249b69768442b86c580c7a0cca Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 27 Jan 2015 14:50:41 +0530 Subject: [PATCH 737/829] Fixed Graphivz issue in Webgrind --- ee/cli/plugins/stack.py | 3 +++ ee/core/variables.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index b431e1a8..a41b7929 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -651,6 +651,9 @@ class EEStackController(CementBaseController): os.makedirs('/var/www/22222/htdocs/php') shutil.move('/tmp/webgrind-master/', '/var/www/22222/htdocs/php/webgrind') + EEShellExec.cmd_exec(self, "sed -i \"s\'/usr/local/bin/dot\'" + "/usr/bin/dot\'\" /var/www/22222/htdocs/" + "php/webgrind/config.php") Log.debug(self, "Setting Privileges of www-data:www-data to " "/var/www/22222/htdocs/php/webgrind/ file ") # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' diff --git a/ee/core/variables.py b/ee/core/variables.py index 3c5e42d9..a2de82bd 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -84,7 +84,8 @@ class EEVariables(): .format(codename=ee_platform_codename)) ee_php = ["php5-fpm", "php5-curl", "php5-gd", "php5-imap", "php5-mcrypt", "php5-xdebug", "php5-common", "php5-readline", - "php5-mysql", "php5-cli", "php5-memcache", "memcached"] + "php5-mysql", "php5-cli", "php5-memcache", "memcached", + "graphviz"] # MySQL repo and packages ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main" From b569c42c029e3692dc435c613c55fbc94274ab1b Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 27 Jan 2015 16:36:22 +0530 Subject: [PATCH 738/829] Now using mustache for ViMbAdmin --- ee/cli/plugins/stack.py | 49 +- ee/cli/templates/vimbadmin.mustache | 662 ++++++++++++++++++++++++++++ 2 files changed, 674 insertions(+), 37 deletions(-) create mode 100644 ee/cli/templates/vimbadmin.mustache diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index a41b7929..e6b580e4 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -737,45 +737,20 @@ class EEStackController(CementBaseController): " vimbadmin@{0} IDENTIFIED BY" " '{1}'".format(self.app.config.get('mysql', 'grant-host'), vm_passwd)) - - # Configure ViMbAdmin settings - config = configparser.ConfigParser(strict=False) - Log.debug(self, "configuring ViMbAdmin ") - config.read('/var/www/22222/htdocs/vimbadmin/application/' - 'configs/application.ini.dist') - config['user']['defaults.mailbox.uid'] = '5000' - config['user']['defaults.mailbox.gid'] = '5000' - config['user']['defaults.mailbox.maildir'] = ("maildir:/var/v" - + "mail/%%d/%%u") - config['user']['defaults.mailbox.homedir'] = ("/srv/vmail/" - + "%%d/%%u") - config['user']['resources.doctrine2.connection.' - 'options.driver'] = 'mysqli' - config['user']['resources.doctrine2.connection.' - 'options.password'] = vm_passwd - config['user']['resources.doctrine2.connection.' - 'options.host'] = EEVariables.ee_mysql_host - config['user']['defaults.mailbox.password_scheme'] = 'md5' - config['user']['securitysalt'] = (''.join(random.sample - (string.ascii_letters - + string.ascii_letters, - 64))) - config['user']['resources.auth.' - 'oss.rememberme.salt'] = (''.join(random.sample - (string.ascii_letters - + string. - ascii_letters, - 64))) vm_salt = (''.join(random.sample(string.ascii_letters + string.ascii_letters, 64))) - config['user']['defaults.mailbox.' - 'password_salt'] = vm_salt - Log.debug(self, "Writting configuration to file " - "/var/www/22222/htdocs/vimbadmin" - "/application/configs/application.ini ") - with open('/var/www/22222/htdocs/vimbadmin/application' - '/configs/application.ini', 'w') as configfile: - config.write(configfile) + + # Custom Vimbadmin configuration by EasyEngine + data = dict(salt=vm_salt, host=EEVariables.ee_mysql_host, + password=vm_passwd) + Log.debug(self, 'Writting the ViMbAdmin configuration to ' + 'file /var/www/22222/htdocs/vimbadmin/application/' + 'configs/application.ini') + ee_vmb = open('/var/www/22222/htdocs/vimbadmin/application/' + 'configs/application.ini', 'w') + self.app.render((data), 'vimbadmin.mustache', + out=ee_vmb) + ee_vmb.close() shutil.copyfile("/var/www/22222/htdocs/vimbadmin/public/" ".htaccess.dist", diff --git a/ee/cli/templates/vimbadmin.mustache b/ee/cli/templates/vimbadmin.mustache new file mode 100644 index 00000000..acdadd7f --- /dev/null +++ b/ee/cli/templates/vimbadmin.mustache @@ -0,0 +1,662 @@ +;; This file is licenesed Under GNU GENERAL PUBLIC LICENSE Version 3 +;; © Copyright 2011 - 2014 Open Source Solutions Limited, Dublin, Ireland. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; ViMbAdmin :: Virtual Mailbox Admin +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; IMPORTANT: Review and change all options in [user] +;; +;; ** This is for ViMbAdmin V3 and later ** +;; +;; See: https://github.com/opensolutions/ViMbAdmin/wiki/Configuration + +[user] + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Installation Keys and Salts +; +; During installation, you will be prompted to enter strings here. This +; is to verify that you are in fact the person authorised to complete the +; installation as well as provide security for cookies and passwords. + +securitysalt = "{{salt}}" +resources.auth.oss.rememberme.salt = "{{salt}}" +defaults.mailbox.password_salt = "{{salt}}" + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; When installing for the first time, it may be useful to set the following +; to 1 BUT ensure you set it to zero again in a production system + +phpSettings.display_startup_errors = 0 +phpSettings.display_errors = 0 +resources.frontController.params.displayExceptions = 0 + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; You database and caching connection. +;; + +resources.doctrine2.connection.options.driver = 'mysqli' +resources.doctrine2.connection.options.dbname = 'vimbadmin' +resources.doctrine2.connection.options.user = 'vimbadmin' +resources.doctrine2.connection.options.password = '{{password}}' +resources.doctrine2.connection.options.host = '{{host}}' +resources.doctrine2.connection.options.charset = 'utf8' + +;; Doctrine2 requires Memcache for maximum efficency. Without Memcache +;; it can be highly inefficient and will slow page requests down. +;; +;; You are strongly advised to install memcache and comment ArrayCache +;; here and uncomment MemcacheCache. +;; + +resources.doctrine2cache.type = 'ArrayCache' +;resources.doctrine2cache.type = 'MemcacheCache' +;resources.doctrine2cache.memcache.servers.0.host = '127.0.0.1' +resources.doctrine2cache.namespace = 'ViMbAdmin3' + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Default values used when creating domains +; +; See: https://github.com/opensolutions/ViMbAdmin/wiki/Configuration +; See: https://github.com/opensolutions/ViMbAdmin/wiki/Quotas + +defaults.domain.quota = 0 +defaults.domain.maxquota = 0 +defaults.domain.transport = "virtual" +defaults.domain.aliases = 0 +defaults.domain.mailboxes = 0 + +defaults.quota.multiplier = 'MB' + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Use server side filtering to reduce pagination time on client side +;; Defaults to off / false +defaults.server_side.pagination.enable = false +defaults.server_side.pagination.min_search_str = 3 +defaults.server_side.pagination.max_result_cnt = 500 + +;; Separate configuration for domain list +defaults.server_side.pagination.domain.enable = false +defaults.server_side.pagination.domain.min_search_str = 3 +defaults.server_side.pagination.domain.max_result_cnt = 500 + +; The number of rows displayed in the tables +; must be one of these: 10, 25, 50, 100 +defaults.table.entries = 50 + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Options for the display of domain and mailbox sizes +;; +;; See: https://github.com/opensolutions/ViMbAdmin/wiki/Mailbox-Sizes +;; +;; Enable or disable display of sizes. Default: disabled + +defaults.list_size.disabled = true + +;; Maildir size units. By default: KB. One of B, KB, MB or GB. +defaults.list_size.multiplier = 'GB' + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Default values for creating mailboxes + +; This sets the uid and gid columns in the mailbox table to the below values +defaults.mailbox.uid = 5000 +defaults.mailbox.gid = 5000 + + +; Set the homedir and maildir values in the mailbox table where the +; following substitutions apply: +; +; %d -> domain part of email address +; %u -> user part of email address +; $m -> full email address +; +; +; http://wiki2.dovecot.org/VirtualUsers/Home + +defaults.mailbox.maildir = "maildir:/var/vmail/%d/%u"" +defaults.mailbox.homedir = "/var/vmail/" + +;minimum mailbox password length +defaults.mailbox.min_password_length = 8 + +; The password hashing function to use. Set to one of: +; +; "plain" - password stored as clear text +; "md5" - password hashed using MD5 without salt (PHP md5()) +; "md5.salted" - password hashed using MD5 with salt (see below) +; "sha1" - password hashed using sha1 without salt +; "sha1.salted" - password hashed using sha1 with salt defined below +; "crypt:XXX" - call the PHP crypt function (with random salt) where XXX is one of: md5, blowfish, sha256, sha512 +; "dovecot:XXX" - call the Dovecot password generator (see next option below) and use the +; scheme specified by XXX. To see available schemes, use 'dovecotpw -l' +; or 'doveadm pw -l' + +defaults.mailbox.password_scheme = "md5" + +; The path to (and initial option(s) if necessary) the Dovecot password generator. Typical +; values may be something like: +; +; "/usr/bin/doveadm pw" +; "/usr/bin/dovecotpw" + +defaults.mailbox.dovecot_pw_binary = "/usr/bin/doveadm pw" + + + +;; A "mailbox alias" will, for example add the following entry to +;; the alias table for a mailbox: name@example.com +;; +;; name@example.com -> name@example.com +;; +;; This is required for aliasing an entire domain. If in doubt, leave it enabled. +mailboxAliases = 1 + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; See: https://github.com/opensolutions/ViMbAdmin/wiki/Archiving-Mailboxes + +server_id = 1 + +;;Archive options +binary.path.chown_R = "/bin/chown -R" +binary.path.tar_cf = "/bin/tar -cf" +binary.path.tar_xf = "/bin/tar -xf" +binary.path.bzip2_q = "/bin/bzip2 -q" +binary.path.bunzip2_q = "/bin/bunzip2 -q" +binary.path.rm_rf = "/bin/rm -rf" + +archive.path = "/srv/archives" + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Enable mailbox deletion on the file system +; +; See: https://github.com/opensolutions/ViMbAdmin/wiki/Deleting-Mailboxes +; + +mailbox_deletion_fs_enabled = false + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Export Mailbox Settings +; +; See: https://github.com/opensolutions/ViMbAdmin/wiki/Export-Settings +; +defaults.export_settings.disabled = true + + +;; Export settings alowed subnets +defaults.export_settings.allowed_subnet[] = "10." +defaults.export_settings.allowed_subnet[] = "192.168." + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Settings email default values. +;; +;; Substituions are as follows: +;; +;; %d -> domain part of email address +;; %u -> user part of email address +;; $m -> full email address +;; +;; See (and skin) the following file to see how the below are used: +;; +;; views/mailbox/email/settings.phtml +;; + +server.smtp.enabled = 1 +server.smtp.host = "mail.%d" +server.smtp.user = "%m" +server.smtp.port = "465" +server.smtp.crypt = "SSL" + +server.pop3.enabled = 1 +server.pop3.host = "gpo.%d" +server.pop3.user = "%m" +server.pop3.port = "995" +server.pop3.crypt = "SSL" + +server.imap.enabled = 1 +server.imap.host = "gpo.%d" +server.imap.user = "%m" +server.imap.port = "993" +server.imap.crypt = "SSL" + +server.webmail.enabled = 1 +server.webmail.host = "https://webmail.%d" +server.webmail.user = "%m" + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Identity + +identity.orgname = "Example Limited" +identity.name = "Example Support Team" +identity.email = "support@example.com" +identity.autobot.name = "ViMbAdmin Autobot" +identity.autobot.email = "autobot@example.com" +identity.mailer.name = "ViMbAdmin Autobot" +identity.mailer.email = "do-not-reply@example.com" + +identity.sitename = "ViMbAdmin" +identity.siteurl = "https://www.example.com/vimbadmin/" + + +;; +;; All mail and correspondence will come from the following;; + +server.email.name = "ViMbAdmin Administrator" +server.email.address = "support@example.com" + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Skinning +;; +;; You can skin ViMbAdmin pages if you wish. +;; +;; See: https://github.com/opensolutions/ViMbAdmin/wiki/Skinning + +; resources.smarty.skin = "myskin" + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; See: http://framework.zend.com/manual/en/zend.mail.smtp-authentication.html +;; +;; Ensure you have a working mail server configuration so the system can +;; send emails: +;; +resources.mailer.smtphost = "localhost" +;resources.mailer.username = "" +;resources.mailer.password = "" +;resources.mailer.auth = "" +;resources.mailer.ssl = "" +;resources.mailer.port = "25" + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Local filesystem logging. +;; +;; We log various things to var/log/YYYY/MM/ if you enable the logger here. +;; +;; It is useful to use the email logger to be alerted of serious errors. +;; + +ondemand_resources.logger.enabled = 1 + +;ondemand_resources.logger.writers.email.from = "admin@example.com" +;ondemand_resources.logger.writers.email.to = "admin@example.com" +;ondemand_resources.logger.writers.email.prefix = "ViMbAdmin_Error" +;ondemand_resources.logger.writers.email.level = 3 + +ondemand_resources.logger.writers.stream.level = 7 + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; ViMbAdmin performs a version check on administrator login and alerts the +;; user if there is a newer version available. +;; +;; This can be disabled by setting the below to 1 +;; + +skipVersionCheck = 0 + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; ViMbAdmin 'pings' the developers as part of the set up process to let +;; them know there is a new installation. +;; +;; All we are interested in is knowing whether people are using the software +;; or not and whether continued support and development is worth the time +;; and effort. +;; +;; Unless you're very shy, PLEASE LET US KNOW YOU'RE USING IT! +;; +;; This can be disabled by setting the below to 1 +;; + +skipInstallPingback = 0 + + + + + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Allow admins to dictate whether a user can use BOTH, IMAP ONLY, +; POP3 ONLY when creating mailboxes. +; +; Must be supported by your POP3/IMAP server. +; +; See https://github.com/opensolutions/ViMbAdmin/wiki/POP3-IMAP-Access-Permissions +; for documentation. +; +; This is handled via a plugin +; + +vimbadmin_plugins.AccessPermissions.disabled = false + +; specify the options which should be allowed for access restrictions +vimbadmin_plugins.AccessPermissions.type.SMTP = "SMTP" +vimbadmin_plugins.AccessPermissions.type.IMAP = "IMAP" +vimbadmin_plugins.AccessPermissions.type.POP3 = "POP3" +vimbadmin_plugins.AccessPermissions.type.SIEVE = "SIEVE" + + + + + + + + + + + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Proceed onwards with caution. +;; +;; The above [user] params are the may ones of consequence. +;; + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Allows to add additional information. +; +; This is handled via a plugin +; + +vimbadmin_plugins.AccessPermissions.disabled = false +vimbadmin_plugins.Jabber.disabled = true +vimbadmin_plugins.DirectoryEntry.disabled = true +vimbadmin_plugins.SharedMailbox.disabled = true +vimbadmin_plugins.SOGo.disabled = true + + +vimbadmin_plugins.AdditionalInfo.disabled = true +vimbadmin_plugins.Addressbook.disabled = true +vimbadmin_plugins.Calendar.disabled = true +vimbadmin_plugins.RoundCube.disabled = true + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; Disabling directory entry subform element +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +vimbadmin_plugins.DirectoryEntry.disabled_elements.JpegPhoto = true +vimbadmin_plugins.DirectoryEntry.disabled_elements.Mail = true +vimbadmin_plugins.DirectoryEntry.disabled_elements.PreferredLanguage = true +vimbadmin_plugins.DirectoryEntry.disabled_elements.Secretary = true + +vimbadmin_plugins.DirectoryEntry.disabled_elements.PersonalTitle = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.GivenName = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Sn = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.DisplayName = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Initials = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.BusinesCategory = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.EmployeeType = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Title = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.DepartmentNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Ou = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.RoomNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.O = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.CarLicense = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.EmployeeNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.HomePhone = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.TelephoneNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Mobile = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Pager = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.FacsimileTelephoneNumber = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.HomePostalAddress = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.LabeledUri = false +vimbadmin_plugins.DirectoryEntry.disabled_elements.Manager = false + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Mailbox AdditionalInfo plugin elements +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + + +;;Additional text messages for plugin. +AdditionalInfo.mailbox.formPreBlurb = "

NB: Do not edit the following. It is sync'd on a nightly basis ..." + +; First Name +vimbadmin_plugins.AdditionalInfo.elements.id.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.id.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.id.options.label = "LDAP Id" + +; First Name +vimbadmin_plugins.AdditionalInfo.elements.first_name.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.first_name.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.first_name.options.label = "First Name" + +; Last Name +vimbadmin_plugins.AdditionalInfo.elements.second_name.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.second_name.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.second_name.options.label = "Last Name" + +; Grade +vimbadmin_plugins.AdditionalInfo.elements.grade.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.grade.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.grade.options.label = "Grade" + +; Grade Id +vimbadmin_plugins.AdditionalInfo.elements.grade_id.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.grade_id.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.grade_id.options.label = "Grade Id" +vimbadmin_plugins.AdditionalInfo.elements.grade_id.options.validators.digits[] = 'Digits' +vimbadmin_plugins.AdditionalInfo.elements.grade_id.options.validators.digits[] = true + +; Department +vimbadmin_plugins.AdditionalInfo.elements.department.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.department.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.department.options.label = "Department" + +; Department Id +vimbadmin_plugins.AdditionalInfo.elements.department_id.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.department_id.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.department_id.options.label = "Department Id" +vimbadmin_plugins.AdditionalInfo.elements.department_id.options.validators.digits[] = 'Digits' +vimbadmin_plugins.AdditionalInfo.elements.department_id.options.validators.digits[] = true + +; Section +vimbadmin_plugins.AdditionalInfo.elements.section.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.section.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.section.options.label = "Section" + +; Extension Number +vimbadmin_plugins.AdditionalInfo.elements.ext_no.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.label = "Extension Number" +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.digits[] = 'Digits' +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.digits[] = true +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.length[] = 'StringLength' +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.length[] = false +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.length.range[] = 4 +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.validators.length.range[] = 4 +;;to disable autocomplete functionality +vimbadmin_plugins.AdditionalInfo.elements.ext_no.options.autocomplete = 'off' + +; Direct Dial +vimbadmin_plugins.AdditionalInfo.elements.d_dial.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.d_dial.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.d_dial.options.label = "Direct Dial" +vimbadmin_plugins.AdditionalInfo.elements.d_dial.options.autocomplete = 'off' + +; Mobile +vimbadmin_plugins.AdditionalInfo.elements.mobile.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.elements.mobile.options.required = false +vimbadmin_plugins.AdditionalInfo.elements.mobile.options.label = "Mobile" +vimbadmin_plugins.AdditionalInfo.elements.mobile.options.autocomplete = 'off' + +;;;;;;; +;; Aliases additional information +;; +; First Name +vimbadmin_plugins.AdditionalInfo.alias.elements.name.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.alias.elements.name.options.required = false +vimbadmin_plugins.AdditionalInfo.alias.elements.name.options.label = "Name" + +; Extension Number +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.required = false +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.label = "Extension Number" +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.digits[] = 'Digits' +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.digits[] = true +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.length[] = 'StringLength' +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.length[] = false +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.length.range[] = 4 +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.validators.length.range[] = 4 +vimbadmin_plugins.AdditionalInfo.alias.elements.ext_no.options.autocomplete = 'off' + +; Direct Dial +vimbadmin_plugins.AdditionalInfo.alias.elements.d_dial.type = "Zend_Form_Element_Text" +vimbadmin_plugins.AdditionalInfo.alias.elements.d_dial.options.required = false +vimbadmin_plugins.AdditionalInfo.alias.elements.d_dial.options.label = "Direct Dial" +vimbadmin_plugins.AdditionalInfo.alias.elements.d_dial.options.autocomplete = 'off' + + +[production : user] + +includePaths.library = APPLICATION_PATH "/../library" +includePaths.osslibrary = APPLICATION_PATH "/../vendor/opensolutions/oss-framework/src/" + +bootstrap.path = APPLICATION_PATH "/Bootstrap.php" +bootstrap.class = "Bootstrap" +appnamespace = "ViMbAdmin" + +temporary_directory = APPLICATION_PATH "/../var/tmp" + +pluginPaths.OSS_Resource = APPLICATION_PATH "/../vendor/opensolutions/oss-framework/src/OSS/Resource" +pluginPaths.ViMbAdmin_Resource = APPLICATION_PATH "/../library/ViMbAdmin/Resource" + +mini_js = 1 +mini_css = 1 + +alias_autocomplete_min_length = 2 + + + +resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" +resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" +resources.modules[] = + + +; doctrine2 +resources.doctrine2.models_path = APPLICATION_PATH +resources.doctrine2.proxies_path = APPLICATION_PATH "/Proxies" +resources.doctrine2.repositories_path = APPLICATION_PATH +resources.doctrine2.xml_schema_path = APPLICATION_PATH "/../doctrine2/xml" +resources.doctrine2.autogen_proxies = 0 +resources.doctrine2.logger = 1 +resources.doctrine2.models_namespace = "Entities" +resources.doctrine2.proxies_namespace = "Proxies" +resources.doctrine2.repositories_namespace = "Repositories" + + +resources.doctrine2cache.autoload_method = "composer" +;resources.doctrine2cache.type = 'ArrayCache' +;resources.doctrine2cache.type = 'MemcacheCache' +;resources.doctrine2cache.memcache.servers.0.host = '127.0.0.1' +;resources.doctrine2cache.memcache.servers.0.port = '11211' +;resources.doctrine2cache.memcache.servers.0.persistent = false +;resources.doctrine2cache.memcache.servers.0.weight = 1 +;resources.doctrine2cache.memcache.servers.0.timeout = 1 +;resources.doctrine2cache.memcache.servers.0.retry_int = 15 + +; resources.doctrine2cache.memcache.servers.1.host = 'xxx' +; resources.doctrine2cache.memcache.servers.2.host = 'yyy' + +resources.namespace.checkip = 0 + +resources.auth.enabled = 1 +resources.auth.oss.adapter = "OSS_Auth_Doctrine2Adapter" +resources.auth.oss.pwhash = "bcrypt" +resources.auth.oss.hash_cost = 9 +resources.auth.oss.entity = "\\Entities\\Admin" +resources.auth.oss.disabled.lost-username = 1 +resources.auth.oss.disabled.lost-password = 0 + +resources.auth.oss.rememberme.enabled = 1 +resources.auth.oss.rememberme.timeout = 2592000 +resources.auth.oss.rememberme.secure = true + +resources.auth.oss.lost_password.use_captcha = true + +resources.session.save_path = APPLICATION_PATH "/../var/session" +resources.session.use_only_cookies = true +resources.session.remember_me_seconds = 3600 +resources.session.name = 'VIMBADMIN3' + +ondemand_resources.logger.writers.stream.path = APPLICATION_PATH "/../var/log" +ondemand_resources.logger.writers.stream.owner = www-data +ondemand_resources.logger.writers.stream.group = www-data +ondemand_resources.logger.writers.stream.mode = single +ondemand_resources.logger.writers.stream.logname = vimbadmin.log + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Smarty View +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +resources.smarty.enabled = 1 +resources.smarty.templates = APPLICATION_PATH "/views" +; resources.smarty.skin = "myskin" +resources.smarty.compiled = APPLICATION_PATH "/../var/templates_c" +resources.smarty.cache = APPLICATION_PATH "/../var/cache" +resources.smarty.config = APPLICATION_PATH "/configs/smarty" +resources.smarty.plugins[] = APPLICATION_PATH "/../library/ViMbAdmin/Smarty/functions" +resources.smarty.plugins[] = APPLICATION_PATH "/../vendor/opensolutions/oss-framework/src/OSS/Smarty/functions" +resources.smarty.plugins[] = APPLICATION_PATH "/../vendor/smarty/smarty/libs/plugins" +resources.smarty.plugins[] = APPLICATION_PATH "/../vendor/smarty/smarty/libs/sysplugins" +resources.smarty.debugging = 0 + + + + +[development : production] + +mini_js = 0 +mini_css = 0 + +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 +resources.frontController.params.displayExceptions = 1 From 6a742abee837cef55780c971f4f78e31e7c0d22c Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 27 Jan 2015 17:40:07 +0530 Subject: [PATCH 739/829] site log command updated --- ee/cli/plugins/site.py | 10 +- ee/cli/plugins/site_functions.py | 66 +++++++++++ ee/core/logwatch.py | 192 +++++++++++++++++++++++++++++++ 3 files changed, 264 insertions(+), 4 deletions(-) create mode 100644 ee/core/logwatch.py diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 91b00827..03bd14c8 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -106,10 +106,10 @@ class EESiteController(CementBaseController): @expose(help="Monitor example.com logs") def log(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) + ee_site_webroot = EEVariables.ee_webroot + ee_domain if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): - EEShellExec.cmd_exec(self, 'tail -f /var/log/nginx/{0}.*.log' - .format(ee_domain)) + logwatch(self, ee_site_webroot + '/logs/') else: Log.error(self, " site {0} does not exists".format(ee_domain)) @@ -457,6 +457,8 @@ class EESiteCreateController(CementBaseController): " {0}".format(ee_wp_creds['wp_user'])) Log.info(self, Log.ENDC + "WordPress admin user password : {0}" .format(ee_wp_creds['wp_pass'])) + + display_cache_settings(self, data) addNewSite(self, ee_www_domain, stype, cache, ee_site_webroot) Log.info(self, "Successfully created site" " http://{0}".format(ee_domain)) @@ -900,7 +902,7 @@ class EESiteUpdateController(CementBaseController): " {0}".format(ee_wp_creds['wp_user'])) Log.info(self, Log.ENDC + "WordPress admin password : {0}" .format(ee_wp_creds['wp_pass']) + "\n\n") - + display_cache_settings(self, data) updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache) Log.info(self, "Successfully updated site" " http://{0}".format(ee_domain)) @@ -916,7 +918,7 @@ class EESiteDeleteController(CementBaseController): (['site_name'], dict(help='domain name to be deleted')), (['--no-prompt'], - dict(help="dont ask for permission for delete", + dict(help="doesnt ask permission for delete", action='store_true')), (['--all'], dict(help="delete all", action='store_true')), diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 92780c92..b0a47ac9 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -433,3 +433,69 @@ def updatewpuserpassword(self, ee_domain, ee_site_webroot): else: Log.error(self, "Invalid WordPress user {0} for {1}." .format(ee_wp_user, ee_domain)) + + +def display_cache_settings(self, data): + if data['wpsc']: + if data['multisite']: + Log.info(self, "Configure WPSC:" + "\t\thttp://{0}/wp-admin/network/settings.php?" + "page=wpsupercache" + .format(data['site_name'])) + else: + Log.info(self, "Configure WPSC:" + "\t\thttp://{0}/wp-admin/options-general.php?" + "page=wpsupercache" + .format(data['site_name'])) + + if data['wpfc']: + if data['multisite']: + Log.info(self, "Configure nginx-helper:" + "\thttp://{0}/wp-admin/network/settings.php?" + "page=nginx".format(data['site_name'])) + else: + Log.info(self, "Configure nginx-helper:" + "\thttp://{0}/wp-admin/options-general.php?" + "page=nginx".format(data['site_name'])) + + if data['wpfc'] or data['w3tc']: + if data['multisite']: + Log.info(self, "Configure W3TC:" + "\t\thttp://{0}/wp-admin/network/admin.php?" + "page=w3tc_general".format(data['site_name'])) + else: + Log.info(self, "Configure W3TC:" + "\t\thttp://{0}wp-admin/admin.php?" + "page=w3tc_general".format(data['site_name'])) + + if data['wpfc']: + Log.info(self, "Page Cache:\t\tDisable") + elif data['w3tc']: + Log.info(self, "Page Cache:\t\tDisk Enhanced") + Log.info(self, "Database Cache:\t\tMemcached") + Log.info(self, "Object Cache:\t\tMemcached") + Log.info(self, "Browser Cache:\t\tDisable") + + +def logwatch(self, logdir): + import zlib + import base64 + import time + from ee.core import logwatch + + def callback(filename, lines): + for line in lines: + if line.find(':::') == -1: + print(line) + else: + data = line.split(':::') + try: + print(data[0], data[1], + zlib.decompress(base64.decodestring(data[2]))) + except Exception as e: + Log.info(time.time(), + 'caught exception rendering a new log line in %s' + % filename) + + l = logwatch.LogWatcher(logdir, callback) + l.loop() diff --git a/ee/core/logwatch.py b/ee/core/logwatch.py new file mode 100644 index 00000000..649d418f --- /dev/null +++ b/ee/core/logwatch.py @@ -0,0 +1,192 @@ + +""" +Real time log files watcher supporting log rotation. +""" + +import os +import time +import errno +import stat +from ee.core.logging import Log + + +class LogWatcher(object): + """Looks for changes in all files of a directory. + This is useful for watching log file changes in real-time. + It also supports files rotation. + + Example: + + >>> def callback(filename, lines): + ... print filename, lines + ... + >>> l = LogWatcher("/var/www/example.com/logs", callback) + >>> l.loop() + """ + + def __init__(self, folder, callback, extensions=["log"], tail_lines=0): + """Arguments: + + (str) @folder: + the folder to watch + + (callable) @callback: + a function which is called every time a new line in a + file being watched is found; + this is called with "filename" and "lines" arguments. + + (list) @extensions: + only watch files with these extensions + + (int) @tail_lines: + read last N lines from files being watched before starting + """ + self.files_map = {} + self.callback = callback + self.folder = os.path.realpath(folder) + self.extensions = extensions + assert (os.path.isdir(self.folder), "%s does not exists" + % self.folder) + assert callable(callback) + self.update_files() + # The first time we run the script we move all file markers at EOF. + # In case of files created afterwards we don't do this. + for id, file in list(iter(self.files_map.items())): + file.seek(os.path.getsize(file.name)) # EOF + if tail_lines: + lines = self.tail(file.name, tail_lines) + if lines: + self.callback(file.name, lines) + + def __del__(self): + self.close() + + def loop(self, interval=0.1, async=False): + """Start the loop. + If async is True make one loop then return. + """ + while 1: + self.update_files() + for fid, file in list(iter(self.files_map.items())): + self.readfile(file) + if async: + return + time.sleep(interval) + + def log(self, line): + """Log when a file is un/watched""" + print(line) + + def listdir(self): + """List directory and filter files by extension. + You may want to override this to add extra logic or + globbling support. + """ + ls = os.listdir(self.folder) + if self.extensions: + return ([x for x in ls if os.path.splitext(x)[1][1:] + in self.extensions]) + else: + return ls + + @staticmethod + def tail(fname, window): + """Read last N lines from file fname.""" + try: + f = open(fname, 'r') + except IOError as err: + if err.errno == errno.ENOENT: + return [] + else: + raise + else: + BUFSIZ = 1024 + f.seek(0, os.SEEK_END) + fsize = f.tell() + block = -1 + data = "" + exit = False + while not exit: + step = (block * BUFSIZ) + if abs(step) >= fsize: + f.seek(0) + exit = True + else: + f.seek(step, os.SEEK_END) + data = f.read().strip() + if data.count('\n') >= window: + break + else: + block -= 1 + return data.splitlines()[-window:] + + def update_files(self): + ls = [] + for name in self.listdir(): + absname = os.path.realpath(os.path.join(self.folder, name)) + try: + st = os.stat(absname) + except EnvironmentError as err: + if err.errno != errno.ENOENT: + raise + else: + if not stat.S_ISREG(st.st_mode): + continue + fid = self.get_file_id(st) + ls.append((fid, absname)) + + # check existent files + for fid, file in list(iter(self.files_map.items())): + # next(iter(graph.items())) + try: + st = os.stat(file.name) + except EnvironmentError as err: + if err.errno == errno.ENOENT: + self.unwatch(file, fid) + else: + raise + else: + if fid != self.get_file_id(st): + # same name but different file (rotation); reload it. + self.unwatch(file, fid) + self.watch(file.name) + + # add new ones + for fid, fname in ls: + if fid not in self.files_map: + self.watch(fname) + + def readfile(self, file): + lines = file.readlines() + if lines: + self.callback(file.name, lines) + + def watch(self, fname): + try: + file = open(fname, "r") + fid = self.get_file_id(os.stat(fname)) + except EnvironmentError as err: + if err.errno != errno.ENOENT: + raise + else: + self.log("watching logfile %s" % fname) + self.files_map[fid] = file + + def unwatch(self, file, fid): + # file no longer exists; if it has been renamed + # try to read it for the last time in case the + # log rotator has written something in it. + lines = self.readfile(file) + self.log("un-watching logfile %s" % file.name) + del self.files_map[fid] + if lines: + self.callback(file.name, lines) + + @staticmethod + def get_file_id(st): + return "%xg%x" % (st.st_dev, st.st_ino) + + def close(self): + for id, file in list(iter(self.files_map.items())): + file.close() + self.files_map.clear() From c6d422d01045993028ba25b20ef2f2ceecbf4c7e Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 27 Jan 2015 17:43:08 +0530 Subject: [PATCH 740/829] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f300886..3a8e1ee5 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ee --help How to install this version on your system?? ```bash sudo apt-get update -sudo apt-get install python3 python3-apt python3-setuptools python3-dev git +sudo apt-get -y install python3 python3-apt python3-setuptools python3-dev git git clone -b python https://github.com/rtCamp/easyengine.git cd easyengine sudo python3 setup.py install From b82929f0fdf34b3c8a030ceae0360e7b4228a949 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Tue, 27 Jan 2015 18:04:52 +0530 Subject: [PATCH 741/829] Better Message for git user.name and user.email --- ee/core/variables.py | 4 ++-- setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index a2de82bd..ade26d28 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -44,8 +44,8 @@ class EEVariables(): ee_user = config['user']['name'] ee_email = config['user']['email'] except Exception as e: - ee_user = input("Enter username for Git:") - ee_email = input("Enter email for Git:") + ee_user = input("Enter your name: ") + ee_email = input("Enter your email: ") # Get System RAM and SWAP details ee_ram = psutil.virtual_memory().total / (1024 * 1024) diff --git a/setup.py b/setup.py index eeacb4a2..81050f6f 100644 --- a/setup.py +++ b/setup.py @@ -37,8 +37,8 @@ except Exception as e: "upcoming version") print("EasyEngine (ee) will NEVER send your information across") - ee_user = input("Enter username for Git:") - ee_email = input("Enter email for Git:") + 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)) From 54bd97cb6e37407f1cc6e0e87044e725f5b96208 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 28 Jan 2015 15:58:15 +0530 Subject: [PATCH 742/829] updated logwatch --- ee/cli/plugins/site.py | 4 +++- ee/cli/plugins/site_functions.py | 6 +++--- ee/core/logwatch.py | 37 +++++++++++++++++--------------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 03bd14c8..0173021a 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -107,9 +107,11 @@ class EESiteController(CementBaseController): def log(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = EEVariables.ee_webroot + ee_domain + if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): - logwatch(self, ee_site_webroot + '/logs/') + logfiles = glob.glob(ee_site_webroot + '/logs/*.log') + logwatch(self, logfiles) else: Log.error(self, " site {0} does not exists".format(ee_domain)) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index b0a47ac9..0886f6a2 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -465,7 +465,7 @@ def display_cache_settings(self, data): "page=w3tc_general".format(data['site_name'])) else: Log.info(self, "Configure W3TC:" - "\t\thttp://{0}wp-admin/admin.php?" + "\t\thttp://{0}/wp-admin/admin.php?" "page=w3tc_general".format(data['site_name'])) if data['wpfc']: @@ -477,7 +477,7 @@ def display_cache_settings(self, data): Log.info(self, "Browser Cache:\t\tDisable") -def logwatch(self, logdir): +def logwatch(self, logfiles): import zlib import base64 import time @@ -497,5 +497,5 @@ def logwatch(self, logdir): 'caught exception rendering a new log line in %s' % filename) - l = logwatch.LogWatcher(logdir, callback) + l = logwatch.LogWatcher(logfiles, callback) l.loop() diff --git a/ee/core/logwatch.py b/ee/core/logwatch.py index 649d418f..8392a0cc 100644 --- a/ee/core/logwatch.py +++ b/ee/core/logwatch.py @@ -24,7 +24,7 @@ class LogWatcher(object): >>> l.loop() """ - def __init__(self, folder, callback, extensions=["log"], tail_lines=0): + def __init__(self, filelist, callback, extensions=["log"], tail_lines=0): """Arguments: (str) @folder: @@ -42,11 +42,14 @@ class LogWatcher(object): read last N lines from files being watched before starting """ self.files_map = {} + self.filelist = filelist self.callback = callback - self.folder = os.path.realpath(folder) + # self.folder = os.path.realpath(folder) self.extensions = extensions - assert (os.path.isdir(self.folder), "%s does not exists" - % self.folder) + # assert (os.path.isdir(self.folder), "%s does not exists" + # % self.folder) + for files in self.filelist: + assert (os.path.isfile(file), "%s does not exists" % file) assert callable(callback) self.update_files() # The first time we run the script we move all file markers at EOF. @@ -77,17 +80,17 @@ class LogWatcher(object): """Log when a file is un/watched""" print(line) - def listdir(self): - """List directory and filter files by extension. - You may want to override this to add extra logic or - globbling support. - """ - ls = os.listdir(self.folder) - if self.extensions: - return ([x for x in ls if os.path.splitext(x)[1][1:] - in self.extensions]) - else: - return ls + # def listdir(self): + # """List directory and filter files by extension. + # You may want to override this to add extra logic or + # globbling support. + # """ + # ls = os.listdir(self.folder) + # if self.extensions: + # return ([x for x in ls if os.path.splitext(x)[1][1:] + # in self.extensions]) + # else: + # return ls @staticmethod def tail(fname, window): @@ -122,8 +125,8 @@ class LogWatcher(object): def update_files(self): ls = [] - for name in self.listdir(): - absname = os.path.realpath(os.path.join(self.folder, name)) + for name in self.filelist: + absname = os.path.realpath(os.path.join(name)) try: st = os.stat(absname) except EnvironmentError as err: From 803380867da79b5b28f5ba87dc80d6ee355108d0 Mon Sep 17 00:00:00 2001 From: shitalp Date: Wed, 28 Jan 2015 16:22:31 +0530 Subject: [PATCH 743/829] Update secure.py --- ee/cli/plugins/secure.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 49fed63c..0c7a6b8e 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -55,7 +55,7 @@ class EESecureController(CementBaseController): 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 [{0}] :".format(passwd)) self.app.pargs.user_pass = password if password == "": self.app.pargs.user_pass = passwd @@ -66,10 +66,10 @@ class EESecureController(CementBaseController): .format(username=self.app.pargs.user_input, password=self.app.pargs.user_pass)) Log.info(self, "Successfully changed HTTP authentication" - " username:{username}" + " username to :{username}" .format(username=self.app.pargs.user_input)) Log.info(self, "Successfully changed HTTP authentication" - " password:{password}" + " password to :{password}" .format(password=self.app.pargs.user_pass)) @expose(hide=True) From f81b5f24a05e5dfbb85aa25219c5c183cd7b5d92 Mon Sep 17 00:00:00 2001 From: shitalp Date: Wed, 28 Jan 2015 16:23:58 +0530 Subject: [PATCH 744/829] change log message in secure.py --- ee/cli/plugins/secure.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 0c7a6b8e..c6e672c1 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -66,10 +66,10 @@ class EESecureController(CementBaseController): .format(username=self.app.pargs.user_input, password=self.app.pargs.user_pass)) Log.info(self, "Successfully changed HTTP authentication" - " username to :{username}" + " username to : {username}" .format(username=self.app.pargs.user_input)) Log.info(self, "Successfully changed HTTP authentication" - " password to :{password}" + " password to : {password}" .format(password=self.app.pargs.user_pass)) @expose(hide=True) From ff00553d2a12f63dca3a95776ac9ed6b4d014186 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 28 Jan 2015 16:44:57 +0530 Subject: [PATCH 745/829] minor fix --- ee/core/logwatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/logwatch.py b/ee/core/logwatch.py index 8392a0cc..2c76be26 100644 --- a/ee/core/logwatch.py +++ b/ee/core/logwatch.py @@ -48,7 +48,7 @@ class LogWatcher(object): self.extensions = extensions # assert (os.path.isdir(self.folder), "%s does not exists" # % self.folder) - for files in self.filelist: + for file in self.filelist: assert (os.path.isfile(file), "%s does not exists" % file) assert callable(callback) self.update_files() From a8a96508c9b18e38bb0b0d2b094ac5853fd37975 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 28 Jan 2015 16:59:59 +0530 Subject: [PATCH 746/829] minor change --- ee/core/logwatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/logwatch.py b/ee/core/logwatch.py index 2c76be26..818f50d3 100644 --- a/ee/core/logwatch.py +++ b/ee/core/logwatch.py @@ -49,7 +49,7 @@ class LogWatcher(object): # assert (os.path.isdir(self.folder), "%s does not exists" # % self.folder) for file in self.filelist: - assert (os.path.isfile(file), "%s does not exists" % file) + assert (os.path.isfile(file)) assert callable(callback) self.update_files() # The first time we run the script we move all file markers at EOF. From 9d5e0b9686a1e1e8f6f975c4029cb372c54c11d0 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 28 Jan 2015 17:03:38 +0530 Subject: [PATCH 747/829] minor modification --- config/bash_completion.d/ee_auto.rc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index 062548bf..162edf4b 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -93,7 +93,8 @@ _ee_complete() *) ;; esac - if [[ ${COMP_WORDS[1]} == "debug" ]] && [ "$prev" != "--start" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]; then + + if [ ${COMP_WORDS[1]} == "debug" ] && ([ "$prev" != "--start" ] || [ "$prev" != "--nginx" ] || [ "$prev" != "--php" ] || [ "$prev" != "--fpm" ] || [ "$prev" != "--mysql" ] || [ "$prev" != "-i" ] || ["$prev" != "--interactive" ] || ["$prev" != "--stop" ]); then retlist="--start --stop --wp --rewrite -i" ret="${retlist[@]/$prev}" COMPREPLY=( $(compgen \ From d7db8d05831d35ee3085d40c714f9b025c106516 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 28 Jan 2015 18:12:11 +0530 Subject: [PATCH 748/829] added log message in stack.py --- ee/cli/plugins/stack.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index e6b580e4..fc9b8569 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -982,24 +982,28 @@ class EEStackController(CementBaseController): apt_packages = apt_packages + EEVariables.ee_nginx else: Log.debug(self, "Nginx already installed") + Log.info(self, "Nginx already installed") if self.app.pargs.php: Log.debug(self, "Setting apt_packages variable for PHP") if not EEAptGet.is_installed(self, 'php5-fpm'): apt_packages = apt_packages + EEVariables.ee_php else: Log.debug(self, "PHP already installed") + Log.info(self, "PHP already installed") if self.app.pargs.mysql: Log.debug(self, "Setting apt_packages variable for MySQL") if not EEShellExec.cmd_exec(self, "mysqladmin ping"): apt_packages = apt_packages + EEVariables.ee_mysql else: Log.debug(self, "MySQL connection is already alive") + Log.info(self, "MySQL connection is already alive") if self.app.pargs.postfix: Log.debug(self, "Setting apt_packages variable for Postfix") if not EEAptGet.is_installed(self, 'postfix'): apt_packages = apt_packages + EEVariables.ee_postfix else: Log.debug(self, "Postfix is already installed") + Log.info(self, "Postfix is already installed") if self.app.pargs.wpcli: Log.debug(self, "Setting packages variable for WP-CLI") if not EEShellExec.cmd_exec(self, "which wp"): @@ -1011,6 +1015,7 @@ class EEStackController(CementBaseController): "WP-CLI"]] else: Log.debug(self, "WP-CLI is already installed") + Log.info(self, "WP-CLI is already installed") if self.app.pargs.phpmyadmin: Log.debug(self, "Setting packages varible for phpMyAdmin ") packages = packages + [["https://github.com/phpmyadmin/" From 0947c80c29dd2535ceaf7dd00ac317dc912a18d8 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 29 Jan 2015 14:25:59 +0530 Subject: [PATCH 749/829] Better commit messges --- ee/cli/plugins/debug.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 9734f82f..11f72b6c 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -70,7 +70,7 @@ class EEDebugController(CementBaseController): if not self.trigger_nginx: Log.info(self, "Nginx debug connection already enabled") - self.msg = self.msg + [" /var/log/nginx/*.error.log"] + self.msg = self.msg + ["/var/log/nginx/*.error.log"] # stop global debug elif not self.start and not self.app.pargs.site_name: @@ -99,7 +99,7 @@ class EEDebugController(CementBaseController): else: Log.info(self, "Debug for site allready enabled") - self.msg = self.msg + ['/var/www//logs/error.log' + self.msg = self.msg + ['/var/www/{0}/logs/error.log' .format(self.app.pargs.site_name)] else: @@ -143,6 +143,7 @@ class EEDebugController(CementBaseController): self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() self.trigger_php = True + self.trigger_nginx = True else: Log.info(self, "PHP debug is allready enabled") @@ -161,6 +162,7 @@ class EEDebugController(CementBaseController): self.app.render((data), 'upstream.mustache', out=ee_nginx) ee_nginx.close() self.trigger_php = True + self.trigger_nginx = True else: Log.info(self, "PHP debug is allready disabled") @@ -185,6 +187,7 @@ class EEDebugController(CementBaseController): Log.info(self, "PHP5-FPM log_level = debug already setup") self.msg = self.msg + ['/var/log/php5/fpm.log'] + # PHP5-FPM stop global debug else: if EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " @@ -280,6 +283,11 @@ class EEDebugController(CementBaseController): .format(webroot)) else: Log.info(self, "WordPress debug log already enabled") + + self.msg = self.msg + ['/var/www/{0}/htdocs/wp-content' + '/debug.log' + .format(self.app.pargs.site_name)] + else: Log.info(self, "{0} domain not valid" .format(self.app.pargs.site_name)) @@ -425,10 +433,11 @@ class EEDebugController(CementBaseController): # Reload PHP if self.trigger_php: EEService.reload_service(self, 'php5-fpm') - # - # if len(self.msg) > 0: - # self.app.log.info("Use following command to check debug logs:" - # "\n{0}".format(self.msg.join())) + + if len(self.msg) > 0: + disp_msg = ' '.join(self.msg) + Log.info(self, "Use following command to check debug logs:\n" + + Log.ENDC + "tail -f {0}".format(disp_msg)) def load(app): From dd85c74901a1f67549c173f3a2b466af623e14d5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 29 Jan 2015 15:05:11 +0530 Subject: [PATCH 750/829] Added -i parameter to ee debug --- ee/cli/plugins/debug.py | 42 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 11f72b6c..7961ad95 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -6,8 +6,11 @@ from ee.core.shellexec import EEShellExec from ee.core.mysql import EEMysql from ee.core.services import EEService from ee.core.logging import Log +from ee.cli.plugins.site_functions import logwatch import os import configparser +import glob +import signal def debug_plugin_hook(app): @@ -382,6 +385,31 @@ class EEDebugController(CementBaseController): Log.info(self, "Nginx rewrite logs for {0} allready " " disabled".format(self.app.pargs.site_name)) + @expose(hide=True) + def signal_handler(self, signal, frame): + self.start = False + if self.app.pargs.nginx: + self.debug_nginx() + if self.app.pargs.php: + self.debug_php() + if self.app.pargs.fpm: + self.debug_fpm() + if self.app.pargs.mysql: + self.debug_mysql() + if self.app.pargs.wp: + self.debug_wp() + if self.app.pargs.rewrite: + self.debug_rewrite() + + # Reload Nginx + if self.trigger_nginx: + EEService.reload_service(self, 'nginx') + + # Reload PHP + if self.trigger_php: + EEService.reload_service(self, 'php5-fpm') + self.app.close(0) + @expose(hide=True) def default(self): self.start = True @@ -435,9 +463,17 @@ class EEDebugController(CementBaseController): EEService.reload_service(self, 'php5-fpm') if len(self.msg) > 0: - disp_msg = ' '.join(self.msg) - Log.info(self, "Use following command to check debug logs:\n" - + Log.ENDC + "tail -f {0}".format(disp_msg)) + if not self.app.pargs.interactive: + disp_msg = ' '.join(self.msg) + Log.info(self, "Use following command to check debug logs:\n" + + Log.ENDC + "tail -f {0}".format(disp_msg)) + else: + signal.signal(signal.SIGINT, self.signal_handler) + watch_list = [] + for w_list in self.msg: + watch_list = watch_list + glob.glob(w_list) + + logwatch(self, watch_list) def load(app): From 036c17c6cd44f9f060e309ca203f44c4dc4b4385 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 29 Jan 2015 17:35:51 +0530 Subject: [PATCH 751/829] Fixed ViMbAdmin config error --- ee/cli/templates/vimbadmin.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/templates/vimbadmin.mustache b/ee/cli/templates/vimbadmin.mustache index acdadd7f..16f54d51 100644 --- a/ee/cli/templates/vimbadmin.mustache +++ b/ee/cli/templates/vimbadmin.mustache @@ -1,5 +1,5 @@ ;; This file is licenesed Under GNU GENERAL PUBLIC LICENSE Version 3 -;; © Copyright 2011 - 2014 Open Source Solutions Limited, Dublin, Ireland. +;; © Copyright 2011 - 2014 Open Source Solutions Limited, Dublin, Ireland. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ViMbAdmin :: Virtual Mailbox Admin @@ -129,7 +129,7 @@ defaults.mailbox.gid = 5000 ; ; http://wiki2.dovecot.org/VirtualUsers/Home -defaults.mailbox.maildir = "maildir:/var/vmail/%d/%u"" +defaults.mailbox.maildir = "maildir:/var/vmail/%d/%u" defaults.mailbox.homedir = "/var/vmail/" ;minimum mailbox password length From 1b521ee9a5edca4b48b861afb3db43390f1ad997 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 29 Jan 2015 17:50:18 +0530 Subject: [PATCH 752/829] Fixed Postfix typo --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index fc9b8569..4c97cf59 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -521,7 +521,7 @@ class EEStackController(CementBaseController): "mailbox_maps.cf\"") EEShellExec.cmd_exec(self, "postconf -e \"virtual_alias_maps " "= mysql:/etc/postfix/mysql/virtual_" - " alias_maps.cf\"") + "alias_maps.cf\"") EEShellExec.cmd_exec(self, "openssl req -new -x509 -days " " 3650 -nodes -subj /commonName=" "{HOSTNAME}/emailAddress={EMAIL}" From 54fff3bfa66a8993113f0dccac5133b4c2ea69cf Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 29 Jan 2015 17:56:01 +0530 Subject: [PATCH 753/829] Fixed another Postfix typo --- ee/cli/plugins/stack.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 4c97cf59..103a3b76 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -514,8 +514,8 @@ class EEStackController(CementBaseController): "= static:5000\"") EEShellExec.cmd_exec(self, "postconf -e \"" " virtual_mailbox_domains = " - " mysql:/etc/postfix/mysql/virtual_" - " domains_maps.cf\"") + "mysql:/etc/postfix/mysql/virtual_" + "domains_maps.cf\"") EEShellExec.cmd_exec(self, "postconf -e \"virtual_mailbox_maps" " = mysql:/etc/postfix/mysql/virtual_" "mailbox_maps.cf\"") @@ -534,7 +534,7 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_cert_file " "= /etc/ssl/certs/postfix.pem\"") EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_key_file " - " = /etc/ssl/private/postfix.pem\"") + "= /etc/ssl/private/postfix.pem\"") # Sieve configuration if not os.path.exists('/var/lib/dovecot/sieve/'): From f894c9e6fe6eb243799c90b0d5b0126000481a6f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 29 Jan 2015 18:00:53 +0530 Subject: [PATCH 754/829] Fixed MySQL host in Postfix configuration --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 103a3b76..31c3345f 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -776,7 +776,7 @@ class EEStackController(CementBaseController): Log.debug(self, "Creating directory " "/etc/postfix/mysql/") os.makedirs('/etc/postfix/mysql/') - data = dict(password=vm_passwd, host=EEVariables.ee_mysql) + data = dict(password=vm_passwd, host=EEVariables.ee_mysql_host) vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf', 'w') self.app.render((data), 'virtual_alias_maps.mustache', From 1eb9a7b5ac728eefb666c9e115e6f1db6ed28bfe Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 30 Jan 2015 13:11:27 +0530 Subject: [PATCH 755/829] Optimized dovecot setup --- ee/cli/plugins/stack.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 31c3345f..c49d9519 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -473,6 +473,19 @@ class EEStackController(CementBaseController): self.app.render((data), 'dovecot.mustache', out=ee_dovecot) ee_dovecot.close() + EEShellExec.cmd_exec(self, "sed -i \"s/\\!include " + "auth-system.conf.ext/#\\!include " + "auth-system.conf.ext/\" " + "/etc/dovecot/conf.d/10-auth.conf") + + EEShellExec.cmd_exec(self, "sed -i \"s\'/etc/dovecot/" + "dovecot.pem\'/etc/ssl/certs/dovecot.pem" + "\'\" /etc/dovecot/conf.d/10-ssl.conf") + EEShellExec.cmd_exec(self, "sed -i \"s\'/etc/dovecot/" + "private/dovecot.pem\'/etc/ssl/private" + "/dovecot.pem\'\" /etc/dovecot/conf.d/" + "10-ssl.conf") + # Custom Postfix configuration needed with Dovecot # Changes in master.cf # TODO: Find alternative for sed in Python @@ -561,7 +574,7 @@ class EEStackController(CementBaseController): "default.sieve") EEGit.add(self, ["/etc/postfix", "/etc/dovecot"], msg="Installed mail server") - EEService.reload_service(self, 'dovecot') + EEService.restart_service(self, 'dovecot') EEService.reload_service(self, 'postfix') if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)): @@ -598,7 +611,7 @@ class EEStackController(CementBaseController): Log.debug(self, "Restarting clamav-daemon service") EEShellExec.cmd_exec(self, "service clamav-daemon restart") EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git") - EEService.reload_service(self, 'dovecot') + EEService.restart_service(self, 'dovecot') EEService.reload_service(self, 'postfix') EEService.reload_service(self, 'amavis') @@ -817,7 +830,7 @@ class EEStackController(CementBaseController): self.app.render((data), '50-user.mustache', out=vm_config) vm_config.close() - EEService.reload_service(self, 'dovecot') + EEService.restart_service(self, 'dovecot') EEService.reload_service(self, 'nginx') EEService.reload_service(self, 'php5-fpm') self.msg = (self.msg + ["Configure ViMbAdmin:\thttps://{0}:" From e2cea7eac5bbdee0a5aa041261e93fc5de15b204 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 30 Jan 2015 13:27:22 +0530 Subject: [PATCH 756/829] Fixed typo --- ee/cli/plugins/stack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index c49d9519..26cbfe65 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -883,8 +883,8 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\[" "\'plugins\'\] " "= array(:\$config\['plugins'\] = " - "array(\n\'sieverules\',:\\\" /var/www" - "/roundcubemail/htdocs/config" + "array(\\n \'sieverules\',:\\\" " + "/var/www/roundcubemail/htdocs/config" "/config.inc.php\"") EEShellExec.cmd_exec(self, "echo \"\$config['sieverules_port']" "=4190;\" >> /var/www/roundcubemail" From d8a8b1be4ab03ec03d932475164854c030b33949 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 30 Jan 2015 14:16:17 +0530 Subject: [PATCH 757/829] Some config changes in postfix --- ee/cli/plugins/stack.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 26cbfe65..9076a67a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -466,7 +466,7 @@ class EEStackController(CementBaseController): "/dovecot.pem") # Custom Dovecot configuration by EasyEngine - data = dict() + data = dict(email=EEVariables.ee_email) Log.debug(self, "Writting configuration into file" "/etc/dovecot/conf.d/99-ee.conf ") ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf', 'w') @@ -789,7 +789,13 @@ class EEStackController(CementBaseController): Log.debug(self, "Creating directory " "/etc/postfix/mysql/") os.makedirs('/etc/postfix/mysql/') - data = dict(password=vm_passwd, host=EEVariables.ee_mysql_host) + + if EEVariables.ee_mysql_host is "localhost": + data = dict(password=vm_passwd, host="127.0.0.1") + else: + data = dict(password=vm_passwd, + host=EEVariables.ee_mysql_host) + vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf', 'w') self.app.render((data), 'virtual_alias_maps.mustache', From b442016d9b47d5379a7f686202e468a4c5a8ff0f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 30 Jan 2015 18:39:18 +0530 Subject: [PATCH 758/829] FQDN check for mail --- ee/cli/plugins/stack.py | 38 ++++++++++++++++++++++++++++--- ee/cli/templates/50-user.mustache | 2 +- ee/core/checkfqdn.py | 22 ++++++++++++++++++ 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 ee/core/checkfqdn.py diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9076a67a..c87dcca9 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -12,6 +12,7 @@ from ee.core.extract import EEExtract from ee.core.mysql import EEMysql from ee.core.addswap import EESwap from ee.core.git import EEGit +from ee.core.checkfqdn import check_fqdn from pynginxconfig import NginxConfig from ee.core.services import EEService import random @@ -44,6 +45,8 @@ class EEStackController(CementBaseController): dict(help='Install admin tools stack', action='store_true')), (['--mail'], dict(help='Install mail server stack', action='store_true')), + (['--mailscanner'], + dict(help='Install mail scanner stack', action='store_true')), (['--nginx'], dict(help='Install Nginx stack', action='store_true')), (['--php'], @@ -588,6 +591,20 @@ class EEStackController(CementBaseController): out=ee_amavis) ee_amavis.close() + # Amavis ViMbadmin configuration + if os.path.isfile("/etc/postfix/mysql/virtual_alias_maps.cf"): + vm_host = os.popen("grep hosts /etc/postfix/mysql/virtual_" + "alias_maps.cf | awk \'{ print $3 }\' |" + " tr -d '\\n'").read() + vm_pass = os.popen("grep password /etc/postfix/mysql/" + "virtual_alias_maps.cf | awk \'{ print " + "$3 }\' | tr -d '\\n'").read() + + data = dict(host=vm_host, password=vm_pass) + vm_config = open('/etc/amavis/conf.d/50-user', 'w') + self.app.render((data), '50-user.mustache', out=vm_config) + vm_config.close() + # Amavis postfix configuration EEShellExec.cmd_exec(self, "postconf -e \"content_filter = " "smtp-amavis:[127.0.0.1]:10024\"") @@ -948,7 +965,8 @@ class EEStackController(CementBaseController): (not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and - (not self.app.pargs.adminer) and (not self.app.pargs.utils)): + (not self.app.pargs.adminer) and (not self.app.pargs.utils) and + (not self.app.pargs.mailscanner)): self.app.pargs.web = True if self.app.pargs.web: @@ -975,6 +993,8 @@ class EEStackController(CementBaseController): self.app.pargs.postfix = True if not EEAptGet.is_installed(self, 'dovecot-core'): + check_fqdn(self, + os.popen("hostname -f | tr -d '\n'").read()) Log.debug(self, "Setting apt_packages variable for mail") apt_packages = apt_packages + EEVariables.ee_mail packages = packages + [["https://github.com/opensolutions/" @@ -990,8 +1010,11 @@ class EEStackController(CementBaseController): "Roundcube"]] if EEVariables.ee_ram > 1024: - apt_packages = (apt_packages + - EEVariables.ee_mailscanner) + self.app.pargs.mailscanner = True + else: + Log.info(self, "System RAM is less than 1GB\nMail " + "scanner packages are not going to install" + " automatically") else: Log.info(self, "Mail server is already installed") @@ -1050,6 +1073,9 @@ class EEStackController(CementBaseController): "htdocs/db/adminer/index.php", "Adminer"]] + if self.app.pargs.mailscanner: + apt_packages = (apt_packages + EEVariables.ee_mailscanner) + if self.app.pargs.utils: Log.debug(self, "Setting packages variable for utils") packages = packages + [["http://phpmemcacheadmin.googlecode" @@ -1149,6 +1175,9 @@ class EEStackController(CementBaseController): EEMysql.execute(self, "drop database IF EXISTS vimbadmin") EEMysql.execute(self, "drop database IF EXISTS roundcubemail") + if self.app.pargs.mailscanner: + apt_packages = (apt_packages + EEVariables.ee_mailscanner) + if self.app.pargs.nginx: Log.debug(self, "Removing apt_packages variable of Nginx") apt_packages = apt_packages + EEVariables.ee_nginx @@ -1225,6 +1254,9 @@ class EEStackController(CementBaseController): EEMysql.execute(self, "drop database IF EXISTS vimbadmin") EEMysql.execute(self, "drop database IF EXISTS roundcubemail") + if self.app.pargs.mailscanner: + apt_packages = (apt_packages + EEVariables.ee_mailscanner) + if self.app.pargs.nginx: Log.debug(self, "Purge apt_packages variable of Nginx") apt_packages = apt_packages + EEVariables.ee_nginx diff --git a/ee/cli/templates/50-user.mustache b/ee/cli/templates/50-user.mustache index e0e0c625..0cee70fb 100644 --- a/ee/cli/templates/50-user.mustache +++ b/ee/cli/templates/50-user.mustache @@ -8,7 +8,7 @@ $final_spam_destiny = D_PASS; # We need to provide list of domains for which filtering need to be done @lookup_sql_dsn = ( -['DBI:mysql:database=vimbadmin;host=127.0.0.1;port=3306', +['DBI:mysql:database=vimbadmin;host={{host}};port=3306', 'vimbadmin', '{{password}}']); diff --git a/ee/core/checkfqdn.py b/ee/core/checkfqdn.py new file mode 100644 index 00000000..ea488a1f --- /dev/null +++ b/ee/core/checkfqdn.py @@ -0,0 +1,22 @@ +from ee.core.shellexec import EEShellExec +from ee.core.variables import EEVariables +import os + + +def check_fqdn(self, ee_host): + #ee_host=os.popen("hostname -f | tr -d '\n'").read() + if '.' in ee_host: + EEVariables.ee_fqdn = ee_host + with open('/etc/hostname', 'w') as hostfile: + hostfile.write(ee_host) + + EEShellExec.cmd_exec(self, "sed -i \"1i\\127.0.0.1 {0}\" /etc/hosts" + .format(ee_host)) + if EEVariables.ee_platform_distro == 'debian': + EEShellExec.cmd_exec(self, "/etc/init.d/hostname.sh start") + else: + EEShellExec.cmd_exec(self, "service hostname restart") + + else: + ee_host = input("Enter hostname [fqdn]:") + check_fqdn(self, ee_host) From cb04cda30fa691aeaa69013086c3922165fd1954 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 30 Jan 2015 19:07:53 +0530 Subject: [PATCH 759/829] Fixed Travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index bcd2a8d0..30990a81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ before_install: - rm -rf ~/.gnupg before_script: + - sudo bash -c 'echo example.com > /etc/hostname' + - sudo service hostname restart - sudo apt-get -qq purge mysql* graphviz* - sudo apt-get -qq autoremove From 4c4ac4989a281d9a13b3bf2502acbf10711680ff Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 30 Jan 2015 19:09:41 +0530 Subject: [PATCH 760/829] changed key server --- ee/cli/plugins/stack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9076a67a..0abc7fd0 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -82,7 +82,8 @@ class EEStackController(CementBaseController): EERepo.add(self, repo_url=EEVariables.ee_mysql_repo) Log.debug(self, 'Adding key for {0}' .format(EEVariables.ee_mysql_repo)) - EERepo.add_key(self, '1C4CBDCDCD2EFD2A') + EERepo.add_key(self, '1C4CBDCDCD2EFD2A', + keyserver="subkeys.pgp.net") chars = ''.join(random.sample(string.ascii_letters, 8)) Log.info(self, "Pre-seeding MySQL") EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " From a8b88c42c1fb8d98fbb06bd91b0e0bd4a6bba918 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 30 Jan 2015 19:14:41 +0530 Subject: [PATCH 761/829] self parameter missing in add_repo --- ee/core/apt_repo.py | 11 ++++++----- ee/core/aptget.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index 4a71a6fb..a2d6f312 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -48,11 +48,12 @@ class EERepo(): "--remove '{ppa_name}'" .format(ppa_name=repo_url)) - def add_key(keyids, keyserver=None): + def add_key(self, keyids, keyserver=None): if keyserver is None: - EEShellExec.cmd_exec("gpg --keyserver {serv}" - .format(serv=(keyserver - or "hkp://keys.gnupg.net")) + EEShellExec.cmd_exec(self, "gpg --keyserver {serv}" + .format(serv=(keyserver or + "hkp://keys.gnupg.net")) + " --recv-keys {key}".format(key=keyids)) - EEShellExec.cmd_exec("gpg -a --export --armor {0}".format(keyids) + EEShellExec.cmd_exec(self, "gpg -a --export --armor {0}" + .format(keyids) + " | apt-key add - ") diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 2e533e19..72b4c4cb 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -50,15 +50,25 @@ class EEAptGet(): #apt_cache.close() return False else: - pkg.mark_install() + try: + print(pkg.name) + pkg.mark_install() + except Exception as e: + Log.debug(self, str(e)) + Log.error(self, str(e)) + try: #apt_pkg.PkgSystemUnLock() result = apt_cache.commit() #apt_cache.close() return result except SystemError as e: + Log.debug(self, 'SystemError: ' + str(e)) Log.error(self, 'SystemError: ' + str(e)) #apt_cache.close() + except Exception as e: + Log.debug(self, str(e)) + Log.error(self, str(e)) else: #apt_cache.close() Log.error(self, 'Unknown package selected (' + @@ -85,6 +95,7 @@ class EEAptGet(): return False else: try: + print(pkg.name) pkg.mark_delete(purge) except SystemError as e: Log.debug(self, 'SystemError: ' + str(e)) @@ -97,6 +108,9 @@ class EEAptGet(): except SystemError as e: Log.debug(self, 'SystemError: ' + str(e)) return False + except Exception as e: + Log.debug(self, str(e)) + Log.error(self, str(e)) # apt_cache.close() else: # apt_cache.close() From 31f5deb90d263d89e2208f56c0bc20c8bd515875 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 2 Feb 2015 12:29:33 +0530 Subject: [PATCH 762/829] Added upgrade script --- upgrade | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 upgrade diff --git a/upgrade b/upgrade new file mode 100644 index 00000000..2b4b6c3f --- /dev/null +++ b/upgrade @@ -0,0 +1,50 @@ +#!/bin/bash + +# EasyEngine update script. +# This script is designed to update current EasyEngine from 2.2.2 to 3.x +# Define echo function +# Blue color + +function ee_lib_echo() +{ + echo $(tput setaf 4)$@$(tput sgr0) +} +# White color +function ee_lib_echo_info() +{ + echo $(tput setaf 7)$@$(tput sgr0) +} +# Red color +function ee_lib_echo_fail() +{ + echo $(tput setaf 1)$@$(tput sgr0) +} + +# 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 +which ee > /dev/null +if [[ $? -ne 0 ]]; then + ee_lib_echo_fail "EasyEngine 2.0 not found" + exit 1 +fi + +# Check old EasyEngine version +ee version | grep "2.2.2" > /dev/null +if [[ $? -ne 0 ]]; then + ee_lib_echo_fail "EasyEngine 2.2.2 not found on your system" + ee_lib_echo_fail "Please update is using command: ee update" + exit 1 +fi + +# 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 on system" From b4aa0bc6b4f4d84c5a9a84ad1dbdd5702e627a31 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 2 Feb 2015 12:41:57 +0530 Subject: [PATCH 763/829] created man pages and added argument if self.py --- docs/ee.8 | 312 +++++++++++++++++++++++++++++++++++++++++ ee/cli/plugins/info.py | 5 +- setup.py | 3 +- 3 files changed, 317 insertions(+), 3 deletions(-) create mode 100644 docs/ee.8 diff --git a/docs/ee.8 b/docs/ee.8 new file mode 100644 index 00000000..6c7f4227 --- /dev/null +++ b/docs/ee.8 @@ -0,0 +1,312 @@ +.TH ee 8 "EasyEngine (ee) version: 2.2.1" "Oct 16,2014" "EasyEngine" +.SH NAME +.B EasyEngine (ee) +\- Manage Nginx Based Websites. +.SH SYNOPSIS +ee [ --version | --help | info | stack | site | debug | update ] +.TP +ee stack [ install | remove | purge ] [ --web | --mail | --all | --nginx | --php | --mysql | --postfix | --adminer | --phpmyadmin | --wpcli | --utils ] +.TP +ee stack [ status | start | stop | reload | restart ] +.TP +ee site [ list | info | show | enable | disable | edit ] [ example.com ] +.TP +ee site create example.com [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] +.TP +ee site update example.com [ --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] +.TP +ee site delete example.com [--db | --files | --all | --no-prompt ] +.TP +ee debug [ -i | --nginx | --rewrite | --php | --fpm | --mysql ] [--stop ] +.TP +ee debug example.com [ -i | --nginx | --rewrite | --wp ] [--stop ] +.TP +ee secure [ --auth | --port | --ip ] +.SH DESCRIPTION +EasyEngine aka ee is the opensource project developed with the purpose to automate web-server configuration. +.br +EasyEngine is the collection of shell scripts that provides automation for the web-server +.br +installation, site creation, services debugging & monitoring. +.SH OPTIONS +.TP +.B --version +.br +Display easyengine (ee) version information. +.TP +.B info +.br +ee info - Display Nginx, PHP, MySQL and ee common location information +.br +ee site info - Diplay given website details like enable, disable. weboot and log files. +.TP +.B --help +.br +Display easyengine (ee) help. +.TP +.B stack +.TP +.B install [ --all | --web | --mail | --nginx | --php | --mysql | --postfix | --adminer | --phpmyadmin | --wpcli | --utils ] +.br +Install Nginx PHP5 MySQL Postfix stack Packages if not used with +.br +any options.Installs specific package if used with option. +.TP +.B remove [ --all | --web | --mail | --nginx | --php | --mysql | --postfix | --adminer | --phpmyadmin | --wpcli | --utils ] +.br +Remove Nginx PHP5 MySQL Postfix stack Packages if not used with +.br +any options. Remove specific package if used with option. +.TP +.B purge [ --all | --web | --mail | --nginx | --php | --mysql | --postfix | --adminer | --phpmyadmin | --wpcli | --utils ] +.br +Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any +.br +options.Purge specific package if used with option. +.TP +.B status +.br +Display status of NGINX, PHP5-FPM, MySQL, Postfix services. +.TP +.B start +.br +Start services NGINX, PHP5-FPM, MySQL, Postfix. +.TP +.B stop +.br +Stop services NGINX, PHP5-FPM, MySQL, Postfix. +.TP +.B reload +.br +Reload services NGINX, PHP5-FPM, MySQL, Postfix. +.TP +.B restart +.br +Restart services NGINX, PHP5-FPM, MySQL, Postfix. +.TP +.B site +.br +.TP +.B cd [ example.com ] +.br +Change directory to webroot of specified site in subshell. +.TP +.B log [ example.com ] +.br +monitor access and error logs for site specified. +.TP +.B list [ enable | available ] +.br +Lists all available sites from /etc/nginx/sites-enabled/ +.br +by default & enable argument. Display sites list from +.br +/etc/nginx/sites-available/ if used with available option. +.TP +.B info [ example.com ] +.br +prints information about site such as access log, error log +.br +location and type of site. +.TP +.B show [ example.com ] +.br +Display NGINX configuration of site. +.TP +.B enable [ example.com ] +.br +Enable site by creating softlink with site file in +.br +/etc/nginx/sites-available to /etc/nginx/sites-enabled/. +.TP +.B disable [ example.com ] +.br +Disable site by Destroying softlink with site file in +.br +/etc/nginx/sites-available to /etc/nginx/sites-enabled/. +.TP +.B edit [ example.com ] +.br +Edit NGINX configuration of site. +.TP +.B create [ example.com ] [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] +.br +Create new site according to given options. If no options provided +.br +create static site with html only. +.TP +.B update [ example.com ] [ --html | --php | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--basic | --wpsc | --w3tc | --wpfc]] +.br +Update site configuration according to specified options. +.TP +.B delete [ example.com ] [--no-prompt ] [ --db | --files ] +.br +Delete site i.e webroot, database, ad configuration permenantly. +.TP +.B debug [ -i | --nginx | --php | --mysql | --rewrite | --fpm ] [ --start | --stop ] +.br +Starts server level debugging. If used without arguments starts debugging +.br +all services, else debug only service provided with argument. Stop +.br +Debugging if used with --stop argument. +.TP +.B debug example.com [ -i | --nginx | --rewrite | --wp ] [ --start | --stop ] +.br +Starts site level debugging. If used without arguments starts debugging all +.br +services, else debug only service provided with argument. Stop Debugging +.br +if used with --stop argument. +.TP +.B secure [ --auth | --port ] +.br +Update security settings. +.TP +.B clean [ --fastcgi | --opcache | --memcache | --all ] +.br +Clean NGINX fastCGI cache, Opcache, Memcache. +.br +Clean NGINX fastCGI cache if no option specified. +.SH ARGUMENTS +.TP +.B -i +.br +setup intractive mode while used with debug. +.TP +.B --nginx +.br +used with ee debug command. used to start or stop nginx debugging. +.TP +.B --php +.br +used with ee debug command. used to start or stop php debugging. +.TP +.B --mysql +.br +used with ee debug command. used to start or stop mysql debugging. +.TP +.B --rewrite +.br +used with ee debug command. used to start or stop nginx rewrite rules debugging. +.TP +.B --fpm +.br +used with ee debug command. used to start or stop fpm debugging. +.TP +.B --wp +.br +used with ee debug command. used to start or stop wordpress site debugging. +.TP +.B --start +.br +used with ee debug command. used to stop debugging. +.TP +.B --stop +.br +used with ee debug command. used to stop debugging. +.TP +.B --html +.br +Create a HTML website. +.TP +.B --php +.br +Create a PHP website. +.TP +.B --mysql +.br +Create a PHP+MySQL website. +.TP +.B --wp +.br +Create a WordPress Website. +.TP +.B --wpsubdir +.br +Create a Wordpress Multisite with Sub Directories Setup. +.TP +.B --wpsubdomain +.br +Create a Wordpress Multisite with Sub Domains Setup. +.br +.TP +.B --db +.br +Delete website database. +.br +.TP +.B --files +.br +Delete website webroot. +.br +.TP +.B --no-prompt +.br +Does not prompt for confirmation when delete command used. +.TP +.B --auth +.br +used with ee secure command. Update credential of HTTP authentication +.TP +.B --port +.br +used with ee secure command. Change EasyEngine admin port 22222. +.TP +.B --ip +.br +used with ee secure command. Update whitelist IP address +.SH WORDPRESS CACHING OPTIONS +.TP +.B --basic +.br +Create WordPress website without cache. +.TP +.B --w3tc +.br +Install and activate Nginx-helper and W3 Total Cache plugin. +.TP +.B --wpsc +.br +Install and activate Nginx-helper and WP Super Cache plugin. +.TP +.B --wpfc +.br +Install and activate Nginx-helper and W3 Total Cache plugin with +.br +Nginx FastCGI cache. +.SH FILES +.br +/etc/easyengine/ee.conf +.SH BUGS +Report bugs at +.SH AUTHOR +.br +.B rtCamp Team +.I \ +.br +.B Mitesh Shah +.I \ +.br +.B Manish +.I \ +.br +.B Gaurav +.I \ +.br +.B Harshad +.I \ +.br +.B Shital +.I \ +.br +.SH "SEE ALSO" +.br +EE: +.I https://rtcamp.com/easyengine/ +.br +FAQ: +.I https://rtcamp.com/easyengine/faq/ +.br +DOCS: +.I https://rtcamp.com/easyengine/docs/ diff --git a/ee/cli/plugins/info.py b/ee/cli/plugins/info.py index 8ba76f44..54c9c89d 100644 --- a/ee/cli/plugins/info.py +++ b/ee/cli/plugins/info.py @@ -5,6 +5,7 @@ from cement.core import handler, hook from pynginxconfig import NginxConfig from ee.core.aptget import EEAptGet from ee.core.shellexec import EEShellExec +from ee.core.logging import Log import os import configparser @@ -180,13 +181,13 @@ class EEInfoController(CementBaseController): if EEAptGet.is_installed(self, 'php5-fpm'): self.info_php() else: - Log.error("PHP5 is not installed") + Log.error(self, "PHP5 is not installed") if self.app.pargs.mysql: if EEShellExec.cmd_exec(self, "mysqladmin ping"): self.info_mysql() else: - Log.error("MySQL is not installed") + Log.error(self, "MySQL is not installed") def load(app): diff --git a/setup.py b/setup.py index 81050f6f..4e0ee309 100644 --- a/setup.py +++ b/setup.py @@ -77,7 +77,8 @@ setup(name='ee', ('/etc/ee/plugins.d', conf), ('/usr/lib/ee/templates', templates), ('/etc/bash_completion.d/', - ['config/bash_completion.d/ee_auto.rc'])], + ['config/bash_completion.d/ee_auto.rc']), + ('/usr/share/man/man8/', ['docs/ee.8'])], setup_requires=[], entry_points=""" [console_scripts] From 9cbf2eb6f0e34c505f8230dc7323f8a9611ee0b5 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 2 Feb 2015 12:54:16 +0530 Subject: [PATCH 764/829] changed version and date in ee.8 --- docs/ee.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ee.8 b/docs/ee.8 index 6c7f4227..842aa547 100644 --- a/docs/ee.8 +++ b/docs/ee.8 @@ -1,4 +1,4 @@ -.TH ee 8 "EasyEngine (ee) version: 2.2.1" "Oct 16,2014" "EasyEngine" +.TH ee 8 "EasyEngine (ee) version: 3.0" "Feb 2,2015" "EasyEngine" .SH NAME .B EasyEngine (ee) \- Manage Nginx Based Websites. From 8f1a085397c07aa3f047d980474a6a321145dbf6 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 2 Feb 2015 15:34:06 +0530 Subject: [PATCH 765/829] Added EasyEngine 2.0 to EasyEngine 3.0 upgrade script --- upgrade | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/upgrade b/upgrade index 2b4b6c3f..7c9a6cec 100644 --- a/upgrade +++ b/upgrade @@ -3,6 +3,9 @@ # EasyEngine update script. # This script is designed to update current EasyEngine from 2.2.2 to 3.x # Define echo function +old_ee_version="2.2.3" +branch=$1 + # Blue color function ee_lib_echo() @@ -28,23 +31,84 @@ if [[ $EUID -ne 0 ]]; then fi # Check old EasyEngine is installed or not -which ee > /dev/null -if [[ $? -ne 0 ]]; then +if [ ! -f /usr/local/sbin/easyengine ]; then ee_lib_echo_fail "EasyEngine 2.0 not found" exit 1 fi # Check old EasyEngine version -ee version | grep "2.2.2" > /dev/null +ee version | grep ${old_ee_version} &>> /dev/null if [[ $? -ne 0 ]]; then - ee_lib_echo_fail "EasyEngine 2.2.2 not found on your system" + 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 +# Capture errors +function ee_lib_error() +{ + echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" + exit $2 +} + # 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 on 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 + +# 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 +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 +fi +git commit -am "Update EasyEngine 2 to EasyEngine 3" > /dev/null + +ee_lib_echo "Successfully update to EasyEngine 3" From 01296edc9fe439ce626d887f17db84bfc7c85425 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 2 Feb 2015 18:13:33 +0530 Subject: [PATCH 766/829] added docstrings --- ee/core/apt_repo.py | 21 ++++- ee/core/aptget.py | 24 +++++- ee/core/database.py | 3 + ee/core/domainvalidate.py | 4 + ee/core/fileutils.py | 58 +++++++++++++- ee/core/git.py | 7 ++ ee/core/logging.py | 16 ++++ ee/core/models.py | 3 + ee/core/services.py | 161 +++++++++++++++++++++----------------- ee/core/shellexec.py | 3 + 10 files changed, 224 insertions(+), 76 deletions(-) diff --git a/ee/core/apt_repo.py b/ee/core/apt_repo.py index a2d6f312..d3e82ed9 100644 --- a/ee/core/apt_repo.py +++ b/ee/core/apt_repo.py @@ -12,6 +12,14 @@ class EERepo(): pass def add(self, repo_url=None, ppa=None): + """ + This function used to add apt repositories and or ppa's + If repo_url is provided adds repo file to + /etc/apt/sources.list.d/ + If ppa is provided add apt-repository using + add-apt-repository + command. + """ if repo_url is not None: repo_file_path = ("/etc/apt/sources.list.d/" @@ -43,12 +51,23 @@ class EERepo(): "'{ppa_name}'" .format(ppa_name=ppa)) - def remove(self, repo_url=None): + def remove(self, ppa=None): + """ + This function used to remove ppa's + If ppa is provided adds repo file to + /etc/apt/sources.list.d/ + command. + """ EEShellExec.cmd_exec(self, "add-apt-repository -y " "--remove '{ppa_name}'" .format(ppa_name=repo_url)) def add_key(self, keyids, keyserver=None): + """ + This function adds imports repository keys from keyserver. + 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 diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 72b4c4cb..46685508 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -10,6 +10,9 @@ class EEAptGet(): """Generic apt-get intialisation""" def update(self): + """ + Similar to `apt-get upgrade` + """ try: apt_cache = apt.cache.Cache() apt_cache.update() @@ -22,6 +25,9 @@ class EEAptGet(): Log.error(self, 'AttributeError: ' + str(e)) def dist_upgrade(): + """ + Similar to `apt-get upgrade` + """ apt_cache = apt.cache.Cache() apt_cache.update() apt_cache.open(None) @@ -33,7 +39,9 @@ class EEAptGet(): return success def install(self, packages): - """Installation of packages""" + """ + Similar to `apt-get install` + """ apt_pkg.init() # #apt_pkg.PkgSystemLock() global apt_cache @@ -79,6 +87,10 @@ class EEAptGet(): continue def remove(self, packages, auto=False, purge=False): + """ + Similar to `apt-get remove/purge` + purge packages if purge=True + """ apt_pkg.init() # apt_pkg.PkgSystemLock() global apt_cache @@ -122,6 +134,9 @@ class EEAptGet(): continue def auto_clean(self): + """ + Similar to `apt-get autoclean` + """ try: apt_get.autoclean("-y") except ErrorReturnCode as e: @@ -129,6 +144,9 @@ class EEAptGet(): Log.error(self, "Unable to apt-get autoclean") def auto_remove(self): + """ + Similar to `apt-get autoremove` + """ try: Log.debug(self, "Running apt-get autoremove") apt_get.autoremove("-y") @@ -137,6 +155,10 @@ class EEAptGet(): Log.error(self, "Unable to apt-get autoremove") def is_installed(self, package_name): + """ + Checks if package is available in cache and is installed or not + returns True if installed otherwise returns False + """ apt_cache = apt.cache.Cache() apt_cache.open() if (package_name.strip() in apt_cache and diff --git a/ee/core/database.py b/ee/core/database.py index 1f06617c..8fb0aa0f 100644 --- a/ee/core/database.py +++ b/ee/core/database.py @@ -13,6 +13,9 @@ Base.query = db_session.query_property() def init_db(): + """ + Initializes and creates all tables from models into the database + """ # import all modules here that might define models so that # they will be registered properly on the metadata. Otherwise # you will have to import them first before calling init_db() diff --git a/ee/core/domainvalidate.py b/ee/core/domainvalidate.py index 2f7eef6a..a9400c9a 100644 --- a/ee/core/domainvalidate.py +++ b/ee/core/domainvalidate.py @@ -3,6 +3,10 @@ from urllib.parse import urlparse def ValidateDomain(url): + """ + This function returns domain name removing http:// and https:// + returns domain name only with or without www as user provided. + """ # Check if http:// or https:// present remove it if present domain_name = url.split('/') diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index ccf576fb..5e8a4b68 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -10,11 +10,12 @@ from ee.core.logging import Log class EEFileUtils(): - """Method to operate on files""" + """Utilities to operate on files""" def __init__(): pass def remove(self, filelist): + """remove files from given path""" for file in filelist: if os.path.isfile(file): Log.info(self, "Removing {0:65}".format(file), end=' ') @@ -33,6 +34,10 @@ class EEFileUtils(): Log.error(self, 'Unable to Remove file ') def create_symlink(self, paths, errormsg=''): + """ + Create symbolic links provided in list with first as source + and second as destination + """ src = paths[0] dst = paths[1] if not os.path.islink(dst): @@ -45,6 +50,9 @@ class EEFileUtils(): Log.debug(self, "Destination: {0} exists".format(dst)) def remove_symlink(self, filepath): + """ + Removes symbolic link for the path provided with filepath + """ try: os.unlink(filepath) except Exception as e: @@ -52,6 +60,11 @@ class EEFileUtils(): Log.error(self, "Unable to reomove symbolic link ...\n") def copyfile(self, src, dest): + """ + Copies files: + src : source path + dest : destination path + """ try: shutil.copy2(src, dest) except shutil.Error as e: @@ -64,6 +77,12 @@ class EEFileUtils(): .fromat(src, dest)) def searchreplace(self, fnm, sstr, rstr): + """ + Search replace strings in file + fnm : filename + sstr: search string + rstr: replace string + """ try: for line in fileinput.input(fnm, inplace=True): print(line.replace(sstr, rstr), end='') @@ -74,6 +93,11 @@ class EEFileUtils(): .format(fnm, sstr, rstr)) def mvfile(self, src, dst): + """ + Moves file from source path to destination path + src : source path + dst : Destination path + """ try: Log.debug(self, "Moving file from {0} to {1}".format(src, dst)) shutil.move(src, dst) @@ -83,6 +107,10 @@ class EEFileUtils(): .format(src, dst)) def chdir(self, path): + """ + Change Directory to path specified + Path : path for destination directory + """ try: os.chdir(path) except OSError as e: @@ -90,6 +118,14 @@ class EEFileUtils(): Log.error(self, 'Unable to Change Directory {0}'.format(path)) def chown(self, path, user, group, recursive=False): + """ + Change Owner for files + change owner for file with path specified + user: username of owner + group: group of owner + recursive: if recursive is True change owner for all + files in directory + """ userid = pwd.getpwnam(user)[2] groupid = pwd.getpwnam(user)[3] try: @@ -111,6 +147,12 @@ class EEFileUtils(): Log.error(self, "Unable to change owner : {0} ".format(path)) def chmod(self, path, perm, recursive=False): + """ + Changes Permission for files + path : file path permission to be changed + perm : permissions to be given + recursive: change permission recursively for all files + """ try: if recursive: for root, dirs, files in os.walk(path): @@ -125,6 +167,11 @@ class EEFileUtils(): Log.error(self, "Unable to change owner : {0}".format(path)) def mkdir(self, path): + """ + create directories. + path : path for directory to be created + Similar to `mkdir -p` + """ try: os.makedirs(path) except OSError as e: @@ -132,6 +179,9 @@ class EEFileUtils(): Log.error(self, "Unable to create directory {0} ".format(path)) def isexist(self, path): + """ + Check if file exist on given path + """ try: if os.path.exists(path): return (True) @@ -142,6 +192,9 @@ class EEFileUtils(): Log.error(self, "Unable to check path {0}".format(path)) def grep(self, fnm, sstr): + """ + Searches for string in file and returns the matched line. + """ try: for line in open(fnm): if sstr in line: @@ -152,6 +205,9 @@ class EEFileUtils(): .format(sstr, fnm)) def rm(self, path): + """ + Remove files + """ if EEFileUtils.isexist(self, path): try: if os.path.isdir(path): diff --git a/ee/core/git.py b/ee/core/git.py index 430a4f3f..5d587c81 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -11,6 +11,10 @@ class EEGit: pass def add(self, paths, msg="Intializating"): + """ + Initializes Directory as repository if not already git repo. + and adds uncommited changes automatically + """ for path in paths: global git git = git.bake("--git-dir={0}/.git".format(path), @@ -40,6 +44,9 @@ class EEGit: Log.debug(self, "EEGit: Path {0} not present".format(path)) def checkfilestatus(self, repo, filepath): + """ + Checks status of file, If its tracked or untracked. + """ global git git = git.bake("--git-dir={0}/.git".format(repo), "--work-tree={0}".format(repo)) diff --git a/ee/core/logging.py b/ee/core/logging.py index 69c2c3bc..a02d47c6 100644 --- a/ee/core/logging.py +++ b/ee/core/logging.py @@ -2,6 +2,10 @@ class Log: + """ + Logs messages with colors for different messages + according to functions + """ HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' @@ -12,16 +16,28 @@ class Log: UNDERLINE = '\033[4m' def error(self, msg): + """ + Logs error into log file + """ print(Log.FAIL + msg + Log.ENDC) self.app.log.error(Log.FAIL + msg + Log.ENDC) self.app.close(1) def info(self, msg, end='\n'): + """ + Logs info messages into log file + """ print(Log.OKBLUE + msg + Log.ENDC, end=end) self.app.log.info(Log.OKBLUE + msg + Log.ENDC) def warn(self, msg): + """ + Logs warning into log file + """ self.app.log.warn(Log.BOLD + msg + Log.ENDC) def debug(self, msg): + """ + Logs debug messages into log file + """ self.app.log.debug(Log.HEADER + msg + Log.ENDC) diff --git a/ee/core/models.py b/ee/core/models.py index bd62fc43..2592a26c 100644 --- a/ee/core/models.py +++ b/ee/core/models.py @@ -3,6 +3,9 @@ from ee.core.database import Base class SiteDB(Base): + """ + Databse model for site table + """ __tablename__ = 'sites' id = Column(Integer, primary_key=True) sitename = Column(String, unique=True) diff --git a/ee/core/services.py b/ee/core/services.py index 20c9c09a..392c7d56 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -13,91 +13,106 @@ class EEService(): pass def start_service(self, service_name): - try: - Log.info(self, "Start : {0:10}" .format(service_name), end='') - retcode = subprocess.getstatusoutput('service {0} start' - .format(service_name)) - if retcode[0] == 0: - Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") - return True - else: - Log.debug(self, "{0}".format(retcode[1])) - Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") - return False - except OSError as e: - Log.debug(self, "{0}".format(e)) - Log.error(self, "\nFailed to start service {0}" - .format(service_name)) + """ + start service + Similar to `service xyz start` + """ + try: + Log.info(self, "Start : {0:10}" .format(service_name), end='') + retcode = subprocess.getstatusoutput('service {0} start' + .format(service_name)) + if retcode[0] == 0: + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + return True + else: + Log.debug(self, "{0}".format(retcode[1])) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") + return False + except OSError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "\nFailed to start service {0}" + .format(service_name)) def stop_service(self, service_name): - try: - Log.info(self, "Stop : {0:10}" .format(service_name), end='') - retcode = subprocess.getstatusoutput('service {0} stop' - .format(service_name)) - if retcode[0] == 0: - Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") - return True - else: - Log.debug(self, "{0}".format(retcode[1])) - Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") - return False - except OSError as e: - Log.debug(self, "{0}".format(e)) - Log.error(self, "\nFailed to stop service : {0}" - .format(service_name)) + """ + Stop service + Similar to `service xyz stop` + """ + try: + Log.info(self, "Stop : {0:10}" .format(service_name), end='') + retcode = subprocess.getstatusoutput('service {0} stop' + .format(service_name)) + if retcode[0] == 0: + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + return True + else: + Log.debug(self, "{0}".format(retcode[1])) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") + return False + except OSError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "\nFailed to stop service : {0}" + .format(service_name)) def restart_service(self, service_name): - try: - Log.info(self, "Restart : {0:10}".format(service_name), end='') - retcode = subprocess.getstatusoutput('service {0} restart' - .format(service_name)) - if retcode[0] == 0: - Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") - return True - else: - Log.debug(self, "{0}".format(retcode[1])) - Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") - return False - except OSError as e: - Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) - Log.error(self, "\nFailed to restart service : {0}" - .format(service_name)) + """ + Restart service + Similar to `service xyz restart` + """ + try: + Log.info(self, "Restart : {0:10}".format(service_name), end='') + retcode = subprocess.getstatusoutput('service {0} restart' + .format(service_name)) + if retcode[0] == 0: + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + return True + else: + Log.debug(self, "{0}".format(retcode[1])) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") + return False + except OSError as e: + Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) + Log.error(self, "\nFailed to restart service : {0}" + .format(service_name)) def reload_service(self, service_name): - try: - if service_name in ['nginx', 'php5-fpm']: - Log.info(self, "Reload : {0:10}".format(service_name), - end='') - retcode = subprocess.getstatusoutput('{0} -t &&' - ' service {0} reload' - .format(service_name)) - if retcode[0] == 0: - # print(retcode[0]) - # subprocess.getstatusoutput('service {0} reload' - # .format(service_name)) - Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + - "]") - return True - else: - Log.debug(self, "{0}".format(retcode[1])) - Log.info(self, "[" + Log.FAIL + "Failed" + - Log.OKBLUE+"]") - return False - - Log.info(self, "Reload : {0:10}".format(service_name), end='') - retcode = subprocess.getstatusoutput('service {0} reload' + """ + Stop service + Similar to `service xyz stop` + """ + try: + if service_name in ['nginx', 'php5-fpm']: + Log.info(self, "Reload : {0:10}".format(service_name), + end='') + retcode = subprocess.getstatusoutput('{0} -t &&' + ' service {0} reload' .format(service_name)) if retcode[0] == 0: - Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + # print(retcode[0]) + # subprocess.getstatusoutput('service {0} reload' + # .format(service_name)) + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + + "]") return True else: Log.debug(self, "{0}".format(retcode[1])) - Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") + Log.info(self, "[" + Log.FAIL + "Failed" + + Log.OKBLUE+"]") return False - except OSError as e: - Log.debug(self, "{0}".format(e)) - Log.error(self, "\nFailed to reload service {0}" - .format(service_name)) + Log.info(self, "Reload : {0:10}".format(service_name), end='') + retcode = subprocess.getstatusoutput('service {0} reload' + .format(service_name)) + if retcode[0] == 0: + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + return True + else: + Log.debug(self, "{0}".format(retcode[1])) + Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") + return False + except OSError as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "\nFailed to reload service {0}" + .format(service_name)) def get_service_status(self, service_name): try: diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index eabb4262..c0791e6a 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -36,6 +36,9 @@ class EEShellExec(): .format(command)) def invoke_editor(self, filepath, errormsg=''): + """ + Open files using sensible editor + """ try: subprocess.call(['sensible-editor', filepath]) except OSError as e: From 6970efd3914db16efd27e776e5818c3aa1a158b4 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 2 Feb 2015 18:27:35 +0530 Subject: [PATCH 767/829] removed hardcoded value from import_slow_log.py ,stack.py and debug.py file and added doc string in clean.py,secure.py --- docs/ee.8 | 2 +- ee/cli/plugins/clean.py | 3 + ee/cli/plugins/debug.py | 35 +-- ee/cli/plugins/import_slow_log.py | 20 +- ee/cli/plugins/secure.py | 3 + ee/cli/plugins/stack.py | 369 +++++++++++++++++++----------- 6 files changed, 276 insertions(+), 156 deletions(-) diff --git a/docs/ee.8 b/docs/ee.8 index 842aa547..68252f27 100644 --- a/docs/ee.8 +++ b/docs/ee.8 @@ -1,4 +1,4 @@ -.TH ee 8 "EasyEngine (ee) version: 3.0" "Feb 2,2015" "EasyEngine" +.TH ee 8 "EasyEngine (ee) version: 3.0" "Feb 2,2014" "EasyEngine" .SH NAME .B EasyEngine (ee) \- Manage Nginx Based Websites. diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index de5ba83a..9718fc3b 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -50,6 +50,7 @@ class EECleanController(CementBaseController): @expose(hide=True) def clean_memcache(self): + """This function Clears memcache""" try: if(EEAptGet.is_installed(self, "memcached")): EEService.restart_service(self, "memcached") @@ -62,6 +63,7 @@ class EECleanController(CementBaseController): @expose(hide=True) def clean_fastcgi(self): + """This function clears Fastcgi cache""" if(os.path.isdir("/var/run/nginx-cache")): Log.info(self, "Cleaning NGINX FastCGI cache") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") @@ -70,6 +72,7 @@ class EECleanController(CementBaseController): @expose(hide=True) def clean_opcache(self): + """This function clears opcache""" try: Log.info(self, "Cleaning opcache") wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 7961ad95..66bcafab 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -7,6 +7,7 @@ from ee.core.mysql import EEMysql from ee.core.services import EEService from ee.core.logging import Log from ee.cli.plugins.site_functions import logwatch +from ee.core.variables import EEVariables import os import configparser import glob @@ -102,8 +103,9 @@ class EEDebugController(CementBaseController): else: Log.info(self, "Debug for site allready enabled") - self.msg = self.msg + ['/var/www/{0}/logs/error.log' - .format(self.app.pargs.site_name)] + self.msg = self.msg + ['{0}{1}/logs/error.log' + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] else: Log.info(self, "{0} domain not valid" @@ -261,9 +263,11 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_wp(self): if self.start and self.app.pargs.site_name: - wp_config = ("/var/www/{0}/wp-config.php" - .format(self.app.pargs.site_name)) - webroot = "/var/www/{0}".format(self.app.pargs.site_name) + wp_config = ("{0}{1}/wp-config.php" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)) + webroot = "{0}{1}".format(EEVariables.ee_webroot, + self.app.pargs.site_name) if os.path.isfile(wp_config): if not EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} |" " grep true".format(wp_config)): @@ -287,18 +291,21 @@ class EEDebugController(CementBaseController): else: Log.info(self, "WordPress debug log already enabled") - self.msg = self.msg + ['/var/www/{0}/htdocs/wp-content' + self.msg = self.msg + ['{0}{1}/htdocs/wp-content' '/debug.log' - .format(self.app.pargs.site_name)] + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] else: Log.info(self, "{0} domain not valid" .format(self.app.pargs.site_name)) elif not self.start and self.app.pargs.site_name: - wp_config = ("/var/www/{0}/wp-config.php" - .format(self.app.pargs.site_name)) - webroot = "/var/www/{0}".format(self.app.pargs.site_name) + wp_config = ("{0}{1}/wp-config.php" + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)) + webroot = "{0}{1}".format(EEVariables.ee_webroot, + self.app.pargs.site_name) if os.path.isfile(wp_config): if EEShellExec.cmd_exec(self, "grep \"\'WP_DEBUG\'\" {0} | " "grep true".format(wp_config)): @@ -365,10 +372,12 @@ class EEDebugController(CementBaseController): Log.info(self, "Nginx rewrite logs for {0} allready setup" .format(self.app.pargs.site_name)) - if ('/var/www/{0}/logs/error.log'.format(self.app.pargs.site_name) + if ('{0}{1}/logs/error.log'.format(EEVariables.ee_webroot, + self.app.pargs.site_name) not in self.msg): - self.msg = self.msg + ['/var/www/{0}/logs/error.log' - .format(self.app.pargs.site_name)] + self.msg = self.msg + ['{0}{1}/logs/error.log' + .format(EEVariables.ee_webroot, + self.app.pargs.site_name)] # Stop Nginx rewrite for site elif not self.start and self.app.pargs.site_name: diff --git a/ee/cli/plugins/import_slow_log.py b/ee/cli/plugins/import_slow_log.py index 72cd395c..41427c19 100644 --- a/ee/cli/plugins/import_slow_log.py +++ b/ee/cli/plugins/import_slow_log.py @@ -2,6 +2,7 @@ from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.shellexec import EEShellExec from ee.core.logging import Log +from ee.core.variables import EEVariables import os @@ -18,20 +19,25 @@ class EEImportslowlogController(CementBaseController): @expose(hide=True) def default(self): - if os.path.isdir("/var/www/22222/htdocs/db/anemometer"): + if os.path.isdir("{0}22222/htdocs/db/anemometer" + .format(EEVariables.ee_webroot)): if os.path.isfile("/var/log/mysql/mysql-slow.log"): # Get Anemometer user name and password Log.error(self, "Importing MySQL slow log to Anemometer") - host = os.popen("grep -e \"\'host\'\" /var/www/22222/htdocs/" - "db/anemometer/conf/config.inc.php " + host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/" + .format(EEVariables.ee_webroot) + + "db/anemometer/conf/config.inc.php " "| head -1 | cut -d\\\' -f4 | " "tr -d '\n'").read() - user = os.popen("grep -e \"\'user\'\" /var/www/22222/htdocs/" - "db/anemometer/conf/config.inc.php " + user = os.popen("grep -e \"\'user\'\" {0}22222/htdocs/" + .format(EEVariables.ee_webroot) + + "db/anemometer/conf/config.inc.php " "| head -1 | cut -d\\\' -f4 | " "tr -d '\n'").read() - password = os.popen("grep -e \"\'password\'\" /var/www/22222/" - "htdocs/db/anemometer/conf/config.inc.php " + password = os.popen("grep -e \"\'password\'\" {0}22222/" + .format(EEVariables.ee_webroot) + + "htdocs/db/anemometer/conf" + "/config.inc.php " "| head -1 | cut -d\\\' -f4 | " "tr -d '\n'").read() diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index c6e672c1..cc8eaaee 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -44,6 +44,7 @@ class EESecureController(CementBaseController): @expose(hide=True) def secure_auth(self): + """This function Secures authentication""" passwd = ''.join([random.choice (string.ascii_letters + string.digits) for n in range(6)]) @@ -74,6 +75,7 @@ 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]:") @@ -100,6 +102,7 @@ class EESecureController(CementBaseController): @expose(hide=True) def secure_ip(self): + """This function Secures IP""" # TODO:remaining with ee.conf updation in file newlist = [] if not self.app.pargs.user_input: diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 53bc4f25..5b4a96f5 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -15,6 +15,7 @@ from ee.core.git import EEGit from ee.core.checkfqdn import check_fqdn from pynginxconfig import NginxConfig from ee.core.services import EEService +from ee.core.variables import EEVariables import random import string import configparser @@ -284,48 +285,64 @@ class EEStackController(CementBaseController): 'sites-enabled/' '22222.conf']) # Create log and cert folder and softlinks - if not os.path.exists('/var/www/22222/logs'): + if not os.path.exists('{0}22222/logs' + .format(EEVariables.ee_webroot)): Log.debug(self, "Creating directory " - "/var/www/22222/logs ") - os.makedirs('/var/www/22222/logs') + "{0}22222/logs " + .format(EEVariables.ee_webroot)) + os.makedirs('{0}22222/logs' + .format(EEVariables.ee_webroot)) - if not os.path.exists('/var/www/22222/cert'): + if not os.path.exists('{0}22222/cert' + .format(EEVariables.ee_webroot)): Log.debug(self, "Creating directory " - "/var/www/22222/cert") - os.makedirs('/var/www/22222/cert') + "{0}22222/cert" + .format(EEVariables.ee_webroot)) + os.makedirs('{0}22222/cert' + .format(EEVariables.ee_webroot)) EEFileUtils.create_symlink(self, ['/var/log/nginx/' '22222.access.log', - '/var/www/22222/' - 'logs/access.log']) + '{0}22222/' + 'logs/access.log' + .format(EEVariables.ee_webroot)] + ) EEFileUtils.create_symlink(self, ['/var/log/nginx/' '22222.error.log', - '/var/www/22222/' - 'logs/error.log']) + '{0}22222/' + 'logs/error.log' + .format(EEVariables.ee_webroot)] + ) EEShellExec.cmd_exec(self, "openssl genrsa -out " - "/var/www/22222/cert/22222.key 2048") + "{0}22222/cert/22222.key 2048" + .format(EEVariables.ee_webroot)) EEShellExec.cmd_exec(self, "openssl req -new -batch -subj " "/commonName=127.0.0.1/ -key " - "/var/www/22222/cert/22222.key " - "-out /var/www/22222/cert/" - "22222.csr") + "{0}22222/cert/22222.key " + "-out {0}22222/cert/" + "22222.csr" + .format(EEVariables.ee_webroot)) - EEFileUtils.mvfile(self, "/var/www/22222/cert/22222.key", - "/var/www/22222/cert/" - "22222.key.org") + EEFileUtils.mvfile(self, "{0}22222/cert/22222.key" + .format(EEVariables.ee_webroot), + "{0}22222/cert/" + "22222.key.org" + .format(EEVariables.ee_webroot)) EEShellExec.cmd_exec(self, "openssl rsa -in " - "/var/www/22222/cert/" + "{0}22222/cert/" "22222.key.org -out " - "/var/www/22222/cert/22222.key") + "{0}22222/cert/22222.key" + .format(EEVariables.ee_webroot)) EEShellExec.cmd_exec(self, "openssl x509 -req -days 3652 " - "-in /var/www/22222/cert/" - "22222.csr -signkey /var/www/" + "-in {0}22222/cert/" + "22222.csr -signkey {0}" "22222/cert/22222.key -out " - "/var/www/22222/cert/22222.crt") + "{0}22222/cert/22222.crt" + .format(EEVariables.ee_webroot)) # Nginx Configation into GIT EEGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git") @@ -405,23 +422,33 @@ class EEStackController(CementBaseController): "profiler_enable] = off\n") # PHP and Debug pull configuration - if not os.path.exists('/var/www/22222/htdocs/fpm/status/'): + if not os.path.exists('{0}22222/htdocs/fpm/status/' + .format(EEVariables.ee_webroot)): Log.debug(self, 'Creating directory ' - '/var/www/22222/htdocs/fpm/status/ ') - os.makedirs('/var/www/22222/htdocs/fpm/status/') - open('/var/www/22222/htdocs/fpm/status/debug', 'a').close() - open('/var/www/22222/htdocs/fpm/status/php', 'a').close() + '{0}22222/htdocs/fpm/status/ ' + .format(EEVariables.ee_webroot)) + os.makedirs('{0}22222/htdocs/fpm/status/' + .format(EEVariables.ee_webroot)) + open('{0}22222/htdocs/fpm/status/debug' + .format(EEVariables.ee_webroot), 'a').close() + open('{0}22222/htdocs/fpm/status/php' + .format(EEVariables.ee_webroot), 'a').close() # Write info.php - if not os.path.exists('/var/www/22222/htdocs/php/'): + if not os.path.exists('{0}22222/htdocs/php/' + .format(EEVariables.ee_webroot)): Log.debug(self, 'Creating directory ' - '/var/www/22222/htdocs/php/ ') - os.makedirs('/var/www/22222/htdocs/php') + '{0}22222/htdocs/php/ ' + .format(EEVariables.ee_webroot)) + os.makedirs('{0}22222/htdocs/php' + .format(EEVariables.ee_webroot)) - with open("/var/www/22222/htdocs/php/info.php", "w") as myfile: + with open("{0}22222/htdocs/php/info.php" + .format(EEVariables.ee_webroot), "w") as myfile: myfile.write("") - EEFileUtils.chown(self, "/var/www/22222", 'www-data', + EEFileUtils.chown(self, "{0}22222" + .format(EEVariables.ee_webroot), 'www-data', 'www-data', recursive=True) EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") @@ -642,31 +669,41 @@ class EEStackController(CementBaseController): EEExtract.extract(self, '/tmp/pma.tar.gz', '/tmp/') Log.debug(self, 'Extracting file /tmp/pma.tar.gz to ' 'loaction /tmp/') - if not os.path.exists('/var/www/22222/htdocs/db'): + if not os.path.exists('{0}22222/htdocs/db' + .format(EEVariables.ee_webroot)): Log.debug(self, "Creating new directory " - "/var/www/22222/htdocs/db") - os.makedirs('/var/www/22222/htdocs/db') + "{0}22222/htdocs/db" + .format(EEVariables.ee_webroot)) + os.makedirs('{0}22222/htdocs/db' + .format(EEVariables.ee_webroot)) shutil.move('/tmp/phpmyadmin-STABLE/', - '/var/www/22222/htdocs/db/pma/') + '{0}22222/htdocs/db/pma/' + .format(EEVariables.ee_webroot)) Log.debug(self, 'Setting Privileges of www-data:www-data to ' - '/var/www/22222/htdocs/db/pma file ') + '{0}22222/htdocs/db/pma file ' + .format(EEVariables.ee_webroot)) # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/db/pma') - EEFileUtils.chown(self, '/var/www/22222', + EEFileUtils.chown(self, '{0}22222' + .format(EEVariables.ee_webroot), EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) if any('/tmp/memcache.tar.gz' == x[1] for x in packages): Log.debug(self, "Extracting memcache.tar.gz to location" - " /var/www/22222/htdocs/cache/memcache ") + " {0}22222/htdocs/cache/memcache " + .format(EEVariables.ee_webroot)) EEExtract.extract(self, '/tmp/memcache.tar.gz', - '/var/www/22222/htdocs/cache/memcache') + '{0}22222/htdocs/cache/memcache' + .format(EEVariables.ee_webroot)) Log.debug(self, "Setting Privileges to " - "/var/www/22222/htdocs/cache/memcache file") + "{0}22222/htdocs/cache/memcache file" + .format(EEVariables.ee_webroot)) # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/cache/memcache') - EEFileUtils.chown(self, '/var/www/22222', + EEFileUtils.chown(self, '{0}22222' + .format(EEVariables.ee_webroot), EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) @@ -676,20 +713,27 @@ class EEStackController(CementBaseController): Log.debug(self, "Extracting file webgrind.tar.gz to " "location /tmp/ ") EEExtract.extract(self, '/tmp/webgrind.tar.gz', '/tmp/') - if not os.path.exists('/var/www/22222/htdocs/php'): + if not os.path.exists('{0}22222/htdocs/php' + .format(EEVariables.ee_webroot)): Log.debug(self, "Creating directroy " - "/var/www/22222/htdocs/php") - os.makedirs('/var/www/22222/htdocs/php') + "{0}22222/htdocs/php" + .format(EEVariables.ee_webroot)) + os.makedirs('{0}22222/htdocs/php' + .format(EEVariables.ee_webroot)) shutil.move('/tmp/webgrind-master/', - '/var/www/22222/htdocs/php/webgrind') + '{0}22222/htdocs/php/webgrind' + .format(EEVariables.ee_webroot)) EEShellExec.cmd_exec(self, "sed -i \"s\'/usr/local/bin/dot\'" - "/usr/bin/dot\'\" /var/www/22222/htdocs/" - "php/webgrind/config.php") + "/usr/bin/dot\'\" {0}22222/htdocs/" + "php/webgrind/config.php" + .format(EEVariables.ee_webroot)) Log.debug(self, "Setting Privileges of www-data:www-data to " - "/var/www/22222/htdocs/php/webgrind/ file ") + "{0}22222/htdocs/php/webgrind/ file " + .format(EEVariables.ee_webroot)) # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # '/var/www/22222/htdocs/php/webgrind/') - EEFileUtils.chown(self, '/var/www/22222', + EEFileUtils.chown(self, '{0}22222' + .format(EEVariables.ee_webroot), EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) @@ -699,14 +743,18 @@ class EEStackController(CementBaseController): Log.debug(self, "Extracting file anemometer.tar.gz to " "location /tmp/ ") EEExtract.extract(self, '/tmp/anemometer.tar.gz', '/tmp/') - if not os.path.exists('/var/www/22222/htdocs/db/'): + if not os.path.exists('{0}22222/htdocs/db/' + .format(EEVariables.ee_webroot)): Log.debug(self, "Creating directory") - os.makedirs('/var/www/22222/htdocs/db/') + os.makedirs('{0}22222/htdocs/db/' + .format(EEVariables.ee_webroot)) shutil.move('/tmp/Anemometer-master', - '/var/www/22222/htdocs/db/anemometer') + '{0}22222/htdocs/db/anemometer' + .format(EEVariables.ee_webroot)) chars = ''.join(random.sample(string.ascii_letters, 8)) - EEShellExec.cmd_exec(self, 'mysql < /var/www/22222/htdocs/db' - '/anemometer/install.sql') + EEShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' + '/anemometer/install.sql' + .format(EEVariables.ee_webroot)) EEMysql.execute(self, 'grant select on *.* to \'anemometer\'' '@\'{0}\''.format(self.app.config.get('mysql', 'grant-host'))) @@ -720,8 +768,9 @@ class EEStackController(CementBaseController): Log.debug(self, "configration Anemometer") data = dict(host=EEVariables.ee_mysql_host, port='3306', user='anemometer', password=chars) - ee_anemometer = open('/var/www/22222/htdocs/db/anemometer' - '/conf/config.inc.php', 'w') + ee_anemometer = open('{0}22222/htdocs/db/anemometer' + '/conf/config.inc.php' + .format(EEVariables.ee_webroot), 'w') self.app.render((data), 'anemometer.mustache', out=ee_anemometer) ee_anemometer.close() @@ -736,27 +785,33 @@ class EEStackController(CementBaseController): Log.debug(self, "Extracting ViMbAdmin.tar.gz to " "location /tmp/") EEExtract.extract(self, '/tmp/vimbadmin.tar.gz', '/tmp/') - if not os.path.exists('/var/www/22222/htdocs/'): + if not os.path.exists('{0}22222/htdocs/' + .format(EEVariables.ee_webroot)): Log.debug(self, "Creating directory " - "/var/www/22222/htdocs/") - os.makedirs('/var/www/22222/htdocs/') + "{0}22222/htdocs/" + .format(EEVariables.ee_webroot)) + os.makedirs('{0}22222/htdocs/' + .format(EEVariables.ee_webroot)) shutil.move('/tmp/ViMbAdmin-{0}/' .format(EEVariables.ee_vimbadmin), - '/var/www/22222/htdocs/vimbadmin/') + '{0}22222/htdocs/vimbadmin/' + .format(EEVariables.ee_webroot)) # Donwload composer and install ViMbAdmin Log.debug(self, "Downloading composer " "https://getcomposer.org/installer | php ") - EEShellExec.cmd_exec(self, "cd /var/www/22222/htdocs" + EEShellExec.cmd_exec(self, "cd {0}22222/htdocs" "/vimbadmin; curl" " -sS https://getcomposer.org/installer |" - " php") + " php".format(EEVariables.ee_webroot)) Log.debug(self, "installation of composer") - EEShellExec.cmd_exec(self, "cd /var/www/22222/htdocs" + EEShellExec.cmd_exec(self, "cd {0}22222/htdocs" "/vimbadmin && " "php composer.phar install --prefer-dist" - " --no-dev && rm -f /var/www/22222/htdocs" - "/vimbadmin/composer.phar") + " --no-dev && rm -f {1}22222/htdocs" + "/vimbadmin/composer.phar" + .format(EEVariables.ee_webroot, + EEVariables.ee_webroot)) # Configure vimbadmin database vm_passwd = ''.join(random.sample(string.ascii_letters, 8)) @@ -775,27 +830,31 @@ class EEStackController(CementBaseController): data = dict(salt=vm_salt, host=EEVariables.ee_mysql_host, password=vm_passwd) Log.debug(self, 'Writting the ViMbAdmin configuration to ' - 'file /var/www/22222/htdocs/vimbadmin/application/' - 'configs/application.ini') - ee_vmb = open('/var/www/22222/htdocs/vimbadmin/application/' - 'configs/application.ini', 'w') + 'file {0}22222/htdocs/vimbadmin/application/' + 'configs/application.ini' + .format(EEVariables.ee_webroot)) + ee_vmb = open('{0}22222/htdocs/vimbadmin/application/' + 'configs/application.ini' + .format(EEVariables.ee_webroot), 'w') self.app.render((data), 'vimbadmin.mustache', out=ee_vmb) ee_vmb.close() - shutil.copyfile("/var/www/22222/htdocs/vimbadmin/public/" - ".htaccess.dist", - "/var/www/22222/htdocs/vimbadmin/public/" - ".htaccess") + shutil.copyfile("{0}22222/htdocs/vimbadmin/public/" + ".htaccess.dist" + .format(EEVariables.ee_webroot), + "{0}22222/htdocs/vimbadmin/public/" + ".htaccess".format(EEVariables.ee_webroot)) Log.debug(self, "Executing command " - "/var/www/22222/htdocs/vimbadmin/bin" + "{0}22222/htdocs/vimbadmin/bin" "/doctrine2-cli.php orm:schema-tool:" - "create") - EEShellExec.cmd_exec(self, "/var/www/22222/htdocs/vimbadmin" + "create".format(EEVariables.ee_webroot)) + EEShellExec.cmd_exec(self, "{0}22222/htdocs/vimbadmin" "/bin/doctrine2-cli.php orm:schema-tool:" - "create") + "create".format(EEVariables.ee_webroot)) - EEFileUtils.chown(self, '/var/www/22222', + EEFileUtils.chown(self, '{0}22222' + .format(EEVariables.ee_webroot), EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) @@ -866,13 +925,17 @@ class EEStackController(CementBaseController): Log.debug(self, "Extracting file /tmp/roundcube.tar.gz " "to location /tmp/ ") EEExtract.extract(self, '/tmp/roundcube.tar.gz', '/tmp/') - if not os.path.exists('/var/www/roundcubemail'): + if not os.path.exists('{0}roundcubemail' + .format(EEVariables.ee_webroot)): Log.debug(self, "Creating new directory " - " /var/www/roundcubemail/") - os.makedirs('/var/www/roundcubemail/') + " {0}roundcubemail/" + .format(EEVariables.ee_webroot)) + os.makedirs('{0}roundcubemail/' + .format(EEVariables.ee_webroot)) shutil.move('/tmp/roundcubemail-{0}/' .format(EEVariables.ee_roundcube), - '/var/www/roundcubemail/htdocs') + '{0}roundcubemail/htdocs' + .format(EEVariables.ee_webroot)) # Configure roundcube database rc_passwd = ''.join(random.sample(string.ascii_letters, 8)) @@ -886,33 +949,39 @@ class EEStackController(CementBaseController): "'{1}'".format(self.app.config.get( 'mysql', 'grant-host'), rc_passwd)) - EEShellExec.cmd_exec(self, "mysql roundcubemail < /var/www/" + EEShellExec.cmd_exec(self, "mysql roundcubemail < {0}" "roundcubemail/htdocs/SQL/mysql" - ".initial.sql") - - shutil.copyfile("/var/www/roundcubemail/htdocs/config/" - "config.inc.php.sample", - "/var/www/roundcubemail/htdocs/config/" - "config.inc.php") + ".initial.sql" + .format(EEVariables.ee_webroot)) + + shutil.copyfile("{0}roundcubemail/htdocs/config/" + "config.inc.php.sample" + .format(EEVariables.ee_webroot), + "{0}roundcubemail/htdocs/config/" + "config.inc.php" + .format(EEVariables.ee_webroot)) EEShellExec.cmd_exec(self, "sed -i \"s\'mysql://roundcube:" "pass@localhost/roundcubemail\'mysql://" "roundcube:{0}@{1}/" - "roundcubemail\'\" /var/www/roundcubemail" + "roundcubemail\'\" {2}roundcubemail" "/htdocs/config/config." "inc.php" .format(rc_passwd, - EEVariables.ee_mysql_host)) + EEVariables.ee_mysql_host, + EEVariables.ee_webroot)) # Sieve plugin configuration in roundcube EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\[" "\'plugins\'\] " "= array(:\$config\['plugins'\] = " "array(\\n \'sieverules\',:\\\" " - "/var/www/roundcubemail/htdocs/config" - "/config.inc.php\"") + "{0}roundcubemail/htdocs/config" + .format(EEVariables.ee_webroot) + + "/config.inc.php\"") EEShellExec.cmd_exec(self, "echo \"\$config['sieverules_port']" - "=4190;\" >> /var/www/roundcubemail" - "/htdocs/config/config.inc.php") + "=4190;\" >> {0}roundcubemail" + .format(EEVariables.ee_webroot) + + "/htdocs/config/config.inc.php") data = dict(site_name='webmail', www_domain='webmail', static=False, @@ -935,23 +1004,29 @@ class EEStackController(CementBaseController): '/etc/nginx/sites-enabled/' 'webmail.conf']) # Create log folder and softlinks - if not os.path.exists('/var/www/roundcubemail/logs'): - os.makedirs('/var/www/roundcubemail/logs') + if not os.path.exists('{0}roundcubemail/logs' + .format(EEVariables.ee_webroot)): + os.makedirs('{0}roundcubemail/logs' + .format(EEVariables.ee_webroot)) EEFileUtils.create_symlink(self, ['/var/log/nginx/' 'webmail.access.log', - '/var/www/roundcubemail/' - 'logs/access.log']) + '{0}roundcubemail/' + 'logs/access.log' + .format(EEVariables.ee_webroot)]) EEFileUtils.create_symlink(self, ['/var/log/nginx/' 'webmail.error.log', - '/var/www/roundcubemail/' - 'logs/error.log']) + '{0}roundcubemail/' + 'logs/error.log' + .format(EEVariables.ee_webroot)]) # Remove roundcube installer EEService.reload_service(self, 'nginx') - EEFileUtils.remove(self, ["/var/www/roundcubemail" - "/htdocs/installer"]) - EEFileUtils.chown(self, '/var/www/roundcubemail', + EEFileUtils.remove(self, ["{0}roundcubemail" + "/htdocs/installer" + .format(EEVariables.ee_webroot)]) + EEFileUtils.chown(self, '{0}roundcubemail' + .format(EEVariables.ee_webroot), EEVariables.ee_php_user, EEVariables.ee_php_user, recursive=True) @@ -1070,8 +1145,9 @@ class EEStackController(CementBaseController): packages = packages + [["http://downloads.sourceforge.net/" "adminer/adminer-{0}.php" "".format(EEVariables.ee_adminer), - "/var/www/22222/" - "htdocs/db/adminer/index.php", + "{0}22222/" + "htdocs/db/adminer/index.php" + .format(EEVariables.ee_webroot), "Adminer"]] if self.app.pargs.mailscanner: @@ -1086,22 +1162,29 @@ class EEStackController(CementBaseController): ["https://raw.githubusercontent.com" "/rtCamp/eeadmin/master/cache/nginx/" "clean.php", - "/var/www/22222/htdocs/cache/" - "nginx/clean.php", "clean.php"], + "{0}22222/htdocs/cache/" + "nginx/clean.php" + .format(EEVariables.ee_webroot), + "clean.php"], ["https://raw.github.com/rlerdorf/" "opcache-status/master/opcache.php", - "/var/www/22222/htdocs/cache/" - "opcache/opcache.php", "opcache.php"], + "{0}22222/htdocs/cache/" + "opcache/opcache.php" + .format(EEVariables.ee_webroot), + "opcache.php"], ["https://raw.github.com/amnuts/" "opcache-gui/master/index.php", - "/var/www/22222/htdocs/" - "cache/opcache/opgui.php", + "{0}22222/htdocs/" + "cache/opcache/opgui.php" + .format(EEVariables.ee_webroot), "Opgui"], ["https://gist.github.com/ck-on/4959032" "/raw/0b871b345fd6cfcd6d2be030c1f33d1" "ad6a475cb/ocp.php", - "/var/www/22222/htdocs/cache/" - "opcache/ocp.php", "OCP.php"], + "{0}22222/htdocs/cache/" + "opcache/ocp.php" + .format(EEVariables.ee_webroot), + "OCP.php"], ["https://github.com/jokkedk/webgrind/" "archive/master.tar.gz", '/tmp/webgrind.tar.gz', 'Webgrind'], @@ -1170,8 +1253,10 @@ class EEStackController(CementBaseController): Log.debug(self, "Removing mail server packages") apt_packages = apt_packages + EEVariables.ee_mail apt_packages = apt_packages + EEVariables.ee_mailscanner - packages = packages + ["/var/www/22222/htdocs/vimbadmin", - "/var/www/roundcubemail"] + packages = packages + ["{0}22222/htdocs/vimbadmin" + .format(EEVariables.ee_webroot), + "{0}roundcubemail" + .format(EEVariables.ee_webroot)] if EEShellExec.cmd_exec(self, "mysqladmin ping"): EEMysql.execute(self, "drop database IF EXISTS vimbadmin") EEMysql.execute(self, "drop database IF EXISTS roundcubemail") @@ -1196,19 +1281,25 @@ class EEStackController(CementBaseController): packages = packages + ['/usr/bin/wp'] if self.app.pargs.phpmyadmin: Log.debug(self, "Removing package variable of phpMyAdmin ") - packages = packages + ['/var/www/22222/htdocs/db/pma'] + packages = packages + ['{0}22222/htdocs/db/pma' + .format(EEVariables.ee_webroot)] if self.app.pargs.adminer: Log.debug(self, "Removing package variable of Adminer ") - packages = packages + ['/var/www/22222/htdocs/db/Adminer'] + packages = packages + ['{0}22222/htdocs/db/Adminer' + .format(EEVariables.ee_webroot)] if self.app.pargs.utils: Log.debug(self, "Removing package variable of utils ") - packages = packages + ['/var/www/22222/htdocs/php/webgrind/', - '/var/www/22222/htdocs/cache/opcache', - '/var/www/22222/htdocs/cache/Nginx/' - 'clean.php', - '/var/www/22222/htdocs/cache/Memcache', + packages = packages + ['{0}22222/htdocs/php/webgrind/' + .format(EEVariables.ee_webroot), + '{0}22222/htdocs/cache/opcache' + .format(EEVariables.ee_webroot), + '{0}22222/htdocs/cache/Nginx/' + 'clean.php'.format(EEVariables.ee_webroot), + '{0}22222/htdocs/cache/Memcache' + .format(EEVariables.ee_webroot), '/usr/bin/pt-query-advisor', - '/var/www/22222/htdocs/db/Anemometer'] + '{0}22222/htdocs/db/Anemometer' + .format(EEVariables.ee_webroot)] if len(apt_packages): Log.debug(self, "Removing apt_packages") @@ -1249,8 +1340,10 @@ class EEStackController(CementBaseController): Log.debug(self, "Removing mail server packages") apt_packages = apt_packages + EEVariables.ee_mail apt_packages = apt_packages + EEVariables.ee_mailscanner - packages = packages + ["/var/www/22222/htdocs/vimbadmin", - "/var/www/roundcubemail"] + packages = packages + ["{0}22222/htdocs/vimbadmin" + .format(EEVariables.ee_webroot), + "{0}roundcubemail" + .format(EEVariables.ee_webroot)] if EEShellExec.cmd_exec(self, "mysqladmin ping"): EEMysql.execute(self, "drop database IF EXISTS vimbadmin") EEMysql.execute(self, "drop database IF EXISTS roundcubemail") @@ -1274,20 +1367,26 @@ class EEStackController(CementBaseController): Log.debug(self, "Purge package variable WPCLI") packages = packages + ['/usr/bin/wp'] if self.app.pargs.phpmyadmin: - packages = packages + ['/var/www/22222/htdocs/db/pma'] + packages = packages + ['{0}22222/htdocs/db/pma'. + format(EEVariables.ee_webroot)] Log.debug(self, "Purge package variable phpMyAdmin") if self.app.pargs.adminer: Log.debug(self, "Purge package variable Adminer") - packages = packages + ['/var/www/22222/htdocs/db/adminer'] + packages = packages + ['{0}22222/htdocs/db/adminer' + .format(EEVariables.ee_webroot)] if self.app.pargs.utils: Log.debug(self, "Purge package variable utils") - packages = packages + ['/var/www/22222/htdocs/php/webgrind/', - '/var/www/22222/htdocs/cache/opcache', - '/var/www/22222/htdocs/cache/nginx/' - 'clean.php', - '/var/www/22222/htdocs/cache/memcache', + packages = packages + ['{0}22222/htdocs/php/webgrind/' + .format(EEVariables.ee_webroot), + '{0}22222/htdocs/cache/opcache' + .format(EEVariables.ee_webroot), + '{0}22222/htdocs/cache/nginx/' + 'clean.php'.format(EEVariables.ee_webroot), + '{0}22222/htdocs/cache/memcache' + .format(EEVariables.ee_webroot), '/usr/bin/pt-query-advisor', - '/var/www/22222/htdocs/db/anemometer' + '{0}22222/htdocs/db/anemometer' + .format(EEVariables.ee_webroot) ] if len(apt_packages): From bd6a2001a2b337046cc70e11792c45e3e13f71aa Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 2 Feb 2015 19:31:30 +0530 Subject: [PATCH 768/829] changed description of secure.py file --- ee/cli/plugins/secure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index cc8eaaee..9deb235c 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -20,7 +20,7 @@ class EESecureController(CementBaseController): label = 'secure' stacked_on = 'base' stacked_type = 'nested' - description = ('clean command cleans different cache ') + description = ('Secure command secure auth, ip and port') arguments = [ (['--auth'], dict(help='secure auth', action='store_true')), From 5a96f33eccf5b7727412d5ff5d95620e9fba5e68 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 2 Feb 2015 19:39:22 +0530 Subject: [PATCH 769/829] Updated with doc strings --- ee/cli/plugins/debug.py | 8 ++++++++ ee/cli/plugins/import_slow_log.py | 1 + ee/cli/plugins/info.py | 4 ++++ ee/cli/plugins/stack.py | 7 ++++++- ee/cli/plugins/stack_services.py | 5 +++++ ee/core/addswap.py | 1 + ee/core/checkfqdn.py | 1 + ee/core/download.py | 5 ++++- ee/core/extract.py | 1 + ee/core/mysql.py | 1 + ee/core/shellexec.py | 1 + 11 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 66bcafab..4d346347 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -53,6 +53,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_nginx(self): + """Start/Stop Nginx debug""" # start global debug if self.start and not self.app.pargs.site_name: try: @@ -134,6 +135,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_php(self): + """Start/Stop PHP debug""" # PHP global debug start if self.start: if not (EEShellExec.cmd_exec(self, "sed -n \"/upstream php" @@ -173,6 +175,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_fpm(self): + """Start/Stop PHP5-FPM debug""" # PHP5-FPM start global debug if self.start: if not EEShellExec.cmd_exec(self, "grep \"log_level = debug\" " @@ -214,6 +217,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_mysql(self): + """Start/Stop MySQL debug""" # MySQL start global debug if self.start: if not EEShellExec.cmd_exec(self, "mysql -e \"show variables like" @@ -262,6 +266,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_wp(self): + """Start/Stop WordPress debug""" if self.start and self.app.pargs.site_name: wp_config = ("{0}{1}/wp-config.php" .format(EEVariables.ee_webroot, @@ -332,6 +337,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def debug_rewrite(self): + """Start/Stop Nginx rewrite rules debug""" # Start Nginx rewrite debug globally if self.start and not self.app.pargs.site_name: if not EEShellExec.cmd_exec(self, "grep \"rewrite_log on;\" " @@ -396,6 +402,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def signal_handler(self, signal, frame): + """Handle Ctrl+c hevent for -i option of debug""" self.start = False if self.app.pargs.nginx: self.debug_nginx() @@ -421,6 +428,7 @@ class EEDebugController(CementBaseController): @expose(hide=True) def default(self): + """Default function of debug""" self.start = True self.interactive = False self.msg = [] diff --git a/ee/cli/plugins/import_slow_log.py b/ee/cli/plugins/import_slow_log.py index 41427c19..fece6771 100644 --- a/ee/cli/plugins/import_slow_log.py +++ b/ee/cli/plugins/import_slow_log.py @@ -19,6 +19,7 @@ class EEImportslowlogController(CementBaseController): @expose(hide=True) def default(self): + """Default function for import slow log""" if os.path.isdir("{0}22222/htdocs/db/anemometer" .format(EEVariables.ee_webroot)): if os.path.isfile("/var/log/mysql/mysql-slow.log"): diff --git a/ee/cli/plugins/info.py b/ee/cli/plugins/info.py index 54c9c89d..4ec74db2 100644 --- a/ee/cli/plugins/info.py +++ b/ee/cli/plugins/info.py @@ -36,6 +36,7 @@ class EEInfoController(CementBaseController): @expose(hide=True) def info_nginx(self): + """Display Nginx information""" version = os.popen("nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2 | " "cut -d'/' -f2 | tr -d '\n'").read() allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | " @@ -65,6 +66,7 @@ class EEInfoController(CementBaseController): @expose(hide=True) def info_php(self): + """Display PHP information""" version = os.popen("php -v | head -n1 | cut -d' ' -f2 |" " cut -d'+' -f1 | tr -d '\n'").read config = configparser.ConfigParser() @@ -138,6 +140,7 @@ class EEInfoController(CementBaseController): @expose(hide=True) def info_mysql(self): + """Display MySQL information""" version = os.popen("mysql -V | awk '{print($5)}' | cut -d ',' " "-f1 | tr -d '\n'").read() host = "localhost" @@ -165,6 +168,7 @@ class EEInfoController(CementBaseController): @expose(hide=True) def default(self): + """default function for info""" if (not self.app.pargs.nginx and not self.app.pargs.php and not self.app.pargs.mysql): self.app.pargs.nginx = True diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 5b4a96f5..b824a965 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -68,11 +68,12 @@ class EEStackController(CementBaseController): @expose(hide=True) def default(self): - # TODO Default action for ee stack command + """default action of ee stack command""" self.app.args.print_help() @expose(hide=True) def pre_pref(self, apt_packages): + """Pre settings to do before installation packages""" if set(EEVariables.ee_postfix).issubset(set(apt_packages)): Log.info(self, "Pre-seeding Postfix") EEShellExec.cmd_exec(self, "echo \"postfix postfix" @@ -143,6 +144,7 @@ class EEStackController(CementBaseController): @expose(hide=True) def post_pref(self, apt_packages, packages): + """Post activity after installation of packages""" if len(apt_packages): if set(EEVariables.ee_postfix).issubset(set(apt_packages)): EEGit.add(self, ["/etc/postfix"], @@ -1033,6 +1035,7 @@ class EEStackController(CementBaseController): @expose(help="Install packages") def install(self, packages=[], apt_packages=[], disp_msg=True): + """Start installation of packages""" self.msg = [] try: # Default action for stack installation @@ -1225,6 +1228,7 @@ class EEStackController(CementBaseController): @expose(help="Remove packages") def remove(self): + """Start removal of packages""" apt_packages = [] packages = [] @@ -1312,6 +1316,7 @@ class EEStackController(CementBaseController): @expose(help="Purge packages") def purge(self): + """Start purging of packages""" apt_packages = [] packages = [] diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index 31d46e13..37943dd0 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -19,6 +19,7 @@ class EEStackStatusController(CementBaseController): @expose(help="Start stack services") def start(self): + """Start services""" services = [] if self.app.pargs.nginx: Log.debug(self, "nginx service start") @@ -46,6 +47,7 @@ class EEStackStatusController(CementBaseController): @expose(help="Stop stack services") def stop(self): + """Stop services""" services = [] if self.app.pargs.nginx: Log.debug(self, "nginx service stop") @@ -73,6 +75,7 @@ class EEStackStatusController(CementBaseController): @expose(help="Restart stack services") def restart(self): + """Restart services""" services = [] if self.app.pargs.nginx: Log.debug(self, "nginx service restart") @@ -100,6 +103,7 @@ class EEStackStatusController(CementBaseController): @expose(help="Get stack status") def status(self): + """Status of services""" services = [] if self.app.pargs.nginx: Log.debug(self, "nginx service status") @@ -128,6 +132,7 @@ class EEStackStatusController(CementBaseController): @expose(help="Reload stack services") def reload(self): + """Reload service""" services = [] if self.app.pargs.nginx: Log.debug(self, "nginx service reload") diff --git a/ee/core/addswap.py b/ee/core/addswap.py index 37291a24..717d67a1 100644 --- a/ee/core/addswap.py +++ b/ee/core/addswap.py @@ -13,6 +13,7 @@ class EESwap(): pass def add(self): + """Swap addition with EasyEngine""" if EEVariables.ee_ram < 512: if EEVariables.ee_swap < 1000: Log.info(self, "Adding SWAP") diff --git a/ee/core/checkfqdn.py b/ee/core/checkfqdn.py index ea488a1f..915b2e24 100644 --- a/ee/core/checkfqdn.py +++ b/ee/core/checkfqdn.py @@ -4,6 +4,7 @@ import os def check_fqdn(self, ee_host): + """FQDN check with EasyEngine, for mail server hostname must be FQDN""" #ee_host=os.popen("hostname -f | tr -d '\n'").read() if '.' in ee_host: EEVariables.ee_fqdn = ee_host diff --git a/ee/core/download.py b/ee/core/download.py index 90e70544..c0796658 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -11,6 +11,8 @@ class EEDownload(): pass def download(self, packages): + """Download packages, packges must be list in format of + [url, path, package name]""" for package in packages: url = package[0] filename = package[1] @@ -21,7 +23,8 @@ class EEDownload(): os.makedirs(directory) Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ') urllib.request.urlretrieve(url, filename) - Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + Log.OKBLUE + "]")) + Log.info(self, "{0}".format("[" + Log.ENDC + "Done" + + Log.OKBLUE + "]")) except urllib.error.URLError as e: Log.debug(self, "[{err}]".format(err=str(e.reason))) Log.error(self, "Unable to donwload file, {0}" diff --git a/ee/core/extract.py b/ee/core/extract.py index 534f7062..d8db19c5 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -8,6 +8,7 @@ class EEExtract(): """Method to extract from tar.gz file""" def extract(self, file, path): + """Function to extract tar.gz file""" try: tar = tarfile.open(file) tar.extractall(path=path) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 3b250c74..da77740f 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -10,6 +10,7 @@ class EEMysql(): """Method for MySQL connection""" def execute(self, statement, errormsg=''): + """Get login details from ~/.my.cnf & Execute MySQL query""" config = configparser.RawConfigParser() cnfpath = expanduser("~")+"/.my.cnf" if [cnfpath] == config.read(cnfpath): diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index c0791e6a..3827d7b8 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -12,6 +12,7 @@ class EEShellExec(): pass def cmd_exec(self, command, errormsg=''): + """Run shell command from Python""" try: Log.debug(self, "Running command: {0}".format(command)) retcode = subprocess.getstatusoutput(command) From 0d7cdd60ebd1551a877569156976465d6c00b534 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 11:34:10 +0530 Subject: [PATCH 770/829] added db sync function --- upgrade | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/upgrade b/upgrade index 7c9a6cec..cc0cb4f7 100644 --- a/upgrade +++ b/upgrade @@ -23,6 +23,102 @@ function ee_lib_echo_fail() echo $(tput setaf 1)$@$(tput sgr0) } +function sync_db() +{ + mkdir /var/lib/ee + + echo "CREATE TABLE sites ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + sitename UNIQUE, + site_type CHAR, + cache_type CHAR, + site_path CHAR, + created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + is_enabled INT, + is_ssl INT, + storage_fs CHAR, + storage_db CHAR + );" | sqlite3 /var/lib/ee/ee.db + + for site in $(ls /etc/nginx/sites-available/ | grep -v default); + do + if [ -f /etc/nginx/sites-available/$site ]; then + ENABLE_STATUS='1' + else + ENABLE_STATUS='0' + fi + # Find out information about current NGINX configuration + EE_SITE_CURRENT_TYPE=$(head -n1 /etc/nginx/sites-available/$site | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + # Detect current website type and cache + if [ "$EE_SITE_CURRENT_TYPE" = "HTML" ]; then + EE_SITE_CURRENT="html" + EE_SITE_CURRENT_CACHE="basic" + elif [ "$EE_SITE_CURRENT_TYPE" = "PHP" ]; then + EE_SITE_CURRENT="php" + EE_SITE_CURRENT_CACHE="basic" + elif [ "$EE_SITE_CURRENT_TYPE" = "MYSQL" ]; then + EE_SITE_CURRENT="mysql" + EE_SITE_CURRENT_CACHE="basic" + # Single WordPress + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE BASIC" ]; then + EE_SITE_CURRENT="wp" + EE_SITE_CURRENT_CACHE="basic" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE WP SUPER CACHE" ]; then + EE_SITE_CURRENT="wp" + EE_SITE_CURRENT_CACHE="wpsc" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT="wp" + EE_SITE_CURRENT_CACHE="w3tc" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FASTCGI" ]; then + EE_SITE_CURRENT="wp" + EE_SITE_CURRENT_CACHE="wpfc" + + # WordPress subdirectory + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR BASIC" ]; then + EE_SITE_CURRENT="wpsubdir" + EE_SITE_CURRENT_CACHE="basic" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR WP SUPER CACHE" ]; then + EE_SITE_CURRENT="wpsubdir" + EE_SITE_CURRENT_CACHE="wpsc" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT="wpsubdir" + EE_SITE_CURRENT_CACHE="w3tc" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FASTCGI" ]; then + EE_SITE_CURRENT="wpsubdir" + EE_SITE_CURRENT_CACHE="wpfc" + + # WordPress subdomain + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN BASIC" ]; then + EE_SITE_CURRENT="wpsubdomain" + EE_SITE_CURRENT_CACHE="basic" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + EE_SITE_CURRENT="wpsubdomain" + EE_SITE_CURRENT_CACHE="wpsc" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT="wpsubdomain" + EE_SITE_CURRENT_CACHE="w3tc" + + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FASTCGI" ]; then + EE_SITE_CURRENT="wpsubdomain" + EE_SITE_CURRENT_CACHE="wpfc" + fi + + WEBROOT="/var/www/$site" + echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db) + VALUES (\"$site\", \"$EE_SITE_CURRENT\", \"$EE_SITE_CURRENT_CACHE\", \"$WEBROOT\", \"$ENABLE_STATUS\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/ee/ee.db + + done +} + + # Checking permissions if [[ $EUID -ne 0 ]]; then ee_lib_echo_fail "Sudo privilege required..." @@ -63,6 +159,17 @@ if [[ $? -ne 0 ]]; then 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 + +sync_db + # Remove old version of EasyEngine (ee) rm -rf /tmp/easyengine &>> /dev/null From 4a7e02d708da8c39714c5741bc59514bd68a2f90 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 11:34:29 +0530 Subject: [PATCH 771/829] minor changes in db_uri --- config/plugins.d/site.conf | 1 - ee/core/database.py | 3 ++- ee/core/variables.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/plugins.d/site.conf b/config/plugins.d/site.conf index 0dad9ff0..2fb468fe 100644 --- a/config/plugins.d/site.conf +++ b/config/plugins.d/site.conf @@ -6,4 +6,3 @@ ### `ee.cli.plugins.example` or from the file path ### `/var/lib/ee/plugins/example.py` enable_plugin = true -db_path = sqlite:////var/lib/ee/ee.sqlite diff --git a/ee/core/database.py b/ee/core/database.py index 8fb0aa0f..573ee099 100644 --- a/ee/core/database.py +++ b/ee/core/database.py @@ -2,9 +2,10 @@ from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy.ext.declarative import declarative_base +from ee.core.variables import EEVariables # db_path = self.app.config.get('site', 'db_path') -engine = create_engine('sqlite:////var/lib/ee/ee.sqlite', convert_unicode=True) +engine = create_engine(EEVariables.ee_db_uri, convert_unicode=True) db_session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine)) diff --git a/ee/core/variables.py b/ee/core/variables.py index ade26d28..be6cb7f7 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -114,6 +114,8 @@ class EEVariables(): # Repo path ee_repo_file = "ee-repo.list" ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file) + basedir = os.path.abspath(os.path.dirname('/var/lib/ee/')) + ee_db_uri = 'sqlite:///' + os.path.join(basedir, 'ee.db') def __init__(self): pass From 5862a6da49491323fa23c6ada9b1d5e44b8e10d5 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 3 Feb 2015 12:28:35 +0530 Subject: [PATCH 772/829] Updated exit message --- setup.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/setup.py b/setup.py index 4e0ee309..87d6a385 100644 --- a/setup.py +++ b/setup.py @@ -86,3 +86,13 @@ setup(name='ee', """, namespace_packages=[], ) + +print("""\033[94m +For EasyEngine (ee) auto completion, run the following command +\033[92m +source /etc/bash_completion.d/ee_auto.rc +\033[94m +EasyEngine (ee) installed successfully +EasyEngine (ee) help: https://rtcamp.com/easyengine/docs/ +\033[0m +""") From f1e17cfee61da09002be524c6ba7d0830fe6c885 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 12:38:03 +0530 Subject: [PATCH 773/829] bug fix in site update --- ee/cli/plugins/site.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 0173021a..8a41781d 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -578,9 +578,9 @@ class EESiteUpdateController(CementBaseController): or self.app.pargs.wpfc or self.app.pargs.wpsc)): if ((oldsitetype not in ['html', 'php', 'mysql', 'wp']) - or (oldsitetype is 'wp' and oldcachetype is 'basic')): - print(oldsitetype, oldcachetype) - Log.error(self, " Cannot update {0}, {1} {2} to wp basic" + or (oldsitetype == 'wp' and oldcachetype == 'basic')): + + Log.error(self, "Cannot update {0} {1} {2} to wp basic" .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -597,8 +597,8 @@ class EESiteUpdateController(CementBaseController): (self.app.pargs.wpfc or self.app.pargs.wpsc)): if (oldsitetype not in ['html', 'php', 'mysql', 'wp'] - or (oldsitetype is 'wp' and oldcachetype is 'w3tc')): - Log.error(self, " Cannot update {0}, {1} {2} to wp w3tc" + or (oldsitetype == 'wp' and oldcachetype == 'w3tc')): + Log.error(self, "Cannot update {0}, {1} {2} to wp w3tc" .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, @@ -616,7 +616,7 @@ class EESiteUpdateController(CementBaseController): (self.app.pargs.wpsc or self.app.pargs.w3tc)): if (oldsitetype not in ['html', 'php', 'mysql', 'wp'] - or (oldsitetype is 'wp' and oldcachetype is 'wpfc')): + or (oldsitetype == 'wp' and oldcachetype == 'wpfc')): Log.error(self, "Cannot update {0}, {1} {2} to wp wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -634,7 +634,7 @@ class EESiteUpdateController(CementBaseController): (self.app.pargs.w3tc or self.app.pargs.wpfc)): if (oldsitetype not in ['html', 'php', 'mysql', 'wp'] - or (oldsitetype is 'wp' and oldcachetype is 'wpsc')): + or (oldsitetype == 'wp' and oldcachetype == 'wpsc')): Log.error(self, "Cannot update {0}, {1} {2} to wp wpsc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -657,7 +657,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] - or (oldsitetype is 'wpsubdir' and oldcachetype is 'basic')): + or (oldsitetype == 'wpsubdir' and oldcachetype == 'basic')): Log.error(self, " Cannot update {0}, {1} {2} " "to wpsubdir basic" .format(ee_domain, oldsitetype, oldcachetype)) @@ -677,7 +677,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] - or (oldsitetype is 'wpsubdir' and oldcachetype is 'w3tc')): + or (oldsitetype == 'wpsubdir' and oldcachetype == 'w3tc')): Log.error(self, " Cannot update {0} {1} {2}" "to wpsubdir w3tc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -698,8 +698,8 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] - or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpfc')): - Log.error(self, " Cannot update {0} {1} {2}" + or (oldsitetype == 'wpsubdir' and oldcachetype == 'wpfc')): + Log.error(self, "Cannot update {0} {1} {2}" " to wpsubdir wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -718,7 +718,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdir'] - or (oldsitetype is 'wpsubdir' and oldcachetype is 'wpsc')): + or (oldsitetype == 'wpsubdir' and oldcachetype == 'wpsc')): Log.error(self, " Cannot update {0} {1} {2}" " to wpsubdir wpsc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -739,7 +739,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] - or (oldsitetype is 'wpsubdomain' and oldcachetype is 'basic')): + or (oldsitetype == 'wpsubdomain' and oldcachetype == 'basic')): Log.error(self, " Cannot update {0} {1} {2}" " to wpsubdomain basic" .format(ee_domain, oldsitetype, oldcachetype)) @@ -760,7 +760,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] or - (oldsitetype is 'wpsubdomain' and oldcachetype is 'w3tc')): + (oldsitetype == 'wpsubdomain' and oldcachetype == 'w3tc')): Log.error(self, " Cannot update {0}, {1} {2}" " to wpsubdomain w3tc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -781,7 +781,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] or - (oldsitetype is 'wpsubdomain' and oldcachetype is 'wpfc')): + (oldsitetype == 'wpsubdomain' and oldcachetype == 'wpfc')): Log.error(self, " Cannot update {0}, {1} {2} " "to wpsubdomain wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -802,7 +802,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] or - (oldsitetype is 'wpsubdomain' and oldcachetype is 'wpsc')): + (oldsitetype == 'wpsubdomain' and oldcachetype == 'wpsc')): Log.error(self, " Cannot update {0}, {1} {2}" " to wpsubdomain wpsc" .format(ee_domain, oldsitetype, oldcachetype)) From 06f6a778774ff34d6d57317d6f20d39b2391e769 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 12:38:24 +0530 Subject: [PATCH 774/829] Added comments --- ee/cli/plugins/sitedb.py | 12 +++++++++++- ee/core/variables.py | 2 ++ upgrade | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index 72a3ee6f..805b72bc 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -9,7 +9,10 @@ import sys def addNewSite(self, site, stype, cache, path, - enabled=True, ssl=False, fs='ext4', db=''): + enabled=True, ssl=False, fs='ext4', db='mysql'): + """ + Add New Site record information into ee database. + """ try: newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db) db_session.add(newRec) @@ -20,6 +23,9 @@ def addNewSite(self, site, stype, cache, path, def getSiteInfo(self, site): + """ + Retrieves site record from ee databse + """ try: q = SiteDB.query.filter(SiteDB.sitename == site).first() return q @@ -30,6 +36,7 @@ def getSiteInfo(self, site): def updateSiteInfo(self, site, stype='', cache='', enabled=True, ssl=False, fs='', db=''): + """updates site record in database""" try: q = SiteDB.query.filter(SiteDB.sitename == site).first() except Exception as e: @@ -39,6 +46,7 @@ def updateSiteInfo(self, site, stype='', cache='', if not q: Log.error(self, "{0} does not exist in database".format(site)) + # Check if new record matches old if not then only update database if stype and q.site_type != stype: q.site_type = stype @@ -60,6 +68,7 @@ def updateSiteInfo(self, site, stype='', cache='', def deleteSiteInfo(self, site): + """Delete site record in database""" try: q = SiteDB.query.filter(SiteDB.sitename == site).first() except Exception as e: @@ -78,6 +87,7 @@ def deleteSiteInfo(self, site): def getAllsites(self): + try: q = SiteDB.query.all() return q diff --git a/ee/core/variables.py b/ee/core/variables.py index be6cb7f7..e3d03117 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -114,6 +114,8 @@ class EEVariables(): # Repo path ee_repo_file = "ee-repo.list" ee_repo_file_path = ("/etc/apt/sources.list.d/" + ee_repo_file) + + # Application dabase file path basedir = os.path.abspath(os.path.dirname('/var/lib/ee/')) ee_db_uri = 'sqlite:///' + os.path.join(basedir, 'ee.db') diff --git a/upgrade b/upgrade index cc0cb4f7..3f44b4cb 100644 --- a/upgrade +++ b/upgrade @@ -27,6 +27,7 @@ function sync_db() { mkdir /var/lib/ee + # Sqlite query to create table `sites` into ee.db which will be used by ee.3.0 echo "CREATE TABLE sites ( id INTEGER PRIMARY KEY AUTOINCREMENT, sitename UNIQUE, @@ -112,6 +113,8 @@ function sync_db() fi WEBROOT="/var/www/$site" + + # Insert query to insert old site information into ee.db echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db) VALUES (\"$site\", \"$EE_SITE_CURRENT\", \"$EE_SITE_CURRENT_CACHE\", \"$WEBROOT\", \"$ENABLE_STATUS\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/ee/ee.db From 92947733943f3787ee7613bf3b420ffb6d54e6b3 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 12:56:10 +0530 Subject: [PATCH 775/829] modified ee site info output --- ee/cli/plugins/site.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 8a41781d..65301ba0 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -79,6 +79,13 @@ class EESiteController(CementBaseController): ee_db_pass = '' if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): + check_site = getSiteInfo(self, ee_domain) + if check_site is None: + Log.error(self, " Site {0} does not exist.".format(ee_domain)) + else: + sitetype = check_site.site_type + cachetype = check_site.cache_type + ee_site_webroot = EEVariables.ee_webroot + ee_domain access_log = (ee_site_webroot + '/logs/access.log') error_log = (ee_site_webroot + '/logs/error.log') @@ -98,7 +105,10 @@ class EESiteController(CementBaseController): data = dict(domain=ee_domain, webroot=ee_site_webroot, accesslog=access_log, errorlog=error_log, dbname=ee_db_name, dbuser=ee_db_user, - dbpass=ee_db_pass) + dbpass=ee_db_pass, type=sitetype + " " + cachetype + + " ({0})".format("enabled" + if check_site.is_enabled else + "disabled")) self.app.render((data), 'siteinfo.mustache') else: Log.error(self, " site {0} does not exists".format(ee_domain)) From 02c1720da90ff0924839d4d3d2ff23477987be95 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 13:59:50 +0530 Subject: [PATCH 776/829] minor bug fix --- ee/cli/plugins/site.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 65301ba0..af59dec0 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -746,13 +746,16 @@ class EESiteUpdateController(CementBaseController): if (self.app.pargs.wpsubdomain and not (self.app.pargs.html or self.app.pargs.php or self.app.pargs.mysql or self.app.pargs.wpsubdir or self.app.pargs.wp)): + if (self.app.pargs.wpsubdomain and not (self.app.pargs.w3tc + or self.app.pargs.wpfc or self.app.pargs.wpsc)): + if (oldsitetype not in ['html', 'php', 'mysql', 'wp', + 'wpsubdomain'] + or (oldsitetype == 'wpsubdomain' and + oldcachetype == 'basic')): - if (oldsitetype not in ['html', 'php', 'mysql', 'wp', - 'wpsubdomain'] - or (oldsitetype == 'wpsubdomain' and oldcachetype == 'basic')): - Log.error(self, " Cannot update {0} {1} {2}" - " to wpsubdomain basic" - .format(ee_domain, oldsitetype, oldcachetype)) + Log.error(self, " Cannot update {0} {1} {2}" + " to wpsubdomain basic" + .format(ee_domain, oldsitetype, oldcachetype)) data = dict(site_name=ee_domain, www_domain=ee_www_domain, static=False, basic=True, wp=True, w3tc=False, @@ -771,6 +774,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] or (oldsitetype == 'wpsubdomain' and oldcachetype == 'w3tc')): + print(oldsitetype, oldcachetype) Log.error(self, " Cannot update {0}, {1} {2}" " to wpsubdomain w3tc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -792,6 +796,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] or (oldsitetype == 'wpsubdomain' and oldcachetype == 'wpfc')): + print(oldsitetype, oldcachetype) Log.error(self, " Cannot update {0}, {1} {2} " "to wpsubdomain wpfc" .format(ee_domain, oldsitetype, oldcachetype)) @@ -813,6 +818,7 @@ class EESiteUpdateController(CementBaseController): if (oldsitetype not in ['html', 'php', 'mysql', 'wp', 'wpsubdomain'] or (oldsitetype == 'wpsubdomain' and oldcachetype == 'wpsc')): + print(oldsitetype, oldcachetype) Log.error(self, " Cannot update {0}, {1} {2}" " to wpsubdomain wpsc" .format(ee_domain, oldsitetype, oldcachetype)) From a5625620d431f2360c4bd7d252f33e6692923624 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 14:38:53 +0530 Subject: [PATCH 777/829] Updated README --- README.md | 105 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 83 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 3a8e1ee5..56237fd1 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,96 @@ +IMPORTANT +============================================ -How To setup this version on your system?? +#### We are looking for [Python Developers] (https://rtcamp.com/careers/python-developer/) to join our team. We offer work from home, so you can join EasyEngine team anywhere! _[Why Python?] (https://rtcamp.com/blog/easyengine-3-roadmap/#whypython)_ + +--- + +[![Stories in Ready](https://badge.waffle.io/rtcamp/easyengine.png?label=ready&title=Ready)](https://waffle.io/rtcamp/easyengine) +[![Stories in Progress](https://badge.waffle.io/rtcamp/easyengine.png?label=in%20progress&title=In%20Progress)](https://waffle.io/rtcamp/easyengine) + +EasyEngine Logo + +[![Travis Build Status](https://travis-ci.org/rtCamp/easyengine.svg "Travis Build Status")] (https://travis-ci.org/rtCamp/easyengine) + +EasyEngine (ee) is a linux shell-script collection, which makes it easy to manage your wordpress sites running on nginx web-server. + +**EasyEngine currently supports:** + +- Ubuntu 12.04 & 14.04 +- Debian 7 + +## Quick Start + +```bash +wget -qO ee rt.cx/ee && sudo bash ee # install easyengine +sudo ee site create example.com --wp # Install required packages & setup WordPress on example.com +``` + +## Update EasyEngine + + +Update Procedure For EasyEngine + +```bash +wget -qO eeup http://rt.cx/eeup && sudo bash eeup +``` + +## More Site Creation Commands + +### Standard WordPress Sites ```bash -sudo apt-get install python3-pip git -sudo pip3 install virtualenv -git clone -b python https://github.com/rtCamp/easyengine.git -cd easyengine -virtualenv ./env --system-site-packages -source ./env/bin/activate -sudo pip3 install -r requirements.txt -sudo python3 setup.py develop -ee --help +ee site create example.com --wp # install wordpress without any page caching +ee site create example.com --w3tc # install wordpress with w3-total-cache plugin +ee site create example.com --wpsc # install wordpress with wp-super-cache plugin +ee site create example.com --wpfc # install wordpress + nginx fastcgi_cache ``` -How to install this version on your system?? +### WordPress Multsite with subdirectory + ```bash -sudo apt-get update -sudo apt-get -y install python3 python3-apt python3-setuptools python3-dev git -git clone -b python https://github.com/rtCamp/easyengine.git -cd easyengine -sudo python3 setup.py install -ee --help +ee site create example.com --wpsubdir # install wpmu-subdirectory without any page caching +ee site create example.com --wpsubdir --w3tc # install wpmu-subdirectory with w3-total-cache plugin +ee site create example.com --wpsubdir --wpsc # install wpmu-subdirectory with wp-super-cache plugin +ee site create example.com --wpsubdir --wpfc # install wpmu-subdirectory + nginx fastcgi_cache ``` +### WordPress Multsite with subdomain + +```bash +ee site create example.com --wpsubdomin # install wpmu-subdomain without any page caching +ee site create example.com --wpsubdomain --w3tc # install wpmu-subdomain with w3-total-cache plugin +ee site create example.com --wpsubdomain --wpsc # install wpmu-subdomain with wp-super-cache plugin +ee site create example.com --wpsubdomain --wpfc # install wpmu-subdomain + nginx fastcgi_cache +``` + +### Non-WordPress Sites +```bash +ee site create example.com --html # create example.com for static/html sites +ee site create example.com --php # create example.com with php support +ee site create example.com --mysql # create example.com with php & mysql support +``` + +## Cheatsheet - Site creation + + +| | Single Site | Multisite w/ Subdir | Multisite w/ Subdom | +|--------------------|---------------|-----------------------|-----------------------| +| **NO Cache** | --wp | --wpsubdir | --wpsubdomain | +| **WP Super Cache** | --wpsc | --wpsubdir --wpsc | --wpsubdomain --wpsc | +| **W3 Total Cache** | --w3tc | --wpsubdir --w3tc | --wpsubdomain --w3tc | +| **Nginx cache** | --wpfc | --wpsubdir --wpfc | --wpsubdomain --wpfc | + -EasyEngine 3.x Developement version +## Useful Links +- [Documentation] (http://rtcamp.com/easyengine/docs/) +- [FAQ] (http://rtcamp.com/easyengine/faq/) +- [Conventions used] (http://rtcamp.com/wordpress-nginx/tutorials/conventions/) +## Donations -Thinking To Contribute??? +[![Donate](https://cloud.githubusercontent.com/assets/4115/5297691/c7b50292-7bd7-11e4-987b-2dc21069e756.png)] (https://rtcamp.com/donate/?project=easyengine) -refer docs to know more on EasyEngine Developement +## License -follow instruction from step 3 in Creating cement app -http://builtoncement.com/2.4/dev/boss_templates.html +Same [GPL] (http://www.gnu.org/licenses/gpl-2.0.txt) that WordPress uses! From 46c473ba9cf977ad0e500b1efc1adffef97a671a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 3 Feb 2015 14:58:28 +0530 Subject: [PATCH 778/829] 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 779/829] 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 780/829] 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 781/829] 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 782/829] 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 783/829] 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 784/829] 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: From 6c4982b70834b53d6ef6c1e7cd6d22d71ef4dc2d Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 19:54:15 +0530 Subject: [PATCH 785/829] changed ee version --- ee/core/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index e3d03117..3cd58bdf 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.0" + ee_version = "3.0.0-beta" # EasyEngine packages versions ee_wp_cli = "0.18.0" From 3bd7cb203943a1c779b6033ee8efd58a0b80e974 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 3 Feb 2015 20:20:30 +0530 Subject: [PATCH 786/829] changed README.md file --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 56237fd1..a119d9bf 100644 --- a/README.md +++ b/README.md @@ -19,20 +19,22 @@ EasyEngine (ee) is a linux shell-script collection, which makes it easy to manag - Ubuntu 12.04 & 14.04 - Debian 7 +### This is Beta version. Donot Try on Production/Live servers + ## Quick Start ```bash -wget -qO ee rt.cx/ee && sudo bash ee # install easyengine +wget http://rt.cx/eebeta && sudo bash install # install easyengine 3.0.0-beta sudo ee site create example.com --wp # Install required packages & setup WordPress on example.com ``` ## Update EasyEngine -Update Procedure For EasyEngine +Update Procedure For EasyEngine to version 3.0.0-beta ```bash -wget -qO eeup http://rt.cx/eeup && sudo bash eeup +wget http://rt.cx/eebeta && sudo bash install ``` ## More Site Creation Commands From 21ecee5a3a38142184990c37539cda6a3437a3f9 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 4 Feb 2015 15:01:57 +0530 Subject: [PATCH 787/829] Autofix database user name --- ee/cli/plugins/site_functions.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index a8851a60..d9b2e83c 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -106,8 +106,7 @@ def setupdatabase(self, data): ' please wait') ee_random10 = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 10))) - ee_db_name = (ee_db_name[0:6] + ee_random10) - + ee_db_username = (ee_db_name[0:6] + ee_random10) # create MySQL database Log.info(self, "Setting up database\t\t", end='') Log.debug(self, "Creating databse {0}".format(ee_db_name)) From 2339a9eba115be87398499e0636a97c4e98d08b3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 4 Feb 2015 16:38:20 +0530 Subject: [PATCH 788/829] Fixed ee stack status --- 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..b20e3be5 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -118,7 +118,7 @@ class EEService(): try: is_exist = subprocess.getstatusoutput('which {0}' .format(service_name)) - if is_exist == 0: + if is_exist[0] == 0: retcode = subprocess.getstatusoutput('service {0} status' .format(service_name)) if retcode[0] == 0: From 5a99c762f0ee1f12a7d2663b7bd6e7b1df166956 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 4 Feb 2015 18:49:32 +0530 Subject: [PATCH 789/829] added --password option for autocompletion --- config/bash_completion.d/ee_auto.rc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index 162edf4b..2e936e1c 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -106,11 +106,17 @@ _ee_complete() case "$mprev" in # HANDLE EVERYTHING AFTER THE THIRD LEVEL NAMESPACE - "create" | "update") + "create") COMPREPLY=( $(compgen \ -W "--html --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc" \ -- $cur) ) ;; + + "update") + COMPREPLY=( $(compgen \ + -W "--password --php --mysql --wp --wpsubdir --wpsubdomain --w3tc --wpfc --wpsc" \ + -- $cur) ) + ;; "delete") COMPREPLY=( $(compgen \ -W "--db --files --all" \ From d97fdcfd16abc0daacd67447675b59ed0ff8f038 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 4 Feb 2015 18:50:29 +0530 Subject: [PATCH 790/829] bug fix for site create command from config --- ee/cli/plugins/site_functions.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index d9b2e83c..a4cd3ac5 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -11,6 +11,7 @@ import string import sys import getpass import glob +import re def setupdomain(self, data): @@ -76,7 +77,7 @@ def setupdatabase(self, data): if prompt_dbname == 'True' or prompt_dbname == 'true': try: - ee_db_name = input('Enter the MySQL database name [{0}]:' + ee_db_name = input('Enter the MySQL database name [{0}]: ' .format(ee_replace_dot)) except EOFError as e: Log.debug(self, "{0}".format(e)) @@ -102,8 +103,8 @@ def setupdatabase(self, data): ee_db_password = ee_random if len(ee_db_username) > 16: - Log.info(self, 'Autofix MySQL username (ERROR 1470 (HY000)),' - ' please wait') + Log.debug(self, 'Autofix MySQL username (ERROR 1470 (HY000)),' + ' please wait') ee_random10 = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 10))) ee_db_username = (ee_db_name[0:6] + ee_random10) @@ -145,8 +146,8 @@ def setupwordpress(self, data): ee_random = (''.join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 15))) ee_wp_prefix = '' - ee_wp_user = '' - ee_wp_pass = '' + # ee_wp_user = '' + # ee_wp_pass = '' Log.info(self, "Downloading Wordpress \t\t", end='') EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) @@ -157,9 +158,8 @@ def setupwordpress(self, data): data = setupdatabase(self, data) if prompt_wpprefix == 'True' or prompt_wpprefix == 'true': try: - ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' - .format(ee_replace_dot)) - while re.match('^[A-Za-z0-9_]*$', ee_wp_prefix): + ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ') + while not re.match('^[A-Za-z0-9_]*$', ee_wp_prefix): Log.warn(self, "table prefix can only " "contain numbers, letters, and underscores") ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ' From d6e4554ad19121eab07c29090e1add50e08d4252 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Wed, 4 Feb 2015 19:44:09 +0530 Subject: [PATCH 791/829] Fixed bug of amavis in stack.py --- ee/cli/plugins/stack.py | 6 +++--- ee/core/services.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index b824a965..716ba8d7 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -640,7 +640,7 @@ class EEStackController(CementBaseController): "smtp-amavis:[127.0.0.1]:10024\"") EEShellExec.cmd_exec(self, "sed -i \"s/1 pickup/1 " "pickup" - "\n -o content_filter=\n -o" + "\\n -o content_filter=\\n -o" " receive_override_options=no_header_body" "_checks/\" /etc/postfix/master.cf") @@ -657,10 +657,10 @@ class EEStackController(CementBaseController): EEShellExec.cmd_exec(self, "freshclam") Log.debug(self, "Restarting clamav-daemon service") EEShellExec.cmd_exec(self, "service clamav-daemon restart") - EEGit.add(self, ["/etc/amavis"], msg="Adding Amvis into Git") + EEGit.add(self, ["/etc/amavis"], msg="Adding Amavis into Git") EEService.restart_service(self, 'dovecot') EEService.reload_service(self, 'postfix') - EEService.reload_service(self, 'amavis') + EEService.restart_service(self, 'amavis') if len(packages): if any('/usr/bin/wp' == x[1] for x in packages): diff --git a/ee/core/services.py b/ee/core/services.py index 13b30ce7..ca039155 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -103,8 +103,8 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: - Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") - return True + Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + return True else: Log.debug(self, "{0}".format(retcode[1])) Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") From ac88dec9344fade052b6bd742d9a810c6b15fb10 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 12:11:36 +0530 Subject: [PATCH 792/829] Fixed import slow log --- ee/cli/plugins/import_slow_log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/import_slow_log.py b/ee/cli/plugins/import_slow_log.py index fece6771..b52bf72b 100644 --- a/ee/cli/plugins/import_slow_log.py +++ b/ee/cli/plugins/import_slow_log.py @@ -24,7 +24,7 @@ class EEImportslowlogController(CementBaseController): .format(EEVariables.ee_webroot)): if os.path.isfile("/var/log/mysql/mysql-slow.log"): # Get Anemometer user name and password - Log.error(self, "Importing MySQL slow log to Anemometer") + Log.info(self, "Importing MySQL slow log to Anemometer") host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/" .format(EEVariables.ee_webroot) + "db/anemometer/conf/config.inc.php " From aa9a4a2230d89d25694eab3cf5d62d94e7dec970 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 12:23:13 +0530 Subject: [PATCH 793/829] Fixed percona toolkit not installing --- ee/core/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 9c97032d..26bae560 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -92,7 +92,7 @@ class EEVariables(): # MySQL repo and packages ee_mysql_repo = ("deb http://repo.percona.com/apt {codename} main" .format(codename=ee_platform_codename)) - ee_mysql = ["percona-server-server-5.6"] + ee_mysql = ["percona-server-server-5.6", "mysqltuner", "percona-toolkit"] # Postfix repo and packages ee_postfix_repo = "" From a79c23afce1e4dc4ec71c22fea09b70bade67420 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 5 Feb 2015 12:34:39 +0530 Subject: [PATCH 794/829] modified ee site enable disable --- ee/cli/plugins/site.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index af59dec0..e3d603c9 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -39,7 +39,7 @@ class EESiteController(CementBaseController): @expose(help="Enable site example.com") def enable(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) - Log.info(self, "Enable domain {0:10}".format(ee_domain), end='') + Log.info(self, "Enable domain {0:10} \t".format(ee_domain), end='') if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): EEFileUtils.create_symlink(self, @@ -47,15 +47,17 @@ class EESiteController(CementBaseController): .format(ee_domain), '/etc/nginx/sites-enabled/{0}' .format(ee_domain)]) + updateSiteInfo(self, ee_domain, enabled=True) Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + EEService.reload_service(self, 'nginx') else: Log.error(self, " site {0} does not exists".format(ee_domain)) @expose(help="Disable site example.com") def disable(self): (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) - Log.info(self, "Disable domain {0:10}".format(ee_domain), end='') + Log.info(self, "Disable domain {0:10} \t".format(ee_domain), end='') if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): if not os.path.isfile('/etc/nginx/sites-enabled/{0}' @@ -68,6 +70,7 @@ class EESiteController(CementBaseController): .format(ee_domain)) updateSiteInfo(self, ee_domain, enabled=False) Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") + EEService.reload_service(self, 'nginx') else: Log.error(self, " site {0} does not exists".format(ee_domain)) From 5e63f059754d535e800e29675adcc8e41c933484 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 13:52:14 +0530 Subject: [PATCH 795/829] MySQL query to debug log --- ee/core/mysql.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index da77740f..d288dab8 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -43,6 +43,7 @@ class EEMysql(): .format(e)) try: + Log.debug(self, "Executing MySQL statement: {0}".format(statement)) cur.execute(statement) except Exception as e: cur.close() From efe4f531e3691bbf227f1894fe75866ee39b5a1a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 14:06:49 +0530 Subject: [PATCH 796/829] Fixed slow query plugin issue --- ee/cli/templates/anemometer.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/templates/anemometer.mustache b/ee/cli/templates/anemometer.mustache index e082ce50..7b85a6a7 100644 --- a/ee/cli/templates/anemometer.mustache +++ b/ee/cli/templates/anemometer.mustache @@ -125,8 +125,8 @@ $conf['plugins'] = array( $conn['db'] = $sample['db_max']; } - $conn['user'] = 'root'; - $conn['password'] = ''; + $conn['user'] = '{{user}}'; + $conn['password'] = '{{password}}'; return $conn; }, From bdb8942bb587eb274d3c9236de4676d93f3f681b Mon Sep 17 00:00:00 2001 From: Gaurav Ashtikar Date: Thu, 5 Feb 2015 14:45:05 +0530 Subject: [PATCH 797/829] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a119d9bf..80779333 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ EasyEngine (ee) is a linux shell-script collection, which makes it easy to manag ## Quick Start ```bash -wget http://rt.cx/eebeta && sudo bash install # install easyengine 3.0.0-beta +wget http://rt.cx/eebeta && sudo bash eebeta # install easyengine 3.0.0-beta sudo ee site create example.com --wp # Install required packages & setup WordPress on example.com ``` From 7f190b959d38b5f5329e5748323d3050caeefee3 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 15:42:57 +0530 Subject: [PATCH 798/829] Fixed mailscan config issue --- ee/cli/plugins/stack.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 716ba8d7..9386fc8a 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -640,10 +640,38 @@ class EEStackController(CementBaseController): "smtp-amavis:[127.0.0.1]:10024\"") EEShellExec.cmd_exec(self, "sed -i \"s/1 pickup/1 " "pickup" - "\\n -o content_filter=\\n -o" + "\\n -o content_filter=\\n -o" " receive_override_options=no_header_body" "_checks/\" /etc/postfix/master.cf") + amavis_master = """smtp-amavis unix - - n - 2 smtp + -o smtp_data_done_timeout=1200 + -o smtp_send_xforward_command=yes + -o disable_dns_lookups=yes + -o max_use=20 +127.0.0.1:10025 inet n - n - - smtpd + -o content_filter= + -o smtpd_delay_reject=no + -o smtpd_client_restrictions=permit_mynetworks,reject + -o smtpd_helo_restrictions= + -o smtpd_sender_restrictions= + -o smtpd_recipient_restrictions=permit_mynetworks,reject + -o smtpd_data_restrictions=reject_unauth_pipelining + -o smtpd_end_of_data_restrictions= + -o smtpd_restriction_classes= + -o mynetworks=127.0.0.0/8 + -o smtpd_error_sleep_time=0 + -o smtpd_soft_error_limit=1001 + -o smtpd_hard_error_limit=1000 + -o smtpd_client_connection_count_limit=0 + -o smtpd_client_connection_rate_limit=0 + -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks + -o local_header_rewrite_clients= +""" + + with open("/etc/postfix/master.cf", "a") as am_config: + am_config.write(amavis_master) + # Amavis ClamAV configuration Log.debug(self, "Adding new user clamav amavis") EEShellExec.cmd_exec(self, "adduser clamav amavis") From ff81c42e0afd0e0f2bfff77b2be83731f493d889 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 16:36:01 +0530 Subject: [PATCH 799/829] Improved Amavis setup --- ee/cli/plugins/stack.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 9386fc8a..38553767 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -1182,7 +1182,15 @@ class EEStackController(CementBaseController): "Adminer"]] if self.app.pargs.mailscanner: - apt_packages = (apt_packages + EEVariables.ee_mailscanner) + if not EEAptGet.is_installed(self, 'amavisd-new'): + if (EEAptGet.is_installed(self, 'dovecot-core') or + self.app.pargs.mail): + apt_packages = (apt_packages + + EEVariables.ee_mailscanner) + else: + Log.error(self, "Failed to find installed Dovecot") + else: + Log.error(self, "Mail scanner allready installed") if self.app.pargs.utils: Log.debug(self, "Setting packages variable for utils") @@ -1266,7 +1274,8 @@ class EEStackController(CementBaseController): (not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and - (not self.app.pargs.adminer) and (not self.app.pargs.utils)): + (not self.app.pargs.adminer) and (not self.app.pargs.utils) and + (not self.app.pargs.mailscanner)): self.app.pargs.web = True if self.app.pargs.web: @@ -1354,7 +1363,8 @@ class EEStackController(CementBaseController): (not self.app.pargs.php) and (not self.app.pargs.mysql) and (not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and (not self.app.pargs.phpmyadmin) and - (not self.app.pargs.adminer) and (not self.app.pargs.utils)): + (not self.app.pargs.adminer) and (not self.app.pargs.utils) and + (not self.app.pargs.mailscanner)): self.app.pargs.web = True if self.app.pargs.web: From 69bed12a4ce6e7d5c2451cf36d598cf68353c3df Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 5 Feb 2015 17:58:00 +0530 Subject: [PATCH 800/829] improved apt-get --- ee/core/aptget.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 46685508..ce6f9712 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -64,19 +64,6 @@ class EEAptGet(): except Exception as e: Log.debug(self, str(e)) Log.error(self, str(e)) - - try: - #apt_pkg.PkgSystemUnLock() - result = apt_cache.commit() - #apt_cache.close() - return result - except SystemError as e: - Log.debug(self, 'SystemError: ' + str(e)) - Log.error(self, 'SystemError: ' + str(e)) - #apt_cache.close() - except Exception as e: - Log.debug(self, str(e)) - Log.error(self, str(e)) else: #apt_cache.close() Log.error(self, 'Unknown package selected (' + @@ -86,6 +73,20 @@ class EEAptGet(): if not install_package(self, package): continue + if apt_cache.install_count > 0: + try: + #apt_pkg.PkgSystemUnLock() + result = apt_cache.commit() + #apt_cache.close() + return result + except SystemError as e: + Log.debug(self, 'SystemError: ' + str(e)) + Log.error(self, 'SystemError: ' + str(e)) + #apt_cache.close() + except Exception as e: + Log.debug(self, str(e)) + Log.error(self, str(e)) + def remove(self, packages, auto=False, purge=False): """ Similar to `apt-get remove/purge` From e5eeb6746c3c84ca23eab9e386e9695e52182937 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Thu, 5 Feb 2015 18:09:33 +0530 Subject: [PATCH 801/829] Fix typo --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index ecb5125d..1b3a5fc2 100644 --- a/install +++ b/install @@ -222,7 +222,7 @@ if [ ! -f /usr/local/sbin/easyengine ]; then install_ee3 git_init else - ee_lib_echo_fail "EasyEngine 3 allready installed on ur system" + ee_lib_echo_fail "EasyEngine 3 allready installed on your system" exit 1 fi else From 4e0c05693a5504413aa985e4cd26b73346c5d48f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 5 Feb 2015 18:22:55 +0530 Subject: [PATCH 802/829] apt-get updated --- ee/core/aptget.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index ce6f9712..90004b5e 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -113,18 +113,6 @@ class EEAptGet(): except SystemError as e: Log.debug(self, 'SystemError: ' + str(e)) return False - try: - # apt_pkg.PkgSystemUnLock() - result = apt_cache.commit() - # apt_cache.close() - return result - except SystemError as e: - Log.debug(self, 'SystemError: ' + str(e)) - return False - except Exception as e: - Log.debug(self, str(e)) - Log.error(self, str(e)) - # apt_cache.close() else: # apt_cache.close() Log.error(self, 'Unknown package selected (' + @@ -134,6 +122,20 @@ class EEAptGet(): if not remove_package(self, package, purge=purge): continue + if apt_cache.delete_count > 0: + try: + # apt_pkg.PkgSystemUnLock() + result = apt_cache.commit() + # apt_cache.close() + return result + except SystemError as e: + Log.debug(self, 'SystemError: ' + str(e)) + return False + except Exception as e: + Log.debug(self, str(e)) + Log.error(self, str(e)) + # apt_cache.close() + def auto_clean(self): """ Similar to `apt-get autoclean` From 7c903a9da9a0ac9f298582c8843bd01b29fd2ea9 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 18:56:37 +0530 Subject: [PATCH 803/829] Removed more hardcoded values --- ee/cli/plugins/debug.py | 11 +++++++---- ee/cli/plugins/stack.py | 30 +++++++++++++---------------- ee/cli/templates/22222.mustache | 12 ++++++------ ee/cli/templates/vimbadmin.mustache | 4 ++-- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 4d346347..0e384246 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -279,8 +279,10 @@ class EEDebugController(CementBaseController): Log.info(self, "Starting WordPress debug") open("{0}/htdocs/wp-content/debug.log".format(webroot), 'a').close() - EEShellExec.cmd_exec(self, "chown www-data: {0}/htdocs/wp-" - "content/debug.log".format(webroot)) + EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-" + "content/debug.log" + "".format(webroot, + EEVariables.ee_php_user)) EEShellExec.cmd_exec(self, "sed -i \"s/define(\'WP_DEBUG\'" ".*/define(\'WP_DEBUG\', true);\\n" "define(\'WP_DEBUG_DISPLAY\', false);" @@ -290,9 +292,10 @@ class EEDebugController(CementBaseController): EEShellExec.cmd_exec(self, "cd {0}/htdocs/ && wp" " plugin --allow-root install " "developer".format(webroot)) - EEShellExec.cmd_exec(self, "chown -R www-data: {0}/htdocs/" + EEShellExec.cmd_exec(self, "chown -R {1}: {0}/htdocs/" "wp-content/plugins" - .format(webroot)) + .format(webroot, + EEVariables.ee_php_user)) else: Log.info(self, "WordPress debug log already enabled") diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 38553767..8e2bab44 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -203,7 +203,7 @@ class EEStackController(CementBaseController): '/etc/nginx/common') os.makedirs('/etc/nginx/common') - data = dict() + data = dict(webroot=EEVariables.ee_webroot) Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/acl.conf') ee_nginx = open('/etc/nginx/common/acl.conf', 'w') @@ -450,8 +450,9 @@ class EEStackController(CementBaseController): myfile.write("") EEFileUtils.chown(self, "{0}22222" - .format(EEVariables.ee_webroot), 'www-data', - 'www-data', recursive=True) + .format(EEVariables.ee_webroot), + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") EEService.reload_service(self, 'php5-fpm') @@ -644,7 +645,7 @@ class EEStackController(CementBaseController): " receive_override_options=no_header_body" "_checks/\" /etc/postfix/master.cf") - amavis_master = """smtp-amavis unix - - n - 2 smtp + amavis_master = ("""smtp-amavis unix - - n - 2 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes @@ -665,9 +666,9 @@ class EEStackController(CementBaseController): -o smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 - -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks - -o local_header_rewrite_clients= -""" + -o receive_override_options=no_header_body_checks,""" + + """no_unknown_recipient_check + -o local_header_rewrite_clients=""") with open("/etc/postfix/master.cf", "a") as am_config: am_config.write(amavis_master) @@ -709,11 +710,9 @@ class EEStackController(CementBaseController): shutil.move('/tmp/phpmyadmin-STABLE/', '{0}22222/htdocs/db/pma/' .format(EEVariables.ee_webroot)) - Log.debug(self, 'Setting Privileges of www-data:www-data to ' + Log.debug(self, 'Setting Privileges of webroot permission to ' '{0}22222/htdocs/db/pma file ' .format(EEVariables.ee_webroot)) - # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - # '/var/www/22222/htdocs/db/pma') EEFileUtils.chown(self, '{0}22222' .format(EEVariables.ee_webroot), EEVariables.ee_php_user, @@ -730,8 +729,6 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting Privileges to " "{0}22222/htdocs/cache/memcache file" .format(EEVariables.ee_webroot)) - # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - # '/var/www/22222/htdocs/cache/memcache') EEFileUtils.chown(self, '{0}22222' .format(EEVariables.ee_webroot), EEVariables.ee_php_user, @@ -757,11 +754,9 @@ class EEStackController(CementBaseController): "/usr/bin/dot\'\" {0}22222/htdocs/" "php/webgrind/config.php" .format(EEVariables.ee_webroot)) - Log.debug(self, "Setting Privileges of www-data:www-data to " + Log.debug(self, "Setting Privileges of webroot permission to " "{0}22222/htdocs/php/webgrind/ file " .format(EEVariables.ee_webroot)) - # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - # '/var/www/22222/htdocs/php/webgrind/') EEFileUtils.chown(self, '{0}22222' .format(EEVariables.ee_webroot), EEVariables.ee_php_user, @@ -858,7 +853,8 @@ class EEStackController(CementBaseController): # Custom Vimbadmin configuration by EasyEngine data = dict(salt=vm_salt, host=EEVariables.ee_mysql_host, - password=vm_passwd) + password=vm_passwd, + php_user=EEVariables.ee_php_user) Log.debug(self, 'Writting the ViMbAdmin configuration to ' 'file {0}22222/htdocs/vimbadmin/application/' 'configs/application.ini' @@ -1017,7 +1013,7 @@ class EEStackController(CementBaseController): static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, - webroot='/var/www', ee_db_name='', + webroot=EEVariables.ee_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', rc=True) diff --git a/ee/cli/templates/22222.mustache b/ee/cli/templates/22222.mustache index ab6d6a5c..c0897d54 100644 --- a/ee/cli/templates/22222.mustache +++ b/ee/cli/templates/22222.mustache @@ -7,13 +7,13 @@ server { access_log /var/log/nginx/22222.access.log rt_cache; error_log /var/log/nginx/22222.error.log; - ssl_certificate /var/www/22222/cert/22222.crt; - ssl_certificate_key /var/www/22222/cert/22222.key; + ssl_certificate {{webroot}}22222/cert/22222.crt; + ssl_certificate_key {{webroot}}22222/cert/22222.key; # Force HTTP to HTTPS error_page 497 =200 https://$host:22222$request_uri; - root /var/www/22222/htdocs; + root {{webroot}}22222/htdocs; index index.php index.htm index.html; # Turn on directory listing @@ -45,16 +45,16 @@ server { } location ~* \.(js|css|jpg|gif|png)$ { - root /var/www/22222/htdocs/; + root {{webroot}}22222/htdocs/; } location ~* /vimbadmin/public/(.*)/(.*) { - root /var/www/22222/htdocs/vimbadmin/public; + root {{webroot}}22222/htdocs/vimbadmin/public; try_files $uri $uri/ /vimbadmin/public/index.php?$args; } location ~* /vimbadmin/public/(.*) { - root /var/www/22222/htdocs/vimbadmin/public; + root {{webroot}}22222/htdocs/vimbadmin/public; try_files $uri $uri/ /vimbadmin/public/index.php?$args; } diff --git a/ee/cli/templates/vimbadmin.mustache b/ee/cli/templates/vimbadmin.mustache index 16f54d51..808d57ce 100644 --- a/ee/cli/templates/vimbadmin.mustache +++ b/ee/cli/templates/vimbadmin.mustache @@ -628,8 +628,8 @@ resources.session.remember_me_seconds = 3600 resources.session.name = 'VIMBADMIN3' ondemand_resources.logger.writers.stream.path = APPLICATION_PATH "/../var/log" -ondemand_resources.logger.writers.stream.owner = www-data -ondemand_resources.logger.writers.stream.group = www-data +ondemand_resources.logger.writers.stream.owner = {{php_user}} +ondemand_resources.logger.writers.stream.group = {{php_user}} ondemand_resources.logger.writers.stream.mode = single ondemand_resources.logger.writers.stream.logname = vimbadmin.log From fa7040d77a7f5479695cec9791869bfaee2a3db2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 19:30:16 +0530 Subject: [PATCH 804/829] EMail validation on setup.py --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index 87d6a385..88863ee6 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ import sys import os import glob import configparser +import re conf = [] templates = [] @@ -39,6 +40,12 @@ except Exception as e: ee_user = input("Enter your name: ") ee_email = input("Enter your email: ") + + while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", + ee_email): + print("EMail not Valid, Please enter again") + 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)) From cd9e456efc10a257f04d84c3c20494c9dfe0b1c9 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 6 Feb 2015 15:45:07 +0530 Subject: [PATCH 805/829] change in messages --- ee/cli/plugins/stack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 38553767..23f9d8ab 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -75,7 +75,7 @@ class EEStackController(CementBaseController): def pre_pref(self, apt_packages): """Pre settings to do before installation packages""" if set(EEVariables.ee_postfix).issubset(set(apt_packages)): - Log.info(self, "Pre-seeding Postfix") + Log.debug(self, "Pre-seeding Postfix") EEShellExec.cmd_exec(self, "echo \"postfix postfix" "/main_mailer_type string \'Internet Site\'\"" " | debconf-set-selections") @@ -90,7 +90,7 @@ class EEStackController(CementBaseController): EERepo.add_key(self, '1C4CBDCDCD2EFD2A', keyserver="subkeys.pgp.net") chars = ''.join(random.sample(string.ascii_letters, 8)) - Log.info(self, "Pre-seeding MySQL") + Log.debug(self, "Pre-seeding MySQL") EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 " "percona-server-server/root_password " "password {chars}\" | " From 2e5093202358eda1be0ec9e91d771bc74f472d99 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 6 Feb 2015 15:45:28 +0530 Subject: [PATCH 806/829] README changes --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 80779333..d25795c7 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ IMPORTANT [![Travis Build Status](https://travis-ci.org/rtCamp/easyengine.svg "Travis Build Status")] (https://travis-ci.org/rtCamp/easyengine) -EasyEngine (ee) is a linux shell-script collection, which makes it easy to manage your wordpress sites running on nginx web-server. +EasyEngine (ee) is a python tool, which makes it easy to manage your wordpress sites running on nginx web-server. **EasyEngine currently supports:** @@ -94,5 +94,4 @@ ee site create example.com --mysql # create example.com with php & mysql supp [![Donate](https://cloud.githubusercontent.com/assets/4115/5297691/c7b50292-7bd7-11e4-987b-2dc21069e756.png)] (https://rtcamp.com/donate/?project=easyengine) ## License - -Same [GPL] (http://www.gnu.org/licenses/gpl-2.0.txt) that WordPress uses! +[MIT] (http://opensource.org/licenses/MIT) From 118f25a0f108d5da8ac5a96dd93d0693c7207ae2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Fri, 6 Feb 2015 16:20:27 +0530 Subject: [PATCH 807/829] Added MIT license --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/LICENSE b/LICENSE index e69de29b..61e6ab0e 100644 --- a/LICENSE +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 rtCamp solutions private limited + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. From 17d2cbde754c05ce0e36cc15d0c3df66ff54b4f6 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Mon, 9 Feb 2015 13:10:38 +0530 Subject: [PATCH 808/829] updated roudcube mail --- ee/core/variables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 9c97032d..2118922e 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -17,7 +17,7 @@ class EEVariables(): # EasyEngine packages versions ee_wp_cli = "0.18.0" ee_adminer = "4.1.0" - ee_roundcube = "1.0.5" + ee_roundcube = "1.1.0" ee_vimbadmin = "3.0.11" # Current date and time of System From 0c1c9574bd8b8d07fcdbf3538ca3dfdad8614b62 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 9 Feb 2015 13:44:02 +0530 Subject: [PATCH 809/829] Fixed Travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 30990a81..b5b08931 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ before_script: - sudo service hostname restart - sudo apt-get -qq purge mysql* graphviz* - sudo apt-get -qq autoremove + - sudo apt-get update script: - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig From a71bdfdea7ecaf0361d9926b5c0717449584b9d2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Mon, 9 Feb 2015 18:13:30 +0530 Subject: [PATCH 810/829] Fixed Roundcube 1.1 installation issue --- ee/cli/plugins/stack.py | 5 +++++ ee/core/variables.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 06485e32..1cf8e729 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -963,6 +963,11 @@ class EEStackController(CementBaseController): '{0}roundcubemail/htdocs' .format(EEVariables.ee_webroot)) + # Install Roundcube depednet pear packages + EEShellExec.cmd_exec(self, "pear install Mail_Mime Net_SMTP" + " Mail_mimeDecode Net_IDNA2-beta " + "Auth_SASL Net_Sieve Crypt_GPG") + # Configure roundcube database rc_passwd = ''.join(random.sample(string.ascii_letters, 8)) Log.debug(self, "Creating Database roundcubemail") diff --git a/ee/core/variables.py b/ee/core/variables.py index c7e795e8..91eace30 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -105,7 +105,7 @@ class EEVariables(): ee_mail = ["dovecot-core", "dovecot-imapd", "dovecot-pop3d", "dovecot-lmtpd", "dovecot-mysql", "dovecot-sieve", "dovecot-managesieved", "postfix-mysql", "php5-cgi", - "php-gettext"] + "php-gettext", "php-pear"] # Mailscanner repo and packages ee_mailscanner_repo = () From 73f8f6971c2119fab56fb0366b9c38b7c6216367 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Mon, 9 Feb 2015 19:22:10 +0530 Subject: [PATCH 811/829] prevent password logging --- ee/cli/plugins/site_functions.py | 44 +++++++++++++++++++++++++++++--- ee/core/aptget.py | 31 ++++++++++++++-------- ee/core/shellexec.py | 5 ++-- 3 files changed, 64 insertions(+), 16 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index a4cd3ac5..b12d3673 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -177,6 +177,15 @@ def setupwordpress(self, data): Log.debug(self, "Setting up wp-config file") if not data['multisite']: Log.debug(self, "Generating wp-config for WordPress Single site") + Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root " + + "core config " + + "--dbname={0} --dbprefix={1} --dbuser={2} " + .format(data['ee_db_name'], ee_wp_prefix, + data['ee_db_user']) + + "--dbpass= " + "--extra-php< Date: Tue, 10 Feb 2015 10:43:12 +0530 Subject: [PATCH 812/829] Fixed Postfix --- ee/cli/plugins/stack.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 1cf8e729..67176200 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -666,8 +666,6 @@ class EEStackController(CementBaseController): -o smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 - -o receive_override_options=no_header_body_checks,""" + - """no_unknown_recipient_check -o local_header_rewrite_clients=""") with open("/etc/postfix/master.cf", "a") as am_config: From 87d36b4544de3497e9c2d2f1393db9286a06b754 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 10 Feb 2015 11:58:04 +0530 Subject: [PATCH 813/829] added code for ee stack install --all,ee stack remove --all, ee stack purge --all --- ee/cli/plugins/stack.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 06485e32..77001965 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -40,6 +40,8 @@ class EEStackController(CementBaseController): stacked_type = 'nested' description = 'Stack command manages stack operations' arguments = [ + (['--all'], + dict(help='Install web stack', action='store_true')), (['--web'], dict(help='Install web stack', action='store_true')), (['--admin'], @@ -1072,6 +1074,11 @@ class EEStackController(CementBaseController): (not self.app.pargs.mailscanner)): self.app.pargs.web = True + if self.app.pargs.all: + self.app.pargs.web = True + self.app.pargs.admin = True + self.app.pargs.mail = True + if self.app.pargs.web: Log.debug(self, "Setting apt_packages variable for Nginx ,PHP" " ,MySQL ") @@ -1274,6 +1281,11 @@ class EEStackController(CementBaseController): (not self.app.pargs.mailscanner)): self.app.pargs.web = True + if self.app.pargs.all: + self.app.pargs.web = True + self.app.pargs.admin = True + self.app.pargs.mail = True + if self.app.pargs.web: self.app.pargs.nginx = True self.app.pargs.php = True @@ -1363,6 +1375,11 @@ class EEStackController(CementBaseController): (not self.app.pargs.mailscanner)): self.app.pargs.web = True + if self.app.pargs.all: + self.app.pargs.web = True + self.app.pargs.admin = True + self.app.pargs.mail = True + if self.app.pargs.web: self.app.pargs.nginx = True self.app.pargs.php = True From 1692b9e0ad874e117f5554c4cf7759752a54e539 Mon Sep 17 00:00:00 2001 From: "shital.rtcamp" Date: Tue, 10 Feb 2015 12:00:27 +0530 Subject: [PATCH 814/829] change stack description --- ee/cli/plugins/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index d18a44d4..8c27ba82 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -41,7 +41,7 @@ class EEStackController(CementBaseController): description = 'Stack command manages stack operations' arguments = [ (['--all'], - dict(help='Install web stack', action='store_true')), + dict(help='Install all stack', action='store_true')), (['--web'], dict(help='Install web stack', action='store_true')), (['--admin'], From 08beab255b889b0524cdc54474d1a7dd41e2aa0f Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 10 Feb 2015 12:03:43 +0530 Subject: [PATCH 815/829] Fixed Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b5b08931..4c1e15aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ before_script: script: - sudo echo -e "[user]\n\tname = abc\n\temail = root@localhost.com" > ~/.gitconfig - sudo echo "Travis Banch = $TRAVIS_BRANCH" - - sudo apt-get install git python3-setuptools python3-dev python3-apt + - sudo apt-get install -y --force-yes git python3-setuptools python3-dev python3-apt - sudo python3 setup.py install - sudo ee --help - sudo ee stack install From b3731527feb1f5d7410cc0cfd4a4ea726ca7cb97 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Tue, 10 Feb 2015 19:54:01 +0530 Subject: [PATCH 816/829] Better setup handling --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 88863ee6..a7f5a3f3 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,10 @@ except Exception as e: print("EasyEngine (ee) will NEVER send your information across") ee_user = input("Enter your name: ") + while ee_user is "": + print("Name not Valid, Please enter again") + ee_user = input("Enter your name: ") + ee_email = input("Enter your email: ") while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", From 9c524ec3cb8f072c9a1eba98d941cd430b6c2f26 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 10 Feb 2015 20:32:07 +0530 Subject: [PATCH 817/829] redirected apt cache update logs to log file --- ee/cli/plugins/site.py | 4 ++-- ee/core/aptget.py | 35 ++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index e3d603c9..f73ea40c 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -1,4 +1,4 @@ -"""EasyEngine site controller.""" +# """EasyEngine site controller.""" from cement.core.controller import CementBaseController, expose from cement.core import handler, hook from ee.core.variables import EEVariables @@ -913,7 +913,7 @@ class EESiteUpdateController(CementBaseController): msg="{0} updated with {1} {2}" .format(ee_www_domain, stype, cache)) # Setup Permissions for webroot - # setwebrootpermissions(self, data['webroot']) + setwebrootpermissions(self, data['webroot']) if ee_auth and len(ee_auth): for msg in ee_auth: Log.info(self, Log.ENDC + msg) diff --git a/ee/core/aptget.py b/ee/core/aptget.py index 04fce81c..b33b3d1d 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -15,15 +15,19 @@ class EEAptGet(): """ try: apt_cache = apt.cache.Cache() - apt_cache.update() - success = (apt_cache.commit( - apt.progress.text.AcquireProgress(), - apt.progress.base.InstallProgress())) - #apt_cache.close() - return success + import sys + orig_out = sys.stdout + sys.stdout = open(self.app.config.get('log.logging', 'file'), 'a') + apt_cache.update(apt.progress.text.AcquireProgress()) + sys.stdout = orig_out + # success = (apt_cache.commit( + # apt.progress.text.AcquireProgress(), + # apt.progress.base.InstallProgress())) + # #apt_cache.close() + # return success except AttributeError as e: Log.error(self, 'AttributeError: ' + str(e)) - except FetchFailedException as e: + except Exception as e: Log.debug(self, 'SystemError: ' + str(e)) Log.error(self, 'Unable to Fetch update') @@ -85,7 +89,12 @@ class EEAptGet(): if apt_cache.install_count > 0: try: #apt_pkg.PkgSystemUnLock() - result = apt_cache.commit() + orig_out = sys.stdout + sys.stdout = open(self.app.config.get('log.logging', 'file'), + 'a') + result = apt_cache.commit(apt.progress.text.AcquireProgress(), + apt.progress.base.InstallProgress()) + sys.stdout = orig_out #apt_cache.close() return result except SystemError as e: @@ -134,7 +143,12 @@ class EEAptGet(): if apt_cache.delete_count > 0: try: # apt_pkg.PkgSystemUnLock() - result = apt_cache.commit() + orig_out = sys.stdout + sys.stdout = open(self.app.config.get('log.logging', 'file'), + 'a') + result = apt_cache.commit(apt.progress.text.AcquireProgress(), + apt.progress.base.InstallProgress()) + sys.stdout = orig_out # apt_cache.close() return result except SystemError as e: @@ -150,7 +164,10 @@ class EEAptGet(): Similar to `apt-get autoclean` """ try: + orig_out = sys.stdout + sys.stdout = open(self.app.config.get('log.logging', 'file'), 'a') apt_get.autoclean("-y") + sys.stdout = orig_out except ErrorReturnCode as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to apt-get autoclean") From c13ad394b7a3214d0595b0999061ff5a9b83e0b2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 11 Feb 2015 10:42:58 +0530 Subject: [PATCH 818/829] Changed version to 3.0.0 and ready for release --- ee/core/variables.py | 2 +- install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/core/variables.py b/ee/core/variables.py index 91eace30..dfd820a2 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.0-beta" + ee_version = "3.0.0" # EasyEngine packages versions ee_wp_cli = "0.18.0" diff --git a/install b/install index 1b3a5fc2..df70c14c 100644 --- a/install +++ b/install @@ -154,7 +154,7 @@ function install_ee3() # Clone EE 3.0 Python branch ee_lib_echo "Cloning EasyEngine 3.0" if [ "$branch" = "" ]; then - branch=python + branch=stable fi 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 From b4d30de9a6a44eaa78fb59693486e1ae02951ab7 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 11 Feb 2015 11:02:11 +0530 Subject: [PATCH 819/829] EasyEngine 3.0 --- config/ee.conf | 10 +++++++++- docs/cs.md | 13 ------------- docs/ds.md | 21 --------------------- 3 files changed, 9 insertions(+), 35 deletions(-) delete mode 100644 docs/cs.md delete mode 100644 docs/ds.md diff --git a/config/ee.conf b/config/ee.conf index ce68b3e5..7472f571 100644 --- a/config/ee.conf +++ b/config/ee.conf @@ -40,22 +40,30 @@ max_files = 7 [stack] -ip-address = 0.0.0.0/0 1.1.1.1 2.2.2.2 +### IP address that will be used in Nginx configurations while installing +ip-address = 127.0.0.1 [mysql] +### MySQL database grant host name grant-host = localhost +### Ask for MySQL db name while site creation db-name = False +### Ask for MySQL user name while site creation db-user = False [wordpress] +### Ask for WordPress prefix while site creation prefix = False +### User name for WordPress sites user = +### Password for WordPress sites password = +### EMail for WordPress sites email = diff --git a/docs/cs.md b/docs/cs.md deleted file mode 100644 index 42122c8c..00000000 --- a/docs/cs.md +++ /dev/null @@ -1,13 +0,0 @@ - -## EasyEngine coding standard - - For contributing EasyEngine you must follow [PEP8](https://www.python.org/dev/peps/pep-0008) style guide. - -- Indentation - - - 4 spaces shoule be used as Indentation as mentioned in above style guide. - -- Class Name - - - -- Function Name - diff --git a/docs/ds.md b/docs/ds.md deleted file mode 100644 index 60ec69c4..00000000 --- a/docs/ds.md +++ /dev/null @@ -1,21 +0,0 @@ - -**EasyEngine 3.x Ditectory Structure** - -``` -easyengine -|-- config -| `-- plugins.d -|-- ee -| |-- cli -| | |-- controllers -| | |-- ext -| | |-- plugins -| | `-- templates -| |-- core -| `-- utils -`-- tests - |-- cli - | |-- ext - | `-- plugins - `-- core -``` From e5174cb0503ffa2c85f6105a9932fa97a625f8c4 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 11 Feb 2015 11:02:56 +0530 Subject: [PATCH 820/829] Updated readme and Liscense --- LICENSE | 2 +- README.md | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index 61e6ab0e..f43e98ae 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 rtCamp solutions private limited +Copyright (c) 2015 rtCamp Solutions Private Limited Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index d25795c7..4b9a1925 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,14 @@ EasyEngine (ee) is a python tool, which makes it easy to manage your wordpress s **EasyEngine currently supports:** -- Ubuntu 12.04 & 14.04 +- Ubuntu 12.04 & 14.04, 14.10 - Debian 7 -### This is Beta version. Donot Try on Production/Live servers ## Quick Start ```bash -wget http://rt.cx/eebeta && sudo bash eebeta # install easyengine 3.0.0-beta +wget http://rt.cx/ee && sudo bash ee # install easyengine 3.0.0-beta sudo ee site create example.com --wp # Install required packages & setup WordPress on example.com ``` @@ -85,7 +84,7 @@ ee site create example.com --mysql # create example.com with php & mysql supp ## Useful Links -- [Documentation] (http://rtcamp.com/easyengine/docs/) +- [Documentation] (http://docs.rtcamp.com/easyengine/docs/) - [FAQ] (http://rtcamp.com/easyengine/faq/) - [Conventions used] (http://rtcamp.com/wordpress-nginx/tutorials/conventions/) From c8aa4eea96f53257746c684fbc2c533db9dbf8c5 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 11 Feb 2015 11:04:23 +0530 Subject: [PATCH 821/829] Minor change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b9a1925..46ff2e40 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ ee site create example.com --mysql # create example.com with php & mysql supp ## Useful Links - [Documentation] (http://docs.rtcamp.com/easyengine/docs/) -- [FAQ] (http://rtcamp.com/easyengine/faq/) +- [FAQ] (http://docs.rtcamp.com/easyengine/faq/) - [Conventions used] (http://rtcamp.com/wordpress-nginx/tutorials/conventions/) ## Donations From f8bae67e1f023d3640b00455c1b4426aa2627115 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 11 Feb 2015 11:14:46 +0530 Subject: [PATCH 822/829] Updated README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46ff2e40..c602c12a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ EasyEngine (ee) is a python tool, which makes it easy to manage your wordpress s **EasyEngine currently supports:** -- Ubuntu 12.04 & 14.04, 14.10 +- Ubuntu 12.04 & 14.04 - Debian 7 From 3a93d7d76307236ab33fac98cafe3c52dcdcb570 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 11 Feb 2015 11:17:43 +0530 Subject: [PATCH 823/829] renoved unused docs --- docs/README.md | 11 ----------- docs/cs.md | 13 ------------- docs/ds.md | 21 --------------------- 3 files changed, 45 deletions(-) delete mode 100644 docs/README.md delete mode 100644 docs/cs.md delete mode 100644 docs/ds.md diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index a18a5a87..00000000 --- a/docs/README.md +++ /dev/null @@ -1,11 +0,0 @@ -**Framework** - -EasyEngine 3.x is based on cement cli application developement framework - -Cement version 2.4.0 - -Know more about Cement From [here](http://builtoncement.com/2.4/) - -**Language** - -EasyEngine intend to use latest version of Python i.e 3.4 to avoid future refactoring. diff --git a/docs/cs.md b/docs/cs.md deleted file mode 100644 index 42122c8c..00000000 --- a/docs/cs.md +++ /dev/null @@ -1,13 +0,0 @@ - -## EasyEngine coding standard - - For contributing EasyEngine you must follow [PEP8](https://www.python.org/dev/peps/pep-0008) style guide. - -- Indentation - - - 4 spaces shoule be used as Indentation as mentioned in above style guide. - -- Class Name - - - -- Function Name - diff --git a/docs/ds.md b/docs/ds.md deleted file mode 100644 index 60ec69c4..00000000 --- a/docs/ds.md +++ /dev/null @@ -1,21 +0,0 @@ - -**EasyEngine 3.x Ditectory Structure** - -``` -easyengine -|-- config -| `-- plugins.d -|-- ee -| |-- cli -| | |-- controllers -| | |-- ext -| | |-- plugins -| | `-- templates -| |-- core -| `-- utils -`-- tests - |-- cli - | |-- ext - | `-- plugins - `-- core -``` From d966157e7db11144e16b09e27ab1444f6ab43a79 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 11 Feb 2015 11:32:39 +0530 Subject: [PATCH 824/829] Updated update script --- install | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/install b/install index df70c14c..8f0046bd 100644 --- a/install +++ b/install @@ -214,28 +214,28 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -# 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 your system" - exit 1 - fi -else +if [ -f /usr/local/sbin/easyengine ]; then # 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 + ee_lib_echo "EasyEngine $old_ee_version not found on your system" + ee_lib_echo "Updating your EasyEngine to $old_ee_version for compability" + wget https://raw.githubusercontent.com/rtCamp/easyengine/old-stable/bin/update && bash update + if [[ $? -ne 0 ]]; then + ee_lib_echo_info "Unbale to update EasyEngine2 to $old_ee_version" + exit 1 + fi fi install_dep sync_db install_ee3 update_to_ee3 git_init +elif [ ! -f /usr/local/bin/ee ]; then + install_dep + install_ee3 + git_init +else + ee_lib_echo_fail "EasyEngine 3 allready installed on your system" + exit 1 fi From 0af2c62fb94c09c3e0e46c81ddc44e4e1895b862 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 11 Feb 2015 11:37:07 +0530 Subject: [PATCH 825/829] Updated EasyEngine --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c602c12a..5c8daf23 100644 --- a/README.md +++ b/README.md @@ -30,10 +30,10 @@ sudo ee site create example.com --wp # Install required packages & setup Wor ## Update EasyEngine -Update Procedure For EasyEngine to version 3.0.0-beta +Update Procedure For EasyEngine to version 3.0 ```bash -wget http://rt.cx/eebeta && sudo bash install +wget http://rt.cx/ee && sudo bash install ``` ## More Site Creation Commands From 1895956e0f74ac2fd1c7baba48e9f5af190a87c4 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 11 Feb 2015 11:38:39 +0530 Subject: [PATCH 826/829] EE 3.0 --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index 8f0046bd..9cd185a0 100644 --- a/install +++ b/install @@ -220,7 +220,7 @@ if [ -f /usr/local/sbin/easyengine ]; then if [[ $? -ne 0 ]]; then ee_lib_echo "EasyEngine $old_ee_version not found on your system" ee_lib_echo "Updating your EasyEngine to $old_ee_version for compability" - wget https://raw.githubusercontent.com/rtCamp/easyengine/old-stable/bin/update && bash update + wget -q https://raw.githubusercontent.com/rtCamp/easyengine/old-stable/bin/update && bash update if [[ $? -ne 0 ]]; then ee_lib_echo_info "Unbale to update EasyEngine2 to $old_ee_version" exit 1 From c09972868eb05b924cdeb1733d17c08b47344e2a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 11 Feb 2015 11:46:19 +0530 Subject: [PATCH 827/829] updated ee update command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c8daf23..aa033b60 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ sudo ee site create example.com --wp # Install required packages & setup Wor Update Procedure For EasyEngine to version 3.0 ```bash -wget http://rt.cx/ee && sudo bash install +wget -q http://rt.cx/ee && sudo bash install ``` ## More Site Creation Commands From 00ce444140b0bf2e595be9640650b4e8eae92b39 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Wed, 11 Feb 2015 12:05:14 +0530 Subject: [PATCH 828/829] Workaround for command not error --- install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install b/install index 9cd185a0..bb2cb291 100644 --- a/install +++ b/install @@ -193,6 +193,9 @@ function update_to_ee3() 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 + # Softlink to fix command not found error + ln -s /usr/local/bin/ee /usr/local/sbin/ee + } function git_init() From 4a401e40db663521522958b48ee96ac8e5db48b4 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 11 Feb 2015 12:25:01 +0530 Subject: [PATCH 829/829] Minor update --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aa033b60..5883aaaa 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ EasyEngine (ee) is a python tool, which makes it easy to manage your wordpress s ## Quick Start ```bash -wget http://rt.cx/ee && sudo bash ee # install easyengine 3.0.0-beta +wget -q http://rt.cx/ee && sudo bash ee # install easyengine 3.0.0-beta sudo ee site create example.com --wp # Install required packages & setup WordPress on example.com ``` @@ -33,7 +33,7 @@ sudo ee site create example.com --wp # Install required packages & setup Wor Update Procedure For EasyEngine to version 3.0 ```bash -wget -q http://rt.cx/ee && sudo bash install +wget -q http://rt.cx/ee && sudo bash ee ``` ## More Site Creation Commands