Browse Source

code optimized

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

14
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

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
}

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

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

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