#!/bin/bash

. ${TOOLKIT}-functions.sh

# performs disk free space checks only if cli-nagios not present
#
have_nagios=$(jtconf cli-nagios.allowed_hosts 2>/dev/null) || :
file="auto-check-freespace"
dest="/etc/kuwatcher/conf.d/"

if [ "X$have_nagios" = "X" ]
then
	installfile "$file" "$dest" root:root 644
else
	uninstallfiles "$dest$file"
	[ -f "$dest$file" ] && {
		rm "$dest$file"
		echo "  removed $dest$file"
	}
fi



# cleanup obsolete stuffs
#
dir="/etc/kuwatcher/conf.d"

[ -f $dir/check-free-space ] && {
	rm -f $dir/check-free-space
	SOMETHING_CHANGED=true
}

$SOMETHING_CHANGED && {
	restart_service kuwatcher "" || exit $?
}

exit 0
