Fixed shellcheck errors

This commit is contained in:
Suvendhu Hansa 2023-02-15 11:17:32 +00:00 committed by Vivek Kumar Dutta
parent 2de7dbc43c
commit 0a2ebdbb67
10 changed files with 109 additions and 111 deletions

View file

@ -6,7 +6,7 @@
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
#
ROOT="$(dirname $0)"
ROOT="$(dirname "${0}")"
CHECK_IDLE_FILE="${ROOT}/bbf_check_idle.sh"
RETRY_TIME=300
@ -46,7 +46,6 @@ handle_whenidle_mode() {
if [ "$?" = "0" ]; then
activate_and_reboot_device "${bank_id}"
else
[ "${end_time}" -gt "$((diff + RETRY_TIME))" ] && {
sleep "${RETRY_TIME}"
}
@ -55,7 +54,6 @@ handle_whenidle_mode() {
fi
while [ "${end_time}" -gt "${diff}" ]; do
sh "${CHECK_IDLE_FILE}"
if [ "$?" = "0" ]; then
activate_and_reboot_device "${bank_id}"

View file

@ -16,13 +16,13 @@ UCI_COMMIT_BBF_DMMAP="uci -q -c /etc/bbfdm/dmmap commit"
UCI_SHOW_BBF_DMMAP="uci -q -c /etc/bbfdm/dmmap show"
uci_get() {
val=$($UCI_GET $1)
echo ${val:-$2}
val=$($UCI_GET "${1}")
echo "${val:-$2}"
}
uci_get_bbf_dmmap() {
val=$($UCI_GET_BBF_DMMAP $1)
echo ${val:-$2}
val=$($UCI_GET_BBF_DMMAP "${1}")
echo "${val:-$2}"
}
get_ip_addr_used() {
@ -43,5 +43,5 @@ get_ip_addr_used() {
fi
fi
echo ${ip_addr_used}
}
echo "${ip_addr_used}"
}

View file

@ -5,8 +5,8 @@
. /usr/share/libubox/jshn.sh
ROOT="$(dirname $0)"
. ${ROOT}/bbf_api
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
DOWNLOAD_TIMEOUT=1800
@ -16,7 +16,7 @@ download_error() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$2" == "both_proto" ] && {
[ "$2" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.download.DiagnosticState="$1"
}
@ -48,7 +48,7 @@ download_launch() {
$UCI_COMMIT_BBF_DMMAP
else
Status=$(uci_get_bbf_dmmap dmmap_diagnostics.download.Status)
[ "${Status}" == "running" ] && {
[ "${Status}" = "running" ] && {
return
}
@ -67,7 +67,7 @@ download_launch() {
return
}
[ "${url:0:7}" != "http://" -a "${url:0:6}" != "ftp://" ] && {
[ "${url:0:7}" != "http://" ] && [ "${url:0:6}" != "ftp://" ] && {
download_error "Error_Other" "${proto}"
return
}
@ -85,7 +85,7 @@ download_launch() {
rx_bytes_start=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes)
time_start=$(date +"%s.282646") # It should be like that time_start=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded
res=$(curl ${ip_proto} --fail --silent --max-time ${DOWNLOAD_TIMEOUT} -w "${format}" ${url} --output /dev/null)
res=$(curl ${ip_proto} --fail --silent --max-time ${DOWNLOAD_TIMEOUT} -w "${format}" "${url}" --output /dev/null)
time_end=$(date +"%s.282646") # It should be like that time_end=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded
tx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes)
@ -132,42 +132,42 @@ download_launch() {
return
}
tcp_open_request_time=$(echo ${time_start} ${time_appconnect} | awk '{printf "%.6f", $1 + $2}')
tcp_open_response_time=$(echo ${time_start} ${time_connect} | awk '{printf "%.6f", $1 + $2}')
rom_time=$(echo ${time_start} ${time_pretransfer} | awk '{printf "%.6f", $1 + $2}')
bom_time=$(echo ${time_start} ${time_starttransfer} | awk '{printf "%.6f", $1 + $2}')
eom_time=$(echo ${time_start} ${time_total} | awk '{printf "%.6f", $1 + $2}')
tcp_open_request_time=$(echo "${time_start}" "${time_appconnect}" | awk '{printf "%.6f", $1 + $2}')
tcp_open_response_time=$(echo "${time_start}" "${time_connect}" | awk '{printf "%.6f", $1 + $2}')
rom_time=$(echo "${time_start}" "${time_pretransfer}" | awk '{printf "%.6f", $1 + $2}')
bom_time=$(echo "${time_start}" "${time_starttransfer}" | awk '{printf "%.6f", $1 + $2}')
eom_time=$(echo "${time_start}" "${time_total}" | awk '{printf "%.6f", $1 + $2}')
separator_idx=$(expr index ${tcp_open_request_time} .)
separator_idx=$(expr index "${tcp_open_request_time}" .)
TCPOpenRequestTime_MicroSec=${tcp_open_request_time:$separator_idx}
TCPOpenRequestTime_Sec=${tcp_open_request_time:0:$(($separator_idx-1))}
TCPOpenRequestTime_Sec=${tcp_open_request_time:0:$((separator_idx-1))}
separator_idx=$(expr index ${tcp_open_response_time} .)
separator_idx=$(expr index "${tcp_open_response_time}" .)
TCPOpenResponseTime_MicroSec=${tcp_open_response_time:$separator_idx}
TCPOpenResponseTime_Sec=${tcp_open_response_time:0:$(($separator_idx-1))}
TCPOpenResponseTime_Sec=${tcp_open_response_time:0:$((separator_idx-1))}
separator_idx=$(expr index ${rom_time} .)
separator_idx=$(expr index "${rom_time}" .)
ROMTime_MicroSec=${rom_time:$separator_idx}
ROMTime_Sec=${rom_time:0:$(($separator_idx-1))}
ROMTime_Sec=${rom_time:0:$((separator_idx-1))}
separator_idx=$(expr index ${bom_time} .)
separator_idx=$(expr index "${bom_time}" .)
BOMTime_MicroSec=${bom_time:$separator_idx}
BOMTime_Sec=${bom_time:0:$(($separator_idx-1))}
BOMTime_Sec=${bom_time:0:$((separator_idx-1))}
separator_idx=$(expr index ${eom_time} .)
separator_idx=$(expr index "${eom_time}" .)
EOMTime_MicroSec=${eom_time:$separator_idx}
EOMTime_Sec=${eom_time:0:$(($separator_idx-1))}
EOMTime_Sec=${eom_time:0:$((separator_idx-1))}
TCPOpenRequestTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenRequestTime_MicroSec}Z" -d @$TCPOpenRequestTime_Sec)
TCPOpenResponseTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenResponseTime_MicroSec}Z" -d @$TCPOpenResponseTime_Sec)
ROMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${ROMTime_MicroSec}Z" -d @$ROMTime_Sec)
BOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${BOMTime_MicroSec}Z" -d @$BOMTime_Sec)
EOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${EOMTime_MicroSec}Z" -d @$EOMTime_Sec)
TCPOpenRequestTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenRequestTime_MicroSec}Z" -d @"${TCPOpenRequestTime_Sec}")
TCPOpenResponseTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenResponseTime_MicroSec}Z" -d @"${TCPOpenResponseTime_Sec}")
ROMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${ROMTime_MicroSec}Z" -d @"${ROMTime_Sec}")
BOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${BOMTime_MicroSec}Z" -d @"${BOMTime_Sec}")
EOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${EOMTime_MicroSec}Z" -d @"${EOMTime_Sec}")
tx_bytes=$((tx_bytes_end-tx_bytes_start))
rx_bytes=$((rx_bytes_end-rx_bytes_start))
test_rx_bytes=$((size_download+size_header))
period_time=$(echo ${time_end} ${time_start} | awk '{printf ($1 - $2) * 1000000}')
period_time=$(echo "${time_end}" "${time_start}" | awk '{printf ($1 - $2) * 1000000}')
json_init
json_add_string "Status" "Complete"

