#!/bin/bash
##
#  Korinf project
#
#  Message functions
#
#  Copyright (c) Etersoft <http://etersoft.ru> 2005-2009
#  Copyright (c) Vitaly Lipatov <lav@etersoft.ru> 2009
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Affero General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.

#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Affero General Public License for more details.

#  You should have received a copy of the GNU Affero General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##

EXIT_PROCESSING=
exit_now()
{
	[ -n "$EXIT_PROCESSING" ] && exit 1
	EXIT_PROCESSING=1
	# disable trap before exit
	trap - EXIT
	[ -n "$MOUNT_MODULE_INCLUDED" ] && end_umount
	exit 1
}

fatal()
{
	echo "FATAL: $@" >&2
	exit_now
}

warning()
{
	echo "WARNING: $@" >&2
	echo "`date` $dist WARNING: $@" | write_report
	[ -n "$CAREBUILD" ] && exit_now
	return 1
}

error()
{
	echo "ERROR: $@" >&2
	echo "`date` $dist ERROR: $@" | write_report
	[ -n "$CAREBUILD" ] && exit_now
	return 1
}

alert()
{
	echo "Alert: $@" >&2
	echo "`date` $dist Alert: $@" | write_report
}
