Author: Steven Chamberlain <steven@pyro.eu.org>
Description: This patch avoids FTBFS due to wrong calculation of timeout
 If the current minute or second wraps around past 59, the timeout
 calculation is wrong, and may get stuck forever.  Since this happens
 in many parts of the testsuite it meant considerable risk of FTBFS.

Index: pkg-virtuoso/appsrc/ODS-Addressbook/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Addressbook/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Addressbook/make_vad.sh	2013-11-23 17:00:12.135557423 +0100
@@ -152,7 +152,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -163,17 +163,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Blog/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Blog/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Blog/make_vad.sh	2013-11-23 17:00:12.135557423 +0100
@@ -122,7 +122,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -133,17 +133,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Bookmark/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Bookmark/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Bookmark/make_vad.sh	2013-11-23 17:00:12.135557423 +0100
@@ -152,7 +152,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -163,17 +163,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Briefcase/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Briefcase/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Briefcase/make_vad.sh	2013-11-23 17:00:12.135557423 +0100
@@ -163,7 +163,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -174,17 +174,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Calendar/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Calendar/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Calendar/make_vad.sh	2013-11-23 17:00:12.135557423 +0100
@@ -151,7 +151,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -162,17 +162,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Community/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Community/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Community/make_vad.sh	2013-11-23 17:00:12.135557423 +0100
@@ -147,7 +147,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -158,17 +158,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Discussion/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Discussion/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Discussion/make_vad.sh	2013-11-23 17:00:12.135557423 +0100
@@ -119,7 +119,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting Virtuoso Server start on port $PORT..."
@@ -130,17 +130,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-FeedManager/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-FeedManager/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-FeedManager/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -151,7 +151,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -162,17 +162,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Framework/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Framework/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Framework/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -149,7 +149,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -160,17 +160,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Framework/oauth/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Framework/oauth/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Framework/oauth/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -197,7 +197,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting Virtuoso Server start on port $PORT..."
@@ -208,17 +208,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 virtuoso_shutdown() {
Index: pkg-virtuoso/appsrc/ODS-Gallery/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Gallery/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Gallery/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -135,7 +135,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -146,17 +146,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Polls/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Polls/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Polls/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -139,7 +139,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -150,17 +150,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-WebMail/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-WebMail/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-WebMail/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -150,7 +150,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -161,17 +161,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/appsrc/ODS-Wiki/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/appsrc/ODS-Wiki/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/appsrc/ODS-Wiki/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -141,7 +141,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true 
+  for i in $(seq 1 15) 
   do
     sleep 4
     echo "Waiting Virtuoso Server start on port $PORT..."
@@ -152,17 +152,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/binsrc/b3s/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/b3s/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/b3s/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -213,7 +213,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting Virtuoso Server start on port $PORT..."
@@ -224,17 +224,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 virtuoso_shutdown() {
Index: pkg-virtuoso/binsrc/bpel/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/bpel/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/bpel/make_vad.sh	2013-11-23 17:00:12.139557262 +0100
@@ -263,7 +263,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting Virtuoso Server start on port $PORT..."
@@ -274,17 +274,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 virtuoso_shutdown() {
Index: pkg-virtuoso/binsrc/hosting/mono/tests/tclrsrv.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/hosting/mono/tests/tclrsrv.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/hosting/mono/tests/tclrsrv.sh	2013-11-23 17:00:12.139557262 +0100
@@ -221,7 +221,7 @@
       rm -f *.lck
       $SERVER +foreground -c tclr.ini $* 1>/dev/null & 
       stat="true"
-      while true 
+      for i in $(seq 1 15) 
 	do
 	  sleep 4
 	      stat=`netstat -an | grep "[\.\:]$PORT " | grep LISTEN` 
@@ -231,20 +231,9 @@
 		    LOG "PASSED: Virtuoso Server successfully started on port $port"
 		    return 0
 	      fi
-		
-	  nowh=`date | cut -f 2 -d :`
-          nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    
-          nowh=`expr $nowh - $starth`
-          nows=`expr $nows - $starts`
-    
-          nows=`expr $nows + $nowh \*  60`
-          if test $nows -ge $timeout
-          then
+        done
               LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
               return 1
-          fi
-        done
 }
 
 WAITALL ()
Index: pkg-virtuoso/binsrc/isparql/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/isparql/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/isparql/make_vad.sh	2013-11-23 17:00:12.143557100 +0100
@@ -126,7 +126,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -137,17 +137,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/binsrc/rdf_mappers/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/rdf_mappers/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/rdf_mappers/make_vad.sh	2013-11-23 17:00:12.143557100 +0100
@@ -260,7 +260,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting Virtuoso Server start on port $PORT..."
@@ -271,17 +271,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 virtuoso_shutdown() {
Index: pkg-virtuoso/binsrc/samples/demo/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/samples/demo/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/samples/demo/make_vad.sh	2013-11-23 17:00:12.143557100 +0100
@@ -124,7 +124,7 @@
       "$SERVER" +wait
   fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -135,17 +135,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/binsrc/samples/demo/mkdemo.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/samples/demo/mkdemo.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/samples/demo/mkdemo.sh	2013-11-23 17:00:12.143557100 +0100
@@ -153,7 +153,7 @@
   starth=`date | cut -f 2 -d :`
   starts=`date | cut -f 3 -d :|cut -f 1 -d " "`
 
-  while true
+  for i in $(seq 1 10)
     do
       sleep 6
       if (netstat -an | grep "$PORT" | grep LISTEN > /dev/null)
@@ -161,19 +161,9 @@
 	  ECHO "Virtuoso server started"
 	  return 0
 	fi
-      nowh=`date | cut -f 2 -d :`
-      nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-
-      nowh=`expr $nowh - $starth`
-      nows=`expr $nows - $starts`
-
-      nows=`expr $nows + $nowh \*  60`
-      if test $nows -ge $timeout
-        then
+  done
 	  ECHO "***WARNING: Could not start Virtuoso DEMO Server within $timeout seconds"
 	  return 1
-	fi
-  done
 }
 
 STOP_SERVER()
Index: pkg-virtuoso/binsrc/samples/demo/mkdoc.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/samples/demo/mkdoc.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/samples/demo/mkdoc.sh	2013-11-23 17:00:12.143557100 +0100
@@ -174,7 +174,7 @@
        starth=`date | cut -f 2 -d :`
        starts=`date | cut -f 3 -d :|cut -f 1 -d " "`
 
-       while true
+       for i in $(seq 1 10)
        do
            sleep 6
            if (netstat -an | grep "$PORT" | grep LISTEN > /dev/null)
@@ -182,19 +182,9 @@
        	ECHO "Virtuoso server started"
        	return 0
            fi
-           nowh=`date | cut -f 2 -d :`
-           nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-
-           nowh=`expr $nowh - $starth`
-           nows=`expr $nows - $starts`
-
-           nows=`expr $nows + $nowh \*  60`
-           if test $nows -ge $timeout
-           then
+       done
        	ECHO "***WARNING: Could not start Virtuoso DOC Server within $timeout seconds"
        	return 1
-           fi
-       done
    fi
 }
 
Index: pkg-virtuoso/binsrc/samples/sparql_demo/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/samples/sparql_demo/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/samples/sparql_demo/make_vad.sh	2013-11-23 17:00:12.143557100 +0100
@@ -123,7 +123,7 @@
     fi
 
     stat="true"
-    while true
+    for i in $(seq 1 15)
     do
 	sleep 4
 	echo "Waiting $SERVER start on port $PORT..."
@@ -134,17 +134,9 @@
 	    LOG "PASSED: $SERVER successfully started on port $PORT"
 	    return 0
 	fi
-	nowh=`date | cut -f 2 -d :`
-	nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-	nowh=`expr $nowh - $starth`
-	nows=`expr $nows - $starts`
-	nows=`expr $nows + $nowh \*  60`
-	if test $nows -ge $timeout
-	then
+    done
 	    LOG "***WARNING: Could not start $SERVER within $timeout seconds"
 	    return 1
-	fi
-    done
 }
 
 
