#!/bin/sh

set -e

database_pw=$(grep -m1 database_password /etc/cacti/debian.php | \
		  awk '{print $3}' | sed "s/';//" | sed "s/'//")
database_pw=${database_pw%%\";}
database_pw=${database_pw#\"}

# Remove the crontab line to prevent the cron from interfering
rm -f /etc/cron.d/cacti

tests/tools/check_all_pages.sh -du cacti -dp ${database_pw}

# To make sure that the autopkgtest/CI sites store the information
if [ -n "${AUTOPKGTEST_ARTIFACTS}" ] ; then
    cp -rf /tmp/check-all-pages/ "${AUTOPKGTEST_ARTIFACTS}"
    # Temporarily until release 1.2.24
    chmod a+r -R "${AUTOPKGTEST_ARTIFACTS}"
fi
