Skip to content

Commit

Permalink
messages improved
Browse files Browse the repository at this point in the history
SSL Messages improved.
General color improved and fixed.
  • Loading branch information
QROkes committed Nov 2, 2018
1 parent c3365e5 commit 43e0f82
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lib/general
Expand Up @@ -61,7 +61,7 @@ db_delete() {
fi
if [[ -z $uroot || -z $proot ]]; then
echo ""
echo "${gre}External DB found in $domain (Press 'Enter' key twice to skip and not delete)"
echo "${gre}External DB found in${blu} $domain ${gre}(Press 'Enter' key twice to skip and not delete)"
read -p "${blu}External DB root username [root]: " uroot
uroot=${uroot:-root}
read -p "External DB root password: " proot
Expand Down
8 changes: 4 additions & 4 deletions lib/install
Expand Up @@ -21,9 +21,9 @@ app_purge() {

set_timezone() {
if [[ -n $(conf_read timezone) ]] && grep -Fxq $(conf_read timezone) /opt/webinoly/lib/timezone.dat; then
[[ $1 == "os" || $1 == "all" ]] && sudo timedatectl set-timezone $(conf_read timezone)
sudo timedatectl set-timezone $(conf_read timezone)
# It's not compatible with multi-php feature.
if [[ ($1 == "php" || $1 == "all") && $(conf_read php) == "true" ]]; then
if [[ $(conf_read php) == "true" ]]; then
sudo sed -i "/date.timezone =/c\date.timezone = $(conf_read timezone)" /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo service php*-fpm reload
fi
Expand Down Expand Up @@ -133,7 +133,7 @@ net.ipv4.conf.default.send_redirects = 0
sudo sed -i "/End of file/i \# WebinolyEnd" /etc/security/limits.conf

swap_create
set_timezone os
set_timezone

sudo sysctl -p -q
sudo systemctl daemon-reload
Expand Down Expand Up @@ -346,7 +346,7 @@ php_optim() {
sudo sed -i "/post_max_size =/c\post_max_size = ${maxuploads}M" /etc/php/$ver/fpm/php.ini
sudo sed -i '/max_file_uploads =/c\max_file_uploads = 20' /etc/php/$ver/fpm/php.ini
sudo sed -i '/session.cookie_httponly =/c\session.cookie_httponly = 1' /etc/php/$ver/fpm/php.ini
set_timezone php
set_timezone

sudo mkdir -p /var/log/php/$ver
sudo touch /var/log/php/$ver/fpm.log
Expand Down
21 changes: 12 additions & 9 deletions lib/site-ssl
Expand Up @@ -43,10 +43,11 @@ site_ssl_on() {
echo "** **"
echo "** If you are getting errors or having issues when trying to get a new certificate **"
echo "** read about the Let's Encrypt rate limit - https://letsencrypt.org/docs/rate-limits/ **"
echo "** **"
echo "** Please, be sure your domain and www subdomain are currently pointing (DNS) to this server **"
echo "*************************************************************************************************${end}"

echo "*************************************************************************************************"
echo "${end}"
[[ $subdomflag == 0 ]] && echo "${blu}Please, be sure that${end} $domain ${blu}and${end} www.$domain ${blu}are both currently pointing (DNS) to this server. ${end}"
[[ $subdomflag == 1 ]] && echo "${blu}Please, be sure that the${end} $domain ${blu}subdomain is currently pointing (DNS) to this server. ${end}"

# We need an email to notify each renew intent (cron)
while [[ -z $cermail ]]
do
Expand Down Expand Up @@ -82,7 +83,7 @@ site_ssl_on() {
sudo certbot certonly --webroot -w /var/www/$root/htdocs/ $domset $param

elif [[ -a /etc/letsencrypt/live/$domain/fullchain.pem ]]; then
echo "${blu}Certificate for $domain already exist and found, wait while we configure your server to use it!${end}"
echo "${blu}Certificate for echo${end} $domain ${blu}already exist and found, wait while we configure your server to use it!${end}"
fi


Expand Down Expand Up @@ -111,7 +112,7 @@ site_ssl_on() {
cronrene=$( sudo grep -F "certbot renew" /var/spool/cron/crontabs/root )
[[ -z $cronmail && -n $cermail && -z $cronrene ]] && echo "MAILTO=${cermail}" | sudo tee -a /var/spool/cron/crontabs/root
[[ -z $cronrene ]] && echo '15 3 * * 7 certbot renew --post-hook "service nginx restart"' | sudo tee -a /var/spool/cron/crontabs/root
echo "${gre}SSL have been successfully enabled for site $domain!${end}"
echo "${gre}SSL have been successfully enabled for your site -${blu} $domain${end}"
else
echo "${red}"
echo "[ERROR] Unable to create the new certificate!"
Expand All @@ -130,7 +131,9 @@ site_ssl_off() {
if [[ -n $value && $value == "force" ]]; then
answer=="N"
else
echo "${blu}"
echo "${blu}Select 'Y' to revoke and delete all the certificate files."
echo "Select 'N' if you only want to deactivate this certificate momentary and you will activate it later again."
echo "${gre}"
echo "Do you want to delete and revoke this certificate [y/N]? "
while read -r -n 1 -s answer; do
answer=${answer:-n}
Expand All @@ -142,8 +145,8 @@ site_ssl_off() {
[[ $(conf_read debug) == "true" ]] && local param="--test-cert" || local param=""
sudo certbot revoke --cert-path /etc/letsencrypt/live/$domain/cert.pem --delete-after-revoke $param
echo "${gre}"
echo "Certificate for your site $domain has been completely removed!"
echo "Certificate for your site${blu} $domain ${gre}has been completely removed!"
echo "${end}"
fi
echo "${gre}SSL has been successfully disabled for site -${blu} $domain!${end}"
echo "${gre}SSL has been successfully disabled for your site -${blu} $domain${end}"
}
8 changes: 4 additions & 4 deletions lib/sites
Expand Up @@ -495,7 +495,7 @@ createsite() {

# Check for duplicate sites
if [[ -a /etc/nginx/sites-available/$domain ]]; then
echo "${red}Site $domain could not be created because already exists!${end}"
echo "${red}Site${blu} $domain ${red}could not be created because already exists!${end}"
exit 1
fi

Expand All @@ -518,7 +518,7 @@ createsite() {
[[ "$wp" == [123] ]] && wpinstall
else
echo "${blu}"
echo " We found a folder with $domain site data, do you want to use it [Y/n]? "
echo " We found a folder with${end} $domain ${blu}site data, do you want to use it [Y/n]? "
while read -r -n 1 -s wwwexist; do
wwwexist=${wwwexist:-y}
[[ $wwwexist == [YyNn] ]] && break
Expand All @@ -542,7 +542,7 @@ createsite() {
sudo chown -R www-data:www-data /var/www
[[ $(conf_read login-www-data) == "true" ]] && sudo chown root:root /var/www

echo "${gre}Site $domain has been successfully created!${end}"
echo "${gre}Site${blu} $domain ${gre}has been successfully created!${end}"
}


Expand Down Expand Up @@ -581,7 +581,7 @@ force_redirect() {
sudo sed -i "/server_name /c \ $sername" /etc/nginx/sites-available/$domain
echo "${gre}Force-Redirection has been successfully disabled!${end}"
else
echo "${red}Force-Redirect is already disabled for site $domain!${end}"
echo "${red}Force-Redirect is already disabled for site${blu} $domain ${end}"
fi
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions plugins/log
Expand Up @@ -100,14 +100,14 @@ if [[ $opt == "-only-error" ]]; then
sudo sed -i '/access_log/c \ access_log off;' /etc/nginx/sites-available/$domain
echo "${gre}Only-Error Log was successfully enabled for ${blu}${domain} ${gre}site!${end}"
else
echo "${red}Access Log is already enabled for ${blu}${domain} ${gre}site!${end}"
echo "${red}Access Log is already enabled for ${blu}${domain} ${red}site!${end}"
fi
elif [[ $value == "off" ]]; then
if [[ -n $islog ]]; then
sudo sed -i "/access_log/c \ access_log \/var\/log\/nginx\/${domain}.access.log we_log;" /etc/nginx/sites-available/$domain
echo "${gre}Only-Error Log was successfully disabled for ${blu}${domain} ${gre}site!${end}"
else
echo "${red}Access Log is already disabled for ${blu}${domain} ${gre}site!${end}"
echo "${red}Access Log is already disabled for ${blu}${domain} ${red}site!${end}"
fi
fi
elif [[ -n $domain && ! -a /etc/nginx/sites-available/$domain ]]; then
Expand Down
26 changes: 13 additions & 13 deletions plugins/site
Expand Up @@ -108,7 +108,7 @@ fi

# Cache validation
if [[ $cache == "-cache" && $wp == [045] ]]; then
echo "${red} Site $domain is not a WP site! ${end}"
echo "${red}Site${blu} $domain ${red}is not a WP site! ${end}"
exit 1
elif [[ -n $cache && ( $cache != "-cache" && $cache != "-root" && $cache != "-root-path" && $cache != "-subdomain" && $cache != "-ignore-ssl" && $cache != "-wildcard" ) && $type != "-parked" ]]; then
echo "${red} $cache is not a valid argument! ${end}"
Expand Down Expand Up @@ -291,46 +291,46 @@ elif [[ "$type" == "-proxy" ]]; then

# Site disabled
elif [[ "$type" == "-off" && ! -L /etc/nginx/sites-enabled/$domain ]]; then
echo "${red}Site $domain doesn't exist or is already disabled!${end}"
echo "${red}Site${blu} $domain ${red}doesn't exist or is already disabled!${end}"
elif [[ "$type" == "-off" && -L /etc/nginx/sites-enabled/$domain ]]; then
echo "${gre}Site $domain has been successfully disabled!${end}"
echo "${gre}Site${blu} $domain ${gre}has been successfully disabled!${end}"
sudo rm /etc/nginx/sites-enabled/$domain


# Site re-enabled
elif [[ "$type" == "-on" && -L /etc/nginx/sites-enabled/$domain ]]; then
echo "${gre}Site $domain is already enabled!${end}"
echo "${gre}Site${blu} $domain ${gre}is already enabled!${end}"
elif [[ "$type" == "-on" && ! -L /etc/nginx/sites-enabled/$domain && -a /etc/nginx/sites-available/$domain ]]; then
sudo ln -s /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/$domain
echo "${gre}Site $domain has been successfully enabled!${end}"
echo "${gre}Site${blu} $domain ${gre}has been successfully enabled!${end}"


# Delete site
elif [[ "$type" == "-delete" && -a /etc/nginx/sites-available/$domain ]]; then
deletesite
echo "${gre}Site $domain has been successfully deleted!${end}"
echo "${gre}Site${blu} $domain ${gre}has been successfully deleted!${end}"


# SSL enabled (Letsencrypt)
elif [[ "$type" == "-ssl-on" && -a /etc/nginx/sites-available/$domain ]]; then
isssl=$( grep -F "ssl on;" /etc/nginx/sites-available/$domain )
[[ -z $isssl ]] && site_ssl_on || echo "${red}SSL is already enabled for site $domain!${end}"
[[ -z $isssl ]] && site_ssl_on || echo "${red}SSL is already enabled for your site -${blu} $domain ${end}"


# SSL disabled (Letsencrypt)
elif [[ "$type" == "-ssl-off" && -a /etc/nginx/sites-available/$domain ]]; then
isssl=$( grep -F "ssl on;" /etc/nginx/sites-available/$domain )
[[ -n $isssl ]] && site_ssl_off || echo "${red}SSL is already disabled for site $domain!${end}"
[[ -n $isssl ]] && site_ssl_off || echo "${red}SSL is already disabled for your site -${blu} $domain ${end}"


# FastCGI Cache disabled
elif [[ "$type" == "-nocache" && -a /etc/nginx/sites-available/$domain ]]; then
isfc=$( grep -F "wpfc.conf" /etc/nginx/sites-available/$domain )
if [[ -n $isfc ]]; then
sudo sed -i '/wpfc.conf/c \ include common/php.conf;' /etc/nginx/sites-available/$domain
echo "${gre} FastCGI Cache in $domain has been disabled!${end}"
echo "${gre}FastCGI Cache in${blu} $domain ${gre}has been disabled!${end}"
else
echo "${red} Site $domain is not a WP site or FastCGI were not enabled!${end}"
echo "${red}Site${blu} $domain ${red}is not a WP site or FastCGI were not enabled!${end}"
fi


Expand All @@ -353,10 +353,10 @@ elif [[ "$type" == "-cache" && -a /etc/nginx/sites-available/$domain ]]; then
done
fi
echo "${gre}"
echo " FastCGI Cache in $domain has been successfully enabled! "
echo " FastCGI Cache in${blu} $domain ${gre}has been successfully enabled! "
echo "${end}"
else
echo "${red} Site $domain is not a WP site or FastCGI is already enabled!${end}"
echo "${red}Site${blu} $domain ${red}is not a WP site or FastCGI is already enabled!${end}"
fi


Expand All @@ -367,7 +367,7 @@ elif [[ "$type" == "-force-redirect" && -a /etc/nginx/sites-available/$domain ]]

# Catch ERROR
elif [[ ! -a /etc/nginx/sites-available/$domain && $type =~ ^(-nocache|-cache|-delete|-off|-on|-ssl-on|-ssl-off|-force-redirect)$ ]]; then
echo "${red}Site $domain doesn't exists!${end}"
echo "${red}Site${blu} $domain ${red}doesn't exists!${end}"
else
[[ -z $type ]] && type=$domain
echo "${red} Argument '${type}' is not a valid option! ${end}"
Expand Down
2 changes: 1 addition & 1 deletion plugins/webinoly
Expand Up @@ -351,7 +351,7 @@ elif [[ $opt == "-timezone" ]]; then
echo ""
fi
conf_write timezone $value
set_timezone all
set_timezone


elif [[ $opt == "-version" || $opt == "-v" || $opt == "-V" ]]; then
Expand Down

0 comments on commit 43e0f82

Please sign in to comment.