test-websites.sh 1.9 KB
Newer Older
Dmytro Bogatov's avatar
Dmytro Bogatov committed
1 2 3 4 5 6
#!/usr/bin/env bash 

set -e

shopt -s globstar

7
declare -A DOMAINS
Dmytro Bogatov's avatar
Dmytro Bogatov committed
8

Dmytro Bogatov's avatar
Dmytro Bogatov committed
9
# Value means expected code
10

Dmytro Bogatov's avatar
Dmytro Bogatov committed
11 12 13 14
SUCCESS="200"
PERMANENT_REDIRECT="301"
FOUND="302"
SERVICE_UNABAILBALE="503"
15

16
MAIN=("dbogatov.org" "dmytro.app" "bogatov.app" "bogatov.dev")
17

Dmytro Bogatov's avatar
Dmytro Bogatov committed
18
DOMAINS["__MAIN__"]=$SUCCESS
19
DOMAINS["status.__MAIN__"]=$SUCCESS
Dmytro Bogatov's avatar
Dmytro Bogatov committed
20 21 22 23 24 25
DOMAINS["blog.__MAIN__"]=$SUCCESS
DOMAINS["legacy.__MAIN__"]=$SUCCESS
DOMAINS["push.__MAIN__"]=$SUCCESS
DOMAINS["socialimps.__MAIN__"]=$SUCCESS
DOMAINS["mail.__MAIN__"]=$SUCCESS
DOMAINS["dns.__MAIN__"]=$SUCCESS
Dmytro Bogatov's avatar
Dmytro Bogatov committed
26 27
DOMAINS["ore.__MAIN__"]=$SUCCESS
DOMAINS["cloz.__MAIN__"]=$SUCCESS
28

29
# DOMAINS["dashboard.dbogatov.org"]=$FOUND
30

31 32
DOMAINS["netwatch.app"]=$SERVICE_UNABAILBALE

33 34
DOMAINS["status.dbogatov.org"]=$SUCCESS

Dmytro Bogatov's avatar
Dmytro Bogatov committed
35 36
DOMAINS["bogatov.kiev.ua"]=$SUCCESS
DOMAINS["blog.bogatov.kiev.ua"]=$SUCCESS
37

Dmytro Bogatov's avatar
Dmytro Bogatov committed
38 39
DOMAINS["visasupport.com.ua"]=$SUCCESS
DOMAINS["zima.visasupport.com.ua"]=$SUCCESS
40

Dmytro Bogatov's avatar
Dmytro Bogatov committed
41 42 43
DOMAINS["visasupport.kiev.ua"]=$SUCCESS
DOMAINS["eu.visasupport.kiev.ua"]=$SUCCESS
DOMAINS["lp.visasupport.kiev.ua"]=$SUCCESS
44

Dmytro Bogatov's avatar
Dmytro Bogatov committed
45
DOMAINS["darinagulley.com"]=$SUCCESS
46

Dmytro Bogatov's avatar
Dmytro Bogatov committed
47
DOMAINS["moon-travel.com.ua"]=$PERMANENT_REDIRECT
48

Dmytro Bogatov's avatar
Dmytro Bogatov committed
49
DOMAINS["nigmatullina.org"]=$SUCCESS
50

Dmytro Bogatov's avatar
Dmytro Bogatov committed
51
DOMAINS["photobarrat.com"]=$SUCCESS
52

Dmytro Bogatov's avatar
Dmytro Bogatov committed
53 54
DOMAINS["shevastream.com/home"]=$SUCCESS

55
# DOMAINS["travelus.com.ua"]=$SUCCESS
Dmytro Bogatov's avatar
Dmytro Bogatov committed
56 57 58 59 60 61 62 63

DOMAINS["veles-russia.com"]=$SUCCESS

DOMAINS["visajapan.com.ua"]=$SUCCESS

DOMAINS["vleskniga.com"]=$SUCCESS

PASSED=true
64 65

for domain in "${!DOMAINS[@]}" 
Dmytro Bogatov's avatar
Dmytro Bogatov committed
66
do
Dmytro Bogatov's avatar
Dmytro Bogatov committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80
	URLS=()

	if [[ $domain = *"__MAIN__"* ]]
	then
		for main in ${MAIN[@]}
		do
			URLS+=(${domain/__MAIN__/$main})
		done
	else
		URLS+=($domain)
	fi

	for url in ${URLS[@]}
	do
81
		code=$(curl -s -o /dev/null -I -w "%{http_code}" https://$url) || true
Dmytro Bogatov's avatar
Dmytro Bogatov committed
82 83 84 85 86 87 88 89 90 91 92

		if [ $code == "${DOMAINS[${domain}]}" ]
		then
			RESULT="PASS"
		else
			RESULT="FAIL"
			PASSED=false
		fi

		echo "$RESULT ($code) : $url"
	done
Dmytro Bogatov's avatar
Dmytro Bogatov committed
93 94
done

Dmytro Bogatov's avatar
Dmytro Bogatov committed
95 96 97 98 99 100 101 102 103 104
echo "Tests complete."

if [ $PASSED == true ]
then
	echo "All tests passed!"
	exit 0
else
	echo "Some tests failed..."
	exit 1
fi