2018-07-13 03:26:48 +02:00
|
|
|
setup() {
|
2018-07-15 06:43:11 +02:00
|
|
|
|
|
|
|
# Write a basic backupninja config file
|
2018-07-13 03:26:48 +02:00
|
|
|
cat << EOF > "${BATS_TMPDIR}/backupninja.conf"
|
|
|
|
when = manual
|
2018-07-15 06:43:11 +02:00
|
|
|
loglevel = 5
|
2018-07-13 03:26:48 +02:00
|
|
|
reportemail = root
|
|
|
|
reportsuccess = yes
|
|
|
|
reportinfo = no
|
|
|
|
reportwarning = yes
|
|
|
|
reportspace = no
|
|
|
|
reporthost =
|
|
|
|
reportuser = ninja
|
|
|
|
reportdirectory = /var/lib/backupninja/reports
|
|
|
|
admingroup = root
|
|
|
|
logfile = ${BATS_TMPDIR}/log/backupninja.log
|
|
|
|
configdirectory = ${BATS_TMPDIR}/backup.d
|
|
|
|
scriptdirectory = /usr/share/backupninja
|
|
|
|
libdirectory = /usr/lib/backupninja
|
|
|
|
usecolors = no
|
|
|
|
EOF
|
|
|
|
|
|
|
|
mkdir "${BATS_TMPDIR}/log" "${BATS_TMPDIR}/backup.d"
|
|
|
|
chmod 0750 "${BATS_TMPDIR}/backup.d"
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
2018-07-15 06:43:11 +02:00
|
|
|
|
|
|
|
# Print the debug log in case the test case fails
|
|
|
|
echo "cat ${BATS_TMPDIR}/log/backupninja.log :"
|
|
|
|
cat "${BATS_TMPDIR}/log/backupninja.log"
|
|
|
|
|
2018-07-13 03:26:48 +02:00
|
|
|
# Clean up
|
|
|
|
rm -rf "${BATS_TMPDIR}/backupninja.conf" \
|
|
|
|
"${BATS_TMPDIR}/log" \
|
|
|
|
"${BATS_TMPDIR}/backup.d" \
|
|
|
|
/var/mail/vagrant \
|
|
|
|
/var/backups/*
|
|
|
|
}
|
|
|
|
|
|
|
|
setconfig() {
|
|
|
|
if grep -q "$2 =" "${BATS_TMPDIR}/$1"; then
|
|
|
|
sed -i "s/^$2.*/$2 = $3/" "${BATS_TMPDIR}/$1"
|
|
|
|
else
|
|
|
|
echo "$2 = $3/" >> "${BATS_TMPDIR}/$1"
|
|
|
|
fi
|
|
|
|
}
|