eole-mariadb/preservice/25-bdd-init

29 lines
457 B
Plaintext
Raw Normal View History

2018-04-12 16:12:42 +02:00
#!/bin/bash
#
# Initialize root password
# and secure MariaDB installation
#
2018-04-12 17:10:39 +02:00
ROLE=$(CreoleGet dbClusterPosition 'Leader')
2018-04-12 16:12:42 +02:00
SECURE_CMD="mysql_secure_installation"
PASSWORD=$(pwgen -1 10)
2018-04-12 16:33:44 +02:00
passwd="/usr/share/eole/sbin/mariadbPwd"
logfile="/var/log/eole/maria-init.log"
2018-04-12 16:12:42 +02:00
2018-04-12 17:10:39 +02:00
if [[ ${ROLE} == "Leader" ]]
then
${passwd} ${PASSWORD}
2018-04-12 16:12:42 +02:00
2018-04-12 17:10:39 +02:00
# Run secure installation script
${SECURE_CMD} > ${logfile} 2>&1 <<__EOF__
2018-04-12 16:33:44 +02:00
${PASSWORD}
2018-04-12 16:12:42 +02:00
y
n
y
y
y
y
2018-04-12 16:33:44 +02:00
__EOF__
2018-04-12 17:10:39 +02:00
else
exit 0
fi