From 5b8518292b0b0514f116f6eb9c418d251df02fbc Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Sat, 12 Nov 2022 14:19:31 -0500
Subject: [PATCH] Clean up to have most output in run.sh file

---
 run.sh               | 55 +++++++++++++++++++++++++++++++++-----------
 src/install_mysql.sh |  9 +++-----
 2 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/run.sh b/run.sh
index e88b4c7..c3d1261 100755
--- a/run.sh
+++ b/run.sh
@@ -28,15 +28,38 @@ function main () {
     if [[ ${user_input} == 1 ]]
     then
         # Handle for Arch Linux.
+        echo "Choose a DB type to install:"
+        echo -e "    ${text_cyan}1${text_reset}) MariaDB"
+        echo -e "    ${text_cyan}2${text_reset}) PostgreSQL"
+        echo ""
+        read user_input
 
-        # Handle for MariaDB install.
-        echo "Starting MariaDB install for Arch Linux."
-        echo -e "To continue, press ${text_cyan}enter${text_reset}. Otherwise, hit ${text_cyan}ctrl+c${text_reset} to cancel."
-        read
+        # Handle user input.
+        if [[ ${user_input} == 1 ]]
+        then
+            # Handle for MariaDB install.
+            echo -e "${text_blue}Installing MariaDB for Arch Linux.${text_reset}"
+            echo -e "${text_blue}Sudo is required for installing/updating system files.${text_reset}"
+            echo -e "${text_blue}This may ask for your system password.${text_reset}"
+            echo -e "${text_blue}To continue, press ${text_cyan}enter${text_blue}. Otherwise, hit ${text_cyan}ctrl+c${text_blue} to cancel.${text_reset}"
+            read
 
-        echo -e "${text_blue}Starting MariaDB installation.${text_reset}"
-        sudo ./install_mysql.sh --os arch --db mariadb
-        echo -e "${text_green}MariaDB installation complete.${text_reset}"
+            echo -e "${text_blue}Starting MariaDB installation.${text_reset}"
+            sudo ./install_mysql.sh --os arch --db mariadb
+            echo -e "${text_green}MariaDB setup & installation complete.${text_reset}"
+
+        elif [[ ${user_input} == 2 ]]
+        then
+            echo -e "${text_blue}Installing PostgreSQL for Arch Linux.${text_reset}"
+            echo -e "${text_blue}Sudo is required for installing/updating system files.${text_reset}"
+            echo -e "${text_blue}This may ask for your system password.${text_reset}"
+            echo -e "${text_blue}To continue, press ${text_cyan}enter${text_blue}. Otherwise, hit ${text_cyan}ctrl+c${text_blue} to cancel.${text_reset}"
+            read
+
+            echo -e "${text_blue}Starting PostgreSQL installation.${text_reset}"
+            sudo ./install_postgresql.sh --os arch
+            echo -e "${text_green}PostgreSQL setup & installation complete.${text_reset}"
+        fi
 
     elif [[ ${user_input} == 2 ]]
     then
@@ -44,6 +67,7 @@ function main () {
         echo "Choose a DB type to install:"
         echo -e "    ${text_cyan}1${text_reset}) MySQL"
         echo -e "    ${text_cyan}2${text_reset}) MariaDB"
+        echo -e "    ${text_cyan}3${text_reset}) PostgreSQL"
         echo ""
         read user_input
 
@@ -51,26 +75,31 @@ function main () {
         if [[ ${user_input} == 1 ]]
         then
             # Handle for MySQL install.
-            echo "Starting MySQL install for Ubuntu."
-            echo -e "To continue, press ${text_cyan}enter${text_reset}. Otherwise, hit ${text_cyan}ctrl+c${text_reset} to cancel."
+            echo -e "${text_blue}Installing MySQL for Ubuntu Linux.${text_reset}"
+            echo -e "${text_blue}Sudo is required for installing/updating system files.${text_reset}"
+            echo -e "${text_blue}This may ask for your system password.${text_reset}"
+            echo -e "${text_blue}To continue, press ${text_cyan}enter${text_blue}. Otherwise, hit ${text_cyan}ctrl+c${text_blue} to cancel.${text_reset}"
             read
 
             echo -e "${text_blue}Starting MySQL installation.${text_reset}"
             sudo ./install_mysql.sh --os ubuntu --db mysql
-            echo -e "${text_green}MySQL installation complete.${text_reset}"
+            echo -e "${text_green}MySQL setup & installation complete.${text_reset}"
 
         elif [[ ${user_input} == 2 ]]
         then
             # Handle for MariaDB install.
-            echo "Starting MariaDB install for Ubuntu."
-            echo -e "To continue, press ${text_cyan}enter${text_reset}. Otherwise, hit ${text_cyan}ctrl+c${text_reset} to cancel."
+            echo -e "${text_blue}Installing MariaDB for Ubuntu Linux.${text_reset}"
+            echo -e "${text_blue}Sudo is required for installing/updating system files.${text_reset}"
+            echo -e "${text_blue}This may ask for your system password.${text_reset}"
+            echo -e "${text_blue}To continue, press ${text_cyan}enter${text_blue}. Otherwise, hit ${text_cyan}ctrl+c${text_blue} to cancel.${text_reset}"
             read
 
             echo -e "${text_blue}Starting MariaDB installation.${text_reset}"
             sudo ./install_mysql.sh --os ubuntu --db mariadb
-            echo -e "${text_green}MariaDB installation complete.${text_reset}"
+            echo -e "${text_green}MariaDB setup & installation complete.${text_reset}"
 
         else
+            # Unhandled type.
             echo -e "${text_orange}Unknown option entered.${text_reset}"
         fi
 
diff --git a/src/install_mysql.sh b/src/install_mysql.sh
index 5ffdc9a..7fd80aa 100755
--- a/src/install_mysql.sh
+++ b/src/install_mysql.sh
@@ -76,9 +76,6 @@ function main () {
  # Installation logic for Arch Linux systems.
  ##
 function install_arch_mariadb () {
-    echo -e "${text_blue}Installing MariaDB for Arch Linux.${text_reset}"
-    echo -e "${text_blue}Sudo is required for installing/updating system files.${text_reset}"
-    echo -e "${text_blue}This may ask for your system password.${text_reset}"
 
     # Install MariaDB.
     pacman -Syu mariadb --noconfirm > /dev/null
@@ -104,12 +101,12 @@ function install_ubuntu_mysql () {
     echo -e "${text_blue}This may ask for your system password.${text_reset}"
 
     # Install MySQL.
-    sudo apt-get update  > /dev/null 2>&1
+    sudo apt-get update > /dev/null 2>&1
     sudo apt-get install mysql-server mysql-client -y
 
     # 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
 
     echo ""
     get_user_confirmation "Allow password login with root user? Recommended for local dev/testing setups."
-- 
GitLab