FAIL sur code d'erreur http

This commit is contained in:
Maniack Crudelis 2016-07-08 21:08:37 +02:00
parent a18cd16f98
commit b23dbbaf31
2 changed files with 51 additions and 39 deletions

View file

@ -7,6 +7,13 @@
echo "" echo ""
# Récupère le dossier du script
if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$PWD/$(dirname "$0" | cut -d '.' -f2)"; fi
source "$script_dir/sub_scripts/lxc_launcher.sh"
source "$script_dir/sub_scripts/testing_process.sh"
source /usr/share/yunohost/helpers
# Vérifie la connexion internet. # Vérifie la connexion internet.
ping -q -c 2 yunohost.org > /dev/null 2>&1 ping -q -c 2 yunohost.org > /dev/null 2>&1
if [ "$?" -ne 0 ]; then # En cas d'échec de connexion, tente de pinger un autre domaine pour être sûr if [ "$?" -ne 0 ]; then # En cas d'échec de connexion, tente de pinger un autre domaine pour être sûr
@ -17,15 +24,12 @@ if [ "$?" -ne 0 ]; then # En cas d'échec de connexion, tente de pinger un autre
fi fi
fi fi
# Récupère le dossier du script
if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$PWD/$(dirname "$0" | cut -d '.' -f2)"; fi
version_script="$(git ls-remote https://github.com/YunoHost/package_check | cut -f 1 | head -n1)" version_script="$(git ls-remote https://github.com/YunoHost/package_check | cut -f 1 | head -n1)"
if [ -e "$script_dir/package_version" ] if [ -e "$script_dir/package_version" ]
then then
if [ "$version_script" != "$(cat "$script_dir/package_version")" ]; then # Si le dernier commit sur github ne correspond pas au commit enregistré, il y a une mise à jour. if [ "$version_script" != "$(cat "$script_dir/package_version")" ]; then # Si le dernier commit sur github ne correspond pas au commit enregistré, il y a une mise à jour.
# Écrit le script de mise à jour, qui sera exécuté à la place de ce script, pour le remplacer et le relancer après. # Écrit le script de mise à jour, qui sera exécuté à la place de ce script, pour le remplacer et le relancer après.
echo "Mise à jour de Package check..." ECHO_FORMAT "Mise à jour de Package check...\n" "white" "bold"
echo -e "#!/bin/bash\n" > "$script_dir/upgrade_script.sh" echo -e "#!/bin/bash\n" > "$script_dir/upgrade_script.sh"
echo "git clone --quiet https://github.com/YunoHost/package_check \"$script_dir/upgrade\"" >> "$script_dir/upgrade_script.sh" echo "git clone --quiet https://github.com/YunoHost/package_check \"$script_dir/upgrade\"" >> "$script_dir/upgrade_script.sh"
echo "sudo cp -a \"$script_dir/upgrade/.\" \"$script_dir/.\"" >> "$script_dir/upgrade_script.sh" echo "sudo cp -a \"$script_dir/upgrade/.\" \"$script_dir/.\"" >> "$script_dir/upgrade_script.sh"
@ -43,14 +47,14 @@ version_plinter="$(git ls-remote https://github.com/YunoHost/package_linter | cu
if [ -e "$script_dir/plinter_version" ] if [ -e "$script_dir/plinter_version" ]
then then
if [ "$version_plinter" != "$(cat "$script_dir/plinter_version")" ]; then # Si le dernier commit sur github ne correspond pas au commit enregistré, il y a une mise à jour. if [ "$version_plinter" != "$(cat "$script_dir/plinter_version")" ]; then # Si le dernier commit sur github ne correspond pas au commit enregistré, il y a une mise à jour.
echo "Mise à jour de package_linter..." ECHO_FORMAT "Mise à jour de package_linter..." "white" "bold"
git clone --quiet https://github.com/YunoHost/package_linter "$script_dir/package_linter_tmp" git clone --quiet https://github.com/YunoHost/package_linter "$script_dir/package_linter_tmp"
sudo cp -a "$script_dir/package_linter_tmp/." "$script_dir/package_linter/." sudo cp -a "$script_dir/package_linter_tmp/." "$script_dir/package_linter/."
sudo rm -r "$script_dir/package_linter_tmp" sudo rm -r "$script_dir/package_linter_tmp"
fi fi
else # Si le fichier de version n'existe pas, il est créé. else # Si le fichier de version n'existe pas, il est créé.
echo "$version_plinter" > "$script_dir/plinter_version" echo "$version_plinter" > "$script_dir/plinter_version"
echo "Installation de package_linter." ECHO_FORMAT "Installation de package_linter." "white"
git clone --quiet https://github.com/YunoHost/package_linter "$script_dir/package_linter" git clone --quiet https://github.com/YunoHost/package_linter "$script_dir/package_linter"
fi fi
echo "$version_plinter" > "$script_dir/plinter_version" echo "$version_plinter" > "$script_dir/plinter_version"
@ -84,10 +88,6 @@ else
fi fi
SOUS_DOMAIN="sous.$DOMAIN" SOUS_DOMAIN="sous.$DOMAIN"
source "$script_dir/sub_scripts/lxc_launcher.sh"
source "$script_dir/sub_scripts/testing_process.sh"
source /usr/share/yunohost/helpers
if [ "$no_lxc" -eq 0 ] if [ "$no_lxc" -eq 0 ]
then # Si le conteneur lxc est utilisé then # Si le conteneur lxc est utilisé
lxc_ok=0 lxc_ok=0

