Manage sqlite sync and shared datastore in ha mode

This commit is contained in:
2019-02-27 11:34:34 +01:00
parent 3e641814cf
commit 36fae0773d
3 changed files with 92 additions and 18 deletions

26
preservice/31-one-ha Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
HA=$(CreoleGet activer_one_ha non)
DBMODE=$(CreoleGet one_database_type "none")
LEADER_DB_FILE="/var/lib/one/one.db.leader"
DBFILE="/var/lib/one/one.db"
# If HA is enabled and a leader database file is present
# we restore the leader database.
if [[ ${HA} == "oui" ]] && [[ ${DBMODE} == "sqlite" ]]
then
if [[ -f ${LEADER_DB_FILE} ]]
then
if [[ $(CreoleGet one_ha_server_index) != "0" ]]
then
onedb restore --sqlite ${DBFILE} ${LEADER_DB_FILE} -f
if [[ $? -eq 0 ]]
then
rm ${LEADER_DB_FILE}
exit ${?}
fi
fi
fi
fi
exit 0