-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.sh
executable file
·56 lines (42 loc) · 1017 Bytes
/
check.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
52
53
54
55
#!/bin/sh
# Parse Command Line Arguments
while [ $# -gt 0 ]; do
case "$1" in
--uri=*)
domain="${1#*=}"
;;
--help)
print_help
;;
*)
printf "Invalid argument, run --help for valid arguments.\n";
exit 1
esac
shift
done
# Help menu
print_help() {
cat <<-HELP
Check a domain with curl to see if redirects are working as expected. More reliable than using a browser because of the lack of caching in curl.
Flags
--domain the short (no protocol) domain to test
HELP
exit 0
}
command_exists () {
type "$1" > /dev/null 2>&1;
}
if command_exists curl; then
printf "Checking: $domain\n"
curl -I $domain
printf "Checking: http://$domain\n"
curl -I http://$domain
printf "Checking: http://www.$domain\n"
curl -I http://www.$domain
printf "Checking: https://www.$domain\n"
curl -I https://www.$domain
printf "Checking: https://$domain\n"
curl -I https://$domain
else
printf "curl is required for this script to function, install from your package manager first"
fi