View file

@ -46,9 +46,15 @@ CHECK_URL () {
curl -LksS -w "%{http_code};%{url_effective}\n" $SOUS_DOMAIN$CHECK_PATH -o "$script_dir/url_output" > "$script_dir/curl_print" curl -LksS -w "%{http_code};%{url_effective}\n" $SOUS_DOMAIN$CHECK_PATH -o "$script_dir/url_output" > "$script_dir/curl_print"
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
ECHO_FORMAT "Erreur de connexion...\n" "lred" "bold" ECHO_FORMAT "Erreur de connexion...\n" "lred" "bold"
curl_error=1
fi fi
ECHO_FORMAT "Adresse de la page: $(cat "$script_dir/curl_print" | cut -d ';' -f2)\n" "white" ECHO_FORMAT "Adresse de la page: $(cat "$script_dir/curl_print" | cut -d ';' -f2)\n" "white"
ECHO_FORMAT "Code HTTP: $(cat "$script_dir/curl_print" | cut -d ';' -f1)\n" "white" HTTP_CODE=$(cat "$script_dir/curl_print" | cut -d ';' -f1)
ECHO_FORMAT "Code HTTP: $HTTP_CODE\n" "white"
if [ "${HTTP_CODE:0:1}" == "0" ] || [ "${HTTP_CODE:0:1}" == "4" ] || [ "${HTTP_CODE:0:1}" == "5" ]
then # Si le code d'erreur http est du type 0xx 4xx ou 5xx, c'est un code d'erreur.
curl_error=1
fi
URL_TITLE=$(grep "<title>" "$script_dir/url_output" | cut -d '>' -f 2 | cut -d '<' -f1) URL_TITLE=$(grep "<title>" "$script_dir/url_output" | cut -d '>' -f 2 | cut -d '<' -f1)
ECHO_FORMAT "Titre de la page: $URL_TITLE\n" "white" ECHO_FORMAT "Titre de la page: $URL_TITLE\n" "white"
if [ "$URL_TITLE" == "YunoHost Portal" ]; then if [ "$URL_TITLE" == "YunoHost Portal" ]; then
@ -95,9 +101,12 @@ CHECK_SETUP_SUBDIR () {
# Installation de l'app # Installation de l'app
SETUP_APP SETUP_APP
LOG_EXTRACTOR LOG_EXTRACTOR
# Test l'accès à l'app
CHECK_PATH=$PATH_TEST
CHECK_URL
tnote=$((tnote+2)) tnote=$((tnote+2))
install_pass=1 install_pass=1
if [ "$YUNOHOST_RESULT" -eq 0 ]; then if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold" ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
note=$((note+2)) note=$((note+2))
GLOBAL_CHECK_SETUP=1 # Installation réussie GLOBAL_CHECK_SETUP=1 # Installation réussie
@ -109,9 +118,6 @@ CHECK_SETUP_SUBDIR () {
fi fi
GLOBAL_CHECK_SUB_DIR=-1 # Installation en sous-dossier échouée GLOBAL_CHECK_SUB_DIR=-1 # Installation en sous-dossier échouée
fi fi
# Test l'accès à l'app
CHECK_PATH=$PATH_TEST
CHECK_URL
# Suppression de l'app # Suppression de l'app
REMOVE_APP REMOVE_APP
if [ "$YUNOHOST_RESULT" -eq 0 ] # Si l'installation a été un succès. On teste la suppression if [ "$YUNOHOST_RESULT" -eq 0 ] # Si l'installation a été un succès. On teste la suppression
@ -164,13 +170,16 @@ CHECK_SETUP_ROOT () {
# Installation de l'app # Installation de l'app
SETUP_APP SETUP_APP
LOG_EXTRACTOR LOG_EXTRACTOR
# Test l'accès à l'app
CHECK_PATH="/"
CHECK_URL
if [ "$install_pass" -gt 0 ]; then # Si install_pass>0, une installation a déjà été faite. if [ "$install_pass" -gt 0 ]; then # Si install_pass>0, une installation a déjà été faite.
tnote=$((tnote+1)) tnote=$((tnote+1))
else else
install_pass=1 install_pass=1
tnote=$((tnote+2)) tnote=$((tnote+2))
fi fi
if [ "$YUNOHOST_RESULT" -eq 0 ]; then if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold" ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
if [ "$GLOBAL_CHECK_SETUP" -eq 1 ]; then if [ "$GLOBAL_CHECK_SETUP" -eq 1 ]; then
note=$((note+1)) note=$((note+1))
@ -186,9 +195,6 @@ CHECK_SETUP_ROOT () {
fi fi
GLOBAL_CHECK_ROOT=-1 # Installation à la racine échouée GLOBAL_CHECK_ROOT=-1 # Installation à la racine échouée
fi fi
# Test l'accès à l'app
CHECK_PATH="/"
CHECK_URL
# Suppression de l'app # Suppression de l'app
REMOVE_APP REMOVE_APP
if [ "$YUNOHOST_RESULT" -eq 0 ] # Si l'installation a été un succès. On teste la suppression if [ "$YUNOHOST_RESULT" -eq 0 ] # Si l'installation a été un succès. On teste la suppression
@ -310,8 +316,10 @@ CHECK_UPGRADE () {
YUNOHOST_RESULT=$? YUNOHOST_RESULT=$?
COPY_LOG 2 COPY_LOG 2
LOG_EXTRACTOR LOG_EXTRACTOR
# Test l'accès à l'app
CHECK_URL
tnote=$((tnote+1)) tnote=$((tnote+1))
if [ "$YUNOHOST_RESULT" -eq 0 ]; then if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold" ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
note=$((note+1)) note=$((note+1))
GLOBAL_CHECK_UPGRADE=1 # Upgrade réussie GLOBAL_CHECK_UPGRADE=1 # Upgrade réussie
@ -319,8 +327,6 @@ CHECK_UPGRADE () {
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold" ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
GLOBAL_CHECK_UPGRADE=-1 # Upgrade échouée GLOBAL_CHECK_UPGRADE=-1 # Upgrade échouée
fi fi
# Test l'accès à l'app
CHECK_URL
if [ "$no_lxc" -ne 0 ]; then if [ "$no_lxc" -ne 0 ]; then
# Suppression de l'app si lxc n'est pas utilisé. # Suppression de l'app si lxc n'est pas utilisé.
REMOVE_APP REMOVE_APP
@ -381,8 +387,10 @@ CHECK_BACKUP_RESTORE () {
YUNOHOST_RESULT=$? YUNOHOST_RESULT=$?
COPY_LOG 2 COPY_LOG 2
LOG_EXTRACTOR LOG_EXTRACTOR
# Test l'accès à l'app
CHECK_URL
tnote=$((tnote+1)) tnote=$((tnote+1))
if [ "$YUNOHOST_RESULT" -eq 0 ]; then if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold" ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
note=$((note+1)) note=$((note+1))
GLOBAL_CHECK_RESTORE=1 # Restore réussi GLOBAL_CHECK_RESTORE=1 # Restore réussi
@ -390,8 +398,6 @@ CHECK_BACKUP_RESTORE () {
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold" ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
GLOBAL_CHECK_RESTORE=-1 # Restore échoué GLOBAL_CHECK_RESTORE=-1 # Restore échoué
fi fi
# Test l'accès à l'app
CHECK_URL
if [ "$no_lxc" -ne 0 ]; then if [ "$no_lxc" -ne 0 ]; then
# Suppression de l'app si lxc n'est pas utilisé. # Suppression de l'app si lxc n'est pas utilisé.
REMOVE_APP REMOVE_APP
@ -463,7 +469,7 @@ CHECK_PUBLIC_PRIVATE () {
fi fi
LOG_EXTRACTOR LOG_EXTRACTOR
tnote=$((tnote+1)) tnote=$((tnote+1))
if [ "$YUNOHOST_RESULT" -eq 0 ]; then if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold" ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
note=$((note+1)) note=$((note+1))
if [ "$1" == "private" ]; then if [ "$1" == "private" ]; then
@ -521,8 +527,17 @@ CHECK_MULTI_INSTANCE () {
CHECK_PATH="$PATH_TEST-2" CHECK_PATH="$PATH_TEST-2"
SETUP_APP SETUP_APP
LOG_EXTRACTOR LOG_EXTRACTOR
# Test l'accès à la 1ère instance de l'app
CHECK_PATH=$CHECK_PATH_first
CHECK_URL
if [ "$curl_error" -ne 0 ]; then
YUNOHOST_RESULT_first=$curl_error
fi
# Test l'accès à la 2e instance de l'app
CHECK_PATH="$PATH_TEST-2"
CHECK_URL
tnote=$((tnote+1)) tnote=$((tnote+1))
if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$YUNOHOST_RESULT_first" -eq 0 ]; then if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$YUNOHOST_RESULT_first" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold" ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
note=$((note+1)) note=$((note+1))
GLOBAL_CHECK_MULTI_INSTANCE=1 # Installation multi-instance réussie GLOBAL_CHECK_MULTI_INSTANCE=1 # Installation multi-instance réussie
@ -530,12 +545,6 @@ CHECK_MULTI_INSTANCE () {
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold" ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
GLOBAL_CHECK_MULTI_INSTANCE=-1 # Installation multi-instance échouée GLOBAL_CHECK_MULTI_INSTANCE=-1 # Installation multi-instance échouée
fi fi
# Test l'accès à la 1ère instance de l'app
CHECK_PATH=$CHECK_PATH_first
CHECK_URL
# Test l'accès à la 2e instance de l'app
CHECK_PATH="$PATH_TEST-2"
CHECK_URL
if [ "$no_lxc" -ne 0 ]; then if [ "$no_lxc" -ne 0 ]; then
# Suppression de la 2e app si lxc n'est pas utilisé. # Suppression de la 2e app si lxc n'est pas utilisé.
REMOVE_APP REMOVE_APP
@ -612,6 +621,13 @@ CHECK_COMMON_ERROR () {
# Installation de l'app # Installation de l'app
SETUP_APP SETUP_APP
LOG_EXTRACTOR LOG_EXTRACTOR
if [ "$1" == "incorrect_path" ] || [ "$1" == "port_already_use" ]; then
# Test l'accès à l'app
CHECK_URL
if [ "$curl_error" -ne 0 ]; then
YUNOHOST_RESULT=$curl_error
fi
fi
tnote=$((tnote+1)) tnote=$((tnote+1))
if [ "$YUNOHOST_RESULT" -eq 0 ]; then # wrong_user et wrong_path doivent aboutir à échec de l'installation. C'est l'inverse pour incorrect_path et port_already_use. if [ "$YUNOHOST_RESULT" -eq 0 ]; then # wrong_user et wrong_path doivent aboutir à échec de l'installation. C'est l'inverse pour incorrect_path et port_already_use.
if [ "$1" == "wrong_user" ]; then if [ "$1" == "wrong_user" ]; then
@ -625,12 +641,12 @@ CHECK_COMMON_ERROR () {
if [ "$1" == "incorrect_path" ]; then if [ "$1" == "incorrect_path" ]; then
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold" ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
note=$((note+1)) note=$((note+1))
GLOBAL_CHECK_PATH=1 # Installation privée réussie GLOBAL_CHECK_PATH=1 # Correction de path réussie
fi fi
if [ "$1" == "port_already_use" ]; then if [ "$1" == "port_already_use" ]; then
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold" ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
note=$((note+1)) note=$((note+1))
GLOBAL_CHECK_PORT=1 # Installation privée réussie GLOBAL_CHECK_PORT=1 # Changement de port réussi
fi fi
else else
if [ "$1" == "wrong_user" ]; then if [ "$1" == "wrong_user" ]; then
@ -652,10 +668,6 @@ CHECK_COMMON_ERROR () {
GLOBAL_CHECK_PORT=-1 # Installation privée échouée GLOBAL_CHECK_PORT=-1 # Installation privée échouée
fi fi
fi fi
if [ "$1" == "incorrect_path" ] || [ "$1" == "port_already_use" ]; then
# Test l'accès à l'app
CHECK_URL
fi
if [ "$no_lxc" -ne 0 ]; then if [ "$no_lxc" -ne 0 ]; then
# Suppression de l'app si lxc n'est pas utilisé. # Suppression de l'app si lxc n'est pas utilisé.
REMOVE_APP REMOVE_APP