
Log command code refactored, messages improved, HTTPS links, Ondrej repo ppa key fixed, source folder issue.
75 lines
1.9 KiB
Bash
75 lines
1.9 KiB
Bash
#!/bin/bash
|
|
|
|
# View logs in real time Plugins
|
|
# Syntax: log <domain> <option>
|
|
# Options: -wp, -error (access log is default and have no option)
|
|
# Notes: If no domain is entered, access logs are displayed.
|
|
|
|
source /opt/webinoly/lib/general
|
|
domain="$1"
|
|
opt="$2"
|
|
|
|
error() {
|
|
echo ""
|
|
echo "${red} Log file not found!!! ${end}"
|
|
echo ""
|
|
exit 1
|
|
}
|
|
|
|
if [[ -z $opt ]]; then
|
|
case "$domain" in
|
|
"-mail")
|
|
if [[ -a /var/log/mail.log && -a /var/log/mail.err ]]; then
|
|
sudo tail -f /var/log/mail.log /var/log/mail.err
|
|
elif [[ -a /var/log/mail.log ]]; then
|
|
sudo tail -f /var/log/mail.log
|
|
elif [[ -a /var/log/mail.err ]]; then
|
|
sudo tail -f /var/log/mail.err
|
|
else
|
|
error
|
|
fi
|
|
;;
|
|
"-fpm"|"-php")
|
|
if [[ -a /var/log/php/$(conf_read php-ver)/fpm.log ]]; then
|
|
sudo tail -f /var/log/php/$(conf_read php-ver)/*.log
|
|
else
|
|
error
|
|
fi
|
|
;;
|
|
"-mysql")
|
|
if [[ -a /var/log/mysql/error.log ]]; then
|
|
sudo tail -f /var/log/mysql/*.log
|
|
else
|
|
error
|
|
fi
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
|
|
# Validations
|
|
if [[ "$domain" == "-error" || "$domain" == "-wp" ]]; then
|
|
domain="$2"
|
|
opt="$1"
|
|
fi
|
|
|
|
if [[ -n "$opt" && "$opt" != "-error" && "$opt" != "-wp" ]]; then
|
|
echo "${red} $opt is not a valid option!${end}"
|
|
exit 1
|
|
fi
|
|
|
|
|
|
# Show the correct log file
|
|
if [[ "$opt" == "-error" && -z "$domain" && -a /var/log/nginx/error.log ]]; then
|
|
sudo tail -f /var/log/nginx/*error.log
|
|
elif [[ "$opt" == "-error" && -n "$domain" && -a /var/log/nginx/$domain.error.log ]]; then
|
|
sudo tail -f /var/log/nginx/$domain.error.log
|
|
elif [[ "$opt" == "-wp" && -n "$domain" && -a /var/www/$domain/htdocs/wp-content/debug.log ]]; then
|
|
sudo tail -f /var/www/$domain/htdocs/wp-content/debug.log
|
|
elif [[ -z "$domain" && -z "$opt" && -a /var/log/nginx/access.log ]]; then
|
|
sudo tail -f /var/log/nginx/*access.log
|
|
elif [[ -n "$domain" && -z "$opt" && -a /var/log/nginx/$domain.access.log ]]; then
|
|
sudo tail -f /var/log/nginx/$domain.access.log
|
|
else
|
|
error
|
|
fi
|