#!/bin/bash
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
# Component: start script for cdm

### Constants ###

EXIT_SUCCESS=0
EXIT_INVALID_USAGE=1


### Local functions ###

# $1 - exit code
function ExitUsage()
{
    echo "${lf_usage}" 1>&2
    exit $1
}

function ExitInvalidUsage()
{
    echo "${l_invalid_arg1}$1${l_invalid_arg2}" 1>&2
    echo "${sf_usage}" 1>&2
    exit ${EXIT_INVALID_USAGE}
}


### Main ###

if [ -f $TTAMSG/common -a -f $TTAMSG/cdm_start ]; then
  . $TTAMSG/common
  . $TTAMSG/cdm_start
else
  echo "Unable to open message file: $TTAMSG/cdm_start"
  exit 1
fi


# Parse command line arguments. Only --help permitted.
[ "$1" = "--help" ] && ExitUsage ${EXIT_SUCCESS}
[ $# = 0 ] || ExitInvalidUsage

# Defer to the old start cdm script
${TTADIR}/bin/scripts/start_cdm

exit ${EXIT_SUCCESS}
