eole-one-master/preservice/31-one-ha

27 lines
618 B
Plaintext
Raw Permalink Normal View History

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