directus db 3
This commit is contained in:
parent
ea5ae902bb
commit
363db01044
39
install.sh
39
install.sh
|
@ -4,6 +4,15 @@ PURPLE='\033[35m'
|
||||||
BOLD='\033[1m'
|
BOLD='\033[1m'
|
||||||
RESET='\033[0m'
|
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}"
|
echo -e "${PURPLE}${BOLD}Deployment Debian + Caddy + Directus + Nuxt${RESET}"
|
||||||
|
|
||||||
if [ "$EUID" -ne 0 ]; then
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
@ -98,7 +107,7 @@ 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
|
||||||
apt -y install expect
|
install_expect
|
||||||
SECURE_MYSQL=$(expect -c "
|
SECURE_MYSQL=$(expect -c "
|
||||||
set timeout 3
|
set timeout 3
|
||||||
spawn mysql_secure_installation
|
spawn mysql_secure_installation
|
||||||
|
@ -138,10 +147,24 @@ if [[ "$answer" == "y" ]]; then
|
||||||
echo -e "${PURPLE}${BOLD}Enter the MariaDB Directus password : ${RESET}"
|
echo -e "${PURPLE}${BOLD}Enter the MariaDB Directus password : ${RESET}"
|
||||||
read -s db_directus_password
|
read -s db_directus_password
|
||||||
echo
|
echo
|
||||||
mysql -u root -p <<EOF
|
if [[ -z "$db_root_password" ]]; then
|
||||||
CREATE USER 'directus'@'localhost' IDENTIFIED BY '${db_password}';
|
echo -e "${PURPLE}${BOLD}Enter the MariaDB root password : ${RESET}"
|
||||||
CREATE DATABASE directus;
|
read -s db_root_password
|
||||||
GRANT ALL PRIVILEGES ON directus.* TO 'directus'@'localhost' IDENTIFIED BY '${db_password}';
|
echo
|
||||||
FLUSH PRIVILEGES;
|
fi
|
||||||
EOF
|
install_expect
|
||||||
fi
|
spawn mariadb -u root -p
|
||||||
|
expect "Enter password:"
|
||||||
|
send "$db_root_password\r"
|
||||||
|
expect "mysql>"
|
||||||
|
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
|
Loading…
Reference in New Issue