"Fossies" - the Fresh Open Source Software Archive

Member "freeha-1.0/service_scripts/cat.stop" (23 Nov 2006, 1164 Bytes) of package /linux/privat/old/freeha-1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 
    4 #-------------------------------------------------------------------------#
    5 # Script to demonstrate stopping a dummy service, for FreeHA              #
    6 #  Provided as a tool to be called from 'stophasrv'                       #
    7 #                                                                         #
    8 #  Standard UNIX status: returns 0 on good, non-0 on bad.                 #
    9 #-------------------------------------------------------------------------#
   10 
   11 # 'service' is  'cat /dev/zero'
   12 # Unfortunately, clean stop of the 'service' is considerably longer than
   13 # starting it.
   14 
   15 if [ -x /usr/ucb/ps ] ; then
   16     PROCLIST="/usr/ucb/ps aux"
   17 else
   18     PROCLIST="ps -ef"
   19 fi
   20 
   21 TESTPID=`$PROCLIST | grep 'cat /d[e]v/zero' |awk '{print $2}'`
   22 
   23 testup(){
   24     ps -e | awk '$1 == "'$TESTPID'" {print "yes"}'
   25 }
   26 
   27 #echo cat.stop: DEBUG: pid is $TESTPID
   28 
   29 if [ "$TESTPID" = "" ] ; then
   30     echo 'cat.stop: no pid for service found. service not running'
   31     exit
   32 fi
   33 
   34 # First do it the nice way...
   35 kill $TESTPID
   36 
   37 val=`testup` 
   38 
   39 
   40 # loop until we kill it DEAD, DEAD, DEAD!
   41 while [ "$val" != "" ] ; do
   42 #   echo val = .${val}.
   43     # then SQUISH IT!!
   44     kill -9 $TESTPID
   45     sleep 1
   46     val=`testup` 
   47 done