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/ diff --git a/bin/easyengine b/bin/easyengine index d6931635..a9f49c6f 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" ] || [ "$EE_THIRD" = "mysql" ]; then # Setup NGINX/PHP repository @@ -146,14 +148,15 @@ 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 + ee_lib_check_fqdn $(hostname -f) + # Install Dovecot ee_mod_install_dovecot - # Install mail scanner packages - ee_mod_install_mailscan # Install ViMbAdmin ee_ven_install_vimbadmin @@ -167,9 +170,6 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then # Configure Dovecot ee_mod_setup_dovecot - # Setup Amavis - ee_mod_setup_mailscan - # Setup ViMbAdmin ee_ven_setup_vimbadmin @@ -178,7 +178,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_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" @@ -188,6 +198,23 @@ 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 + + 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" + ee_lib_echo "Successfully installed mail scanner packages" fi # EasyEngine remove/purge @@ -240,8 +267,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 @@ -252,12 +279,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/bin/install b/bin/install index 24efda35..81e8403c 100644 --- a/bin/install +++ b/bin/install @@ -82,38 +82,20 @@ 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 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 @@ -211,9 +193,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..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,56 +395,45 @@ 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 - - # 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" + # 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/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 ;; diff --git a/src/lib/ee_lib_ram.sh b/src/lib/ee_lib_ram.sh new file mode 100644 index 00000000..3144140d --- /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 < 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 > 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 +} \ No newline at end of file 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' 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/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" 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_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/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/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 75% 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..2c5f0013 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 && \ @@ -25,6 +25,15 @@ 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 + # 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 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..1e0b7dfb 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_sieve.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_sieve.sh @@ -30,5 +30,7 @@ function ee_mod_setup_sieve() # 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/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 = " $? } 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..17cef9ee --- /dev/null +++ b/src/modules/stack/remove/mail/ee_mod_remove_mailscaner.sh @@ -0,0 +1,18 @@ +# 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/ee_ven_install_utils.sh b/src/vendor/ee_ven_install_utils.sh index 502598d1..b211c71f 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 @@ -87,7 +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'@'localhost' IDENTIFIED BY '$ee_anemometer_pass';" + + # 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 \ @@ -103,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/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 @@ -111,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/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 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 } 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