Index: pkg-virtuoso/binsrc/samples/xpath/files2dav.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/samples/xpath/files2dav.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/samples/xpath/files2dav.sh	2013-11-23 17:00:12.143557100 +0100
@@ -104,7 +104,7 @@
   starth=`date | cut -f 2 -d :`
   starts=`date | cut -f 3 -d :|cut -f 1 -d " "`
 
-  while true 
+  for i in $(seq 1 10) 
     do
       sleep 6
       if (netstat -an | grep "$PORT" | grep LISTEN > /dev/null) 
@@ -112,19 +112,9 @@
 	  ECHO "Virtuoso server started"     
 	  return 0
 	fi
-      nowh=`date | cut -f 2 -d :`
-      nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-
-      nowh=`expr $nowh - $starth`
-      nows=`expr $nows - $starts`
-
-      nows=`expr $nows + $nowh \*  60`
-      if test $nows -ge $timeout 
-        then
+  done
 	  ECHO "***WARNING: Could not start Virtuoso DEMO Server within $timeout seconds"
 	  return 1
-	fi
-  done
 }
 
 STOP_SERVER()
Index: pkg-virtuoso/binsrc/samples/xquery/files2dav.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/samples/xquery/files2dav.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/samples/xquery/files2dav.sh	2013-11-23 17:00:12.143557100 +0100
@@ -104,7 +104,7 @@
   starth=`date | cut -f 2 -d :`
   starts=`date | cut -f 3 -d :|cut -f 1 -d " "`
 
