This commit is contained in:
kyodev 2017-08-28 10:09:07 +02:00
parent bee379a445
commit d90a0b9419
2 changed files with 28 additions and 9 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=1.2.0
date="27/08/2017"
version=1.3.0
date="28/08/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getIp"
@ -118,8 +118,9 @@ f__user(){ # v21/08/2017-4
return 0
}
# test wget, $1 url à tester affiche url testée & entêtes http, sortie script sur erreur
f__wget_test(){ #v25/08/2017
# test wget, $1 url à tester, sortie script, sur erreur ou retour à la normale
# si $2=print affiche url testée & entêtes http & location (si présente) et sortie normale fonction
f__wget_test(){ #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"
@ -130,10 +131,23 @@ f__wget_test(){ #v25/08/2017
[ "$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)"
f__error "erreur wget: $retourWget" "url: $1" "$retourHttp" \
"Erreur wget" "si persistance, contacter $projet $contact en indiquant les messages précédents"
local retourHttp="$(grep -i 'HTTP/' "$file_test_wget" | tr -d '\n' | xargs)"
local location="$(grep -i 'location' $file_test_wget | xargs)"
if [ "$2" == "print" ] && [ -z "$retourWget" ]; then
echo -e "\n$1"
echo "$GREEN$retourHttp$COLOR"
[ "$location" ] && echo "$YELLOW$location"
echo "$COLOR"
return
fi
if [ "$retourWget" ]; then
rm "$file_test_wget"
f__error "erreur wget, $retourWget" "url: $1" "$YELLOW$retourHttp" \
"si persistance, contacter $projet $contact en indiquant les messages précédents"
fi
if [ "$(grep -c '200' <<< $retourHttp)" -ne 0 ]; then echo -e "$GREEN\ntout est ok, réessayer\n$COLOR"; fi
rm "$file_test_wget"
exit 0
}
fgi_help(){
@ -262,7 +276,7 @@ fgi_ip_public(){ # $1=IPv4|IPv6, assigne $ip_public # v18/08/2017
fi
}
# inscription dans tache upgrade en anacron hebdomadaire, via cron horaire
# inscription dans tache upgrade en anacron hebdomadaire, via cron horaire, $1=upgrade|install|remove
fscript_cronAnacron(){ # v27/08/2017
[ "$(type -t fscript_cronAnacron_special)" ] && fscript_cronAnacron_special # test, si fonction spécifique, appel
local dirAnacron="/home/$user_/.config/anacron"
@ -377,7 +391,7 @@ PATH='/usr/sbin:/usr/bin:/sbin:/bin' ; IFS=' '; TERM=xterm
export PATH TERM
f__affichage
fileLogs="/var/log/sdeb_$script.log"
fileDev="fileDev"
fileDev="/opt/bin/fileDev"
f__requis "gawk wget ip>iproute2" # requis pour fonctionnement programme
options="$@"

View File

@ -1,6 +1,11 @@
# changelog getIp
## 1.3.0 28/08/2017
* fix bug: localisation fileDev
* révision f__wget_test
## 1.2.0 27/08/2017
* fix bug upgrade