mirror of https://framagit.org/kyodev/kyopages.git
maj
This commit is contained in:
parent
75cb0307eb
commit
5e26b235ae
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
version=5/12/2017
|
version=16/01/2018
|
||||||
|
|
||||||
# si $1=all affichage complet
|
# si $1=all affichage complet
|
||||||
f__affichage(){ # 5/12/2017
|
f__affichage(){ # 5/12/2017
|
||||||
|
@ -52,14 +52,18 @@ EOF
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# test wget, $1=url à tester, sortie du script (même si url testée ok) avec affichage erreur ou ok
|
f__error(){ # 16/01/2018 divert
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# test wget, $1=url à tester, $2=''|print|loc|test
|
||||||
|
# par défaut, 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=print affiche url testée & entêtes http & location, return 0
|
||||||
# si $2=loc affiche seulement location, return 0
|
# si $2=loc affiche seulement location, return 0
|
||||||
# si $2=test return 0 si ok, return 1 si KO
|
# si $2=test return 0 si ok, return 1 si KO
|
||||||
f__wget_test(){ # 11/12/2017
|
f__wget_test(){ # 16/01/2018
|
||||||
local file_test_wget retourWget retourHttp location
|
local file_test_wget="/tmp/testWget-$script" 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"
|
wget -Sq --timeout=5 --tries=2 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget"
|
||||||
retourWget="$?"
|
retourWget="$?"
|
||||||
[ "$retourWget" == 1 ] && retourWget="1: code erreur générique"
|
[ "$retourWget" == 1 ] && retourWget="1: code erreur générique"
|
||||||
|
@ -73,36 +77,35 @@ f__wget_test(){ # 11/12/2017
|
||||||
retourHttp=$( grep -i 'HTTP/' "$file_test_wget" | tr -d '\n' | xargs )
|
retourHttp=$( grep -i 'HTTP/' "$file_test_wget" | tr -d '\n' | xargs )
|
||||||
location=$( grep -i 'location' $file_test_wget | xargs )
|
location=$( grep -i 'location' $file_test_wget | xargs )
|
||||||
if [ "$2" == "test" ]; then
|
if [ "$2" == "test" ]; then
|
||||||
rm "$file_test_wget" 2>/dev/null
|
rm -f "$file_test_wget"
|
||||||
# spécial maintenance frama.link, pas de redirection sur page status framalink
|
# spécial maintenance frama.link, pas de redirection sur page status framalink
|
||||||
[ "$( grep -c '303' <<< $retourHttp )" -ne 0 ] && return 1 # 303 See Other
|
grep -q '303' <<< $retourHttp && return 1 # 303 See Other
|
||||||
[ "$retourWget" == "0" ] && return 0 || return 1
|
[ "$retourWget" == "0" ] && return 0 || return 1
|
||||||
fi
|
fi
|
||||||
if [ "$2" == "print" ]; then
|
if [ "$2" == "print" ]; then
|
||||||
if [ "$retourWget" != "0" ]; then
|
if [ "$retourWget" != "0" ]; then
|
||||||
echo "erreur wget: $RED$retourWget"
|
echo " erreur wget: erreur $RED$retourWget"
|
||||||
echo -e "$BLUE $1$STD\t$RED $retourHttp"
|
echo -e "$BLUE $1$STD\t$RED $retourHttp$STD"
|
||||||
else
|
else
|
||||||
echo -e "$BLUE $1$STD\t$GREEN $retourHttp"
|
echo -e "$BLUE $1$STD\t$GREEN $retourHttp$STD"
|
||||||
fi
|
fi
|
||||||
echo "$STD"
|
|
||||||
fi
|
fi
|
||||||
if [ "$2" == "print" ] || [ "$2" == "loc" ]; then
|
if [ "$2" == "print" ] || [ "$2" == "loc" ]; then
|
||||||
[ "$location" ] && echo -n "$YELLOW $location" || echo -n "$YELLOW no location"
|
[ "$location" ] && echo -n "$YELLOW $location" || echo -n "$YELLOW no location"
|
||||||
echo "$STD"
|
echo "$STD"
|
||||||
rm "$file_test_wget" 2>/dev/null
|
rm -f "$file_test_wget"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ "$retourWget" != "0" ]; then
|
if [ "$retourWget" != "0" ]; then
|
||||||
rm "$file_test_wget" 2>/dev/null
|
rm -f "$file_test_wget"
|
||||||
# f__error "wget, $retourWget" "$1" "$YELLOW$retourHttp" "$location"
|
f__error "wget, erreur $retourWget" "$1" "$YELLOW$retourHttp" "$location"
|
||||||
echo -e "$RED erreur wget, $retourWget \n $1 \n $YELLOW$retourHttp \n $location$STD" # pour les diags
|
echo -e "$RED erreur wget, $retourWget \n $1 \n $YELLOW$retourHttp \n $location$STD" # pour les diags
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ "$(grep -c '200' <<< $retourHttp)" -ne 0 ]; then
|
if grep -q '200' <<< $retourHttp; then
|
||||||
echo -e "$GREEN\ntout est ok, réessayer$STD\n"
|
echo -e "$GREEN\ntout est ok, réessayer$STD\n"
|
||||||
fi
|
fi
|
||||||
rm "$file_test_wget" 2>/dev/null
|
rm -f "$file_test_wget"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue