#!/bin/bash
cmd=${1:-create}
post_hook=/etc/commit/post-hooks.d/99ifmgrctl-apply

case $cmd in 
	create)
		echo -e '#!/bin/bash\nifmgrctl apply\n' > $post_hook
		[[ -r $post_hook ]]  || { echo "$0: can't create $post_hook"; exit 1; }
		chmod a+x $post_hook
		;;
	delete)
		[[ -r $post_hook ]] && rm -f $post_hook
		;;
	*)
		echo "$0: unknown command" >&2
		exit 1
esac
exit 0
