1#!/bin/sh 2# wait for amd to die on local host before returning from program. 3# Usage: wait4amd2die [delay [count]] 4# If not specified, delay=5 seconds and count=6 (total 30 seconds) 5# If at end of total delay amd is till up, return 1; else return 0. 6# 7# Package: am-utils-6.x 8# Author: Erez Zadok <ezk@cs.columbia.edu> 9 10#set -x 11 12# set path 13prefix=@prefix@ 14exec_prefix=@exec_prefix@ 15PATH=@sbindir@:@bindir@:/usr/bin:/bin:${PATH} 16export PATH 17 18# how long to wait? 19if test -n "$1" 20then 21 delay=$1 22else 23 delay=3 24fi 25# how many times to delay 26if test -n "$2" 27then 28 count=$2 29else 30 count=10 31fi 32 33i=1 34maxcount=`expr $count + 1` 35while [ $i != $maxcount ]; do 36 # run amq 37 @sbindir@/amq > /dev/null 2>&1 38 if [ $? != 0 ] 39 then 40 # amq failed to run (because amd is dead) 41 echo "wait4amd2die: amd is down!" 42 exit 0 43 fi 44 echo "wait4amd2die: delay $delay sec ($i of $count)..." 45 sleep $delay 46 i=`expr $i + 1` 47done 48echo "wait4amd2die: amd is still up..." 49exit 1 50