#!/bin/sh
# This shell script invokes NetBox's housekeeping management command, which
# intended to be run nightly.
#
# If you want to enable this script, copy it to %%PREFIX%%/etc/periodic/daily
# and place the following into /etc/periodic.conf:
#
# daily_netbox_housekeeping_enable="YES"
#
# If NetBox has been installed into a nonstandard location, update the paths
# below.
command="%%PYTHON_CMD%%"
netbox_root="%%DATADIR%%"

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]; then
	. /etc/defaults/periodic.conf
	source_periodic_confs
fi

rc=0

case "$daily_netbox_housekeeping_enable" in
	[Yy][Ee][Ss])
	echo ""
	echo "Running NetBox housekeeping:"
	$command "$netbox_root/manage.py" housekeeping
	rc=$?
esac

exit $rc
