#!/bin/bash # # Initialize root password # and secure MariaDB installation # [[ "$(CreoleGet dbEnable)" == "non" ]] && 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 service mariadb start ${passwd} ${PASSWORD} # Run secure installation script ${SECURE_CMD} > ${logfile} 2>&1 <<__EOF__ ${PASSWORD} y n y y y y __EOF__ service mariadb stop else exit 0 fi