Compare commits

..

14 Commits

5 changed files with 64 additions and 40 deletions

View File

@ -95,8 +95,8 @@
</family>
<family name="Database Cluster">
<variable name='dbClusterPosition' type='string' description="Rôle dans la grappe" mandatory='True'/>
<variable name='ifDBCluster' type='string' description="Interface réseau dédiée à la grappe BDD"/>
<!-- FIXME : Fill this variable with nom_machine -->
<variable name='nodeName' type='string' description="Nom du noeud local"/>
@ -137,6 +137,10 @@
<param>['Default','Custom']</param>
</check>
<check name='valid_enum' target='dbClusterPosition'>
<param>['Leader','Node']</param>
</check>
<group master='accName'>
<slave>accLimits</slave>
<slave>accLimitTarget</slave>

View File

@ -2,16 +2,14 @@
db=$(CreoleGet dbEnable non)
cluster=$(CreoleGet dbEnableCluster non)
role=$(CreoleGet dbClusterPosition 'Node')
gstateFile="/var/lib/mysql/grastate.dat"
if [[ ${db} == "oui" ]]
then
if [[ ${cluster} == "oui" ]]
then
if [[ ! -e ${gstateFile} ]]
then
galera_new_cluster
fi
[[ ${role} == "Leader" ]] && galera_new_cluster
fi
fi

29
preservice/25-bdd-init Normal file
View File

@ -0,0 +1,29 @@
#!/bin/bash
#
# Initialize root password
# and secure MariaDB installation
#
ROLE=$(CreoleGet dbClusterPosition 'Leader')
SECURE_CMD="mysql_secure_installation"
PASSWORD=$(pwgen -1 10)
passwd="/usr/share/eole/sbin/mariadbPwd"
logfile="/var/log/eole/maria-init.log"
if [[ ${ROLE} == "Leader" ]]
then
${passwd} ${PASSWORD}
# Run secure installation script
${SECURE_CMD} > ${logfile} 2>&1 <<__EOF__
${PASSWORD}
y
n
y
y
y
y
__EOF__
else
exit 0
fi

View File

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

28
scripts/mariadbPwd Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
#
# Renew MariaDB root password
# Just like old (mysql_pwd.py)
#
cmd="mysql"
options='--defaults-file=/etc/mysql/debian.cnf'
role=$(CreoleGet dbClusterRole 'Leader')
if [[ ${role} == "Leader"]]
then
if [[ -z ${1} ]]
then
read -s -p "New Password : " password
echo
else
password="${1}"
fi
sql="FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY '${password}';"
${cmd} ${options} -e "${sql}"
exit $?
else
echo "This command don't work in a MariaDB Cluster Node, try in the Leader"
exit 3
fi