Napi now has a standalone --apply option and we modified check_web_site_size to be able to do total bytes or just alnum
This commit is contained in:
+26
-8
@@ -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}'
|
# 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=""
|
verbose=""
|
||||||
size=0
|
size=0
|
||||||
|
checkSize=""
|
||||||
|
|
||||||
while [ -n "$1" ]; do
|
while [ -n "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
--alpha) checkType="alpha"; shift 1;;
|
||||||
-v) verbose="true"; shift 1;;
|
-v) verbose="true"; shift 1;;
|
||||||
-u) url="$2"; shift 2;;
|
-u) url="$2"; shift 2;;
|
||||||
-s) size="$2"; shift 2;;
|
-s) size="$2"; shift 2;;
|
||||||
@@ -14,16 +19,27 @@ while [ -n "$1" ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# curl -skL "https://www.wyze.com/products/wyze-cam-v3" -w '%{size_download}' -o /dev/null
|
check_size_total() {
|
||||||
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"
|
||||||
[ -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
|
|
||||||
checkSize=$(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=$?
|
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
|
case $status in
|
||||||
0) ;;
|
0) ;;
|
||||||
@@ -36,6 +52,8 @@ case $status in
|
|||||||
52) echo "WARNING: $url returned no data" && exit 1;;
|
52) echo "WARNING: $url returned no data" && exit 1;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
check_size_${checkType}
|
||||||
|
|
||||||
if [ "$size" = "$checkSize" ]; then
|
if [ "$size" = "$checkSize" ]; then
|
||||||
echo "OK; received $size bytes|bytes=${checkSize}B"
|
echo "OK; received $size bytes|bytes=${checkSize}B"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -446,6 +446,12 @@ if [ -n "${myOptions[Create]}" ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
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
|
# 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 used an existing file, then just use that
|
||||||
# If we're in test mode, then skip this part
|
# If we're in test mode, then skip this part
|
||||||
|
|||||||
Reference in New Issue
Block a user