#!/bin/sh #ident "@(#)S86dsradius 1.24 12/01/99 SMI" # # # Copyright 12/01/99 Sun Microsystems, Inc. All Rights Reserved # # # Start/Stop Simple Ldap Daemon # trap 'echo "$0: Interrupted "; exit 1' INT QUIT USAGE="Usage: `basename $0` { start | stop | refresh }" BASEDIR=`/bin/pkgparam SUNWsdsr BASEDIR 2>/dev/null` if [ -z "$BASEDIR" ] # pkg not installed then BASEDIR=/opt # set default. Maybe the dir is nfs mounted fi PATH=/usr/sbin:/usr/bin:$BASEDIR/SUNWconn/ldap/lib:$BASEDIR/SUNWconn/ldap/sbin:$BASEDIR/SUNWconn/ldap/bin LD_LIBRARY_PATH=$BASEDIR/SUNWconn/ldap/lib:$LD_LIBRARY_PATH export PATH LD_LIBRARY_PATH # # Set NLSPATH for I18N # NLSPATH=${NLSPATH}:${BASEDIR}/SUNWconn/lib/locale/%L/%N.cat export NSLPATH logdir=`/bin/grep -i "^LogDir" /etc/opt/SUNWconn/ldap/current/dsradiusd.conf | awk '{ print $2 }'` logfile=dsradius.log case "$1" in 'start') pid=`/bin/ps -fe | /bin/grep $BASEDIR/SUNWconn/ldap/lib/dsradiusd | /bin/grep -v grep|/bin/awk '{print $2}'` if [ -n "$pid" ] then echo "Another DSRadius daemon is already running" exit 1 fi if [ -d $logdir ] then cd $logdir test -f $logfile.8 && /bin/mv $logfile.8 $logfile.9 test -f $logfile.7 && /bin/mv $logfile.7 $logfile.8 test -f $logfile.6 && /bin/mv $logfile.6 $logfile.7 test -f $logfile.5 && /bin/mv $logfile.5 $logfile.6 test -f $logfile.4 && /bin/mv $logfile.4 $logfile.5 test -f $logfile.3 && /bin/mv $logfile.3 $logfile.4 test -f $logfile.2 && /bin/mv $logfile.2 $logfile.3 test -f $logfile.1 && /bin/mv $logfile.1 $logfile.2 test -f $logfile && /bin/mv $logfile $logfile.1 /bin/touch $logfile else echo "Log directory $logdir does not exist" echo "DSRadius daemon not started" exit 1 fi echo "Starting DSRadius daemon \c" $BASEDIR/SUNWconn/ldap/lib/dsradiusd -y 50 -z 50 & >/dev/null 2>&1 /bin/sleep 2 until [ -s $logfile ] do echo ".\c" pid=`/bin/ps -fe | /bin/grep $BASEDIR/SUNWconn/ldap/lib/dsradiusd | /bin/grep -v grep|/bin/awk '{print $2}'` if [ -z "$pid" ] then echo "DSRadius daemon not started" /bin/cat $logfile exit 1 fi sleep 1 done pid=`/bin/ps -fe | /bin/grep $BASEDIR/SUNWconn/ldap/lib/dsradiusd | /bin/grep -v grep|/bin/awk '{print $2}'` if [ -z "$pid" ] then echo "DSRadius daemon not started" /bin/cat $logfile exit 1 fi echo "" ;; 'stop') pidradius=`/bin/ps -fe | /bin/grep $BASEDIR/SUNWconn/ldap/lib/dsradiusd | /bin/grep -v grep|/bin/awk '{print $2}'` if [ -n "$pidradius" ] then echo "Stopping DSRadius daemon" kill -TERM $pidradius else echo "DSRadius daemon not running" fi /bin/sleep 1 pidradius2=`/bin/ps -fe | /bin/grep $BASEDIR/SUNWconn/ldap/lib/dsradiusd | /bin/grep -v grep|/bin/awk '{print $2}'` if [ -n "$pidradius2" ] then /bin/sleep 2 if [ -n "$pidradius" ] then pid=`/bin/ps -fe | /bin/grep $BASEDIR/SUNWconn/ldap/lib/dsradiusd | /bin/grep -v grep|/bin/awk '{print $2}'` if [ -n "$pid" ] then kill -9 $pid echo "DSRadius daemon killed" else echo "DSRadius daemon stopped" fi fi else if [ -n "$pidradius" ] then echo "DSRadius daemon stopped" fi fi if [ -f /var/opt/SUNWconn/ldap/log/dsradius.pid ] then /bin/rm -f /var/opt/SUNWconn/ldap/log/dsradius.pid fi ;; 'refresh') pidradius=`/bin/ps -fe | /bin/grep $BASEDIR/SUNWconn/ldap/lib/dsradiusd | /bin/grep -v grep|/bin/awk '{print $2}'` if [ -n "$pidradius" ] then echo "Refreshing the DSRadius daemon RAS Cache..." for pid in $pidradius; do kill -HUP $pid sleep 3 done else echo "DSRadius daemon not running" exit 1 fi ;; *) echo ${USAGE} exit 1 ;; esac exit 0