forked from offa/android-foss
/
check_manually.sh
executable file
·51 lines (43 loc) · 1.01 KB
/
check_manually.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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