View file

@ -4,8 +4,8 @@
. /usr/share/libubox/jshn.sh
ROOT="$(dirname $0)"
. ${ROOT}/bbf_api
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
iplayercap_error() {
json_init
@ -13,7 +13,7 @@ iplayercap_error() {
json_dump
# Store data in dmmap
[ "$2" == "both_proto" ] && {
[ "$2" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.DiagnosticState="${1}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.SoftwareVersion=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.iplayercapacity.BOMTime=""
@ -107,7 +107,7 @@ iplayercap_launch() {
[ -z "${slow_adj_thresh}" ] && slow_adj_thresh=3
[ -z "${num_interval}" ] && num_interval=10
if [ -z "${role}" ] || [ "${role}" == "Sender" ]; then
if [ -z "${role}" ] || [ "${role}" = "Sender" ]; then
options="$options -u"
else
options="$options -d"
@ -117,17 +117,17 @@ iplayercap_launch() {
options="$options -j"
fi
if [ -n "${DSCP}" ] && [ ${DSCP} -gt 0 ]; then
if [ -n "${DSCP}" ] && [ "${DSCP}" -gt 0 ]; then
options="$options -m $DSCP"
fi
if [ "${proto_ver}" == "IPv4" ]; then
if [ "${proto_ver}" = "IPv4" ]; then
options="$options -4"
elif [ "${proto_ver}" == "IPv6" ]; then
elif [ "${proto_ver}" = "IPv6" ]; then
options="$options -6"
fi
if [ "${udp_content}" == "random" ]; then
if [ "${udp_content}" = "random" ]; then
options="$options -X"
fi
@ -158,8 +158,8 @@ iplayercap_launch() {
return
fi
if [ -n "${mode_subintervals}" ] && [ ${mode_subintervals} -gt 0 ]; then
if [ ${mode_subintervals} -lt ${num_interval} ]; then
if [ -n "${mode_subintervals}" ] && [ "${mode_subintervals}" -gt 0 ]; then
if [ "${mode_subintervals}" -lt ${num_interval} ]; then
options="$options -i ${mode_subintervals}"
else
iplayercap_error "Error_Internal" "${proto}"
@ -169,14 +169,14 @@ iplayercap_launch() {
options="$options -P ${test_subinterval} -t ${t_val} -F ${feedback_interval}"
if [ "${test_type}" == "Search" ]; then
if [ "${test_type}" = "Search" ]; then
options="$options -q ${seq_err_thresh} -L ${lower_thresh} -U ${upper_thresh} -h ${high_speed_delta} -c ${slow_adj_thresh}"
if [ "${dup_ignore}" -eq 0 ]; then
options="$options -R"
fi
fi
output=$(udpst $options -f jsonf $host 2>&1)
output=$(udpst "${options}" -f jsonf "${host}" 2>&1)
if [ "$?" -eq 127 ] || [ "$?" -eq 255 ]; then
iplayercap_error "Error_Internal" "${proto}"
return
@ -185,7 +185,7 @@ iplayercap_launch() {
json_init
json_load "$output"
[ "${proto}" == "both_proto" ] && {
[ "${proto}" = "both_proto" ] && {
json_get_var err ErrorStatus
if [ "${err}" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
@ -326,7 +326,7 @@ iplayercap_launch() {
while json_is_a ${idx} object
do
json_select ${idx}
if ["$?" -ne 0 ]; then
if [ "$?" -ne 0 ]; then
iplayercap_error "Error_Internal" "${proto}"
failed=1
break

View file

@ -5,8 +5,8 @@
. /usr/share/libubox/jshn.sh
ROOT="$(dirname $0)"
. ${ROOT}/bbf_api
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
ipping_error() {
json_init
@ -23,7 +23,7 @@ ipping_error() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$3" == "both_proto" ] && {
[ "$3" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.DiagnosticState="$1"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.SuccessCount=0
$UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.FailureCount="$cnt"
@ -78,7 +78,7 @@ ipping_launch() {
while [ $idx -lt "${nbr_of_rep}" ]; do
idx=$((idx+1))
res=$(ping -q $ip_proto -c 1 -s $dsize -W $timeout $device $host 2>&1)
res=$(ping -q ${ip_proto} -c 1 -s ${dsize} -W ${timeout} ${device} "${host}" 2>&1)
ba=$(echo "$res" | grep "bad address")
[ -n "$ba" ] && {
@ -147,7 +147,7 @@ ipping_launch() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "${proto}" == "both_proto" ] && {
[ "${proto}" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.DiagnosticState="Complete"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.IPAddressUsed="${ip_addr_used}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.ipping.SuccessCount="${success_count}"

View file

@ -4,8 +4,8 @@
. /usr/share/libubox/jshn.sh
ROOT="$(dirname $0)"
. ${ROOT}/bbf_api
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
get_nslookup_log_file() {
IDX=1
@ -26,7 +26,7 @@ nslookup_error() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$3" == "both_proto" ] && {
[ "$3" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.nslookup.DiagnosticState="$1"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.nslookup.SuccessCount=0
$UCI_COMMIT_BBF_DMMAP
@ -60,10 +60,10 @@ nslookup_launch() {
while [ $i -lt "${cnt}" ]; do
i=$((i+1))
nslookup -debug $hostname $dnsserver >>${LOG_FILE} 2>&1
nslookup -debug "${hostname}" "${dnsserver}" >>"${LOG_FILE}" 2>&1
error_code="$?"
nxd=$(cat ${LOG_FILE} | grep "NXDOMAIN")
nxd=$(cat "${LOG_FILE}" | grep "NXDOMAIN")
[ -n "$nxd" ] && {
nslookup_error "Error_DNSServerNotResolved" "${cnt}" "${proto}"
return;
@ -74,7 +74,7 @@ nslookup_launch() {
return;
}
echo "++++++++++++++++++++++++++++++" >>${LOG_FILE}
echo "++++++++++++++++++++++++++++++" >>"${LOG_FILE}"
done
AnswerType="Authoritative"
@ -123,7 +123,7 @@ nslookup_launch() {
json_close_object
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$proto" == "both_proto" ] && {
[ "$proto" = "both_proto" ] && {
$UCI_ADD_BBF_DMMAP dmmap_diagnostics NSLookupResult
$UCI_SET_BBF_DMMAP dmmap_diagnostics.@NSLookupResult[$j].Status="${status}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.@NSLookupResult[$j].AnswerType="${AnswerType}"
@ -138,8 +138,8 @@ nslookup_launch() {
AnswerType="Authoritative"
fi
done <${LOG_FILE}
rm -f ${LOG_FILE}
done <"${LOG_FILE}"
rm -f "${LOG_FILE}"
json_close_array
json_add_string "Status" "Complete"
@ -147,7 +147,7 @@ nslookup_launch() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$proto" == "both_proto" ] && {
[ "$proto" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.nslookup.DiagnosticState="Complete"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.nslookup.SuccessCount="${success_count}"
$UCI_COMMIT_BBF_DMMAP

View file

@ -4,8 +4,8 @@
. /usr/share/libubox/jshn.sh
ROOT="$(dirname $0)"
. ${ROOT}/bbf_api
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
serverselection_error() {
json_init
@ -18,7 +18,7 @@ serverselection_error() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$3" == "both_proto" ] && {
[ "$3" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.DiagnosticState="$1"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.FastestHost=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.MinimumResponseTime=9999
@ -71,7 +71,7 @@ serverselection_launch() {
while [ $i -lt "$nbr_of_rep" ]; do
i=$((i+1))
res=$(ping -q $ip_proto -c 1 -W $timeout $device $host 2>&1)
res=$(ping -q ${ip_proto} -c 1 -W ${timeout} ${device} "${host}" 2>&1)
ba=$(echo "$res" | grep "bad address")
[ -n "$ba" ] && {
@ -172,7 +172,7 @@ serverselection_launch() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "${proto}" == "both_proto" ] && {
[ "${proto}" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.DiagnosticState="Complete"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.FastestHost="${fasthost}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.serverselection.IPAddressUsed="${ip_addr_used}"

View file

@ -4,8 +4,8 @@
. /usr/share/libubox/jshn.sh
ROOT="$(dirname $0)"
. ${ROOT}/bbf_api
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
get_traceroute_log_file() {
IDX=1
@ -27,7 +27,7 @@ traceroute_error() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$3" == "both_proto" ] && {
[ "$3" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.DiagnosticState="$1"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.IPAddressUsed=""
$UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.ResponseTime=0
@ -66,7 +66,7 @@ traceroute_launch() {
return
}
res=$(traceroute -m $maxhop -w $timeout -q $cnt $ip_proto $device $host $dsize 2>&1 >${LOG_FILE})
res=$(traceroute -m ${maxhop} -w ${timeout} -q ${cnt} ${ip_proto} ${device} "${host}" "${dsize}" 2>&1 >"${LOG_FILE}")
error_code="$?"
ba=$(echo "$res" | grep "bad address")
@ -101,16 +101,16 @@ traceroute_launch() {
json_close_object
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$proto" == "both_proto" ] && {
[ "$proto" = "both_proto" ] && {
$UCI_ADD_BBF_DMMAP dmmap_diagnostics RouteHops
$UCI_SET_BBF_DMMAP dmmap_diagnostics.@RouteHops[$i].host="${host}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.@RouteHops[$i].ip="${ip}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.@RouteHops[$i].time="${time}"
}
done < ${LOG_FILE}
done < "${LOG_FILE}"
rm -f ${LOG_FILE}
rm -f "${LOG_FILE}"
i=$((i+1))
json_close_array
@ -121,7 +121,7 @@ traceroute_launch() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$proto" == "both_proto" ] && {
[ "$proto" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.DiagnosticState="Complete"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.NumberOfHops="${i}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.traceroute.ResponseTime="${resp_time}"

View file

@ -4,8 +4,8 @@
. /usr/share/libubox/jshn.sh
ROOT="$(dirname $0)"
. ${ROOT}/bbf_api
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
udpecho_error()
{
@ -20,7 +20,7 @@ udpecho_error()
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$3" == "both_proto" ] && {
[ "$3" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.DiagnosticState="$1"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.SuccessCount=0
$UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.FailureCount="$2"
@ -65,7 +65,7 @@ udpecho_launch() {
return
}
[[ "$host" == *"."* ]] && ip_proto="4" || ip_proto="6"
[[ "$host" = *"."* ]] && ip_proto="4" || ip_proto="6"
micros=1000
success_count=0
@ -129,7 +129,7 @@ udpecho_launch() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "${proto}" == "both_proto" ] && {
[ "${proto}" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.DiagnosticState="Complete"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.IPAddressUsed="${ip_addr_used}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.udpechodiag.SuccessCount="${success_count}"

View file

@ -5,8 +5,8 @@
. /usr/share/libubox/jshn.sh
ROOT="$(dirname $0)"
. ${ROOT}/bbf_api
ROOT="$(dirname "${0}")"
. "${ROOT}"/bbf_api
UPLOAD_TIMEOUT=1800
@ -16,7 +16,7 @@ upload_error() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "$2" == "both_proto" ] && {
[ "$2" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.DiagnosticState="$1"
}
@ -49,7 +49,7 @@ upload_launch() {
$UCI_COMMIT_BBF_DMMAP
else
Status=$(uci_get_bbf_dmmap dmmap_diagnostics.upload.Status)
[ "${Status}" == "running" ] && {
[ "${Status}" = "running" ] && {
return
}
@ -68,7 +68,7 @@ upload_launch() {
return
}
[ "${url:0:7}" != "http://" -a "${url:0:6}" != "ftp://" ] && {
[ "${url:0:7}" != "http://" ] && [ "${url:0:6}" != "ftp://" ] && {
upload_error "Error_Other" "${proto}"
return
}
@ -88,7 +88,7 @@ upload_launch() {
rx_bytes_start=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes)
time_start=$(date +"%s.282646") # It should be like that time_start=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded
res=$(dd if=/dev/zero bs=$bs count=$count 2>/dev/null | curl ${ip_proto} --fail --silent --max-time ${UPLOAD_TIMEOUT} -T - ${url} -w "${format}"|grep -wo '{.*}')
res=$(dd if=/dev/zero bs="${bs}" count=${count} 2>/dev/null | curl ${ip_proto} --fail --silent --max-time ${UPLOAD_TIMEOUT} -T - "${url}" -w "${format}"|grep -wo '{.*}')
time_end=$(date +"%s.282646") # It should be like that time_end=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded
tx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes)
@ -134,41 +134,41 @@ upload_launch() {
return
}
tcp_open_request_time=$(echo ${time_start} ${time_appconnect} | awk '{printf "%.6f", $1 + $2}')
tcp_open_response_time=$(echo ${time_start} ${time_connect} | awk '{printf "%.6f", $1 + $2}')
rom_time=$(echo ${time_start} ${time_pretransfer} | awk '{printf "%.6f", $1 + $2}')
bom_time=$(echo ${time_start} ${time_starttransfer} | awk '{printf "%.6f", $1 + $2}')
eom_time=$(echo ${time_start} ${time_total} | awk '{printf "%.6f", $1 + $2}')
tcp_open_request_time=$(echo "${time_start}" "${time_appconnect}" | awk '{printf "%.6f", $1 + $2}')
tcp_open_response_time=$(echo "${time_start}" "${time_connect}" | awk '{printf "%.6f", $1 + $2}')
rom_time=$(echo "${time_start}" "${time_pretransfer}" | awk '{printf "%.6f", $1 + $2}')
bom_time=$(echo "${time_start}" "${time_starttransfer}" | awk '{printf "%.6f", $1 + $2}')
eom_time=$(echo "${time_start}" "${time_total}" | awk '{printf "%.6f", $1 + $2}')
separator_idx=$(expr index ${tcp_open_request_time} .)
separator_idx=$(expr index "${tcp_open_request_time}" .)
TCPOpenRequestTime_MicroSec=${tcp_open_request_time:$separator_idx}
TCPOpenRequestTime_Sec=${tcp_open_request_time:0:$(($separator_idx-1))}
TCPOpenRequestTime_Sec=${tcp_open_request_time:0:$((separator_idx-1))}
separator_idx=$(expr index ${tcp_open_response_time} .)
separator_idx=$(expr index "${tcp_open_response_time}" .)
TCPOpenResponseTime_MicroSec=${tcp_open_response_time:$separator_idx}
TCPOpenResponseTime_Sec=${tcp_open_response_time:0:$(($separator_idx-1))}
TCPOpenResponseTime_Sec=${tcp_open_response_time:0:$((separator_idx-1))}
separator_idx=$(expr index ${rom_time} .)
separator_idx=$(expr index "${rom_time}" .)
ROMTime_MicroSec=${rom_time:$separator_idx}
ROMTime_Sec=${rom_time:0:$(($separator_idx-1))}
ROMTime_Sec=${rom_time:0:$((separator_idx-1))}
separator_idx=$(expr index ${bom_time} .)
separator_idx=$(expr index "${bom_time}" .)
BOMTime_MicroSec=${bom_time:$separator_idx}
BOMTime_Sec=${bom_time:0:$(($separator_idx-1))}
BOMTime_Sec=${bom_time:0:$((separator_idx-1))}
separator_idx=$(expr index ${eom_time} .)
separator_idx=$(expr index "${eom_time}" .)
EOMTime_MicroSec=${eom_time:$separator_idx}
EOMTime_Sec=${eom_time:0:$(($separator_idx-1))}
EOMTime_Sec=${eom_time:0:$((separator_idx-1))}
TCPOpenRequestTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenRequestTime_MicroSec}Z" -d @$TCPOpenRequestTime_Sec)
TCPOpenResponseTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenResponseTime_MicroSec}Z" -d @$TCPOpenResponseTime_Sec)
ROMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${ROMTime_MicroSec}Z" -d @$ROMTime_Sec)
BOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${BOMTime_MicroSec}Z" -d @$BOMTime_Sec)
EOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${EOMTime_MicroSec}Z" -d @$EOMTime_Sec)
TCPOpenRequestTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenRequestTime_MicroSec}Z" -d @"${TCPOpenRequestTime_Sec}")
TCPOpenResponseTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${TCPOpenResponseTime_MicroSec}Z" -d @"${TCPOpenResponseTime_Sec}")
ROMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${ROMTime_MicroSec}Z" -d @"${ROMTime_Sec}")
BOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${BOMTime_MicroSec}Z" -d @"${BOMTime_Sec}")
EOMTime=$(date -u +"%Y-%m-%dT%H:%M:%S.${EOMTime_MicroSec}Z" -d @"${EOMTime_Sec}")
tx_bytes=$((tx_bytes_end-tx_bytes_start))
rx_bytes=$((rx_bytes_end-rx_bytes_start))
period_time=$(echo ${time_end} ${time_start} | awk '{printf ($1 - $2) * 1000000}')
period_time=$(echo "${time_end}" "${time_start}" | awk '{printf ($1 - $2) * 1000000}')
json_init
json_add_string "Status" "Complete"
@ -198,7 +198,7 @@ upload_launch() {
json_dump
# Store data in dmmap_diagnostics for both protocols (cwmp/usp)
[ "${proto}" == "both_proto" ] && {
[ "${proto}" = "both_proto" ] && {
$UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.DiagnosticState="Complete"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.IPAddressUsed="${ip_addr_used}"
$UCI_SET_BBF_DMMAP dmmap_diagnostics.upload.ROMTime="${ROMTime}"