2018-04-12 16:12:42 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Initialize root password
|
|
|
|
# and secure MariaDB installation
|
|
|
|
#
|
|
|
|
|
2018-05-09 14:25:25 +02:00
|
|
|
[[ "$(CreoleGet dbEnable)" == "non" ]] && exit 0
|
|
|
|
|
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"
|
2018-05-09 13:32:42 +02:00
|
|
|
logdir="/var/log/eole"
|
|
|
|
logfile="${logdir}/maria-init.log"
|
|
|
|
|
|
|
|
[[ ! -d "${logdir}" ]] && mkdir -p ${logdir}
|
2018-04-12 16:12:42 +02:00
|
|
|
|
2018-04-12 17:10:39 +02:00
|
|
|
if [[ ${ROLE} == "Leader" ]]
|
|
|
|
then
|
2018-05-09 13:32:42 +02:00
|
|
|
service mariadb start
|
2018-04-12 17:10:39 +02:00
|
|
|
${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-05-09 13:32:42 +02:00
|
|
|
service mariadb stop
|
2018-04-12 17:10:39 +02:00
|
|
|
else
|
|
|
|
exit 0
|
|
|
|
fi
|