kyopages/scripts/diag_getFirefox

134 lines
5.4 KiB
Bash
Executable File

#!/bin/bash
version=28/08/2017
f__affichage(){
# définition couleurs
YELLOW="$(printf "\033[0;33m")" # ?
GREEN="$(printf "\033[0;32m")" # ok
BLUE="$(printf "\033[0;34m")" # info
RED="$(printf "\033[0;31m")" # alerte
COLOR="$(printf "\033[0m")" # standard
clear
[ "$1" == all ] || return
printf "$YELLOW"
[ "$(which figlet)" ] && figlet "$(basename $0)" || echo -e "\t\t\t$(basename $0)"
echo -e "$GREEN\t\t\tversion $version$COLOR\n"
}
f_help(){
f__affichage all
printf $BLUE
cat << 'EOF'
----------------------------------------------------------------------
pour chaque architecture linux ou linux64 (32 ou 64 bits):
==========================================================
canal: url récup canal
HTTP/1.1 302 Found HTTP/1.1 200 OK --> 302: redirection temporaire (normal) 200: archive trouvée, téléchargeable
une erreur 404 indiquerait une nouvelle url à déterminer
une erreur 5xx indiquerait une erreur au niveau du serveur, réessayer +tard
une erreur 4xx.. humm, réessayer +tard?
Location: url réelle de l'archive du canal si redirection
=== versions ===
Beta/Dev: xyz --> la version xyz est bient détecté, sinon revoir cette fonction
Nightly : xyz --> la version xyz est bient détecté, sinon revoir cette fonction
----------------------------------------------------------------------
liens de téléchargement manuels:
latest & esr : https://www.mozilla.org/en-US/firefox/notes/
beta / dev / nightly: https://www.mozilla.org/fr/firefox/channel/desktop/
EOF
echo $COLOR
exit
}
# test wget, $1 url à tester affiche url testée, entêtes http, location si présente
f__wget_test_diag(){ #v28/08/2017
local file_test_wget="/tmp/testWget-$RANDOM"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget" || local retourWget="$?"
[ "$retourWget" == 1 ] && retourWget="code erreur générique"
[ "$retourWget" == 2 ] && retourWget="parse erreur (ligne de commande?)"
[ "$retourWget" == 3 ] && retourWget="erreur Entrée/sortie fichier"
[ "$retourWget" == 4 ] && retourWget="défaut réseau"
[ "$retourWget" == 5 ] && retourWget="défaut vérification SSL"
[ "$retourWget" == 6 ] && retourWget="défaut authentification"
[ "$retourWget" == 7 ] && retourWget="erreur de protocole"
[ "$retourWget" == 8 ] && retourWget="réponse serveur en erreur"
local retourHttp="$(grep -i 'HTTP/' "$file_test_wget" | tr -d '\n' | xargs)"
local location="$(grep -i 'location' $file_test_wget | xargs)"
if [ "$retourWget" ]; then
echo "erreur wget: $retourWget"
echo "$RED $retourHttp"
echo " $1"
[ "$location" ] && echo "$YELLOW $location" || echo "no location"
echo "$COLOR"
exit 1
else
echo " $1"
echo "$GREEN $retourHttp$COLOR"
[ "$location" ] && echo "$YELLOW $location" || echo " no location"
echo "$COLOR"
fi
rm "$file_test_wget"
}
### start --------------------------------------------------------------
user_agent="Mozilla/5.0 Firefox"
file_tempo_test="tempoDiag-$RANDOM"
f__affichage
[ "$1" == "-h" ] && f_help
for architecture in linux linux64; do
echo -e "\n Architecture: $architecture"
echo " ====================="
for produit in latest esr beta dev nightly; do
if [ "$produit" == "latest" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$produit&os=$architecture&lang=fr"
elif [ "$produit" == "esr" ] || [ "$produit" == "beta" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$produit-latest&os=$architecture&lang=fr"
elif [ "$produit" == "dev" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$produit""edition-latest-ssl&os=$architecture&lang=fr"
elif [ "$produit" == "nightly" ]; then
recup_url="https://download.mozilla.org/?product=firefox-$produit-latest-l10n-ssl&os=$architecture&lang=fr" ;fi
printf " $produit":
f__wget_test_diag "$recup_url" "$produit"
done
done
echo -e "\n === versions ==="
recup_url="https://download.mozilla.org/?product=firefox-beta-latest&os=linux64&lang=fr"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$recup_url" &>"$file_tempo_test"
verBeta="$(grep -i 'location' $file_tempo_test | sed -E 's/.*firefox-(.*)\.tar.bz2/\1/')"
recup_url="https://download.mozilla.org/?product=firefox-nightly-latest-l10n-ssl&os=linux64&lang=fr"
wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$recup_url" &>"$file_tempo_test"
verNightly="$(grep -i 'location' $file_tempo_test | sed -E 's/.*firefox-(.*)\.fr.linux.*/\1/')"
echo " Beta/Dev: $GREEN$verBeta"
echo " Nightly : $GREEN$verNightly"
echo "$COLOR"
rm $file_tempo_test
exit
autres liens
latest: https://www.mozilla.org/fr/firefox/new/
esr: https://www.mozilla.org/en-US/firefox/organizations/
------
https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest/README.txt
https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest-beta/README.txt
https://download.mozilla.org/?product=firefox-nightly-latest-l10n-ssl&os=linux&lang=fr
https://download-installer.cdn.mozilla.net/pub/firefox/releases/latest-esr/README.txt
------
périmé
https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-aurora-l10n/ 404
https://download.mozilla.org/?product=firefox-aurora-latest-l10n-ssl&os=linux&lang=fr 404 dev edition