Merge branch 'develop' into dist/eole/2.7.0/develop

This commit is contained in:
vincent 2019-03-01 09:19:03 +01:00
commit 458e5b4ca2
2 changed files with 52 additions and 36 deletions

View File

@ -1,5 +1,15 @@
#!/bin/bash
/usr/share/eole/sbin/onehost_create_all
ha=$(CreoleGet activer_one_ha non)
if [[ ${ha} == "oui" ]]
then
indx=$(CreoleGet one_ha_server_index)
else
indx="0"
fi
if [[ ${1} == "instance" ]] && [[ ${indx} == "0" ]]
then
/usr/share/eole/sbin/onehost_create_all
fi
exit 0

View File

@ -28,6 +28,7 @@ EOF
REMOTEKEY=$(su - oneadmin -c "ssh ${host} 'cat ~oneadmin/.ssh/id_rsa.pub'")
if ! grep -qs "$REMOTEKEY" ~oneadmin/.ssh/authorized_keys; then
su - oneadmin -c "echo ${REMOTEKEY} >> ~oneadmin/.ssh/authorized_keys"
su - oneadmin -c "ssh-keyscan $host"
fi
}
@ -46,20 +47,20 @@ function copy_files()
function sync_db()
{
local ip=${1}
local user="oneadmin"
local DBFILE="/var/lib/one/one.db"
local DBBCK="/tmp/one.db.bck"
local ret=0
local user="oneadmin"
local DBFILE="/var/lib/one/one.db"
local DBBCK="/tmp/one.db.bck"
local ret=0
if [[ ! -f ${DBBCK} ]]
then
cmd="onedb backup --sqlite ${DBFILE} ${DBBCK}"
ret=$(su - ${user} -c -- "${cmd}")
fi
if [[ ! -f ${DBBCK} ]]
then
cmd="onedb backup --sqlite ${DBFILE} ${DBBCK}"
ret=$(su - ${user} -c -- "${cmd}")
fi
cmd2="scp ${DBBCK} ${ip}:${DBFILE}.leader"
ret=$(su - ${user} -c -- "${cmd2}")
return ${?}
cmd2="scp ${DBBCK} ${ip}:${DBFILE}.leader"
ret=$(su - ${user} -c -- "${cmd2}")
return ${?}
}
#
@ -69,10 +70,10 @@ function sync_db()
#
function sync_nodes()
{
# Need to sync hosts with rsync after creation, ONE 5.6.1 bug
cmd2="onehost sync -f --rsync"
ret2=$(su - ${ONEUSER} -c -- "${cmd2}")
return ${?}
# Need to sync hosts with rsync after creation, ONE 5.6.1 bug
cmd2="onehost sync -f --rsync"
ret2=$(su - ${ONEUSER} -c -- "${cmd2}")
return ${?}
}
#
@ -159,6 +160,18 @@ fi
HAPY_HA=$(CreoleGet activer_one_ha "non")
master=1
if [[ ${HAPY_HA} == "oui" ]]; then
idx=$(CreoleGet one_ha_server_index)
if [[ ${idx} != "0" ]]; then
EchoBleu "Mode HA: (on) Index : [${idx}]"
echo -e "\t$(basename ${0}) doit être lancé uniquement sur le leader (index 0)"
exit 0
else
master=0
fi
fi
declare -a HAPY_SLV=('')
ONEUSER=$(CreoleGet virt_user)
HAPY_SLV=$(echo $(CreoleGet one_nodes) | sed -e "s/\n/ /g")
@ -174,14 +187,7 @@ then
exit 1
fi
master=1
if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then
if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then
exit 0
else
master=0
fi
fi
for host in ${HAPY_SLV}; do
echo -e "\n"
EchoOrange "Traitement du noeud ${host}"
@ -196,17 +202,17 @@ for host in ${HAPY_SLV}; do
EchoVert " * Enregistrement du noeud"
register_node ${host}
# wait_node_ok ${host}
if [[ ${HAPY_HA} == "oui" ]]
then
if [[ $DBMODE == "sqlite" ]]
then
if [[ $(CreoleGet one_ha_server_index) == "0" ]]
then
sync_db ${host}
fi
fi
fi
sync_nodes
if [[ ${HAPY_HA} == "oui" ]]
then
if [[ $DBMODE == "sqlite" ]]
then
if [[ $(CreoleGet one_ha_server_index) == "0" ]]
then
sync_db ${host}
fi
fi
fi
sync_nodes
wait_node_ok ${HAPY_SLV[${i}]}
if [[ ${?} -ne 0 ]]
then