#!/bin/sh
# This script is run after commit to reset the evaluated flag for each feature
# The locking is needed because we want to make sure we have reset the flag
# but once it has been reset we don't want it reset again

LOCKFILE=/ifs/.ifsvar/upgrade/EVAL_RESET_LOCK
FLAG_DIR=/ifs/.ifsvar/upgrade
EVAL_RESET_FILE=$FLAG_DIR/LIC_EVAL_RESET_COMPLETE

mkdir -p $FLAG_DIR

case $# in
	0)
		exec lockf $LOCKFILE $0 under-lock || exit 0
		;;
	1)
		HOSTNAME=`hostname`
		if [ ! -f $EVAL_RESET_FILE ]; then
			# Reset the licenses
			echo $HOSTNAME resetting...
			python -c "import isi.licensing.reset_eval as reset; reset.do_reset()" || exit 1
			echo $HOSTNAME reset
		else
			echo $HOSTNAME $EVAL_RESET_FILE found, skipping.
		fi
		;;
esac

