scripts/check-uninsane: implement --verbose flag
This commit is contained in:
parent
7d6a420c52
commit
6f0a455d0b
|
@ -8,12 +8,40 @@ echo ""
|
||||||
OVPNS_IPV4=185.157.162.178
|
OVPNS_IPV4=185.157.162.178
|
||||||
DOOF_IPV4=205.201.63.12
|
DOOF_IPV4=205.201.63.12
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: check-uninsane [flags ...]"
|
||||||
|
echo "flags:"
|
||||||
|
echo "- --verbose: show commands before running them"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
verbose=
|
||||||
|
parseArgs() {
|
||||||
|
while [ "$#" -ne 0 ]; do
|
||||||
|
local arg=$1
|
||||||
|
shift
|
||||||
|
case $arg in
|
||||||
|
(--verbose)
|
||||||
|
verbose=1
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
last_error=0
|
last_error=0
|
||||||
check() {
|
check() {
|
||||||
local label=$1
|
local label=$1
|
||||||
shift
|
shift
|
||||||
printf "checking %s\n" "$label"
|
if [ -n "$verbose" ]; then
|
||||||
"$@" > /dev/null
|
printf "checking %s (%s) \n" "$label" "$*"
|
||||||
|
"$@"
|
||||||
|
else
|
||||||
|
printf "checking %s\n" "$label"
|
||||||
|
"$@" > /dev/null
|
||||||
|
fi
|
||||||
local rc=$?
|
local rc=$?
|
||||||
if [ $rc -ne 0 ]; then
|
if [ $rc -ne 0 ]; then
|
||||||
last_error=$rc
|
last_error=$rc
|
||||||
|
@ -41,6 +69,7 @@ if [ $last_error -eq 0 ]; then
|
||||||
fi
|
fi
|
||||||
last_error=0
|
last_error=0
|
||||||
|
|
||||||
|
parseArgs "$@"
|
||||||
|
|
||||||
check "uninsane.org. DNS" nslookup uninsane.org.
|
check "uninsane.org. DNS" nslookup uninsane.org.
|
||||||
check "[1.1.1.1] uninsane.org. DNS" nslookup uninsane.org. 1.1.1.1
|
check "[1.1.1.1] uninsane.org. DNS" nslookup uninsane.org. 1.1.1.1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user