#!/usr/bin/sh

##  Copyright 2012-2026 Carnegie Mellon University
##  See license information in LICENSE.txt.
##
##  etc/systemd/super_mediator_startup.  Generated from super_mediator_startup.in by configure.
##
#
# Running "systemctl start super_mediator" invokes this script to
# build the command line arguments and to exec the program.
#
##  ------------------------------------------------------------------------
##  Authors: Emily Sarneso, Dwight Beaver
##  ------------------------------------------------------------------------
##  @DISTRIBUTION_STATEMENT_BEGIN@
##  super_mediator-1.14
##
##  Copyright 2026 Carnegie Mellon University.
##
##  NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING
##  INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON
##  UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
##  AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR
##  PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF
##  THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF
##  ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT
##  INFRINGEMENT.
##
##  Licensed under a GNU GPL 2.0-style license, please see LICENSE.txt or
##  contact permission@sei.cmu.edu for full terms.
##
##  [DISTRIBUTION STATEMENT A] This material has been approved for public
##  release and unlimited distribution.  Please see Copyright notice for
##  non-US Government use and distribution.
##
##  This Software includes and/or makes use of Third-Party Software each
##  subject to its own license.
##
##  DM26-0748
##  @DISTRIBUTION_STATEMENT_END@
##  ------------------------------------------------------------------------

RETVAL=0

MYNAME="super_mediator"

# autoconf stuff
prefix=/usr
exec_prefix=/usr

# super_mediator.conf must be located in the SCRIPT_CONFIG_LOCATION directory
# to work.
# Edit this line or set the SCRIPT_CONFIG_LOCATION environment variable if
# super_mediator.conf is not located in the default location.
if [ "x$SCRIPT_CONFIG_LOCATION" = "x" ] ; then
    SCRIPT_CONFIG_LOCATION=/etc
fi

# If invoked as an instantiated service, apply the instance name
if [ -n "$1" ] ; then
    SCRIPT_CONFIG=${SCRIPT_CONFIG_LOCATION}/${MYNAME}.$1.conf
else
    SCRIPT_CONFIG=${SCRIPT_CONFIG_LOCATION}/${MYNAME}.conf
fi

if [ ! -f "${SCRIPT_CONFIG}" ] ; then
    echo "$0: Configuration file '${SCRIPT_CONFIG}' does not exit" 1>&2
    exit 1
fi

check_executable()
{
    if [ ! -x $1 ] ; then
        echo "$0: $1 is not executable or not found."
        exit 1
    fi
}

SMBIN=/usr/bin/super_mediator

check_executable ${SMBIN}

# build the argument lists

SMARGS=""
SMARGS="$SMARGS -c ${SCRIPT_CONFIG}"

exec $SMBIN $SMARGS
