eole-mariadb/preservice/25-bdd-init

29 lines
457 B
Bash

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