gau1991
11 years ago
19 changed files with 393 additions and 39 deletions
@ -0,0 +1,10 @@ |
|||
#Enables debug in interactive mode |
|||
|
|||
function ee_mod_debug_interactive() |
|||
{ |
|||
if [ -z "$EE_DEBUG_SITENAME" ]; then |
|||
tail -f /var/log/nginx/*.error.log /var/log/php5/*.log /var/log/mysql/*.log |
|||
else |
|||
tail -f /var/log/nginx/*.error.log /var/log/php5/*.log /var/log/mysql/*.log /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log |
|||
fi |
|||
} |
@ -0,0 +1,24 @@ |
|||
|
|||
|
|||
function ee_mod_debug_kill() |
|||
{ |
|||
if [ "$EE_DEBUG" = "--start" ]; then |
|||
if [ -z "$EE_DEBUG_SITENAME" ]; then |
|||
ee debug --stop |
|||
else |
|||
ee debug --stop $EE_DEBUG_SITENAME |
|||
fi |
|||
fi |
|||
|
|||
# Unset trap so we don't get infinite loop |
|||
trap - EXIT |
|||
|
|||
# Flush file system buffers |
|||
# More details: info coreutils 'sync invocation' |
|||
sync |
|||
|
|||
# Successfull exit |
|||
exit 0; |
|||
} |
|||
|
|||
trap "ee_mod_debug_kill" EXIT |
@ -0,0 +1,24 @@ |
|||
# Enables MySQL debug mode |
|||
|
|||
function ee_mod_debug_mysql_start() |
|||
{ |
|||
# Check MySql slow logs is on |
|||
#grep slow-query-log /etc/mysql/my.cnf &>> $EE_COMMAND_LOG |
|||
mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG |
|||
|
|||
if [ $? -ne 0 ]; then |
|||
# Enable MySQL slow logs |
|||
ee_lib_echo "Setting up MySQL slow log, please wait..." |
|||
mysql -u -e "set global slow_query_log = 'ON';" |
|||
mysql -u -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" |
|||
mysql -u -e "set global long_query_time=2;" |
|||
mysql -u -e "set global log_queries_not_using_indexes = 'ON';" |
|||
#sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf |
|||
#sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf |
|||
#sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf |
|||
else |
|||
# Lets disable MySQL restart trigger |
|||
#EE_DEBUG_MYSQL="" |
|||
ee_lib_echo "MySQL slow log already enabled" |
|||
fi |
|||
} |
@ -0,0 +1,24 @@ |
|||
# MySQL debug mode |
|||
|
|||
function ee_mod_debug_mysql_stop() |
|||
{ |
|||
# Check MySql slow logs is off |
|||
#grep slow-query-log /etc/mysql/my.cnf &>> $EE_COMMAND_LOG |
|||
mysql -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG |
|||
|
|||
if [ $? -eq 0 ]; then |
|||
# Disable MySQL slow logs |
|||
ee_lib_echo "Stopping MySQL slow log, please wait..." |
|||
mysql -e "set global slow_query_log = 'OFF';" |
|||
mysql -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" |
|||
mysql -e "set global long_query_time=10;" |
|||
mysql -e "set global log_queries_not_using_indexes = 'OFF';" |
|||
#sed -i "/slow-query-log/d" /etc/mysql/my.cnf |
|||
#sed -i "s/long_query_time/#long_query_time/" /etc/mysql/my.cnf |
|||
#sed -i "s/log-queries-not-using-indexes/#log-queries-not-using-indexes/" /etc/mysql/my.cnf |
|||
else |
|||
# Lets disable MySQL restart trigger |
|||
#EE_DEBUG_MYSQL="" |
|||
ee_lib_echo "MySQL slow log already disable" |
|||
fi |
|||
} |
@ -0,0 +1,15 @@ |
|||
# Enables NGINX rewrite_log mode for $EE_DOMAIN |
|||
|
|||
function ee_mod_nginx_rewrite_site_start() |
|||
{ |
|||
grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG |
|||
if [ $? -ne 0 ]; then |
|||
# Enable NGINX rewrite logs |
|||
ee_lib_echo "Setting up NGINX rewrite logs for $EE_DOMAIN" |
|||
sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN |
|||
else |
|||
# Lets disable NGINX reload trigger |
|||
EE_DEBUG_REWRITE="" |
|||
ee_lib_echo "Rewrites logs already on for $EE_DOMAIN" |
|||
fi |
|||
} |
@ -0,0 +1,15 @@ |
|||
# Disables NGINX rewrite_log mode for $EE_DOMAIN |
|||
|
|||
function ee_mod_debug_nginx_rewrite_site_stop() |
|||
{ |
|||
grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG |
|||
if [ $? -eq 0 ]; then |
|||
# Disable NGINX rewrite logs |
|||
ee_lib_echo "Stopping up NGINX rewrite logs for $EE_DOMAIN" |
|||
sed -i "/rewrite_log.*/d" /etc/nginx/sites-available/$EE_DOMAIN |
|||
else |
|||
# Lets disable NGINX reload trigger |
|||
EE_DEBUG_REWRITE="" |
|||
ee_lib_echo "Rewrites logs already stop for $EE_DOMAIN" |
|||
fi |
|||
} |
@ -0,0 +1,15 @@ |
|||
# Enables NGINX rewrite_log mode |
|||
|
|||
function ee_mod_debug_nginx_rewrite_start() |
|||
{ |
|||
grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG |
|||
if [ $? -ne 0 ]; then |
|||
# Enable NGINX rewrite logs |
|||
ee_lib_echo "Setting up NGINX rewrite logs, please wait..." |
|||
sed -i '/http {/a \\trewrite_log on;' /etc/nginx/nginx.conf |
|||
else |
|||
# Lets disable NGINX reload trigger |
|||
EE_DEBUG_REWRITE="" |
|||
ee_lib_echo "NGINX rewrites logs already on" |
|||
fi |
|||
} |
@ -0,0 +1,15 @@ |
|||
# Disables NGINX rewrite_log mode |
|||
|
|||
function ee_mod_debug_nginx_rewrite_stop() |
|||
{ |
|||
grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG |
|||
if [ $? -eq 0 ]; then |
|||
# Disable NGINX rewrite logs |
|||
ee_lib_echo "Stopping NGINX Rewrite Logs, Please Wait..." |
|||
sed -i "/rewrite_log.*/d" /etc/nginx/nginx.conf |
|||
else |
|||
# Lets disable NGINX reload trigger |
|||
EE_DEBUG_REWRITE="" |
|||
ee_lib_echo "NGINX rewrites logs already stop" |
|||
fi |
|||
} |
@ -0,0 +1,15 @@ |
|||
# Enable NGINX site debug mode |
|||
|
|||
function ee_mod_debug_nginx_site_start() |
|||
{ |
|||
grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG |
|||
if [ $? -ne 0 ]; then |
|||
# Enable NGINX debug log |
|||
ee_lib_echo "Setting up $EE_DOMAIN error logs in debugging mode,please wait..." |
|||
sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$EE_DOMAIN |
|||
else |
|||
# Lets disable NGINX reload trigger |
|||
EE_DEBUG_NGINX="" |
|||
ee_lib_echo "Already started $EE_DOMAIN error logs in debugging mode" |
|||
fi |
|||
} |
@ -0,0 +1,15 @@ |
|||
# Disables NGINX site debug mode |
|||
|
|||
function ee_mod_debug_nginx_site_stop() |
|||
{ |
|||
grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG |
|||
if [ $? -eq 0 ]; then |
|||
# Disable NGINX debug log |
|||
ee_lib_echo "Disable $EE_DOMAIN error logs in debugging mode,please wait..." |
|||
sed -i "s/error.log debug;/error.log;/" /etc/nginx/sites-available/$EE_DOMAIN |
|||
else |
|||
# Lets disable NGINX reload trigger |
|||
EE_DEBUG_NGINX="" |
|||
ee_lib_echo "Already stopped $EE_DOMAIN error logs in debugging mode" |
|||
fi |
|||
} |
@ -0,0 +1,30 @@ |
|||
# Enables NGINX debug mode |
|||
|
|||
function ee_mod_debug_nginx_start() |
|||
{ |
|||
# Lets disable NGINX reload trigger |
|||
EE_DEBUG_NGINX="" |
|||
|
|||
if [ -z "$EE_IP_ADDRESS" ]; then |
|||
#read -p "Enter the single IP address for debugging: " EE_IP_ADDRESS |
|||
EE_IP_ADDRESS="0.0.0.0/0" |
|||
fi |
|||
|
|||
for ee_debug_ip_address in $(echo $EE_IP_ADDRESS); do |
|||
grep "debug_connection $ee_debug_ip_address" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG |
|||
if [ $? -ne 0 ]; then |
|||
# Enable debug connection |
|||
ee_lib_echo "Setting up NGINX debug connection, please wait..." |
|||
|
|||
# EasyEngine found new IP address which is not present in nginx.conf |
|||
sed -i "/events {/a \\\t$(echo debug_connection $ee_debug_ip_address\;)" /etc/nginx/nginx.conf |
|||
|
|||
# Lets trigger the NGINX reload |
|||
EE_DEBUG_NGINX="--nginx" |
|||
fi |
|||
done |
|||
|
|||
if [ -z "$EE_DEBUG_NGINX" ]; then |
|||
ee_lib_echo "NGINX debug connection already enabled" |
|||
fi |
|||
} |
@ -0,0 +1,14 @@ |
|||
# Disables NGINX debug mode |
|||
|
|||
function ee_mod_debug_nginx_stop() |
|||
{ |
|||
grep "debug_connection" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG |
|||
if [ $? -eq 0 ]; then |
|||
ee_lib_echo "Stopping NGINX debug connection, please wait..." |
|||
sed -i "/debug_connection.*/d" /etc/nginx/nginx.conf |
|||
else |
|||
# Lets disable NGINX reload trigger |
|||
EE_DEBUG_NGINX="" |
|||
ee_lib_echo "NGINX debug connection already stopped" |
|||
fi |
|||
} |
@ -0,0 +1,14 @@ |
|||
# Enables PHP5-FPM debug mode |
|||
|
|||
function ee_mod_debug_php_fpm_start() |
|||
{ |
|||
grep "log_level = debug" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG |
|||
if [ $? -ne 0 ]; then |
|||
# Enable PHP5-FPM error logs in debug mode |
|||
ee_lib_echo "Setting up PHP5-FPM log level in debug mode, please wait..." |
|||
sed -i "s';log_level.*'log_level = debug'" /etc/php5/fpm/php-fpm.conf |
|||
else |
|||
EE_DEBUG_FPM="" |
|||
ee_lib_echo "PHP5-FPM log level is already in debug mode" |
|||
fi |
|||
} |
@ -0,0 +1,14 @@ |
|||
# Disables PHP5-FPM debug mode |
|||
|
|||
function ee_mod_debug_php_fpm_stop() |
|||
{ |
|||
grep "log_level = notice" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG |
|||
if [ $? -ne 0 ]; then |
|||
# Disable PHP5-FPM error logs in debug mode |
|||
ee_lib_echo "Stopping PHP5-FPM log level in debug mode, please wait..." |
|||
sed -i "s/log_level = debug/log_level = notice/" /etc/php5/fpm/php-fpm.conf |
|||
else |
|||
EE_DEBUG_FPM="" |
|||
ee_lib_echo "PHP5-FPM log level already in notice (default) mode" |
|||
fi |
|||
} |
@ -0,0 +1,32 @@ |
|||
# Enables PHP debug mode |
|||
|
|||
function ee_mod_debug_php_start() |
|||
{ |
|||
# Lets disable PHP restart trigger |
|||
EE_DEBUG_PHP="" |
|||
|
|||
if [ -z $EE_DEBUG_SITENAME ]; then |
|||
grep -B2 9001 /etc/nginx/conf.d/upstream.conf \ |
|||
| grep php &>> $EE_COMMAND_LOG |
|||
if [ $? -ne 0 ]; then |
|||
ee_lib_echo "Enable PHP5-FPM slow log, please wait..." |
|||
sed -i "4 s/9000/9001/" /etc/nginx/conf.d/upstream.conf |
|||
|
|||
# Lets trigger the NGINX reload |
|||
EE_DEBUG_NGINX="--nginx" |
|||
else |
|||
ee_lib_echo "PHP5-FPM slow log already enabled" |
|||
fi |
|||
else |
|||
grep 9001 /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG |
|||
if [ $? -ne 0 ]; then |
|||
ee_lib_echo "Enable PHP5-FPM slow log for $EE_DOMAIN, please wait..." |
|||
sed -i "s/fastcgi_pass.*/fastcgi_pass debug;/g" /etc/nginx/sites-available/$EE_DOMAIN |
|||
|
|||
# Lets trigger the NGINX reload |
|||
EE_DEBUG_NGINX="--nginx" |
|||
else |
|||
ee_lib_echo "PHP5-FPM slow log already enabled for $EE_DOMAIN" |
|||
fi |
|||
fi |
|||
} |
@ -0,0 +1,32 @@ |
|||
# Disables PHP debug mode |
|||
|
|||
function ee_mod_debug_php_stop() |
|||
{ |
|||
# Lets disable PHP restart trigger |
|||
EE_DEBUG_PHP="" |
|||
|
|||
if [ -z $EE_DEBUG_SITENAME ]; then |
|||
grep -B2 9001 /etc/nginx/conf.d/upstream.conf \ |
|||
| grep php &>> $EE_COMMAND_LOG |
|||
if [ $? -eq 0 ]; then |
|||
ee_lib_echo "Disable PHP5-FPM slow log, please wait..." |
|||
sed -i "4 s/9001/9000/" /etc/nginx/conf.d/upstream.conf |
|||
|
|||
# Lets trigger the NGINX reload |
|||
EE_DEBUG_NGINX="--nginx" |
|||
else |
|||
ee_lib_echo "PHP5-FPM slow log already disabled" |
|||
fi |
|||
else |
|||
grep "fastcgi_pass debug;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG |
|||
if [ $? -eq 0 ]; then |
|||
ee_lib_echo "Disable PHP5-FPM slow log for $EE_DOMAIN, please wait..." |
|||
sed -i "s/fastcgi_pass.*/fastcgi_pass php;/g" /etc/nginx/sites-available/$EE_DOMAIN |
|||
|
|||
# Lets trigger NGINX reload |
|||
EE_DEBUG_NGINX="--nginx" |
|||
else |
|||
ee_lib_echo "PHP5-FPM slow log already disabled for $EE_DOMAIN" |
|||
fi |
|||
fi |
|||
} |
@ -0,0 +1,30 @@ |
|||
# Enables WordPress debug mode |
|||
|
|||
function ee_mod_debug_wordpress_start() |
|||
{ |
|||
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 |
|||
# Debug WordPress |
|||
ee_lib_echo "Start WordPress debug logs for $EE_DOMAIN" |
|||
|
|||
# Create debug.log & change 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 debug |
|||
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 |
|||
|
|||
# Install developer plugin |
|||
cd /var/www/$EE_DOMAIN/htdocs/ |
|||
ee_lib_echo "Installing developer plugin, please wait..." |
|||
wp plugin --allow-root install developer &>> $EE_COMMAND_LOG \ |
|||
|| ee_lib_error "Unable to install developer plugin, exit status = " $? |
|||
else |
|||
ee_lib_echo "WordPress debug log already started for $EE_DOMAIN" |
|||
fi |
|||
else |
|||
ee_lib_echo_fail "Unable to find wp-config.php file, seems like not WordPress site" |
|||
fi |
|||
} |
@ -0,0 +1,16 @@ |
|||
# Disables WordPress debug mode |
|||
|
|||
function ee_mod_debug_wordpress_stop() |
|||
{ |
|||
grep "'WP_DEBUG'" /var/www/$EE_DOMAIN/wp-config.php | grep true &>> $EE_COMMAND_LOG |
|||
if [ $? -eq 0 ]; then |
|||
# Stop debug WordPress |
|||
ee_lib_echo "Stopping WordPress debug logs for $EE_DOMAIN" |
|||
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 |
|||
else |
|||
ee_lib_echo "WordPress debug log already stopped for $EE_DOMAIN" |
|||
fi |
|||
} |
Loading…
Reference in new issue