5 changed files with 69 additions and 74 deletions
@ -0,0 +1,69 @@ |
|||||
|
# NGINX debug |
||||
|
|
||||
|
function ee_mod_debug_nginx() |
||||
|
{ |
||||
|
if [ "$1" = "start" ]; then |
||||
|
if [ -z $EE_DOMAIN ]; then |
||||
|
# Enable NGINX debug for all IP |
||||
|
if [ -z "$EE_IP_ADDRESS" ]; then |
||||
|
# Global IP |
||||
|
EE_IP_ADDRESS="0.0.0.0/0" |
||||
|
fi |
||||
|
|
||||
|
for ee_ip in $EE_IP_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 |
||||
|
else |
||||
|
grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG |
||||
|
if [ $? -ne 0 ]; then |
||||
|
ee_lib_echo "Enable debug for $EE_DOMAIN, please wait..." |
||||
|
sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$EE_DOMAIN \ |
||||
|
|| ee_lib_error "Unable to activate debug for $EE_DOMAIN, exit status = " $? |
||||
|
# NGINX reload trigger |
||||
|
EE_TRIGGER_NGINX="true" |
||||
|
else |
||||
|
# Display message |
||||
|
ee_lib_echo "Already enabled debug for $EE_DOMAIN" |
||||
|
fi |
||||
|
fi |
||||
|
elif [ "$1" = "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 debug for $EE_DOMAIN, please wait..." |
||||
|
sed -i "s/error.log debug;/error.log;/" /etc/nginx/sites-available/$EE_DOMAIN \ |
||||
|
|| ee_lib_error "Unable to deactivate debug for $EE_DOMAIN, exit status = " $? |
||||
|
# NGINX reload trigger |
||||
|
EE_TRIGGER_NGINX="true" |
||||
|
else |
||||
|
# Display message |
||||
|
ee_lib_echo "Already enabled debug for $EE_DOMAIN" |
||||
|
fi |
||||
|
fi |
||||
|
fi |
||||
|
} |
@ -1,15 +0,0 @@ |
|||||
# 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 |
|
||||
} |
|
@ -1,15 +0,0 @@ |
|||||
# 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 |
|
||||
} |
|
@ -1,30 +0,0 @@ |
|||||
# 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 |
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
# 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 |
|
||||
} |
|
Loading…
Reference in new issue