-  while true 
+  for i in $(seq 1 10) 
     do
       sleep 6
       if (netstat -an | grep "$PORT" | grep LISTEN > /dev/null) 
@@ -112,19 +112,9 @@
 	  ECHO "Virtuoso server started"     
 	  return 0
 	fi
-      nowh=`date | cut -f 2 -d :`
-      nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-
-      nowh=`expr $nowh - $starth`
-      nows=`expr $nows - $starts`
-
-      nows=`expr $nows + $nowh \*  60`
-      if test $nows -ge $timeout 
-        then
+  done
 	  ECHO "***WARNING: Could not start Virtuoso DEMO Server within $timeout seconds"
 	  return 1
-	fi
-  done
 }
 
 STOP_SERVER()
Index: pkg-virtuoso/binsrc/sync/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/sync/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/sync/make_vad.sh	2013-11-23 17:00:12.143557100 +0100
@@ -113,7 +113,7 @@
       virtuoso +wait
   fi
   stat="true"
-  while true 
+  for i in $(seq 1 15) 
   do
     sleep 4
     echo "Waiting Virtuoso Server start on port $PORT..."
@@ -124,17 +124,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/binsrc/tests/biftest/thook.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/tests/biftest/thook.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/tests/biftest/thook.sh	2013-11-23 17:00:12.143557100 +0100
@@ -136,7 +136,7 @@
 	      rm $LOCKFILE
           fi
 	RUN $SERVER +foreground $* &
-	while true
+	for i in $(seq 1 12)
 	do
             sleep 5
 	    stat=`netstat -an | grep "[\.\:]$port " | grep LISTEN`
@@ -145,19 +145,9 @@
 		LOG "PASSED: Virtuoso Server successfully started on port $port"
 		return 0
 	    fi
-	    nowh=`date | cut -f 2 -d :`
-	    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-
-	    nowh=`expr $nowh - $starth`
-	    nows=`expr $nows - $starts`
-
-	    nows=`expr $nows + $nowh \*  60`
-	    if test $nows -ge $timeout
-	    then
+	done
 		LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
 		return 1
-	    fi
-	done
 }
 echo "STARTED : thook.sh"
 echo "STARTED : thook.sh" > $OUTPUT
Index: pkg-virtuoso/binsrc/tests/suite/test_fn.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/tests/suite/test_fn.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/tests/suite/test_fn.sh	2013-11-23 17:01:18.824862688 +0100
@@ -316,7 +316,7 @@
 	then
 	    return
 	fi
-	while true
+	for i in $(seq 1 120)
 	do
 	    stat=`netstat -an | grep "[\.\:]$port " | grep LISTEN`
 	    if [ "z$stat" != "z" ]
@@ -325,25 +325,15 @@
 		return 0
 	    fi
             sleep 1
-	    nowh=`date | cut -f 2 -d :`
-	    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-
-	    nowh=`expr $nowh - $starth`
-	    nows=`expr $nows - $starts`
-
-	    nows=`expr $nows + $nowh \*  60`
-	    if test $nows -ge $timeout
-	    then
+	done
 		LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
 		return 1
