directus db

This commit is contained in:
Valentin 2024-02-23 17:07:19 +01:00
parent 24d93ecf44
commit 15e2b819a2
1 changed files with 16 additions and 4 deletions

View File

@ -98,7 +98,6 @@ if [[ "$answer" == "y" ]]; then
echo -e "${PURPLE}${BOLD}Enter the MariaDB root password : ${RESET}" echo -e "${PURPLE}${BOLD}Enter the MariaDB root password : ${RESET}"
read -s db_root_password read -s db_root_password
echo echo
echo -e "${PURPLE}${BOLD}${db_root_password}${RESET}"
apt -y install expect apt -y install expect
SECURE_MYSQL=$(expect -c " SECURE_MYSQL=$(expect -c "
set timeout 3 set timeout 3
@ -110,9 +109,9 @@ if [[ "$answer" == "y" ]]; then
expect \"Change the root password? \\[Y/n\\]\" expect \"Change the root password? \\[Y/n\\]\"
send \"y\r\" send \"y\r\"
expect \"New password:\" expect \"New password:\"
send \"${db_root_password}\r\" send \"$db_root_password\r\"
expect \"Re-enter new password:\" expect \"Re-enter new password:\"
send \"${db_root_password}\r\" send \"$db_root_password\r\"
expect \"Remove anonymous users?\" expect \"Remove anonymous users?\"
send \"y\r\" send \"y\r\"
expect \"Disallow root login remotely?\" expect \"Disallow root login remotely?\"
@ -128,8 +127,21 @@ if [[ "$answer" == "y" ]]; then
# https://gist.github.com/coderua/5592d95970038944d099 # https://gist.github.com/coderua/5592d95970038944d099
fi fi
#
# DIRECTUS DB
#
echo -e "${PURPLE}${BOLD}Setup Directus database ? (y/n) ${RESET}" echo -e "${PURPLE}${BOLD}Setup Directus database ? (y/n) ${RESET}"
read answer read answer
if [[ "$answer" == "y" ]]; then if [[ "$answer" == "y" ]]; then
echo "yooooo" echo -e "${PURPLE}${BOLD}Generate and store the password somewhere safe${RESET}"
echo -e "${PURPLE}${BOLD}Enter the MariaDB Directus password : ${RESET}"
read -s db_directus_password
echo
mysql -u root -p <<EOF
CREATE USER 'directus'@'localhost' IDENTIFIED BY '${db_password}';
CREATE DATABASE directus;
GRANT ALL PRIVILEGES ON directus.* TO 'directus'@'localhost' IDENTIFIED BY '${db_password}';
FLUSH PRIVILEGES;
EOF
fi fi