diff --git a/wait_for_8080.bash b/wait_for_8080.bash index fbee79d4..6834af9e 100755 --- a/wait_for_8080.bash +++ b/wait_for_8080.bash @@ -3,9 +3,9 @@ # wait_for_8080.bash # # Use as a trigger for starting a script that connects to the GUI -# Usage: ./wait_for_8080.bash SECONDS URL +# Usage: ./wait_for_8080.bash SECONDS URL NEXT_PROGRAM # Example: -# ./wait_for_8080.bash $((60 * 2)) http://localhost:8080/ +# ./wait_for_8080.bash $((60 * 2)) http://localhost:8080/ "/home/lanforge/scripts/scenario.py" # The URL must be exact and include the http port in the URL. # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # set -vux @@ -13,12 +13,12 @@ DEFAULT_WAIT_SECS=$(( 60 * 5 )) # 5 minutes WAIT_SECS=${1:-$DEFAULT_WAIT_SECS} URL=${2:-http://localhost:8080/} - +NEXT_PROGRAM=${3:-} if [[ x$WAIT_SECS = x ]] || (( $WAIT_SECS < 1 )); then - echo "Usage: $0 SECONDS URL" + echo "Usage: $0 SECONDS URL NEXT_PROGRAM" echo "The URL must be exact and include the http port in the URL." echo "Example:" - echo " $0 600 http://localhost:8080/" + echo " $0 600 http://localhost:8080/ '/usr/bin/xterm -e top'" exit 1 fi @@ -29,7 +29,10 @@ while (( $SECS_WAITED <= $WAIT_SECS )); do curl -o /dev/null -sq $URL if (( $? == 0 )); then echo "Connected to $URL in $SECS_WAITED" | tee >( logger -t lfclient) - exit 0 + if [[ x$NEXT_PROGRAM == x ]]; then + exit 0 + fi + exec $NEXT_PROGRAM fi sleep 1 SECS_WAITED=$(( SECS_WAITED+=1 ))