mysql_secure_installation correction 4
This commit is contained in:
parent
0d4e1a3a86
commit
80b47e2f43
32
install.sh
32
install.sh
|
@ -98,13 +98,31 @@ 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
|
||||||
mariadb -e "UPDATE mysql.user SET Password = PASSWORD('${db_root_password}') WHERE User = 'root'"
|
apt -y install expect
|
||||||
mariadb -e "DROP USER ''@'localhost'"
|
SECURE_MYSQL=$(expect -c "
|
||||||
mariadb -e "DROP USER ''@'$(hostname)'"
|
set timeout 3
|
||||||
mariadb -e "DROP DATABASE test"
|
spawn mysql_secure_installation
|
||||||
mariadb -e "FLUSH PRIVILEGES"
|
expect \"Enter current password for root (enter for none):\"
|
||||||
# https://fedingo.com/how-to-automate-mysql_secure_installation-script/
|
send \"\r\"
|
||||||
# to replace mysql_secure_installation
|
expect \"root password?\"
|
||||||
|
send \"y\r\"
|
||||||
|
expect \"New password:\"
|
||||||
|
send \"$db_root_password\r\"
|
||||||
|
expect \"Re-enter new password:\"
|
||||||
|
send \"$db_root_password\r\"
|
||||||
|
expect \"Remove anonymous users?\"
|
||||||
|
send \"y\r\"
|
||||||
|
expect \"Disallow root login remotely?\"
|
||||||
|
send \"y\r\"
|
||||||
|
expect \"Remove test database and access to it?\"
|
||||||
|
send \"y\r\"
|
||||||
|
expect \"Reload privilege tables now?\"
|
||||||
|
send \"y\r\"
|
||||||
|
expect eof
|
||||||
|
")
|
||||||
|
echo "${SECURE_MYSQL}"
|
||||||
|
apt -y purge expect
|
||||||
|
# https://gist.github.com/coderua/5592d95970038944d099
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "${PURPLE}${BOLD}Setup Directus database ? (y/n) ${RESET}"
|
echo -e "${PURPLE}${BOLD}Setup Directus database ? (y/n) ${RESET}"
|
||||||
|
|
Loading…
Reference in New Issue