### Package specific variables and functions
if [ -z "${SYNOPKG_PKGNAME}" ] || [ -z "${SYNOPKG_DSM_VERSION_MAJOR}" ]; then
  echo "Error: Environment variables are not set." 1>&2;
  echo "Please run me using synopkg instead. Example: \"synopkg start [packagename]\"" 1>&2;
exit 1; fi
# Base service USER to run background process prefixed according to DSM
USER="postgresql"
PRIV_PREFIX=sc-
SYNOUSER_PREFIX=svc-
if [ -n "${SYNOPKG_DSM_VERSION_MAJOR}" ] && [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 6 ]; then EFF_USER="${SYNOUSER_PREFIX}${USER}"; else EFF_USER="${PRIV_PREFIX}${USER}"; fi
# start-stop-status script redirect stdout/stderr to LOG_FILE
LOG_FILE="${SYNOPKG_PKGVAR}/${SYNOPKG_PKGNAME}.log"
# Service command has to deliver its pid into PID_FILE
PID_FILE="${SYNOPKG_PKGVAR}/${SYNOPKG_PKGNAME}.pid"

# Invoke shell function if available
call_func ()
{
    FUNC=$1
    if type "$FUNC" 2>/dev/null | grep -q 'function' 2>/dev/null; then
        if [ -n "${INST_LOG}" ]; then
            echo "Invoke $FUNC" >> ${INST_LOG}
        fi
        eval ${FUNC}
    fi
}

