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 #!/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 exit 0

View File

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