|
@@ -0,0 +1,37 @@
|
|
1
|
+#!/bin/bash
|
|
2
|
+
|
|
3
|
+#shellcheck disable=SC1090
|
|
4
|
+. "$(sfpath)" || exit 3
|
|
5
|
+
|
|
6
|
+shellfu import pretty
|
|
7
|
+
|
|
8
|
+PRETTY_DEBUG=${PRETTY_DEBUG:-true}
|
|
9
|
+
|
|
10
|
+usage() {
|
|
11
|
+ mkusage "$@" "URL" \
|
|
12
|
+ -- \
|
|
13
|
+ "Show errors seen when connecting to URL." \
|
|
14
|
+ "" \
|
|
15
|
+ "Content is ignored, and instead just errors are printed to stdout" \
|
|
16
|
+ "so that they can be used in notifications, etc. Errors collected" \
|
|
17
|
+ "include socket errors, TLS/SSL errors and HTTP errors (eg. 404)." \
|
|
18
|
+ "" \
|
|
19
|
+ "Exit status is zero if there WERE errors, one if there were none," \
|
|
20
|
+ "two if this script was used incorrectly and three and more in case"\
|
|
21
|
+ "of other failure circumstances."
|
|
22
|
+}
|
|
23
|
+
|
|
24
|
+main() {
|
|
25
|
+ local HtUrl
|
|
26
|
+ while true; do case $1 in
|
|
27
|
+ -*) usage -w "unknown argument: $1" ;;
|
|
28
|
+ *) break ;;
|
|
29
|
+ esac done
|
|
30
|
+ HtUrl=$1
|
|
31
|
+ test -n "$HtUrl" || usage -w "no URL?"
|
|
32
|
+ curl -fLs "$HtUrl" >/dev/null \
|
|
33
|
+ || echo "URL failed, error status: $?" \
|
|
34
|
+ || grep .
|
|
35
|
+}
|
|
36
|
+
|
|
37
|
+main "$@"
|