#!/bin/bash version=07/09/2017 # si $1=all affichage complet f__affichage(){ # v07/09/2017 # 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 [ "$1" == all ] || return clear printf "$YELLOW" [ "$(which figlet)" ] && figlet -w120 "$(basename $0)" || echo -e "\t\t\t$(basename $0)" echo -e "$GREEN\t\t\tversion $version$COLOR\n" } f_help(){ # v07/09/2017 f__affichage all printf $BLUE cat << 'EOF' ---------------------------------------------------------------------- === versions Thunderbird === latest: x.y.z Beta: x.y.z 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 Location: url réelle de l'archive du canal si redirection ---------------------------------------------------------------------- liens de téléchargement manuels: latest : https://www.mozilla.org/fr/thunderbird/ beta : https://www.mozilla.org/fr/thunderbird/channel/ EOF printf $COLOR exit } # $1 url à tester, si $2=loc affiche seulement location, affiche url testée, entêtes http, location si présente f__wget_test_diag(){ #v07/09/2017 local file_test_wget retourHttp location file_test_wget="/tmp/testWget-$RANDOM" wget -Sq --tries=1 --timeout=10 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget" || 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" retourHttp="$(grep -i 'HTTP/' "$file_test_wget" | tr -d '\n' | xargs)" location="$(grep -i 'location' $file_test_wget | xargs)" if [ "$2" == "loc" ]; then [ "$location" ] && echo "$YELLOW $location$COLOR" || echo "$YELLOW no location$COLOR" return fi if [ "$retourWget" ]; then echo "erreur wget: $RED$retourWget$COLOR" echo -e "$BLUE $1$COLOR\t$RED $retourHttp$COLOR" [ "$location" ] && echo "$YELLOW $location" || echo "$YELLOWno location" else echo -e "$BLUE $1$COLOR\t$GREEN $retourHttp$YELLOW" [ "$location" ] && echo " $location" || echo " no location" fi printf "$COLOR" rm "$file_test_wget" } test_url_dl_thunderbird(){ # v 07/09/2017 local recup_url architecture for architecture in linux linux64; do echo " Architecture: $architecture" echo " =====================" for produit in latest beta; do [ "$produit" == "beta" ] && prefixe="$produit-" recup_url="https://download.mozilla.org/?product=thunderbird-$prefixe""latest&os=$architecture&lang=fr" printf " $produit": f__wget_test_diag "$recup_url" done done } # assigne $verLatest, $verBeta test_version_thunderbird(){ # v 07/09/2017 local recup_url prefixe version architecture="linux64" echo -e "\n === versions Thunderbird ===" for produit in latest beta; do [ "$produit" == "beta" ] && prefixe="$produit-" recup_url="https://download.mozilla.org/?product=thunderbird-$prefixe""latest&os=$architecture&lang=fr" version="$(sed -E 's#.*thunderbird/releases/(.*)/linux-.*$#\1#' <<< $(f__wget_test_diag "$recup_url" "loc"))" if [ "$produit" == "latest" ]; then verLatest="$(sed -E 's#.*thunderbird/releases/(.*)/linux-.*$#\1#' <<< $(f__wget_test_diag $recup_url loc))" elif [ "$produit" == "beta" ]; then verBeta="$(sed -E 's#.*thunderbird/releases/(.*)/linux-.*$#\1#' <<< $(f__wget_test_diag $recup_url loc))" fi done [ "$verLatest" ] || verLatest="$RED""NA" [ "$verBeta" ] || verBeta="$RED""NA" echo -e " latest: $GREEN$verLatest$COLOR Beta: $GREEN$verBeta$COLOR" } # start user_agent="Mozilla/5.0 Firefox" f__affichage [ "$1" == "-h" ] && f_help test_version_thunderbird echo test_url_dl_thunderbird echo exit autres liens https://releases.mozilla.org/pub/thunderbird/releases/latest/ https://releases.mozilla.org/pub/thunderbird/releases/latest-beta/ https://releases.mozilla.org/pub/thunderbird/nightly/latest-comm-central-l10n/