1*a53f50b9Schristos#!/bin/sh 2*a53f50b9Schristos# wait for amd to start up and then execute program 3*a53f50b9Schristos# usage: wait4amd <hostname> [<command> [args ...]] 4*a53f50b9Schristos# If only hostname is supplied, command defaults to rsh $hostname 5*a53f50b9Schristos# 6*a53f50b9Schristos# Package: am-utils-6.x 7*a53f50b9Schristos# Author: Erez Zadok <ezk@cs.columbia.edu> 8*a53f50b9Schristos 9*a53f50b9Schristos#set -x 10*a53f50b9Schristos 11*a53f50b9Schristosif [ "X$1" = "X" ]; then 12*a53f50b9Schristos echo "Usage: wait4amd <hostname> [<command> [args ...]]" 13*a53f50b9Schristos exit 1 14*a53f50b9Schristoselse 15*a53f50b9Schristos hostname=$1 16*a53f50b9Schristos shift 17*a53f50b9Schristosfi 18*a53f50b9Schristos 19*a53f50b9Schristos# set path 20*a53f50b9Schristosprefix=@prefix@ 21*a53f50b9Schristosexec_prefix=@exec_prefix@ 22*a53f50b9SchristosPATH=@sbindir@:@bindir@:${PATH} 23*a53f50b9Schristosexport PATH 24*a53f50b9Schristos 25*a53f50b9Schristoswhile true 26*a53f50b9Schristosdo 27*a53f50b9Schristos amq -h $hostname > /dev/null 2>&1 28*a53f50b9Schristos if [ $? != 0 ] 29*a53f50b9Schristos then 30*a53f50b9Schristos # failed 31*a53f50b9Schristos echo "Amd not up. Sleeping..." 32*a53f50b9Schristos sleep 5; 33*a53f50b9Schristos else 34*a53f50b9Schristos echo "Amd is active on host $hostname!" 35*a53f50b9Schristos cmd=$* 36*a53f50b9Schristos if [ -z "${cmd}" ] 37*a53f50b9Schristos then 38*a53f50b9Schristos cmd="rlogin $hostname" 39*a53f50b9Schristos fi 40*a53f50b9Schristos echo "Running: $cmd" 41*a53f50b9Schristos $cmd 42*a53f50b9Schristos echo "Sleep 1 second" 43*a53f50b9Schristos sleep 1 44*a53f50b9Schristos fi 45*a53f50b9Schristosdone 46