diff --git a/scripts/README.md b/scripts/README.md index 47409a4..c644fdb 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,3 +1,42 @@ -ce git est en cours de transfert +la nouvelle plateforme officielle est celle du groupe sdeb, [sur framagit](https://framagit.org/sdeb) -la nouvelle plateforme officielle est donc celle du groupe sdeb, [sur framagit](https://framagit.org/sdeb) + +## getFirefox + +script bash: chargeur / installeur des versions officielles Mozilla Firefox latest, ESR, beta, nightly. installation et fonctionnement en parallèle possible. Mise à jour automatique par Firefox autorisée (selon la périodicité du canal Firefox). + +## getFlashPlayer + +script bash: télécharge et installe la version officielle du plugin FlashPlayer pour Firefox (NPAPI) + +## getInfo + +script bash collectant des informations sur la configuration d'un PC. Un rapport au format markdown est formé. Ce rapport peut être exporté sur un pastebin avec rendu markdown pour partager les informations dans le but de se faire dépanner + +## getIp + +script bash: affiche les Ips publiques ou locales d'un PC + +## getThunderbird + +script bash: chargeur / installeur des versions officielles Thunderbird latest, beta. installation et fonctionnement en parallèle possible. Mise à jour automatique par Thunderbird autorisée (selon la prériodicité du canal). + +## getXfox + +script bash: chargeur / installeur des versions officielles de Waterfox et Tor Browser, Mise à jour automatique par les applications autorisée. + +## ipupdate + +mise à jour IP sur service de DNS dynamique ( duckdns / dynu / freemyip / nh / noip ) + +## nsOpenNic + +manage OpenNic DNS in resolv.conf + +## nstest + +speed test of open dns + +## pasthis + +export to a pastebin wtih command line diff --git a/scripts/tests/dev_by-id b/scripts/tests/dev_by-id deleted file mode 100644 index 25469c3..0000000 --- a/scripts/tests/dev_by-id +++ /dev/null @@ -1,27 +0,0 @@ -lrwxrwxrwx 1 root root 9 25 oct. 19:30 ata-Crucial_CT750MX300SSD1_16141256D05D -> ../../sdb -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-Crucial_CT750MX300SSD1_16141256D05D-part1 -> ../../sdb1 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-Crucial_CT750MX300SSD1_16141256D05D-part2 -> ../../sdb2 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-Crucial_CT750MX300SSD1_16141256D05D-part3 -> ../../sdb3 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-Crucial_CT750MX300SSD1_16141256D05D-part4 -> ../../sdb4 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-Crucial_CT750MX300SSD1_16141256D05D-part5 -> ../../sdb5 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-Crucial_CT750MX300SSD1_16141256D05D-part6 -> ../../sdb6 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-Crucial_CT750MX300SSD1_16141256D05D-part7 -> ../../sdb7 -lrwxrwxrwx 1 root root 9 25 oct. 19:30 ata-CT500BX100SSD1_1536F00C06F0 -> ../../sda -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-CT500BX100SSD1_1536F00C06F0-part1 -> ../../sda1 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-CT500BX100SSD1_1536F00C06F0-part2 -> ../../sda2 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 ata-CT500BX100SSD1_1536F00C06F0-part5 -> ../../sda5 -lrwxrwxrwx 1 root root 9 28 oct. 16:25 ata-HL-DT-ST_DVDRAM_GT90N_M52D5NL0816 -> ../../sr0 -lrwxrwxrwx 1 root root 9 28 oct. 16:25 wwn-0x5001480000000000 -> ../../sr0 -lrwxrwxrwx 1 root root 9 25 oct. 19:30 wwn-0x500a07511256d05d -> ../../sdb -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a07511256d05d-part1 -> ../../sdb1 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a07511256d05d-part2 -> ../../sdb2 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a07511256d05d-part3 -> ../../sdb3 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a07511256d05d-part4 -> ../../sdb4 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a07511256d05d-part5 -> ../../sdb5 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a07511256d05d-part6 -> ../../sdb6 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a07511256d05d-part7 -> ../../sdb7 -lrwxrwxrwx 1 root root 9 25 oct. 19:30 wwn-0x500a0751f00c06f0 -> ../../sda -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a0751f00c06f0-part1 -> ../../sda1 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a0751f00c06f0-part2 -> ../../sda2 -lrwxrwxrwx 1 root root 10 25 oct. 19:30 wwn-0x500a0751f00c06f0-part5 -> ../../sda5 -lrwxrwxrwx. 1 root root 9 28 oct. 21:52 ata-TSSTcorp_DVD+_-RW_TS-U633J_R86X6GRZB00420 -> ../../sr1 diff --git a/scripts/tests/diag_getFlashPlayer b/scripts/tests/diag_getFlashPlayer deleted file mode 100755 index 5fbb371..0000000 --- a/scripts/tests/diag_getFlashPlayer +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/bash - -version=5/12/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 - STD="$(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" -} - - # test wget, $1=url à tester, sortie du script (même si url testée ok) avec affichage erreur ou ok - # si $2=print affiche url testée & entêtes http & location, return 0 - # si $2=loc affiche seulement location, return 0 - # si $2=test return 0 si ok, return 1 si KO -f__wget_test(){ # 11/12/2017 - local file_test_wget retourWget retourHttp location - - file_test_wget="/tmp/testWget-$$-$RANDOM" - wget -Sq --timeout=5 --tries=2 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget" - retourWget="$?" - [ "$retourWget" == 1 ] && retourWget="1: code erreur générique" - [ "$retourWget" == 2 ] && retourWget="2: parse erreur (ligne de commande?)" - [ "$retourWget" == 3 ] && retourWget="3: erreur Entrée/sortie fichier" - [ "$retourWget" == 4 ] && retourWget="4: défaut réseau" - [ "$retourWget" == 5 ] && retourWget="5: défaut vérification SSL" - [ "$retourWget" == 6 ] && retourWget="6: défaut authentification" - [ "$retourWget" == 7 ] && retourWget="7: erreur de protocole" - [ "$retourWget" == 8 ] && retourWget="8: 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" == "test" ]; then - rm "$file_test_wget" 2>/dev/null - # spécial maintenance frama.link, pas de redirection sur page status framalink - [ "$( grep -c '303' <<< $retourHttp )" -ne 0 ] && return 1 # 303 See Other - [ "$retourWget" == "0" ] && return 0 || return 1 - fi - if [ "$2" == "print" ]; then - if [ "$retourWget" != "0" ]; then - echo "erreur wget: $RED$retourWget" - echo -e "$BLUE $1$STD\t$RED $retourHttp" - else - echo -e "$BLUE $1$STD\t$GREEN $retourHttp" - fi - echo "$STD" - fi - if [ "$2" == "print" ] || [ "$2" == "loc" ]; then - [ "$location" ] && echo -n "$YELLOW $location" || echo -n "$YELLOW no location" - echo "$STD" - rm "$file_test_wget" 2>/dev/null - return 0 - fi - if [ "$retourWget" != "0" ]; then - rm "$file_test_wget" 2>/dev/null -# f__error "wget, $retourWget" "$1" "$YELLOW$retourHttp" "$location" - echo -e "$RED erreur wget, $retourWget \n $1 \n $YELLOW$retourHttp \n $location$STD" # pour les diags - return 1 - fi - if [ "$(grep -c '200' <<< $retourHttp)" -ne 0 ]; then - echo -e "$GREEN\ntout est ok, réessayer$STD\n" - fi - rm "$file_test_wget" 2>/dev/null - exit 0 -} - -version_online(){ # 07/09/2017 - echo " détection version flash en ligne" - echo " ================================" - verFlash="$(wget -q --tries=1 --timeout=15 --user-agent="$user_agent" -O - "$urlOnline" | \ - sed -nr 's/^.*AUTO_ID.*Version[[:blank:]]+([0-9].*[0-9]).*$/\1/p')" || verFlash="na" - echo " \$urlOnline: $BLUE$urlOnline$COLOR" - echo " détecté: \$verFlash: $GREEN$verFlash" - echo "$COLOR" -} - -detect_v1(){ # 5/12/2017 - echo " url chargement flashplayer v1" - echo " =============================" - local archi - if [ "$(uname -m)" == "i686" ] || [ "$(uname -m)" == "i386" ]; then archi='i386'; - elif [ "$(uname -m)" == "x86_64" ] || [ "$(uname -m)" == "amd64" ]; then archi='x86_64'; - else echo "architecture non reconnue" ; fi - local recup1="https://fpdownload.adobe.com/get/flashplayer/pdc/" - local recup_url="$recup1$verFlash/flash_player_npapi_linux.$archi.tar.gz" - f__wget_test "$recup_url" print -} - -# html page adobe -#

Version 26.0.0.137

- - # start -user_agent="Mozilla/5.0 Firefox" -urlOnline="https://get.adobe.com/fr/flashplayer/" -f__affichage all - - # détection version flash en ligne" -version_online - # url chargement flashplayer v1 -detect_v1 -echo - -exit - -## v2 essai non transformé -#lien site: -https://get.adobe.com/fr/flashplayer/download/?installer=FP_26.0_for_Linux_32-bit_(.tar.gz)_-_NPAPI&sType=6630&standalone=1 -https://get.adobe.com/fr/flashplayer/download/?installer=FP_26.0_for_Linux_32-bit_(.tar.gz)_-_NPAPI&sType=6630&standalone=1 -#lien calculé - -#base standard: entetes ok, download KO, taille environ 11 Ko -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" --referer="$urlOnline" \ - --debug -o log -O "$file" "$recup_url" - -#essais -wget --keep-session-cookies --ignore-length --tries=1 --timeout=15 --user-agent="$user_agent" -O "$file_test_wget" "$urlOnline" - -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" \ - --debug -o log -O "$file" "$recup_url" -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" --keep-session-cookies \ - --debug -o log -O "$file" "$recup_url" -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" --keep-session-cookies \ - --no-hsts --debug -o log -O "$file" "$recup_url" -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" --keep-session-cookies \ - --no-hsts --ignore-length --debug -o log -O "$file" "$recup_url" - -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" --referer="$urlOnline" \ - --debug -o log -O "$file" "$recup_url" -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" --referer="$urlOnline" --keep-session-cookies \ - --debug -o log -O "$file" "$recup_url" -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" --referer="$urlOnline" --keep-session-cookies \ - --no-hsts --debug -o log -O "$file" "$recup_url" -wget -c --tries=1 --timeout=15 --user-agent="$user_agent" --referer="$urlOnline" --keep-session-cookies \ - --no-hsts --ignore-length --debug -o log -O "$file" "$recup_url" - - -curl -L -O -v --header "User-Agent: $user_agent" -o "$file" "$recup_url" - -L suivre les redirections -C - reprendre -O sauve fichier avec même nom que distant -o file sauve fichier sous file -v verbose - -curl -I "$recup_url" -HTTP/1.1 200 OK -Date: Fri, 14 Jul 2017 10:18:32 GMT -Server: JRun Web Server -Content-Type: text/html; charset=UTF-8 -Cache-Control: private, no-store, no-cache -Content-Language: fr-FR -Content-Language: fr-FR -Set-Cookie: SETTINGS.LOCALE=fr%5Ffr; HttpOnly;domain=.adobe.com;expires=Sun, 07-Jul-2047 17:18:32 GMT;path=/cfusion/ diff --git a/scripts/tests/diag_getThunderbird b/scripts/tests/diag_getThunderbird deleted file mode 100755 index 56cac6f..0000000 --- a/scripts/tests/diag_getThunderbird +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/bash - -version=5/12/2017 - - # si $1=all affichage complet -f__affichage(){ # 5/12/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 - STD="$(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(){ # 25/12/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/ - latest : https://www.mozilla.org/en-US/thunderbird/all/ - - beta : https://www.mozilla.org/fr/thunderbird/channel/ - beta : https://www.mozilla.org/en-US/thunderbird/beta/all/ - -EOF - printf $COLOR - exit -} - - # test wget, $1=url à tester, sortie du script (même si url testée ok) avec affichage erreur ou ok - # si $2=print affiche url testée & entêtes http & location, return 0 - # si $2=loc affiche seulement location, return 0 - # si $2=test return 0 si ok, return 1 si KO -f__wget_test(){ # 11/12/2017 - local file_test_wget retourWget retourHttp location - - file_test_wget="/tmp/testWget-$$-$RANDOM" - wget -Sq --timeout=5 --tries=2 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget" - retourWget="$?" - [ "$retourWget" == 1 ] && retourWget="1: code erreur générique" - [ "$retourWget" == 2 ] && retourWget="2: parse erreur (ligne de commande?)" - [ "$retourWget" == 3 ] && retourWget="3: erreur Entrée/sortie fichier" - [ "$retourWget" == 4 ] && retourWget="4: défaut réseau" - [ "$retourWget" == 5 ] && retourWget="5: défaut vérification SSL" - [ "$retourWget" == 6 ] && retourWget="6: défaut authentification" - [ "$retourWget" == 7 ] && retourWget="7: erreur de protocole" - [ "$retourWget" == 8 ] && retourWget="8: 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" == "test" ]; then - rm "$file_test_wget" 2>/dev/null - # spécial maintenance frama.link, pas de redirection sur page status framalink - [ "$( grep -c '303' <<< $retourHttp )" -ne 0 ] && return 1 # 303 See Other - [ "$retourWget" == "0" ] && return 0 || return 1 - fi - if [ "$2" == "print" ]; then - if [ "$retourWget" != "0" ]; then - echo "erreur wget: $RED$retourWget" - echo -e "$BLUE $1$STD\t$RED $retourHttp" - else - echo -e "$BLUE $1$STD\t$GREEN $retourHttp" - fi - echo "$STD" - fi - if [ "$2" == "print" ] || [ "$2" == "loc" ]; then - [ "$location" ] && echo -n "$YELLOW $location" || echo -n "$YELLOW no location" - echo "$STD" - rm "$file_test_wget" 2>/dev/null - return 0 - fi - if [ "$retourWget" != "0" ]; then - rm "$file_test_wget" 2>/dev/null -# f__error "wget, $retourWget" "$1" "$YELLOW$retourHttp" "$location" - echo -e "$RED erreur wget, $retourWget \n $1 \n $YELLOW$retourHttp \n $location$STD" # pour les diags - return 1 - fi - if [ "$(grep -c '200' <<< $retourHttp)" -ne 0 ]; then - echo -e "$GREEN\ntout est ok, réessayer$STD\n" - fi - rm "$file_test_wget" 2>/dev/null - exit 0 -} - -test_url_dl_thunderbird(){ # 5/12/2017 - local recup_url fu_archi - for fu_archi in linux linux64; do - echo " Architecture: $fu_archi" - echo " =====================" - for canal in latest beta; do - [ "$canal" == "beta" ] && prefixe="$canal-" - recup_url="https://download.mozilla.org/?product=thunderbird-$prefixe""latest&os=$fu_archi&lang=fr" - printf " $canal": - f__wget_test "$recup_url" print - done - done -} - - # assigne $verLatest, $verBeta -test_version_thunderbird(){ # 5/12/2017 - local recup_url prefixe verOnline verTbOnline - - echo -e "\n === versions Thunderbird ===" - - for canal in latest beta; do - # version online - [ "$canal" == "beta" ] && prefixe="$canal-" - recup_url="https://download.mozilla.org/?product=thunderbird-$prefixe""latest&os=$fu_archi&lang=fr" - verOnline="$( sed -E 's#.*thunderbird/releases/(.*)/linux-.*$#\1#' <<< $( f__wget_test $recup_url loc ) )" - verTbOnline+="$( printf "%-7s: %-12s" $canal $verOnline )" - done - [ "$verTbOnline" ] || verTbOnline="$RED""aucune(s)" - - echo -e " $GREEN$verTbOnline$COLOR" -} - - # start -user_agent="Mozilla/5.0 Firefox" -f__affichage -[ "$1" == "-h" ] && f_help -fu_archi="linux64" - -test_version_thunderbird -echo -test_url_dl_thunderbird -echo - -#nouveaux formats?: -#https://download.mozilla.org/?product=thunderbird-52.5.2-SSL&os=linux64&lang=fr -#https://download.mozilla.org/?product=thunderbird-58.0b2-SSL&os=linux64&lang=fr - -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/ diff --git a/scripts/tests/diag_ip_public b/scripts/tests/diag_ip_public deleted file mode 100755 index 2eb1556..0000000 --- a/scripts/tests/diag_ip_public +++ /dev/null @@ -1,235 +0,0 @@ -#!/bin/bash - - # test connexion, return 0|1, 0 si ip valide, si $1=log : log si perte cnx, requiert $histo_cnx (fichier historique) -f__cnx(){ # 19/04/2018 - - #~ if ! ping -c1 -w1 8.8.8.8 &>/dev/null; then - if ! nc -z -w1 8.8.8.8 53 2>/dev/null ; then - #~ [ "$1" == 'log' ] && f__log "cnx down" "$histo_cnx" - return 1 - else - return 0 - fi -} - - # $1=bas-haut (ex: 0-5), nombre aléatoire entre bas & haut inclus, si [$2=seq] liste avec départ aléatoire -f__random(){ # 25/04/2018 2 - local bas haut max rand start xyz - - [ "${1//*-*}" ] && return 1 # bad format, no - - bas=${1%-*} - haut=${1#*-} - max=$(( 32768 / ( haut + 1 ) * ( haut + 1 ) )) - while (( (rand=RANDOM) >= max )); do : ; done - if [ "$2" == "seq" ]; then - #~ while (( (start=RANDOM) >= max )); do - #~ : - #~ done - start=$(( bas + ( rand % (haut+1-bas) ) )) - for (( xyz=start; xyz <= haut; xyz++ )); do echo "$xyz"; done - (( (start-bas) > 0 )) && for (( xyz=bas; xyz < start; xyz++ )); do echo "$xyz"; done - return - fi - echo $(( bas + ( rand % (haut+1 -bas) ) )) -} - - # [-4]|[-6], par défaut -4, return 0|1, 0 si ip valide -f__validate_ip(){ # 21/04/2018 - local regex #ip6: https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses ()https://stackoverflow.com/a/17871737/9580455) - - if [[ "$1" == "-6" ]]; then - regex="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$" - else - regex="(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])" - regex="^$regex\\.$regex\\.$regex\\.$regex$" - fi - [[ "$1" =~ ^- ]] && shift - #~ [[ "$1" =~ $regex ]] && echo -n ok || echo -n " KO" ; echo "-$1-" - [[ "$1" =~ $regex ]] && return 0 || return 1 -} - - # $1 [-4]|-6, par défaut -4, affiche public ip, requiert f__validate_ip -f_ip_pub_diag(){ # 02/05/2018 - local proto larg ip_pub cmd server user_agent="Mozilla/5.0 Firefox" - declare -a base cmds - - if [ "$1" == '-6' ] ; then - proto="-6" - larg=40 - else - proto="-4" - larg=18 - fi - f__cnx 'log' || return 1 # no connnection, return with error - - type -p host &>/dev/null && cmds+=( "host -R0 -W1 -t " ) # deprecated - type -p dig &>/dev/null && cmds+=( "dig +short +timeout=1 +retry=1 " ) - type -p wget &>/dev/null && cmds+=( "wget --user-agent=$user_agent --quiet --timeout=1 --tries=1 -o /dev/null -O - " ) - type -p curl &>/dev/null && cmds+=( "curl --silent --location --retry 0 --max-time 1 " ) - - for cmd in "${cmds[@]}"; do - if [[ "$proto" == '-4' && "$cmd" =~ ^(host|dig) ]] ; then - base=( "${dns4[@]}" ) - elif [[ "$proto" == '-6' && "$cmd" =~ ^(host|dig) ]] ; then - base=( "${dns6[@]}" ) - elif [[ "$proto" == '-4' && "$cmd" =~ ^(wget|curl) ]] ; then - base=( "${raw4[@]}" ) - elif [[ "$proto" == '-6' && "$cmd" =~ ^(wget|curl) ]] ; then - base=( "${raw6[@]}" ) - fi - for server in "${base[@]}"; do - printf "%-28s: " "${server#*@}" - getTime start - [[ "$cmd" =~ ^host ]] && server="${server//@}" # host - # shellcheck disable=SC2086 - ip_pub=$( $cmd $server ) - ip_pub=${ip_pub##*has address } # extraction command host - ip_pub=${ip_pub##*has IPv6 address } # extraction command host - ip_pub=${ip_pub#*\"} # extraction o-o.myaddr.l.google.com - ip_pub=${ip_pub%\"*} # extraction o-o.myaddr.l.google.com - printf "%-${larg}s " "$( cat -A <<< "${ip_pub:0:$larg}" )" #~ printf "%-${larg}s" "$ip_pub" - f__validate_ip "$1" "$ip_pub" || printf "%s " invalid - getTime end - done - echo "(${cmd%% *})" - sleep 10 - done -} - - # getTime start : comptage départ - # getTime end : comptage fin, calcul fin - départ, affichage différence en ms - # getTime end:sec : idem sauf affichage différence en s - # getTime affichage date en ms, sans unité, pour traitement externe à la fonction - # declare -g time -getTime(){ # 21/04/2018 - local date sec ms time2 - declare -g time - date=$( date +%s.%N ) # s.ns - sec=${date%\.*} # s - ms=${date#*\.} # ns - ms=${ms::-6} # ms - if [[ "$*" =~ "start" ]]; then - time="$sec$ms" - elif [[ "$*" =~ "end" ]]; then - if [[ "$*" =~ "sec" ]]; then - time2=$(( $sec$ms-time )) - echo "${time2::-3}.${time2: -3} s" - else - echo "$(( $sec$ms-time )) ms" - fi - else - echo "$sec$ms" # ms sans unité - fi -} - - { # serveur ip - raw4=( - v4.ident.me # raw ip4 only - ipv4.whatismyip.akamai.com # raw ip4 only - alma.ch/myip.cgi # raw ip4 only - api.infoip.io/ip # raw ip4 only - api.ipify.org # raw ip4 only - myip.dnsdynamic.org # raw ip4 only - ipecho.net/plain # raw ip4 only - ipinfo.io/ip # raw ip4 only - eth0.me # raw ip4 only - - #~ checkip.amazonaws.com # raw ip4 only lent & aléatoire O4/2018 - #~ ifconfig.me/ip # raw ip4 only pas fiable? http://ifconfig.me/ infoS - ) - - raw6=( - v6.ident.me # raw, ip6 defaut - ipv6.whatismyip.akamai.com # raw, ip6 defaut - canhazip.com # raw, ip6 defaut - ip.tyk.nu # raw, ip6 defaut - myexternalip.com/raw # raw, ip6 defaut parfois ip4 - smart-ip.net/myip # raw, ip6 defaut ! requiert user-agent - diagnostic.opendns.com/myip # raw, ip6 defaut - icanhazip.com # raw, ip6 defaut - wgetip.com # raw, ip6 defaut - wtfismyip.com/text # raw, ip6 defaut - l2.io/ip # raw, ip6 defaut - tnx.nl/ip # raw, ip6 defaut - bot.whatismyipaddress.com # raw, ip6 defaut pb parfois sort ip4 - - #~ ipof.in/txt # raw, ip6 defaut NRP - #~ ident.me # raw, ip6 defaut - ) - - dns4=( - "A myip.opendns.com @resolver1.opendns.com" - "A myip.opendns.com @resolver2.opendns.com" - "A myip.opendns.com @resolver3.opendns.com" - "A myip.opendns.com @resolver4.opendns.com" - "A whoami.akamai.net @ns1-1.akamaitech.net" - ) - - dns6=( - "AAAA myip.opendns.com @resolver1.ipv6-sandbox.opendns.com" - "AAAA myip.opendns.com @resolver2.ipv6-sandbox.opendns.com" - "TXT o-o.myaddr.l.google.com @ns1.google.com" - ) - } - -f_ip_pub_diag -4 -f_ip_pub_diag -6 - -{ # inutilisé - -servers_list=( -#~ https://major.io/icanhazip-com-faq/ - check.torproject.org # tor - - checkip.dyndns.com # 1/2 raw ip4 only Current IP Address: 88.191.35.123 - checkip.dyndns.org/plain # 1/2 raw ip4 only Current IP Address: 88.191.35.123 - - bobborst.com/tools/whatsmyip # - canyouseeme.org # - checkmyip.com # - checkip.dns.he.net # 1/2 raw: Your IP address is : 2a01:e35:8bf2:37b0::d7c5:972f - checkip.dynu.com # 1/2 raw: Current IP Address: 88.191.35.123 - ipcheckv6.dynu.com - displaymyip.com # - dslreports.com/whatismyip # - findmyip.co # - formyip.com # - geoiptool.com # - getmyipaddress.org # - httpbin.org/ip # 1/2 raw ip4 only, json - infosniper.net # - ip-adress.com # - ip-adress.eu # - ip.changeip.com # 1/2 raw ip4 only ip_pub=${ip_pub##*IPADDR=} ip_pub=${ip_pub%%-->*} # extraction ip.changeip.com - ipchicken.com # - ipgoat.com # - iplocation.net # - ip-lookup.net # ip6 defaut, - lawrencegoetz.com/programs/ipinfo # - mon-ip.com # locale - monippublique.com # - myexternalip.com # ip6 curl -I "http://myexternalip.com" - my-ip-address.co # - myipnumber.com # - myipv3.hn.org # - portchecktool.com # - privateinternetaccess.com/pages/whats-my-ip # - sshmyip.com # 1/2 raw ip6 only, json - telnetmyip.com # 1/2 raw ip6 only, json - tracemyip.org # - trackip.net # - websiteipaddress.com # - whatismyip.akamai.com # - whatsmydns.net/whats-my-ip-address.html # - whatsmyip.net # ip6 defaut -) - - -divers=( - 'ssh sshmyip.com' # - 'telnet telnetmyip.com' # - 'telnet|nc 6.ifcfg.me 23' # NRP - 'telnet|nc 4.ifcfg.me 23' # NRP -) - -} diff --git a/scripts/tests/lspci b/scripts/tests/lspci deleted file mode 100644 index 0fcb320..0000000 --- a/scripts/tests/lspci +++ /dev/null @@ -1,16 +0,0 @@ -00:00.0 Host bridge: Intel Corporation System Controller Hub (SCH Poulsbo) (rev 07) -00:02.0 VGA compatible controller: Intel Corporation System Controller Hub (SCH Poulsbo) Graphics Controller (rev 07) -00:1b.0 Audio device: Intel Corporation System Controller Hub (SCH Poulsbo) HD Audio Controller (rev 07) -00:1c.0 PCI bridge: Intel Corporation System Controller Hub (SCH Poulsbo) PCI Express Port 1 (rev 07) -00:1c.1 PCI bridge: Intel Corporation System Controller Hub (SCH Poulsbo) PCI Express Port 2 (rev 07) -00:1d.0 USB controller: Intel Corporation System Controller Hub (SCH Poulsbo) USB UHCI #1 (rev 07) -00:1d.1 USB controller: Intel Corporation System Controller Hub (SCH Poulsbo) USB UHCI #2 (rev 07) -00:1d.2 USB controller: Intel Corporation System Controller Hub (SCH Poulsbo) USB UHCI #3 (rev 07) -00:1d.7 USB controller: Intel Corporation System Controller Hub (SCH Poulsbo) USB EHCI #1 (rev 07) -00:1f.0 ISA bridge: Intel Corporation System Controller Hub (SCH Poulsbo) LPC Bridge (rev 07) -00:1f.1 IDE interface: Intel Corporation System Controller Hub (SCH Poulsbo) IDE Controller (rev 07) -01:00.0 Network controller: Qualcomm Atheros AR9285 Wireless Network Adapter (PCI-Express) (rev 01) -03:00.0 Ethernet controller: Qualcomm Atheros AR8132 Fast Ethernet (rev c0) - -04:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Opal XT [Radeon R7 M265] (rev ff) -00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) diff --git a/scripts/tests/lspci_mm b/scripts/tests/lspci_mm deleted file mode 100644 index db578cd..0000000 --- a/scripts/tests/lspci_mm +++ /dev/null @@ -1,21 +0,0 @@ -00:00.0 "Host bridge" "Intel Corporation" "Broadwell-U Host Bridge -OPI" -r09 "Dell" "Device 0695" -00:03.0 "Audio device" "Intel Corporation" "Broadwell-U Audio Controller" -r09 "Dell" "Device 0695" -00:14.0 "USB controller" "Intel Corporation" "Wildcat Point-LP USB xHCI Controller" -r03 -p30 "Dell" "Device 0695" -00:16.0 "Communication controller" "Intel Corporation" "Wildcat Point-LP MEI Controller #1" -r03 "Dell" "Device 0695" -00:1b.0 "Audio device" "Intel Corporation" "Wildcat Point-LP High Definition Audio Controller" -r03 "Dell" "Device 0695" -00:1c.0 "PCI bridge" "Intel Corporation" "Wildcat Point-LP PCI Express Root Port #1" -re3 "" "" -00:1c.2 "PCI bridge" "Intel Corporation" "Wildcat Point-LP PCI Express Root Port #3" -re3 "" "" -00:1c.3 "PCI bridge" "Intel Corporation" "Wildcat Point-LP PCI Express Root Port #4" -re3 "" "" -00:1c.4 "PCI bridge" "Intel Corporation" "Wildcat Point-LP PCI Express Root Port #5" -re3 "" "" -00:1d.0 "USB controller" "Intel Corporation" "Wildcat Point-LP USB EHCI Controller" -r03 -p20 "Dell" "Device 0695" -00:1f.0 "ISA bridge" "Intel Corporation" "Wildcat Point-LP LPC Controller" -r03 "Dell" "Device 0695" -00:1f.2 "SATA controller" "Intel Corporation" "Wildcat Point-LP SATA Controller [AHCI Mode]" -r03 -p01 "Dell" "Device 0695" -00:1f.3 "SMBus" "Intel Corporation" "Wildcat Point-LP SMBus Controller" -r03 "Dell" "Device 0695" -02:00.0 "Ethernet controller" "Realtek Semiconductor Co., Ltd." "RTL8101/2/6E PCI Express Fast/Gigabit Ethernet controller" -r07 "Dell" "Device 0695" -03:00.0 "Network controller" "Intel Corporation" "Wireless 3160" -r83 "Intel Corporation" "Dual Band Wireless AC 3160" - -00:02.0 "VGA compatible controller" "Intel Corporation" "System Controller Hub (SCH Poulsbo) Graphics Controller" -r07 "ASUSTeK Computer Inc." "System Controller Hub (SCH Poulsbo) Graphics Controller" -00:02.0 "VGA compatible controller" "Intel Corporation" "HD Graphics 5500" -r09 "Dell" "Device 0695" -04:00.0 "Display controller" "Advanced Micro Devices, Inc. [AMD/ATI]" "Opal XT [Radeon R7 M265]" -rff -pff "" "" -00:02.0 "VGA compatible controller" "Intel Corporation" "3rd Gen Core processor Graphics Controller" -r09 "ASUSTeK Computer Inc." "3rd Gen Core processor Graphics Controller" -01:00.0 "3D controller" "NVIDIA Corporation" "GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M]" -rff -pff "" "" diff --git a/scripts/tests/lspci_nnv b/scripts/tests/lspci_nnv deleted file mode 100644 index 8b87107..0000000 --- a/scripts/tests/lspci_nnv +++ /dev/null @@ -1,131 +0,0 @@ -00:00.0 Host bridge [0600]: Intel Corporation System Controller Hub (SCH Poulsbo) [8086:8100] (rev 07) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) [1043:83ce] - Flags: bus master, fast devsel, latency 0 - -00:1b.0 Audio device [0403]: Intel Corporation System Controller Hub (SCH Poulsbo) HD Audio Controller [8086:811b] (rev 07) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) HD Audio Controller [1043:83ce] - Flags: bus master, fast devsel, latency 0, IRQ 23 - Memory at f3f38000 (64-bit, non-prefetchable) [size=16K] - Capabilities: - Kernel driver in use: snd_hda_intel - Kernel modules: snd_hda_intel - -00:1c.0 PCI bridge [0604]: Intel Corporation System Controller Hub (SCH Poulsbo) PCI Express Port 1 [8086:8110] (rev 07) (prog-if 00 [Normal decode]) - Flags: bus master, fast devsel, latency 0, IRQ 16 - Bus: primary=00, secondary=03, subordinate=03, sec-latency=0 - I/O behind bridge: 0000e000-0000efff - Memory behind bridge: fbf00000-fbffffff - Prefetchable memory behind bridge: 80000000-801fffff - Capabilities: - Kernel driver in use: pcieport - Kernel modules: shpchp - -00:1c.1 PCI bridge [0604]: Intel Corporation System Controller Hub (SCH Poulsbo) PCI Express Port 2 [8086:8112] (rev 07) (prog-if 00 [Normal decode]) - Flags: bus master, fast devsel, latency 0, IRQ 17 - Bus: primary=00, secondary=01, subordinate=02, sec-latency=0 - I/O behind bridge: 0000d000-0000dfff - Memory behind bridge: f4000000-fbefffff - Prefetchable memory behind bridge: cc000000-cfffffff - Capabilities: - Kernel driver in use: pcieport - Kernel modules: shpchp - -00:1d.0 USB controller [0c03]: Intel Corporation System Controller Hub (SCH Poulsbo) USB UHCI #1 [8086:8114] (rev 07) (prog-if 00 [UHCI]) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) USB UHCI [1043:83ce] - Flags: bus master, fast devsel, latency 0, IRQ 20 - I/O ports at b880 [size=32] - Kernel driver in use: uhci_hcd - Kernel modules: uhci_hcd - -00:1d.1 USB controller [0c03]: Intel Corporation System Controller Hub (SCH Poulsbo) USB UHCI #2 [8086:8115] (rev 07) (prog-if 00 [UHCI]) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) USB UHCI [1043:83ce] - Flags: bus master, fast devsel, latency 0, IRQ 21 - I/O ports at c080 [size=32] - Kernel driver in use: uhci_hcd - Kernel modules: uhci_hcd - -00:1d.2 USB controller [0c03]: Intel Corporation System Controller Hub (SCH Poulsbo) USB UHCI #3 [8086:8116] (rev 07) (prog-if 00 [UHCI]) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) USB UHCI [1043:83ce] - Flags: bus master, fast devsel, latency 0, IRQ 18 - I/O ports at c480 [size=32] - Kernel driver in use: uhci_hcd - Kernel modules: uhci_hcd - -00:1d.7 USB controller [0c03]: Intel Corporation System Controller Hub (SCH Poulsbo) USB EHCI #1 [8086:8117] (rev 07) (prog-if 20 [EHCI]) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) USB EHCI [1043:83ce] - Flags: bus master, fast devsel, latency 0, IRQ 19 - Memory at f3f37c00 (32-bit, non-prefetchable) [size=1K] - Capabilities: - Kernel driver in use: ehci-pci - Kernel modules: ehci_pci - -00:1f.0 ISA bridge [0601]: Intel Corporation System Controller Hub (SCH Poulsbo) LPC Bridge [8086:8119] (rev 07) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) LPC Bridge [1043:83ce] - Flags: fast devsel - Kernel driver in use: lpc_sch - Kernel modules: lpc_sch - -00:1f.1 IDE interface [0101]: Intel Corporation System Controller Hub (SCH Poulsbo) IDE Controller [8086:811a] (rev 07) (prog-if 80 [Master]) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) IDE Controller [1043:83ce] - Flags: bus master, fast devsel, latency 0 - [virtual] Memory at 000001f0 (32-bit, non-prefetchable) [size=8] - [virtual] Memory at 000003f0 (type 3, non-prefetchable) - [virtual] Memory at 00000170 (32-bit, non-prefetchable) [size=8] - [virtual] Memory at 00000370 (type 3, non-prefetchable) - I/O ports at ffa0 [size=16] - Kernel driver in use: pata_sch - Kernel modules: pata_sch, ata_generic - -01:00.0 Network controller [0280]: Qualcomm Atheros AR9285 Wireless Network Adapter (PCI-Express) [168c:002b] (rev 01) - Subsystem: AzureWave AW-NE785 / AW-NE785H 802.11bgn Wireless Full or Half-size Mini PCIe Card [1a3b:1089] - Physical Slot: eeepc-wifi - Flags: bus master, fast devsel, latency 0, IRQ 17 - Memory at fbef0000 (64-bit, non-prefetchable) [size=64K] - Capabilities: - Kernel driver in use: ath9k - Kernel modules: ath9k - -03:00.0 Ethernet controller [0200]: Qualcomm Atheros AR8132 Fast Ethernet [1969:1062] (rev c0) - Subsystem: ASUSTeK Computer Inc. AR8132 Fast Ethernet [1043:14e5] - Flags: bus master, fast devsel, latency 0, IRQ 24 - Memory at fbfc0000 (64-bit, non-prefetchable) [size=256K] - I/O ports at e880 [size=128] - Capabilities: - Kernel driver in use: atl1c - Kernel modules: atl1c - -00:02.0 VGA compatible controller [0300]: Intel Corporation System Controller Hub (SCH Poulsbo) Graphics Controller [8086:8108] (rev 07) (prog-if 00 [VGA controller]) - Subsystem: ASUSTeK Computer Inc. System Controller Hub (SCH Poulsbo) Graphics Controller [1043:83ce] - Flags: bus master, fast devsel, latency 0, IRQ 22 - Memory at f3f80000 (32-bit, non-prefetchable) [size=512K] - I/O ports at c880 [size=8] - Memory at d0000000 (32-bit, non-prefetchable) [size=256M] - Memory at f3f40000 (32-bit, non-prefetchable) [size=256K] - [virtual] Expansion ROM at 000c0000 [disabled] [size=128K] - Capabilities: - Kernel driver in use: gma500 - Kernel modules: gma500_gfx - -05:02.0 VGA compatible controller [0300]: Intel Corporation HD Graphics 5500 [8086:1616] (rev 09) (prog-if 00 [VGA controller]) - Subsystem: Dell Device [1028:0695] - Flags: bus master, fast devsel, latency 0, IRQ 49 - Memory at d0000000 (64-bit, non-prefetchable) [size=16M] - Memory at c0000000 (64-bit, prefetchable) [size=256M] - I/O ports at 5000 [size=64] - [virtual] Expansion ROM at 000c0000 [disabled] [size=128K] - Capabilities: - Kernel driver in use: i915 - Kernel modules: i915 - -04:00.0 3D controller [0302]: NVIDIA Corporation GF117M [GeForce 610M/710M/810M/820M / GT 620M/625M/630M/720M] [10de:1140] (rev a1) - Subsystem: ASUSTeK Computer Inc. GeForce GT 720M [1043:124d] - Flags: bus master, fast devsel, latency 0, IRQ 32 - Memory at f6000000 (32-bit, non-prefetchable) [size=16M] - Memory at e0000000 (64-bit, prefetchable) [size=256M] - Memory at f0000000 (64-bit, prefetchable) [size=32M] - I/O ports at e000 [size=128] - [virtual] Expansion ROM at f7000000 [disabled] [size=512K] - Capabilities: - Kernel driver in use: nvidia - Kernel modules: nvidia - diff --git a/scripts/tests/style_guide.md b/scripts/tests/style_guide.md deleted file mode 100644 index 9355e3f..0000000 --- a/scripts/tests/style_guide.md +++ /dev/null @@ -1,61 +0,0 @@ -## général - -* utf-8 -* indentation: TABULATION -* $() pas \` -* pas de commandes séquentielle avec ; -* pas de "_conditions compactes_" **(condition && action1 || action2)**, par lisibilité, lors affectation variables, au moins pour la première affectation, donc if then else multilignes -* pas de "_conditions compactes_" sur des action importantes/dangereuses, en particulier si action1 peut être en erreur et induire donc, aussi, action 2, donc if then else multilignes -* éventuellement, remplacer condition compactes et simples par if then else sur une ligne pour éviter warning shellcheck -* == pour marquer les équivalences, = pour les assignations, bien que = pourraient être utilisées pour - les équivalences -* même si '[[ ]]' permettrait d'éviter les guillemets, il sont quand même mis par convention, ne serait ce que - pour une coloration syntaxique homogène - - - -## fonctions - -sauf exception (initialisation), les fonctions utilisent ce principe de nommage: - -* f__ : fonctions utilitaires, communes à plusieurs scripts - * variables publiques: pas de conventions de nommage pour l'instant (à faire) - * à faire : fu_ (Utilité) - -* f_ : fonction généraliste propre au script - * variables publiques: AUCUNE - -* fi_ : affichage/présentation - * variables publiques: $fe_ (Exception) - * éviter les variables publiques - * exceptions: sous-fonctions, sortie pour lisibilité, variables n'a pas à respecter le nommage (sous-fonction) - -* figet_ : calculs/préparation - * variables publiques: $fg_ (Général) - * aucun affichage - - -## variables - -* toutes les variables internes à la fonction doivent être déclarées en local en tête de fonction -* les variables publiques sont signalées en première lignes de commentaire au-dessus de la déclaration de fonction -* nommage - * fg_ : pour une variable de fonction figet_ - * fe_ : pour une variable de fonction f_ (attention aux collisions avec un nom de fonction) - - - - #### * Note: [[ -n $something ]] - double brackets does not require quotes for variables: ie, "$something". - #### * Always use quotes, double or single, for all string values. - #### * All new code/methods must be in a function. - - #### * For all boolean tests, use 'true' / 'false'. - #### !! Do NOT use 0 or 1 unless it's a function return. - #### * Avoid complicated tests in the if condition itself. - #### * To 'return' a value in a function, use 'echo '. - #### * For gawk: use always if ( num_of_cores > 1 ) { hanging { starter for all blocks - #### This lets us use one method for all gawk structures, including BEGIN/END, if, for, etc - #### * Using ${VAR} is about 30% slower than $VAR because bash has to check the stuff for actions - #### SUBSHELLS ARE EXPENSIVE! - run these two if you do not believe me. - #### time for (( i=0; i<1000; i++ )) do ff='/usr/local/bin/foo.pid';ff=${ff##*/};ff=${ff%.*};done;echo $ff - #### time for (( i=0; i<1000; i++ )) do ff='/usr/local/bin/foo.pid';ff=$( basename $ff | cut -d '.' -f 1 );done;echo $ff