Move wait_ssh() to tct/conf/conf.sh 96/95296/6
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 18 Oct 2016 14:15:47 +0000 (16:15 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 10 Jan 2017 09:49:05 +0000 (10:49 +0100)
Change-Id: I55f0426b19a503ca998e711d350d5c4249381848
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
tct/conf/conf.sh
tct/minnow_prepare_flash_conf.sh

index b8d8d00..26f0d21 100755 (executable)
@@ -77,6 +77,49 @@ copy_ssh() {
     done
 }
 
+wait_ssh() {
+    SDMUX="$1"
+    test -n "${SDMUX}" || die "Missing argument: sdmux"
+
+    CONNECT_CNT=0
+    SLEEP=${INIT_SLEEP}
+
+    sleep "${SLEEP}"
+
+    while ! ping -c 1 "${IP}" -W 1 | grep -q icmp_seq
+    do
+        printf ","
+        if [ ${SLEEP} -ge ${MAX_SLEEP} ]
+        then
+            die "Timeout: host not found in the network!"
+        fi
+        if [ ${SLEEP} -ge ${RESTART_SLEEP} ]
+        then
+            echo "Restarting ${SDMUX}" >&2
+            restart_device "${SDMUX}"
+        fi
+        sleep "${SLEEP}"
+        SLEEP=$((SLEEP+INC_SLEEP))
+        CONNECT_CNT=$((CONNECT_CNT+1))
+    done
+
+    printf "\n" >&2
+
+    SLEEP=10
+
+    while ! nc -q 1 "${IP}" 22 </dev/null
+    do
+        printf "."
+        if [ ${SLEEP} -ge ${MAX_SLEEP} ]
+        then
+            die "Timeout: ssh port not open!"
+        fi
+        SLEEP=$((SLEEP+INC_SLEEP))
+        CONNECT_CNT=$((CONNECT_CNT+1))
+    done
+    echo "${CONNECT_CNT}"
+}
+
 copy_sdb() {
     ID="$1"
     FILE="$2"
index 8f7308d..09a4a42 100755 (executable)
@@ -63,42 +63,7 @@ restart_device "${SDMUX}"
 
 echo "### conf ###"
 
-CONNECT_CNT=0
-SLEEP=${INIT_SLEEP}
-
-sleep "${SLEEP}"
-
-while ! ping -c 1 "${IP}" -W 1 | grep -q icmp_seq
-do
-    printf ","
-    if [ ${SLEEP} -ge ${MAX_SLEEP} ]
-    then
-        die "Timeout: host not found in the network!"
-    fi
-    if [ ${SLEEP} -ge ${RESTART_SLEEP} ]
-    then
-        echo "Restarting MINNOW" >&2
-        restart_device "${SDMUX}"
-    fi
-    sleep "${SLEEP}"
-    SLEEP=$((SLEEP+INC_SLEEP))
-    CONNECT_CNT=$((CONNECT_CNT+1))
-done
-
-printf "\n"
-
-SLEEP=10
-
-while ! nc -q 1 "${IP}" 22 </dev/null
-do
-    printf "."
-    if [ ${SLEEP} -ge 60 ]
-    then
-        die "Timeout: ssh port not open!"
-    fi
-    SLEEP=$((SLEEP+10))
-    CONNECT_CNT=$((CONNECT_CNT+1))
-done
+CONNECT_CNT="$(wait_ssh "${SDMUX}")"
 printf "\n"
 
 echo "CONNECT_CNT $CONNECT_CNT" > sysctl.result