#! /bin/bash -i

#
# This script presents an upstart service in the ExaGear guest system as
# a host service.
#
# Copyright (c) 2013 "Elbrus Technologies" LLC. All rights reserved.
#
# This script comes with NO warranty, not even for MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#

if [ -z "$1" ] ; then
    echo "Use:"
    echo "    $0 name-of-guest-service"
    echo "to make the host's upstart daemon control a guest service."
    exit 1
fi

. $EXAGEAR_GUEST_CONFFILE

if [ $DELEGATE_RC_SCRIPTS_AUTOMATICALLY == "Y" ]; then
    echo "The guest image $EXAGEAR_IMAGE_NAME uses automatic integration of the startup"
    echo "and shutdown mechanisms of the host and guest systems. If you want to use"
    echo "this script to enable the autostart of individual guest services, please"
    echo "first disable the automatic integration. You can do this by editing the file"
    echo "    $EXAGEAR_GUEST_CONFFILE"
    exit 0
fi

$(realpath $(dirname $0))/upstart-integration/upstart-service-converter $1
