wait4amd2die.in revision 38494
198944Sobrien#!/bin/sh 2130803Smarcel# wait for amd to die on local host before returning from program. 398944Sobrien# Usage: wait4amd2die [delay [count]] 498944Sobrien# If not specified, delay=5 seconds and count=6 (total 30 seconds) 598944Sobrien# If at end of total delay amd is till up, return 1; else return 0. 698944Sobrien# 798944Sobrien# Package: am-utils-6.0 898944Sobrien# Author: Erez Zadok <ezk@cs.columbia.edu> 998944Sobrien 1098944Sobrien#set -x 1198944Sobrien 1298944Sobrien# set path 1398944Sobrienprefix=@prefix@ 1498944Sobrienexec_prefix=@exec_prefix@ 1598944SobrienPATH=@sbindir@:@bindir@:/usr/bin:/bin:${PATH} 1698944Sobrienexport PATH 1798944Sobrien 1898944Sobrien# how long to wait? 1998944Sobrienif test -n "$1" 2098944Sobrienthen 2198944Sobrien delay=$1 2298944Sobrienelse 2398944Sobrien delay=5 2498944Sobrienfi 2598944Sobrien# how many times to delay 2698944Sobrienif test -n "$2" 2798944Sobrienthen 28130803Smarcel count=$2 29130803Smarcelelse 30130803Smarcel count=6 31130803Smarcelfi 32130803Smarcel 33130803Smarceli=1 34130803Smarcelmaxcount=`expr $count + 1` 35130803Smarcelwhile [ $i != $maxcount ]; do 36130803Smarcel # run amq 37130803Smarcel @sbindir@/amq > /dev/null 2>&1 3898944Sobrien if [ $? != 0 ] 3998944Sobrien then 4098944Sobrien # amq failed to run (because amd is dead) 4198944Sobrien echo "wait4amd2die: amd is down!" 4298944Sobrien exit 0 4398944Sobrien fi 4498944Sobrien echo "wait4amd2die: delay $delay sec ($i of $count)..." 45130803Smarcel sleep $delay 46130803Smarcel i=`expr $i + 1` 47130803Smarceldone 48130803Smarcelecho "wait4amd2die: amd is still up..." 49130803Smarcelexit 1 50130803Smarcel