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