39 lines
668 B
Bash
39 lines
668 B
Bash
#!/bin/bash
|
|
#
|
|
# Initialize root password
|
|
# and secure MariaDB installation
|
|
#
|
|
|
|
INITDONE="/etc/eole/.galera"
|
|
|
|
[[ "$(CreoleGet dbEnable)" == "non" ]] && exit 0
|
|
[[ -e ${INITDONE} ]] && exit 0
|
|
|
|
ROLE=$(CreoleGet dbClusterPosition 'Leader')
|
|
SECURE_CMD="mysql_secure_installation"
|
|
PASSWORD=$(pwgen -1 10)
|
|
passwd="/usr/share/eole/sbin/mariadbPwd"
|
|
logdir="/var/log/eole"
|
|
logfile="${logdir}/maria-init.log"
|
|
|
|
[[ ! -d "${logdir}" ]] && mkdir -p ${logdir}
|
|
|
|
if [[ ${ROLE} == "Leader" ]]
|
|
then
|
|
${passwd} ${PASSWORD}
|
|
|
|
# Run secure installation script
|
|
${SECURE_CMD} > ${logfile} 2>&1 <<__EOF__
|
|
${PASSWORD}
|
|
y
|
|
n
|
|
y
|
|
y
|
|
y
|
|
y
|
|
__EOF__
|
|
touch ${INITDONE}
|
|
exit ${?}
|
|
else
|
|
exit 0
|
|
fi |