#!/bin/sh
# Run by daily cron job.

failed=""

. /etc/ikiwiki-hosting/ikiwiki-hosting.conf

for site in $(ikisite list); do
	# Rotate logs, gc git repos, etc.
	if ! ikisite compact "$site"; then
		echo "ikisite compact $site failed" >&2
		failed=1
	fi

	# Update calendars for sites that have the calendar plugin enabled.
	if ! ikisite calendar "$site"; then
		echo "ikisite calendar $site failed" >&2
		failed=1
	fi
done

# Reload apache so it will start logging to the new site log files.
/etc/init.d/apache2 reload
		
if [ "$failed" ]; then
	exit 1
else
	exit 0
fi
