#!/bin/sh
#
# "$Id: ec_backends.method 1101 2008-10-17 18:13:31Z elkner $"
#
# description:
# Startup/shutdown script for EduComponent Backends
#
# default: S/K39 0/K39 1/K39 2/K39 3/S90
. /lib/svc/share/smf_include.sh
NAME="EduComponents Backend "
SPOOLER_FMRI='svc:/application/ec/spooler:default'
USE_RCTL='true'
export USE_RCTL
# Read command line arguments
method="$1" # %m
BACKEND_NAME="$2"
instance="$3" # %i
Usage() {
echo "Usage: $0 {start|status|stop} instance BackendName"
}
if [ -z "$BACKEND_NAME" ]; then
echo "Missing BackendName - exiting"
Usage
exit $SMF_EXIT_ERR_FATAL
fi
# Set defaults; SMF_FMRI should have been set, but just in case.
if [ -z "$SMF_FMRI" ]; then
if [ -z "$instance" ]; then
instance=`echo "$BACKEND_NAME" | tr '[:upper:]' '[:lower:]'`
exit $SMF_EXIT_ERR_NOSMF
fi
SMF_FMRI="svc:/application/ec/backend:${instance}"
fi
getoptions() {
VAL=`/usr/bin/svcprop -p 'options/basedir' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
BACKENDCTL="${VAL}/bin/backendctl"
else
echo "Property 'options/basedir' is not set for $SMF_FMRI - exiting"
exit $SMF_EXIT_ERR_CONFIG
fi
cmdopts=""
VAL=`/usr/bin/svcprop -p 'options/logdir' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -L $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/tmpdir' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -t $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/vardir' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -v $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/workdir' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -w $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/loglevel' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -l $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/sphost' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -H $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/port' $SPOOLER_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -P $VAL "
else
echo "WARNING: property 'options/port' of $SPOOLER_FMRI is not set!"
fi
VAL=`/usr/bin/svcprop -p 'options/trace' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -T $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/cleanup' $SMF_FMRI 2>/dev/null`
if [ "$VAL" = 'false' ]; then
cmdopts="${cmdopts} -d "
fi
VAL=`/usr/bin/svcprop -p 'options/interpreter' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -i $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/compiler' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -c $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/vardir' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -v $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/host' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -b $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/port' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -B $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/user' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -u $VAL "
fi
VAL=`/usr/bin/svcprop -p 'options/authfile' $SMF_FMRI 2>/dev/null`
if [ -n "$VAL" -a "$VAL" != '""' ]; then
cmdopts="${cmdopts} -a $VAL "
fi
}
getoptions
if [ ! -x "${BACKENDCTL}" ]; then
echo "${BACKENDCTL} does not exist"
echo "Adjust property 'options/basedir' for $SMF_FMRI"
exit $SMF_EXIT_ERR_FATAL
fi
case "$method" in
start)
echo "Starting $NAME $BACKEND_NAME ... \c"
echo "${BACKENDCTL} ${cmdopts} $BACKEND_NAME start"
${BACKENDCTL} ${cmdopts} "$BACKEND_NAME" start
ST=$?
if [ $ST -ne 0 ]; then
echo 'failed.'
exit $ST
else
echo 'done.'
fi
;;
stop)
echo "Stopping $NAME $BACKEND_NAME ... \c"
${BACKENDCTL} ${cmdopts} "$BACKEND_NAME" stop
if [ $? -eq 0 ]; then
echo 'done.'
else
echo 'failed.'
exit $SMF_EXIT_ERR_OTHER
fi
;;
status)
${BACKENDCTL} ${cmdopts} "$BACKEND_NAME" status
;;
*)
exit $SMF_EXIT_ERR_FATAL
;;
esac
exit $SMF_EXIT_OK