#!/bin/ksh

# "meta" script running the following rc.d(8) scripts with the given argument;
# note that "daemon_*" variables are not passed to the child scripts.
_pkg_scripts="kopano_server kopano_spooler kopano_monitor kopano_gateway kopano_ical kopano_search"

if [[ $1 == restart ]]; then
	$0 stop && $0 start
	exit
fi

if [[ $1 == stop ]]; then
	for _i in ${_pkg_scripts}; do _l="${_i} ${_l}"; done
	_pkg_scripts=${_l% }
fi

for _i in ${_pkg_scripts}; do
	if [[ -x /etc/rc.d/${_i} ]]; then
		/etc/rc.d/${_i} $@ || exit $?
	fi
done
