eole-mariadb/pretemplate/25-bdd-init

38 lines
494 B
Plaintext
Raw Normal View History

#!/bin/bash
#
# Initialize root password
# and secure MariaDB installation
#
function genPasswordToFile()
{
local file=${1}
pwgen -1 10 > ${file}
chmod 600 ${file}
}
ROLE=$(CreoleGet dbClusterPosition)
WRITERFILE="/root/.bddadm"
SECURE_CMD="mysql_secure_installation"
[[ ${ROLE} == "Node" ]] && exit 0
[[ -e ${WRITERFILE} ]] && exit 0
genPasswordToFile ${WRITERFILE}
pass=$(< ${WRITERFILE})
# Run secure installation script
${SECURE_CMD} <<__EOF__
y
${pass}
${pass}
y
y
y
y
__EOF__