stack messages improved

Installation messages improved and some small code improvements.
This commit is contained in:
Cristhian Martínez Ochoa 2018-03-31 21:08:40 -06:00
parent ea82e4d459
commit ef9a7d0af4
2 changed files with 52 additions and 91 deletions

View file

@ -101,7 +101,9 @@ linux_purge() {
messagend_install() {
echo "${gre}*****************************************************************************************"
echo "${gre}"
echo ""
echo "*****************************************************************************************"
echo "************ INSTALLATION HAS FINISHED SUCCESSFULLY ************"
echo "*****************************************************************************************${end}"
if [[ $1 == "dbpass" ]]; then
@ -127,7 +129,7 @@ nginx_install() {
fi
conf_write nginx true
messagend_install
echo "${gre}Nginx has been installed successfully! ${end}"
}
@ -159,14 +161,12 @@ php_install() {
sudo cp /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf /opt/webinoly/templates/source/
conf_write php true
messagend_install
echo "${gre}PHP has been installed successfully! ${end}"
}
mysql_install() {
if [[ $(conf_read mysql-client) != "true" ]]; then
mysql_client_install
fi
[[ $(conf_read mysql-client) != "true" ]] && mysql_client_install
pre_install
# debconf-utils for unattended scripts
@ -200,7 +200,7 @@ FLUSH PRIVILEGES;
_EOF_
conf_write mysql true
messagend_install
echo "${gre}MySQL has been installed successfully! ${end}"
}
@ -376,6 +376,7 @@ mysql_tool() {
[[ -d /usr/share/phpmyadmin ]] && sudo mv /usr/share/phpmyadmin /var/www/$(conf_read tools-port)/htdocs/pma
conf_write mysql-tool true
echo "${gre}PhpMyAdmin has been installed successfully! ${end}"
}

View file

@ -30,14 +30,14 @@ if [[ $arg == "-purge=force" || $opt == "-purge-server-all=force" || $opt == "-p
fi
# LEMP without Optimization for testing purpose (just packages)!
if [[ $arg == "-noptim" && $opt == "-lemp" ]]; then
if ! [[ $(conf_read nginx) == "true" || $(conf_read php) == "true" || $(conf_read mysql) == "true" ]]; then
nginx_install
php_install
mysql_install
echo ""
echo "${gre} LEMP without optimization has been installed!!! ${end}"
echo "${gre}LEMP without optimization has been installed!!! ${end}"
echo ""
messagend_install dbpass
else
@ -45,11 +45,10 @@ if [[ $arg == "-noptim" && $opt == "-lemp" ]]; then
fi
# Delete some stack
elif [[ $arg == "-purge" && ( $opt == "-html" || $opt == "-nginx" ) ]]; then
if [[ $(conf_read nginx) != "true" ]]; then
echo "${red} Nginx is not installed, hence can not be deleted! ${end}"
echo "${red}Nginx is not installed, hence can not be deleted! ${end}"
clear_force_flag
exit 1
fi
@ -57,13 +56,12 @@ elif [[ $arg == "-purge" && ( $opt == "-html" || $opt == "-nginx" ) ]]; then
echo ""
echo "${red} ¡ C A U T I O N ! You are about to remove NGINX from your server!"
echo ""
if [[ $(conf_read force-flag) != "true" ]]; then
echo " ${blu} Are you sure [y/N]? ${end}"
while read -r -n 1 -s answer; do
answer=${answer:-n}
if [[ $answer = [YyNn] ]]; then
break
fi
[[ $answer = [YyNn] ]] && break
done
fi
@ -75,15 +73,11 @@ elif [[ $arg == "-purge" && ( $opt == "-html" || $opt == "-nginx" ) ]]; then
echo "${blu}Do you want to delete your sites data directory (/var/www) [Y/n]? ${end}"
while read -r -n 1 -s answer; do
answer=${answer:-y}
if [[ $answer = [YyNn] ]]; then
break
fi
[[ $answer = [YyNn] ]] && break
done
fi
if [[ $answer == [Yy] ]]; then
if [[ $(conf_read mysql-tool) == "true" ]]; then
stack -pma -purge
fi
[[ $(conf_read mysql-tool) == "true" ]] && stack -pma -purge
site -delete-all
sudo rm -rf /var/www/$(conf_read tools-port)
sudo rm -rf /var/www/html
@ -95,19 +89,15 @@ elif [[ $arg == "-purge" && ( $opt == "-html" || $opt == "-nginx" ) ]]; then
echo | sudo add-apt-repository --remove 'ppa:nginx/stable'
sudo apt-get -y autoremove
sudo rm $HOME/www
sudo rm $HOME/sites-available
sudo rm $HOME/sites-available
linux_purge
if [[ $(conf_read php-tool) != "true" ]]; then
conf_write web-tool purged
fi
[[ $(conf_read php-tool) != "true" ]] && conf_write web-tool purged
conf_write nginx purged
conf_write nginx-optim purged
conf_write nginx-tool purged
echo ""
echo "${gre} Nginx has been deleted successfully! ${end}"
echo "${gre}Nginx has been deleted successfully! ${end}"
echo ""
else
echo ""
@ -118,7 +108,7 @@ elif [[ $arg == "-purge" && ( $opt == "-html" || $opt == "-nginx" ) ]]; then
elif [[ $arg == "-purge" && $opt == "-php" ]]; then
if [[ $(conf_read php) != "true" ]]; then
echo "${red} PHP is not installed, hence can not be deleted! ${end}"
echo "${red}PHP is not installed, hence can not be deleted! ${end}"
clear_force_flag
exit 1
fi
@ -127,20 +117,17 @@ elif [[ $arg == "-purge" && $opt == "-php" ]]; then
echo "${red} ¡ C A U T I O N ! You are about to remove PHP from your server!"
echo " This action will also remove PhpMyAdmin if its installed because depends on PHP. ${end}"
echo ""
if [[ $(conf_read force-flag) != "true" ]]; then
echo " ${blu} Are you sure [y/N]? ${end}"
while read -r -n 1 -s answer; do
answer=${answer:-n}
if [[ $answer = [YyNn] ]]; then
break
fi
[[ $answer = [YyNn] ]] && break
done
fi
if [[ $answer == [Yy] || $(conf_read force-flag) == "true" ]]; then
if [[ $(conf_read mysql-tool) == "true" ]]; then
stack -pma -purge
fi
[[ $(conf_read mysql-tool) == "true" ]] && stack -pma -purge
sudo service php*-fpm stop
sudo apt-get -y purge php*-fpm php*-curl php*-gd php*-imap php*-mcrypt php*-readline php*-common php*-recode php*-mysql php*-cli php*-mbstring php*-bcmath php*-mysql php*-opcache php*-zip php*-xml php*-soap php-imagick graphviz php-pear php-xdebug php-msgpack
sudo apt-get -y purge php-memcached php-memcache memcached
@ -150,18 +137,19 @@ elif [[ $arg == "-purge" && $opt == "-php" ]]; then
sudo apt-get -y autoremove
sudo rm -rf /etc/php
sudo rm /opt/webinoly/templates/source/*
conf_write php purged
conf_write php-optim purged
if [[ $(conf_read php-tool) == "true" ]]; then
rm -rf /var/www/$(conf_read tools-port)/htdocs/fpm
rm -rf /var/www/$(conf_read tools-port)/htdocs/php
conf_write php-tool purged
fi
if [[ $(conf_read nginx-tool) != "true" ]]; then
conf_write web-tool purged
fi
[[ $(conf_read nginx-tool) != "true" ]] && conf_write web-tool purged
echo ""
echo "${gre} PHP has been deleted successfully! ${end}"
echo "${gre}PHP has been deleted successfully! ${end}"
echo ""
else
echo ""
@ -172,7 +160,7 @@ elif [[ $arg == "-purge" && $opt == "-php" ]]; then
elif [[ $arg == "-purge" && $opt == "-mysql" ]]; then
if [[ $(conf_read mysql) != "true" ]]; then
echo "${red} MySQL is not installed, hence can not be deleted! ${end}"
echo "${red}MySQL is not installed, hence can not be deleted! ${end}"
clear_force_flag
exit 1
fi
@ -180,13 +168,12 @@ elif [[ $arg == "-purge" && $opt == "-mysql" ]]; then
echo ""
echo "${red} ¡ C A U T I O N ! You are about to remove MySQL from your server! ${end}"
echo ""
if [[ $(conf_read force-flag) != "true" ]]; then
echo " ${blu} Are you sure [y/N]? ${end}"
while read -r -n 1 -s answer; do
answer=${answer:-n}
if [[ $answer = [YyNn] ]]; then
break
fi
[[ $answer = [YyNn] ]] && break
done
fi
@ -220,7 +207,7 @@ elif [[ $arg == "-purge" && $opt == "-mysql" ]]; then
conf_write mysql-client purged
conf_write mysql purged
echo ""
echo "${gre} MySQL has been deleted successfully! ${end}"
echo "${gre}MySQL has been deleted successfully! ${end}"
echo ""
else
echo ""
@ -239,6 +226,7 @@ elif [[ $arg == "-purge" && $opt == "-pma" ]]; then
echo ""
echo "${red} ¡ C A U T I O N ! You are about to remove PhpMyAdmin from your server! ${end}"
echo ""
if [[ $(conf_read force-flag) != "true" && $(conf_read delautopma) != "true" ]]; then
echo " ${blu} Are you sure [y/N]? ${end} "
while read -r -n 1 -s answer; do
@ -257,7 +245,7 @@ elif [[ $arg == "-purge" && $opt == "-pma" ]]; then
sudo rm -rf /var/www/$(conf_read tools-port)/htdocs/pma
conf_write mysql-tool purged
echo ""
echo "${gre} PhpMyAdmin has been deleted successfully! ${end}"
echo "${gre}PhpMyAdmin has been deleted successfully! ${end}"
echo ""
else
echo ""
@ -276,27 +264,22 @@ elif [[ $arg == "-purge" && $opt == "-web-tools" ]]; then
echo ""
echo "${red} ¡ C A U T I O N ! You are about to remove all your Web Tools (Postfix, Redis, Memcached, Duplicity and Letsencrypt) from your server! ${end}"
echo ""
if [[ $(conf_read force-flag) != "true" ]]; then
echo " ${blu} Are you sure [y/N]? ${end} "
while read -r -n 1 -s answer; do
answer=${answer:-n}
if [[ $answer = [YyNn] ]]; then
break
fi
[[ $answer = [YyNn] ]] && break
done
fi
if [[ $answer == [Yy] || $(conf_read force-flag) == "true" ]]; then
if [[ $(conf_read nginx-tool) == "true" ]]; then
sudo apt-get -y purge letsencrypt python-boto duplicity duply
fi
if [[ $(conf_read php-tool) == "true" ]]; then
sudo apt-get -y purge redis-server php-redis postfix php-memcached php-memcache memcached
fi
[[ $(conf_read nginx-tool) == "true" ]] && sudo apt-get -y purge letsencrypt python-boto duplicity duply
[[ $(conf_read php-tool) == "true" ]] && sudo apt-get -y purge redis-server php-redis postfix php-memcached php-memcache memcached
sudo apt-get -y autoremove
conf_write web-tool purged
echo ""
echo "${gre} Web Tools have been deleted successfully! ${end}"
echo "${gre}Web Tools have been deleted successfully! ${end}"
echo ""
else
echo ""
@ -316,25 +299,21 @@ elif [[ $arg != "-purge" && $arg != "-notools" && -n "$arg" ]]; then
echo ""
# Install some stack
elif [[ $opt == "-html" || $opt == "-nginx" ]]; then
if [[ $(conf_read nginx) != "true" ]]; then
nginx_install
nginx_optim
if [[ $arg != "-notools" ]]; then
nginx_tool
fi
[[ $arg != "-notools" ]] && nginx_tool
echo ""
echo "${gre} Nginx has been installed successfully! ${end}"
echo "${gre}Nginx has been successfully Optimized by Webinoly! ${end}"
echo ""
else
echo "${red}Nginx is already installed!${end}"
if [[ $(conf_read nginx-optim) != "true" ]]; then
nginx_optim
echo "${gre}"
echo "NGINX has been optimized by Webinoly!"
echo "NGINX has been successfully Optimized by Webinoly!"
echo "${end}"
fi
if [[ $(conf_read nginx-tool) != "true" && $arg != "-notools" ]]; then
@ -352,29 +331,23 @@ elif [[ $opt == "-php" ]]; then
echo "${blu}Nginx is not installed, do you want to install it too [Y/n]?${end} "
while read -r -n 1 -s answer; do
answer=${answer:-y}
if [[ $answer = [YyNn] ]]; then
break
fi
[[ $answer = [YyNn] ]] && break
done
if [[ $answer != [Nn] ]]; then
stack -nginx $arg
fi
[[ $answer != [Nn] ]] && stack -nginx $arg
fi
php_install
php_optim
if [[ $arg != "-notools" ]]; then
php_tool
fi
[[ $arg != "-notools" ]] && php_tool
echo ""
echo "${gre} PHP has been installed successfully! ${end}"
echo "${gre}PHP has been successfully Optimized by Webinoly! ${end}"
echo ""
else
echo "${red}PHP is already installed!${end}"
if [[ $(conf_read php-optim) != "true" ]]; then
php_optim
echo "${gre}"
echo "PHP has been optimized by Webinoly!"
echo "PHP has been successfully Optimized by Webinoly!"
echo "${end}"
fi
if [[ $(conf_read php-tool) != "true" && $arg != "-notools" ]]; then
@ -388,12 +361,7 @@ elif [[ $opt == "-php" ]]; then
elif [[ $opt == "-mysql" ]]; then
if [[ $(conf_read mysql) != "true" ]]; then
mysql_install
if [[ $arg != "-notools" ]]; then
stack -pma
fi
echo ""
echo "${gre} MySQL (MariaDB) has been installed successfully! ${end}"
echo ""
[[ $arg != "-notools" ]] && stack -pma
messagend_install dbpass
else
echo "${red}MySQL is already installed!${end}"
@ -411,24 +379,16 @@ elif [[ $opt == "-pma" ]]; then
clear_force_flag
exit 1
fi
if [[ $(conf_read mysql-tool) != "true" ]]; then
mysql_tool
echo ""
echo "${gre} PhpMyAdmin has been installed successfully! ${end}"
echo ""
else
echo "${red}PhpMyAdmin is already installed!${end}"
fi
[[ $(conf_read mysql-tool) != "true" ]] && mysql_tool || echo "${red}PhpMyAdmin is already installed!${end}"
elif [[ $opt == "-lemp" ]]; then
stack -nginx $arg
stack -php $arg
stack -mysql $arg
echo ""
echo "${gre} Nginx, PHP, MySQL (MariaDB) and other useful tools have been installed successfully! ${end}"
echo "${gre}Nginx, PHP, MySQL (MariaDB) and some other useful tools have been installed successfully! ${end}"
echo ""
elif [[ $opt == "-php-ver="* ]]; then
phpver=$(echo "${opt}" | cut -d'=' -f 2 -s)
if [[ -n $phpver && ($phpver == "7.2" || $phpver == "7.1" || $phpver == "7.0" || $phpver == "5.6") ]]; then
@ -456,6 +416,7 @@ elif [[ $opt == "-php-ver="* ]]; then
echo "${red} Please, enter a valid PHP version!${end}"
fi
# Info & Purge-Server-All
elif [[ $opt == "-info" ]]; then
system_info
@ -470,9 +431,7 @@ elif [[ $opt == "-purge-server-all" ]]; then
echo " ${blu} Are you sure [y/N]? ${end}"
while read -r -n 1 -s answer; do
answer=${answer:-n}
if [[ $answer = [YyNn] ]]; then
break
fi
[[ $answer = [YyNn] ]] && break
done
else
answer="Y"
@ -500,6 +459,7 @@ else
echo "${red} $opt is not a valid option! ${end}"
fi
# Clear FORCE flag in config file
if [[ $force == 1 ]]; then
clear_force_flag