Dmitry Sutyagin 0f7a39be83 Fix: exec_pair trace; SPT bugs; print non-0 exit
- Fix crash when hitting logger.warning in exec_pair
- Fix SPT bugs:
  - iperf sometimes not installed for HW to HW test
  - iperf_server_stop broken in several ways
  - glance download script has wrong filename
  - SPT_parser traces on empty glance output
- Print to stdout on non-0 exit to tell about unclean exit to user
- Reorder SPT copy-paste line once more

Change-Id: I7a37b5fce5bc620cc9e2db8d232180c215cd3782
2017-02-24 14:56:11 -08:00

24 lines
721 B
Bash

#!/bin/bash
SPT_IPERF_PORT=${SPT_IPERF_PORT:-"65432"}
# install iperf
which iperf &>/dev/null
if [ "$?" -ne "0" ]
then
result="$(DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install iperf 2>&1)"
[ "$?" -ne "0" ] && echo -e "failed to install iperf:\n$result" && exit 1
fi
# add firewall rule
if [ "$(iptables -S | grep -c spt-temporary-rule-tcp-${SPT_IPERF_PORT})" -eq 0 ]
then
result="$(iptables -I INPUT 1 -p tcp --dport ${SPT_IPERF_PORT} -j ACCEPT -m comment --comment "spt-temporary-rule-tcp-${SPT_IPERF_PORT}" 2>&1)"
[ "$?" -ne "0" ] && echo -e "failed to add iptables rule:\n$result" && exit 1
fi
# start iperf server
outfile=$(mktemp)
iperf -s -p $SPT_IPERF_PORT &> $outfile &
printf $outfile