2018-04-12 12:07:27 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Initialize root password
|
|
|
|
# and secure MariaDB installation
|
|
|
|
#
|
|
|
|
|
|
|
|
function genPasswordToFile()
|
|
|
|
{
|
2018-04-12 14:10:27 +02:00
|
|
|
local file=${1}
|
|
|
|
pwgen -1 10 > ${file}
|
|
|
|
chmod 600 ${file}
|
2018-04-12 12:07:27 +02:00
|
|
|
}
|
2018-04-12 12:14:05 +02:00
|
|
|
ROLE=$(CreoleGet dbClusterPosition)
|
2018-04-12 12:07:27 +02:00
|
|
|
WRITERFILE="/root/.bddadm"
|
|
|
|
SECURE_CMD="mysql_secure_installation"
|
2018-04-12 14:10:27 +02:00
|
|
|
oldPass=""
|
2018-04-12 12:07:27 +02:00
|
|
|
|
2018-04-12 14:10:27 +02:00
|
|
|
#[[ ${ROLE} == "Node" ]] && exit 0
|
|
|
|
[[ -e ${WRITERFILE} ]] && oldPass=$(< ${WRITERFILE})
|
2018-04-12 12:14:05 +02:00
|
|
|
|
2018-04-12 12:07:27 +02:00
|
|
|
genPasswordToFile ${WRITERFILE}
|
|
|
|
pass=$(< ${WRITERFILE})
|
|
|
|
|
|
|
|
# Run secure installation script
|
|
|
|
${SECURE_CMD} <<__EOF__
|
2018-04-12 14:10:27 +02:00
|
|
|
${oldPass}
|
2018-04-12 12:07:27 +02:00
|
|
|
y
|
|
|
|
${pass}
|
|
|
|
${pass}
|
|
|
|
y
|
|
|
|
y
|
|
|
|
y
|
|
|
|
y
|
2018-04-12 14:10:27 +02:00
|
|
|
__EOF__
|