Create check_manually.sh

This commit is contained in:
szaimen 2020-10-13 23:34:18 +02:00 committed by GitHub
commit 06b949afe4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

51
check_manually.sh Normal file
View file

@ -0,0 +1,51 @@
#!/bin/bash
SOURCE_FILE=README.md
LINKS=$(grep "http" "$SOURCE_FILE" \
| grep -oP "http.*" \
| sed "s|)$||" \
| sed "s|) .*||" \
| grep -v img.shields.io \
| grep -v travis-ci.org)
mapfile -t LINKS <<< "$LINKS"
for link in "${LINKS[@]}"
do
echo "Testing $link"
STATUS_CODE="$(curl -LI "$link" -o /dev/null -w '%{http_code}\n' -s)"
if [[ "$STATUS_CODE" != "200" ]]
then
FALSE_LINKS+=("$link")
fi
done
FDROID_LINKS=$(grep -oP "https://f-droid.*" "$SOURCE_FILE" \
| sed "s|)].*||" \
| grep -v "https://f-droid.org/)")
mapfile -t FDROID_LINKS <<< "$FDROID_LINKS"
for link in "${FDROID_LINKS[@]}"
do
echo "Testing $link"
STATUS_CODE="$(curl -LI "$link" -o /dev/null -w '%{http_code}\n' -s)"
if [[ "$STATUS_CODE" != "200" ]]
then
FALSE_LINKS+=("$link")
fi
done
if [ -n "${FALSE_LINKS[*]}" ]
then
clear
echo "Some links weren't reachable."
for link in "${FALSE_LINKS[@]}"
do
echo "$link"
done
exit 1
else
echo "No false link was found"
fi