Last active
October 26, 2022 16:04
-
-
Save absane/238ea90c6346a2f1709991090919b2cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function sortpercent { | |
cat | sort | uniq -c | sort -rn | awk '{s+=$1;lines=lines"\n"$0} END {printf "%d Total",s;print lines}' | awk '!max{max=$1}{s=$1/max*100;c=$1;$1="";printf "%30s %10d %7.2f%%\n",$0,c,s;}' | |
} | |
tempDatesFile=$(mktemp) | |
while read -r item; do | |
curl -s -X $'GET' \ | |
-H $'Host: www.ui.com' -H $'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0' -H $'Accept: application/json, text/javascript, */*; q=0.01' -H $'Accept-Language: en-US,en;q=0.7,ko-KR;q=0.3' -H $'X-Requested-With: XMLHttpRequest' -H $'Referer: https://www.ui.com/download/unifi/unifi-ap' -H $'Sec-Fetch-Dest: empty' -H $'Sec-Fetch-Mode: cors' -H $'Sec-Fetch-Site: same-origin' -H $'Te: trailers' \ | |
'https://www.ui.com/download/?group='${item} | jq '.downloads[].date_published' | cut -d '"' -f2 | |
done < <(curl -s https://www.ui.com/download/unifi/unifi-ap/ | grep 'downloadMenu' | grep -oP '(?<=\<a href=\"\#)[a-z\-]{1,}(?=\")') | tee "${tempDatesFile}" | |
while read -r year; do | |
echo "Unifi firmware release days in $year" | |
while read -r d; do | |
date +%A -d"${d}" 2> /dev/null | |
done < <(cat "${tempDatesFile}" | grep "$year") | sortpercent | |
echo -e "---" | |
done < <(cat "${tempDatesFile}" | cut -d '-' -f1 | sort -uV | grep -P "[0-9]{4}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment