Napi now has a standalone --apply option and we modified check_web_site_size to be able to do total bytes or just alnum

dev
Eric Loyd 1 year ago
parent 1ed55ac09c
commit c93d3059f8

@ -2,11 +2,16 @@
# curl -s https://www.homedepot.com/p/HDX-Black-5-Tier-Plastic-Garage-Storage-Shelving-Unit-36-in-W-x-74-in-H-x-18-in-D-241592/306331734 | grep -v href | md5sum | awk '{print $1}'
checkType="total"
agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0"
status=""
verbose=""
size=0
checkSize=""
while [ -n "$1" ]; do
case "$1" in
--alpha) checkType="alpha"; shift 1;;
-v) verbose="true"; shift 1;;
-u) url="$2"; shift 2;;
-s) size="$2"; shift 2;;
@ -14,16 +19,27 @@ while [ -n "$1" ]; do
esac
done
# curl -skL "https://www.wyze.com/products/wyze-cam-v3" -w '%{size_download}' -o /dev/null
agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0"
[ -n "$verbose" ] && echo "DEBUG: curl --connect-timeout 10 -A \"$agent\" -skL \"$url\" -w \"%{size_download}\" -o /dev/null"
checkSize=$(curl --connect-timeout 10 -A "$agent" -skL "$url" -w "%{size_download}" -o /dev/null)
status=$?
if [ "$status" != "0" ]; then
sleep 2
check_size_total() {
[ -n "$verbose" ] && echo "DEBUG: curl --connect-timeout 10 -A \"$agent\" -skL \"$url\" -w \"%{size_download}\" -o /dev/null"
checkSize=$(curl --connect-timeout 10 -A "$agent" -skL "$url" -w "%{size_download}" -o /dev/null)
status=$?
fi
if [ "$status" != "0" ]; then
sleep 2
checkSize=$(curl --connect-timeout 10 -A "$agent" -skL "$url" -w "%{size_download}" -o /dev/null)
status=$?
fi
}
check_size_alpha() {
output=`curl --connect-timeout 10 -A "$agent" -skL "$url"`
status=$?
if [ "$status" != "0" ]; then
sleep 2
output=`curl --connect-timeout 10 -A "$agent" -skL "$url"`
status=$?
fi
checkSize=`echo "$output" | tr -d -c "[:alnum:]" | wc -c`
}
case $status in
0) ;;
@ -36,6 +52,8 @@ case $status in
52) echo "WARNING: $url returned no data" && exit 1;;
esac
check_size_${checkType}
if [ "$size" = "$checkSize" ]; then
echo "OK; received $size bytes|bytes=${checkSize}B"
exit 0

@ -446,6 +446,12 @@ if [ -n "${myOptions[Create]}" ]; then
exit
fi
# If all we said was --apply, then we want to apply previous changes
if [ -n "${myOptions[Apply]}" ]; then
do_apply
exit
fi
# Grab a copy of the JSON data so we don't have to keep making calls over and over
# If we used an existing file, then just use that
# If we're in test mode, then skip this part

Loading…
Cancel
Save