eole-one-master/posttemplate/90-one-db

50 lines
638 B
Plaintext
Raw Normal View History

#!/bin/bash
#
# AIM : Manage Opennebula database update
#
#
. /usr/lib/eole/ihm.sh
function clean_backups()
{
file=${1}
bcks=($(ls ${file}_*))
nbbck=$(expr ${#bcks[@]} - 2)
if [[ ${nbbck} -gt 1 ]]
then
EchoGras "Cleaning up old backups !"
for idx in `seq 0 ${nbbck}`
do
rm -f ${bcks[${idx}]}
done
fi
}
function updateDB()
{
local dbfile='/var/lib/one/one.db'
local cmd="onedb"
local res=0
if [[ -f ${dbfile} ]]
then
$cmd upgrade -f -s ${dbfile}
res=${?}
clean_backups ${dbfile}
return ${res}
else
return 0
fi
}
echo
EchoGras "Mise à jour de la base de données ONE"
echo
updateDB
echo
exit ${?}