echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3
echo -n "Waiting for ceph initialization"
-starttime=$(date +%s)
-# support for GNU netcat and BSD netcat
-while ! (nc -c -w 1 ${host} ${port} </dev/null >&/dev/null \
- || nc -w 1 ${host} ${port} </dev/null >&/dev/null); do
- sleep 1
- echo -n '.'
- if (( $(date +%s) > starttime + 60 )); then
- echo
- echo "[ERROR] Waited 60 seconds, no response" >&2
- exit 1
- fi
-done
-echo
+if ! "$thisFolder"/env/wait-for-connection ${host} ${port} 60; then
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+fi
sleep 1
echo "Create ceph user"
echo $container >> $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp
echo -n "Waiting for ftp initialization"
-starttime=$(date +%s)
-# support for GNU netcat and BSD netcat
-while ! (nc -c -w 1 ${host} 21 </dev/null >&/dev/null \
- || nc -w 1 ${host} 21 </dev/null >&/dev/null); do
- sleep 1
- echo -n '.'
- if (( $(date +%s) > starttime + 60 )); then
- echo
- echo "[ERROR] Waited 60 seconds, no response" >&2
- exit 1
- fi
-done
-echo
+if ! "$thisFolder"/env/wait-for-connection ${host} 21 60; then
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+fi
sleep 1
if [ -n "$DEBUG" ]; then
echo $container >> $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp
echo -n "Waiting for sftp initialization"
-starttime=$(date +%s)
-# support for GNU netcat and BSD netcat
-while ! (nc -c -w 1 ${host} 22 </dev/null >&/dev/null \
- || nc -w 1 ${host} 22 </dev/null >&/dev/null); do
- sleep 1
- echo -n '.'
- if (( $(date +%s) > starttime + 60 )); then
- echo
- echo "[ERROR] Waited 60 seconds, no response" >&2
- exit 1
- fi
-done
-echo
+if ! "$thisFolder"/env/wait-for-connection ${host} 22 60; then
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+fi
sleep 1
if [ -n "$DEBUG" ]; then
echo $container >> $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb
echo -n "Waiting for samba initialization"
-starttime=$(date +%s)
-# support for GNU netcat and BSD netcat
-while ! (nc -c -w 1 ${host} 445 </dev/null >&/dev/null \
- || nc -w 1 ${host} 445 </dev/null >&/dev/null); do
- sleep 1
- echo -n '.'
- if (( $(date +%s) > starttime + 60 )); then
- echo
- echo "[ERROR] Waited 60 seconds, no response" >&2
- exit 1
- fi
-done
-echo
+if ! "$thisFolder"/env/wait-for-connection ${host} 445 60; then
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+fi
sleep 1
if [ -n "$DEBUG" ]; then
password=!owncloud123
host=WIN-9GTFAS08C15
-if ! (nc -c -w 1 ${host} 445 </dev/null >&/dev/null \
- || nc -w 1 ${host} 445 </dev/null >&/dev/null); then
+if ! "$thisFolder"/env/wait-for-connection ${host} 445 0; then
echo "[ERROR] Server not reachable" >&2
exit 1
fi
echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift
echo -n "Waiting for ceph initialization"
-starttime=$(date +%s)
-# support for GNU netcat and BSD netcat
-while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
- || nc -w 1 ${host} 80 </dev/null >&/dev/null); do
- sleep 1
- echo -n '.'
- if (( $(date +%s) > starttime + 60 )); then
- echo
- echo "[ERROR] Waited 60 seconds, no response" >&2
- exit 1
- fi
-done
-echo
+if ! "$thisFolder"/env/wait-for-connection ${host} 80 60; then
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+fi
sleep 1
cat > $thisFolder/config.swift.php <<DELIM
container=`docker run -P $parameter -d -e ADMINLOGIN=test -e ADMINPWD=test morrisjobke/owncloud`
-host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4`
+host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container`
echo -n "Waiting for ownCloud initialization"
-starttime=$(date +%s)
-# support for GNU netcat and BSD netcat
-while ! (nc -c -w 1 ${host} 80 </dev/null >&/dev/null \
- || nc -w 1 ${host} 80 </dev/null >&/dev/null); do
- sleep 1
- echo -n '.'
- if (( $(date +%s) > starttime + 60 )); then
- echo
- echo "[ERROR] Waited 60 seconds, no response" >&2
- exit 1
- fi
-done
-echo
+if ! "$thisFolder"/env/wait-for-connection ${host} 80 60; then
+ echo "[ERROR] Waited 60 seconds, no response" >&2
+ exit 1
+fi
# wait at least 5 more seconds - sometimes the webserver still needs some additional time
sleep 5
--- /dev/null
+#!/usr/bin/php
+<?php
+
+$timeout = 60;
+
+switch ($argc) {
+case 4:
+ $timeout = (float)$argv[3];
+case 3:
+ $host = $argv[1];
+ $port = (int)$argv[2];
+ break;
+default:
+ fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n");
+ exit(2);
+}
+
+if ($timeout < 0) {
+ fwrite(STDERR, 'Timeout must be greater than zero'."\n");
+ exit(2);
+}
+if ($port < 1) {
+ fwrite(STDERR, 'Port must be an integer greater than zero'."\n");
+ exit(2);
+}
+
+$socketTimeout = (float)ini_get('default_socket_timeout');
+if ($socketTimeout > $timeout) {
+ $socketTimeout = $timeout;
+}
+
+$stopTime = time() + $timeout;
+do {
+ $sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout);
+ if ($sock !== false) {
+ fclose($sock);
+ fwrite(STDOUT, "\n");
+ exit(0);
+ }
+ sleep(1);
+ fwrite(STDOUT, '.');
+} while (time() < $stopTime);
+
+fwrite(STDOUT, "\n");
+exit(1);