#! /bin/sh # stop dccd # This script assumes that it is being run by root or the DCC user, probably # while the system is stopping. # --S-LICENSE-- # $Revision: 1.30 $ # @configure_input@ exec 1>&2 /dev/null 2>&1 \ && grep '^32702[ ]' $DCC_HOMEDIR/ids >/dev/null 2>&1; then GREY_SRVR_ID=32702 fi SRVR_ID="$GREY_SRVR_ID" DCCD_ARGS="$GREY_DCCD_ARGS" CDCC_ARGS=" $CDCC_ARGS 'grey on'" fi if test -z "$SRVR_ID"; then if test X"$DEBUG" = "X-x"; then echo "${GREY}SRVR_ID not set in $DCC_HOMEDIR/dcc_conf" fi exit fi # talk where the current server should be listening SRVR_ADDR=`expr X"$DCCD_ARGS" : '.*-a[ ]*\([^ , ]*\)'` SRVR_PORT=`expr X"$DCCD_ARGS" : '.*-a[ ]*[^ , ]*,\([^ , ]*\)'` if test -n "$SRVR_ADDR"; then CDCC_ARGS="$CDCC_ARGS 'server $SRVR_ADDR'" fi if test -n "$SRVR_PORT"; then CDCC_ARGS="$CDCC_ARGS 'port $SRVR_PORT'" fi CDCC0="@bindir@/cdcc $CDCC_ARGS 'id $SRVR_ID'" CDCC="$CDCC0 $CDCC_QUIET" # stop a current dbclean if test -s $DCC_HOMEDIR/$DB_NM.lock; then kill `cat $DCC_HOMEDIR/$DB_NM.lock` >/dev/null 2>&1 fi # stop the current daemon, including giving it time to shut down gracefully # After telling the daemon to stop, keep telling the daemon to politely # stop flooding until it stops answering or we run out of patience. # Then tell it to pull the plug. if eval "$CDCC '$SYSSTOP' 'sleep 0.5'"; then LCNT=0 while eval "$CDCC 'flood list' 'sleep 0.5'" ; do LCNT=`expr $LCNT + 1` # Pull the plug on the floods after 5 seconds if test "$LCNT" -ge 10; then if test "$VERBOSE" = "-v"; then if test "$LCNT" -eq 10; then eval "$CDCC0 'flood list'" fi fi eval "$CDCC 'flood halt' 'sleep 0.5'" fi # give up after another second to let the daemon close the file if test "$LCNT" -gt 12; then break; fi done fi set +x if test X"$DEBUG" = "X-x"; then echo "The final cdcc command should have failed, since that is how" echo "this script knows that dccd has stopped." fi