Correct management of leadership

This commit is contained in:
Philippe Caseiro 2018-04-12 17:10:39 +02:00
parent d138e0715b
commit 3cbfed8f2d
2 changed files with 27 additions and 14 deletions

View File

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

View File

@ -6,15 +6,23 @@
cmd="mysql" cmd="mysql"
options='--defaults-file=/etc/mysql/debian.cnf' options='--defaults-file=/etc/mysql/debian.cnf'
if [[ -z ${1} ]] role=$(CreoleGet dbClusterRole 'Leader')
if [[ ${role} == "Leader"]]
then then
read -s -p "New Password : " password if [[ -z ${1} ]]
echo 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 else
password="${1}" echo "This command don't work in a MariaDB Cluster Node, try in the Leader"
fi exit 3
fi
sql="FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY '${password}';"
${cmd} ${options} -e "${sql}"
exit $?