mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Do not show unavailable ressources if not asking for it
This commit is contained in:
parent
85bee3d9b7
commit
de56cf144d
2 changed files with 69 additions and 57 deletions
|
@ -50,6 +50,7 @@ interrupt=0
|
|||
notice=0
|
||||
build_lxc=0
|
||||
bash_mode=0
|
||||
show_resources=0
|
||||
|
||||
# If no arguments provided
|
||||
if [ "$#" -eq 0 ]
|
||||
|
@ -70,6 +71,7 @@ else
|
|||
arguments[$i]=${arguments[$i]//--help/-h}
|
||||
arguments[$i]=${arguments[$i]//--build-lxc/-l}
|
||||
arguments[$i]=${arguments[$i]//--bash-mode/-y}
|
||||
arguments[$i]=${arguments[$i]//--show-resources/-r}
|
||||
done
|
||||
|
||||
# Read and parse all the arguments
|
||||
|
@ -83,7 +85,7 @@ else
|
|||
# Initialize the index of getopts
|
||||
OPTIND=1
|
||||
# Parse with getopts only if the argument begin by -
|
||||
getopts ":b:fihly" parameter || true
|
||||
getopts ":b:fihlyr" parameter || true
|
||||
case $parameter in
|
||||
b)
|
||||
# --branch=branch-name
|
||||
|
@ -115,6 +117,11 @@ else
|
|||
bash_mode=1
|
||||
shift_value=1
|
||||
;;
|
||||
r)
|
||||
# --show-resources
|
||||
show_resources=1
|
||||
shift_value=1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid argument: -${OPTARG:-}"
|
||||
notice=1
|
||||
|
@ -166,6 +173,8 @@ package_check.sh [OPTION]... PACKAGE_TO_CHECK
|
|||
Install LXC and build the container if necessary.
|
||||
-y, --bash-mode
|
||||
Do not ask for continue check. Ignore auto_remove.
|
||||
-r, --show-resources
|
||||
Show the unavailable resources when accessing the url.
|
||||
EOF
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -356,64 +356,67 @@ CHECK_URL () {
|
|||
lynx -dump -force_html "$script_dir/url_output" | head --lines 20 | tee --append "$test_result"
|
||||
echo -e "\e[0m"
|
||||
|
||||
# Get all the resources for the main page of the app.
|
||||
local HTTP_return
|
||||
local moved=0
|
||||
local ignored=0
|
||||
while read HTTP_return
|
||||
do
|
||||
# Ignore robots.txt and ynhpanel.js. They always redirect to the portal.
|
||||
if echo "$HTTP_return" | grep --quiet "$check_domain/robots.txt\|$check_domain/ynhpanel.js"; then
|
||||
ECHO_FORMAT "Ressource ignored:" "white"
|
||||
ECHO_FORMAT " ${HTTP_return##*http*://}\n"
|
||||
ignored=1
|
||||
fi
|
||||
if [ $show_resources -eq 1 ]
|
||||
then
|
||||
# Get all the resources for the main page of the app.
|
||||
local HTTP_return
|
||||
local moved=0
|
||||
local ignored=0
|
||||
while read HTTP_return
|
||||
do
|
||||
# Ignore robots.txt and ynhpanel.js. They always redirect to the portal.
|
||||
if echo "$HTTP_return" | grep --quiet "$check_domain/robots.txt\|$check_domain/ynhpanel.js"; then
|
||||
ECHO_FORMAT "Ressource ignored:" "white"
|
||||
ECHO_FORMAT " ${HTTP_return##*http*://}\n"
|
||||
ignored=1
|
||||
fi
|
||||
|
||||
# If it's the line with the resource to get
|
||||
if echo "$HTTP_return" | grep --quiet "^--.*-- http"
|
||||
then
|
||||
# Get only the resource itself.
|
||||
local resource=${HTTP_return##*http*://}
|
||||
# If it's the line with the resource to get
|
||||
if echo "$HTTP_return" | grep --quiet "^--.*-- http"
|
||||
then
|
||||
# Get only the resource itself.
|
||||
local resource=${HTTP_return##*http*://}
|
||||
|
||||
# Else, if would be the HTTP return code.
|
||||
else
|
||||
# If the return code is different than 200.
|
||||
if ! echo "$HTTP_return" | grep --quiet "200 OK$"
|
||||
then
|
||||
# Skipped the check of ignored ressources.
|
||||
if [ $ignored -eq 1 ]
|
||||
then
|
||||
ignored=0
|
||||
continue
|
||||
fi
|
||||
# Isolate the http return code.
|
||||
http_code="${HTTP_return##*awaiting response... }"
|
||||
http_code="${http_code:0:3}"
|
||||
# If the return code is 301 or 302, let's check the redirection.
|
||||
if echo "$HTTP_return" | grep --quiet "30[12] Moved"
|
||||
then
|
||||
ECHO_FORMAT "Ressource moved:" "white"
|
||||
ECHO_FORMAT " $resource\n"
|
||||
moved=1
|
||||
else
|
||||
ECHO_FORMAT "Resource unreachable (Code $http_code)" "red" "bold"
|
||||
ECHO_FORMAT " $resource\n"
|
||||
# curl_error=1
|
||||
moved=0
|
||||
fi
|
||||
else
|
||||
if [ $moved -eq 1 ]
|
||||
then
|
||||
if echo "$resource" | grep --quiet "/yunohost/sso/"
|
||||
then
|
||||
ECHO_FORMAT "The previous resource is redirected to the YunoHost portal\n" "red"
|
||||
# curl_error=1
|
||||
fi
|
||||
fi
|
||||
moved=0
|
||||
fi
|
||||
fi
|
||||
done <<< "$(cd "$package_path"; LC_ALL=C wget --adjust-extension --page-requisites --no-check-certificate $check_domain$curl_check_path 2>&1 | grep "^--.*-- http\|^HTTP request sent")"
|
||||
# Else, if would be the HTTP return code.
|
||||
else
|
||||
# If the return code is different than 200.
|
||||
if ! echo "$HTTP_return" | grep --quiet "200 OK$"
|
||||
then
|
||||
# Skipped the check of ignored ressources.
|
||||
if [ $ignored -eq 1 ]
|
||||
then
|
||||
ignored=0
|
||||
continue
|
||||
fi
|
||||
# Isolate the http return code.
|
||||
http_code="${HTTP_return##*awaiting response... }"
|
||||
http_code="${http_code:0:3}"
|
||||
# If the return code is 301 or 302, let's check the redirection.
|
||||
if echo "$HTTP_return" | grep --quiet "30[12] Moved"
|
||||
then
|
||||
ECHO_FORMAT "Ressource moved:" "white"
|
||||
ECHO_FORMAT " $resource\n"
|
||||
moved=1
|
||||
else
|
||||
ECHO_FORMAT "Resource unreachable (Code $http_code)" "red" "bold"
|
||||
ECHO_FORMAT " $resource\n"
|
||||
# curl_error=1
|
||||
moved=0
|
||||
fi
|
||||
else
|
||||
if [ $moved -eq 1 ]
|
||||
then
|
||||
if echo "$resource" | grep --quiet "/yunohost/sso/"
|
||||
then
|
||||
ECHO_FORMAT "The previous resource is redirected to the YunoHost portal\n" "red"
|
||||
# curl_error=1
|
||||
fi
|
||||
fi
|
||||
moved=0
|
||||
fi
|
||||
fi
|
||||
done <<< "$(cd "$package_path"; LC_ALL=C wget --adjust-extension --page-requisites --no-check-certificate $check_domain$curl_check_path 2>&1 | grep "^--.*-- http\|^HTTP request sent")"
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue