From 152c93d42dc3d0aa928894cfaf807b4e6d3c376b Mon Sep 17 00:00:00 2001 From: martinl Date: Sun, 16 Aug 2020 21:16:13 +0300 Subject: [PATCH] Add general Armbian check, add iperf3, typo fix (#4) * Add general Armbian check, add iperf3, typo fix * Add ssh -o StrictHostKeyChecking=no for tests --- go.sh | 4 ++-- lib/functions.sh | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/go.sh b/go.sh index 64c2aa4..1f3fa9f 100755 --- a/go.sh +++ b/go.sh @@ -10,7 +10,7 @@ # -sudo apt install -y -qq jq expect sshpass nmap &>/dev/null +sudo apt install -y -qq jq expect sshpass nmap iperf3 &>/dev/null # @@ -286,7 +286,7 @@ echo "This whole procedure took "$((($(date +%s) - $START)/60))" minutes". if [[ -n $UPLOAD_SERVER && -n $UPLOAD_LOCATION ]]; then - # uload report + # upload report rsync -arP --delete ${SRC}/reports/${REPORT}.html -e 'ssh -p 22' ${UPLOAD_SERVER}:${UPLOAD_LOCATION} # set link to latest ssh ${UPLOAD_SERVER} "cd ${UPLOAD_LOCATION} ; ln -sf ${REPORT}.html latest.html" diff --git a/lib/functions.sh b/lib/functions.sh index 95608db..63ee7a0 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -36,7 +36,7 @@ function remote_exec(){ do sleep 1; f=$(( $f + 1 )); [[ $f -gt 5 ]] && return 1 done - [[ $? -eq 0 ]] && timeout $TIMEOUT sshpass -p ${PASS_ROOT} ssh ${2} ${USER_ROOT}@${USER_HOST} "${1}" 2> /dev/null + [[ $? -eq 0 ]] && timeout $TIMEOUT sshpass -p ${PASS_ROOT} ssh -o StrictHostKeyChecking=no ${2} ${USER_ROOT}@${USER_HOST} "${1}" 2> /dev/null } @@ -50,14 +50,20 @@ function get_board_data(){ local UPT1=${UptimeString#*'up '} local UPT2=${UPT1%'user'*} local time=${UPT2%','*} + + BOARD_DATA=$(remote_exec "cat /etc/armbian-release") + if [ "$BOARD_DATA" == "" ]; then + echo "Remote host is not runnig Armbian. Exiting.." + exit + fi + echo -e "$BOARD_DATA" >> ${SRC}/logs/${USER_HOST}.txt 2>&1 + BOARD_UPTIME=${time//','} root_uuid=$(remote_exec "sed -e 's/^.*root=//' -e 's/ .*$//' < /proc/cmdline") root_partition=$(remote_exec "blkid | tr -d '\":' | grep \"${root_uuid}\" | awk '{print \$1}'") root_partition_device="${root_partition::-2}" BOARD_UBOOT=$(remote_exec "dd status=none if=${root_partition_device} count=5000 | strings | grep armbian | grep U-Boot | tail -1 | cut -f1 -d\"(\"") - BOARD_DATA=$(remote_exec "cat /etc/armbian-release") BOARD_KERNEL=$(remote_exec "uname -sr") - echo -e "$BOARD_DATA" >> ${SRC}/logs/${USER_HOST}.txt 2>&1 BOARD_BOARD=$(echo -e "$BOARD_DATA" | grep -w BOARD | sed 's/\"//g' | cut -d "=" -f2) BOARD_NAME=$(echo -e "$BOARD_DATA" | grep BOARD_NAME | sed 's/\"//g' | cut -d "=" -f2) BOARD_URL="https://www.armbian.com/"$(echo -e "$BOARD_DATA" | grep BOARD | head -1 | cut -d "=" -f2)