change tab to 4 spaces + add ssh-keyscan

This commit is contained in:
Emmanuel Garette 2019-02-28 11:10:45 +01:00
parent 10369f18f9
commit d7a4769ec0
1 changed files with 28 additions and 27 deletions

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 ${?}
} }
# #
@ -196,17 +197,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