diff --git a/src/install_mysql.sh b/src/install_mysql.sh index 4b5964acb04713c625c76d129d8e64861acae857..5ffdc9a7d8d58497e6c038a80a8b111c18eafdf6 100755 --- a/src/install_mysql.sh +++ b/src/install_mysql.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash ### - # Installs and sets up MySQL/MariaDB. + # Install and set up for MySQL/MariaDB. ## @@ -14,6 +14,8 @@ set -e ### # Script entry point. + # Checks that expected args were provided, to indicate what database type is being installed to what OS. + # Then calls the corresponding function to actually execute logic. ## function main () { @@ -74,7 +76,9 @@ function main () { # Installation logic for Arch Linux systems. ## function install_arch_mariadb () { - echo "Installing 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 @@ -95,16 +99,42 @@ function install_arch_mariadb () { # MySQL installation logic for Ubuntu systems. ## function install_ubuntu_mysql () { - echo "Installing MySQL..." + 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}" - # Install MariaDB. - sudo apt-get update + # Install MySQL. + 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 + echo "" + get_user_confirmation "Allow password login with root user? Recommended for local dev/testing setups." + if [[ ${return_value} == true ]] + then + # Get desired password to use for root login. + user_input="" + while [[ "${user_input}" == "" ]] + do + echo -e "${text_cyan}Enter desired password:${text_reset}" + read user_input + done + + # Update root account to login with password. + sudo mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${user_input}'; FLUSH PRIVILEGES;" + fi + + echo "" + echo "" + echo -e "${text_blue}Initial MySQL setup complete.${text_reset}" + echo -e "${text_blue}Now running additional configuration. This will give a few more prompts...${text_reset}" + echo "" + + sleep 3 + # Proceed with initial configuration. mysql_secure_installation @@ -122,7 +152,9 @@ function install_ubuntu_mysql () { # MariaDB installation logic for Ubuntu systems. ## function install_ubuntu_mariadb () { - echo "Installing MariaDB..." + 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}" # Install MariaDB. sudo apt-get update > /dev/null 2>&1