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