From 5cf8858635a885c58ae6b53f3218b635e909686b Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Mon, 26 Oct 2020 21:59:52 -0400 Subject: [PATCH] Improve script user output handling --- install_mysql.sh | 35 +++++++++++++++++++++++------------ run.sh | 4 ++++ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/install_mysql.sh b/install_mysql.sh index 87d1a43..b8948ae 100755 --- a/install_mysql.sh +++ b/install_mysql.sh @@ -8,6 +8,10 @@ . $(dirname ${0})/utils.sh +# Stop on error. +set -e + + ### # Script entry point. ## @@ -51,6 +55,7 @@ function main () { elif [[ ${kwargs["db"]} == "mariadb" ]] then install_ubuntu_mariadb + else echo -e "${text_red}Unrecognized database type. Terminating script.${text_reset}" exit 1 fi @@ -69,15 +74,17 @@ function main () { # Installation logic for Arch Linux systems. ## function install_arch_mariadb () { + echo "Installing MariaDB..." + # Install MariaDB. - pacman -Syu mariadb --noconfirm + pacman -Syu mariadb --noconfirm > /dev/null # Run initial configuration. - sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql + sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql > /dev/null # Start MariaDB service and set to start on boot. - systemctl enable mariadb.service - systemctl start mariadb.service + systemctl enable mariadb.service > /dev/null + systemctl start mariadb.service > /dev/null # Proceed with initial configuration. mysql_secure_installation @@ -88,13 +95,15 @@ function install_arch_mariadb () { # MySQL installation logic for Ubuntu systems. ## function install_ubuntu_mysql () { + echo "Installing MySQL..." + # Install MariaDB. - sudo apt update - sudo apt install mysql-server mysql-client -y + sudo apt-get update > /dev/null 2>&1 + sudo apt-get install mysql-server mysql-client -y > /dev/null # Start MariaDB service and set to start on boot. - systemctl enable mysql.service - systemctl start mysql.service + systemctl enable mysql.service > /dev/null + systemctl start mysql.service > /dev/null # Proceed with initial configuration. mysql_secure_installation @@ -105,13 +114,15 @@ function install_ubuntu_mysql () { # MariaDB installation logic for Ubuntu systems. ## function install_ubuntu_mariadb () { + echo "Installing MariaDB..." + # Install MariaDB. - sudo apt update - sudo apt install mariadb-server -y + sudo apt-get update > /dev/null 2>&1 + sudo apt-get install mariadb-server -y > /dev/null # Start MariaDB service and set to start on boot. - systemctl enable mariadb.service - systemctl start mariadb.service + systemctl enable mariadb.service > /dev/null + systemctl start mariadb.service > /dev/null # Proceed with initial configuration. mysql_secure_installation diff --git a/run.sh b/run.sh index 3b043e9..7e701e6 100755 --- a/run.sh +++ b/run.sh @@ -8,6 +8,10 @@ . $(dirname ${0})/utils.sh +# Stop on error. +set -e + + ### # Script entry point. ## -- GitLab