#!/bin/sh # # "$Id: initd.script,v 1.3 2005/02/10 07:25:43 elkner Exp $" # # description: # Startup/shutdown script for the Cyrus SASL authentification daemon # # default: S/K39 0/K39 1/K39 2/S80 . /lib/svc/share/smf_include.sh SPATH="@CLIENT_BASEDIR@/sbin" DAEMON="saslauthd" # directory, where the socket should be created SOCKETDIR="/var/run" # the authitification mechanism to use AUTH="shadow" # other options OPTIONS="" NAME="Cyrus SASL authentification daemon" # Read command line arguments method="$1" # %m instance="$2" # %i # Set defaults; SMF_FMRI should have been set, but just in case. if [ -z "$SMF_FMRI" ]; then if [ -z "$instance" ]; then instance="default" fi SMF_FMRI="svc:/network/saslauthd:${instance}" fi ZN=`/sbin/zonename` if [ "$ZN" = "global" ]; then ZPPID=1 else ZPPID=`pgrep -x zsched 2>/dev/null` fi getoptions() { VAL=`/usr/bin/svcprop -p 'options/authmech' $SMF_FMRI 2>/dev/null` if [ -z "$VAL" -o "$VAL" = '""' ]; then cmdopts="-a $AUTH" else cmdopts="-a $VAL" fi VAL=`/usr/bin/svcprop -p 'options/sockdir' $SMF_FMRI 2>/dev/null` if [ -z "$VAL" -o "$VAL" = '""' ]; then cmdopts="${cmdopts} -m $SOCKETDIR" else cmdopts="${cmdopts} -m $VAL" fi VAL=`/usr/bin/svcprop -p 'options/other' $SMF_FMRI 2>/dev/null | sed -e 's,\\\\,,g'` if [ -n "$VAL" -a "$VAL" != '""' ]; then cmdopts="${cmdopts} ${VAL}" fi } case "$method" in start) if [ ! -x "${SPATH}/${DAEMON}" ]; then echo "${SPATH}/${DAEMON} does not exist" exit $SMF_EXIT_ERR_FATAL fi pid=`pgrep -x -u 0 -P $ZPPID ${DAEMON}` if [ -z "$pid" ]; then echo "Starting $NAME ... \c" getoptions ${SPATH}/${DAEMON} ${cmdopts} if [ $? -ne 0 ]; then echo "failed." exit $SMF_EXIT_ERR_CONFIG else echo "done." fi else echo "$NAME is already running." fi ;; stop) pid=`pgrep -x -u 0 -P $ZPPID $DAEMON` if [ -n "$pid" ]; then echo "Stopping $NAME ... \c" pkill -x -u 0 -P $ZPPID $DAEMON if [ $? -eq 0 ]; then echo 'done.' fi fi ;; status) pid=`pgrep -x -u 0 -P $ZPPID $DAEMON` if [ -n "$pid" ]; then echo "$NAME is running." else echo "$NAME is not running." fi ;; *) echo "Usage: $0 {start|status|stop}" exit $SMF_EXIT_ERR_FATAL ;; esac exit $SMF_EXIT_OK