#!/bin/sh -e
#
# Copyright 2001-2018 Univention GmbH
#
# http://www.univention.de/
#
# All rights reserved.
#
# The source code of this program is made available
# under the terms of the GNU Affero General Public License version 3
# (GNU AGPL V3) as published by the Free Software Foundation.
#
# Binary versions of this program provided by Univention to you as
# well as other copyrighted, protected or trademarked materials like
# Logos, graphics, fonts, specific documentations and configurations,
# cryptographic keys etc. are subject to a license agreement between
# you and Univention and not subject to the GNU AGPL V3.
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided 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 with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

@%@UCRWARNING=# @%@

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/usr/sbin/univention-virtual-machine-manager-daemon  # Introduce the server's location here
NAME="uvmmd"              # Introduce the short server's name here
LOGDIR=/var/log/univention # Log directory to use

LOGFILE="$LOGDIR/virtual-machine-manager-daemon-errors.log"  # Server logfile

# virConnSetErrorFunc() is not exposed to the Python API, so
# libvirt always logs errors to STDERR in addition to UVMMds error handling.
export LIBVIRT_DEBUG=error # libvirt default error log level for stderr
export LIBVIRT_LOG_OUTPUTS=4:file:/dev/null # additional libvirt errors are ignored

DAEMON_OPTS=        # Additional options given to the server

if [ -f "/etc/default/$NAME" ] ; then
	. "/etc/default/$NAME"
fi

exec >>"$LOGFILE" 2>&1
echo "=== $$ === $(date --rfc-2822) ==="
exec "$DAEMON" -l "$LOGFILE" $DAEMON_OPTS