-	    fi
-	done
 }
 
 CHECK_PORT()
 {
   port=$1
-  while true
+  for i in $(seq 1 60)
   do
     stat=`netstat -an | grep "[\.\:]$port " | grep LISTEN`
     if [ "z$stat" = "z" ]
@@ -352,19 +342,9 @@
 	return 0
     fi
     sleep 1
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done  
 	LOG "***FAILED: Port $port is not freed during $timeout seconds"
 	exit 1
-    fi
-  done  
 }
 
 STOP_SERVER()
Index: pkg-virtuoso/binsrc/tests/suite/tpc-d/tpcd.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/tests/suite/tpc-d/tpcd.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/tests/suite/tpc-d/tpcd.sh	2013-11-23 17:00:12.147556938 +0100
@@ -207,7 +207,7 @@
       rm -f *.lck
       $SERVER +foreground -c tpcd.ini $* 1>/dev/null & 
       stat="true"
-      while true 
+      for i in $(seq 1 15) 
 	do
 	  sleep 4
 	      stat=`netstat -an | grep "[\.\:]$PORT " | grep LISTEN` 
Index: pkg-virtuoso/binsrc/tutorial/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/tutorial/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/tutorial/make_vad.sh	2013-11-23 17:00:12.147556938 +0100
@@ -113,7 +113,7 @@
       "$SERVER" +wait
       fi
   stat="true"
-  while true
+  for i in $(seq 1 15)
   do
     sleep 4
     echo "Waiting $SERVER start on port $PORT..."
@@ -124,17 +124,9 @@
       LOG "PASSED: $SERVER successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start $SERVER within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/binsrc/vsp/admin/debug/make_vad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/vsp/admin/debug/make_vad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/vsp/admin/debug/make_vad.sh	2013-11-23 17:00:12.147556938 +0100
@@ -79,7 +79,7 @@
 	  virtuoso +wait
   fi
   stat="true"
-  while true 
+  for i in $(seq 1 15) 
   do
     sleep 4
     echo "Waiting Virtuoso Server start on port $PORT..."
@@ -90,17 +90,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command_safe () {
Index: pkg-virtuoso/binsrc/vspx/suite/vspx_suite.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/vspx/suite/vspx_suite.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/vspx/suite/vspx_suite.sh	2013-11-23 17:00:12.147556938 +0100
@@ -48,7 +48,7 @@
   rm -f *.lck
   $SERVER
   stat="true"
-  while true 
+  for i in $(seq 1 15) 
   do
     sleep 4
     LOG "CHECKING: Is Virtuoso Server successfully started on port $PORT?"
@@ -59,17 +59,9 @@
       LOG "PASSED: Virtuoso Server successfully started on port $PORT"
       return 0
     fi
-    nowh=`date | cut -f 2 -d :`
-    nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-    nowh=`expr $nowh - $starth`
-    nows=`expr $nows - $starts`
-    nows=`expr $nows + $nowh \*  60`
-    if test $nows -ge $timeout
-    then
+  done
       LOG "***WARNING: Could not start Virtuoso Server within $timeout seconds"
       return 1
-    fi
-  done
 }
 
 do_command() {
Index: pkg-virtuoso/binsrc/yacutia/mkvad.sh
===================================================================
--- pkg-virtuoso.orig/binsrc/yacutia/mkvad.sh	2013-11-23 17:00:12.151556777 +0100
+++ pkg-virtuoso/binsrc/yacutia/mkvad.sh	2013-11-23 17:00:12.147556938 +0100
@@ -161,7 +161,7 @@
   starth=`date | cut -f 2 -d :`
   starts=`date | cut -f 3 -d :|cut -f 1 -d " "`
 
-  while true
+  for i in $(seq 1 10)
     do
       sleep 6
       if (netstat -an | grep "$PORT" | grep LISTEN > /dev/null)
@@ -169,19 +169,9 @@
     ECHO "Virtuoso server started"
     return 0
   fi
-      nowh=`date | cut -f 2 -d :`
-      nows=`date | cut -f 3 -d : | cut -f 1 -d " "`
-
-      nowh=`expr $nowh - $starth`
-      nows=`expr $nows - $starts`
-
-      nows=`expr $nows + $nowh \*  60`
-      if test $nows -ge $timeout
-        then
+  done
     ECHO "***WARNING: Could not start Virtuoso Server within $timeout seconds"
     return 1
-  fi
-  done
 }
 
 STOP_SERVER()
