diff --git a/install.sh b/install.sh index 702108f..56a4c57 100644 --- a/install.sh +++ b/install.sh @@ -4,6 +4,15 @@ PURPLE='\033[35m' BOLD='\033[1m' RESET='\033[0m' +install_expect() { + if ! command -v expect &> /dev/null; then + sudo apt install -y expect + echo -e "${PURPLE}${BOLD}expect installed${RESET}" + else + echo -e "${PURPLE}${BOLD}expect already installed${RESET}" + fi +} + echo -e "${PURPLE}${BOLD}Deployment Debian + Caddy + Directus + Nuxt${RESET}" if [ "$EUID" -ne 0 ]; then @@ -98,7 +107,7 @@ if [[ "$answer" == "y" ]]; then echo -e "${PURPLE}${BOLD}Enter the MariaDB root password : ${RESET}" read -s db_root_password echo - apt -y install expect + install_expect SECURE_MYSQL=$(expect -c " set timeout 3 spawn mysql_secure_installation @@ -138,10 +147,24 @@ if [[ "$answer" == "y" ]]; then echo -e "${PURPLE}${BOLD}Enter the MariaDB Directus password : ${RESET}" read -s db_directus_password echo - mysql -u root -p <" + send "CREATE USER 'directus'@'localhost' IDENTIFIED BY '${db_directus_password}';\r" + send "CREATE DATABASE directus;\r" + send "GRANT ALL PRIVILEGES ON directus.* TO 'directus'@'localhost' IDENTIFIED BY '${db_directus_password}';\r" + send "FLUSH PRIVILEGES;\r" + expect "mysql>" + send "exit\r" + wait +fi + + +# TODO REMOVE EXPECT IF IT IS INSTALLED \ No newline at end of file