better site check

Now we have an option to check for nginx and php including tools and optim.
Subfolder option now check if subfolder exists.
This commit is contained in:
Cristhian Martínez Ochoa 2020-01-04 18:07:30 -07:00
parent d4d53df0f6
commit 5c47e39782
4 changed files with 21 additions and 19 deletions

View file

@ -69,6 +69,12 @@ check_for_nginx() {
exit 1
fi
}
check_for_nginx_tool() {
if [[ $(conf_read nginx) != "true" || $(conf_read nginx-optim) != "true" || $(conf_read nginx-tool) != "true" ]]; then
echo "${red}[ERROR] NGINX Tools are required and not found! ${end}"
exit 1
fi
}
check_for_php() {
if [[ $(conf_read php) != "true" && $1 == "-ask" ]]; then
echo "${red}"
@ -88,6 +94,12 @@ check_for_php() {
exit 1
fi
}
check_for_php_tool() {
if [[ $(conf_read php) != "true" || $(conf_read php-optim) != "true" || $(conf_read php-tool) != "true" ]]; then
echo "${red}[ERROR] PHP Tools are required and not found! ${end}"
exit 1
fi
}
check_for_mysql() {
if [[ $(conf_read mysql) != "true" && $1 == "-ask" ]]; then
echo "${red}"

View file

@ -52,6 +52,7 @@ site_ssl_on() {
local path=$domain
# Some validations to prevent errors when creating certs.
check_for_nginx_tool
if [[ -n $root && -a /etc/nginx/sites-available/$root ]]; then
path=$root
elif [[ -n $root && ! -a /etc/nginx/sites-available/$root ]]; then
@ -75,22 +76,6 @@ site_ssl_on() {
exit 1
fi
# Check if Letsencrypt is installed
if [[ $(conf_read nginx-tool) != "true" || ! -a /usr/bin/letsencrypt ]]; then
echo "${red}Seems like Let's Encrypt tool is not installed!"
echo "${blu}Do you want to install it now? [y/N]? ${end}"
while read -r -n 1 -s answer; do
answer=${answer:-n}
echo ""
[[ $answer = [YyNn] ]] && break
done
[[ $answer == [Yy] ]] && sudo stack -nginx=force
if [[ $(conf_read nginx-tool) != "true" || ! -a /usr/bin/letsencrypt ]]; then
echo "${red}[ERROR] Let's Encrypt is required and not found! ${end}"
exit 1
fi
fi
echo "${gre}"
echo "*************************************************************************************************"

View file

@ -110,10 +110,12 @@ fi
if [[ -n $subfolder && ! ( $subfolder =~ ^\/([A-Za-z0-9_\/\-]+)?[^\/]$ ) ]]; then
echo "${red}[ERROR] Please, enter a valid value for subfolder!${end}"
exit 1
fi
if [[ -n $subfolder && $type != [123] && -z $delete && -z $cache && -z $yoast_sitemap && -z $multisite_convert && -z $clone_from && -z $replace_content ]]; then
elif [[ -n $subfolder && $type != [123] && -z $delete && -z $cache && -z $yoast_sitemap && -z $multisite_convert && -z $clone_from && -z $replace_content ]]; then
echo "${red}[ERROR] Subfolder option is only supported for WordPress sites!${end}"
exit 1
elif [[ -n $subfolder && ( -n $delete || -n $cache || -n $yoast_sitemap || -n $multisite_convert || -n $clone_from || -n $replace_content ) && ! -d /var/www/$domain/htdocs$subfolder ]]; then
echo "${red}[ERROR] Subfolder not found!${end}"
exit 1
else
subname=$(echo $subfolder | sed "s/\//_/g")
fi
@ -523,6 +525,9 @@ elif [[ -n $ssl ]]; then
elif [[ $ssl == "off" && ! -a /etc/nginx/sites-available/$domain && -a /etc/letsencrypt/live/$domain/cert.pem ]]; then
echo "${red}[WARNING] SSL Orphan-Cert found and will be revoked automatically!${end}"
ssl_revoke
elif [[ -n $domain && ! -f /etc/nginx/sites-available/$domain ]]; then
echo "${red}[ERROR] Domain not found! ${end}"
exit 1
else
echo "${red}[ERROR] Invalid value for SSL command! ${end}"
exit 1

View file

@ -639,7 +639,7 @@ elif [[ -n $smtp ]]; then
elif [[ -n $backup ]]; then
check_for_nginx
check_for_nginx_tool
if [[ $backup == "local" ]]; then
bkp_local_db
elif [[ $backup == "s3" && -n $list ]]; then