Browse Source

code optimized

old-stable
harshadyeola 10 years ago
parent
commit
5f53192185
  1. 12
      bin/easyengine
  2. 41
      src/modules/ee_mod_clean.sh
  3. 1
      src/modules/site/ee_mod_site_log.sh
  4. 48
      src/modules/stack/ee_mod_cache_clean.sh
  5. 14
      src/modules/stack/install/ee_mod_repo_mysql.sh

12
bin/easyengine

@ -46,7 +46,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
# EasyEngine install # EasyEngine install
if [ "$EE_SECOND" = "install" ]; then 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" ] || [ "$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 # Setup NGINX/PHP repository
ee_mod_repo_$EE_THIRD ee_mod_repo_$EE_THIRD
@ -544,8 +544,8 @@ elif [ "$EE_FIRST" = "site" ]; then
ee_lib_service nginx reload ee_lib_service nginx reload
fi fi
elif [ "$EE_SECOND" = "log" ]; then elif [ "$EE_SECOND" = "log" ]; then
# tail -f log # Display logs for websites
ee_mod_site_log ${@:3}|| ee_lib_error "Unable to check logs, exit status = " $? ee_mod_site_log ${@:3}
#EasyEngine cd #EasyEngine cd
elif [ "$EE_SECOND" = "cd" ]; then elif [ "$EE_SECOND" = "cd" ]; then
@ -553,7 +553,7 @@ elif [ "$EE_FIRST" = "site" ]; then
EE_DOMAIN_CHECK=$EE_THIRD EE_DOMAIN_CHECK=$EE_THIRD
ee_lib_check_domain ee_lib_check_domain
#Check the website exist # Check the website exist
ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ 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 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" ee_lib_echo_escape "\t--ip\tUpdate whitelist IP address"
fi fi
# EasyEngine clean # Clean cache
elif [ "$EE_FIRST" = "clean" ]; then elif [ "$EE_FIRST" = "clean" ]; then
ee_mod_cache_clean ${@:2} || ee_lib_error "Unable to clean cache = " $? ee_mod_clean ${@:2}
# EasyEngine update # EasyEngine update

41
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
}

1
src/modules/site/ee_mod_site_log.sh

@ -9,7 +9,6 @@ function ee_mod_site_log()
done done
else else
for ee_domain_name in $@; do for ee_domain_name in $@; do
EE_DOMAIN_CHECK=$ee_domain_name EE_DOMAIN_CHECK=$ee_domain_name
ee_lib_check_domain ee_lib_check_domain

48
src/modules/stack/ee_mod_cache_clean.sh

@ -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
}

14
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 = " $?
}
Loading…
Cancel
Save