Merge branch 'vendor/OPENSSL'
[dragonfly.git] / contrib / amd / scripts / wait4amd2die.in
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.0
8 # Author:       Erez Zadok <ezk@cs.columbia.edu>
9
10 #set -x
11
12 # set path
13 prefix=@prefix@
14 exec_prefix=@exec_prefix@
15 PATH=@sbindir@:@bindir@:/usr/bin:/bin:${PATH}
16 export PATH
17
18 # how long to wait?
19 if test -n "$1"
20 then
21         delay=$1
22 else
23         delay=5
24 fi
25 # how many times to delay
26 if test -n "$2"
27 then
28         count=$2
29 else
30         count=6
31 fi
32
33 i=1
34 maxcount=`expr $count + 1`
35 while [ $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`
47 done
48 echo "wait4amd2die: amd is still up..."
49 exit 1