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
|
||||
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
|
||||
check() {
|
||||
local label=$1
|
||||
shift
|
||||
printf "checking %s\n" "$label"
|
||||
"$@" > /dev/null
|
||||
if [ -n "$verbose" ]; then
|
||||
printf "checking %s (%s) \n" "$label" "$*"
|
||||
"$@"
|
||||
else
|
||||
printf "checking %s\n" "$label"
|
||||
"$@" > /dev/null
|
||||
fi
|
||||
local rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
last_error=$rc
|
||||
|
@ -41,6 +69,7 @@ if [ $last_error -eq 0 ]; then
|
|||
fi
|
||||
last_error=0
|
||||
|
||||
parseArgs "$@"
|
||||
|
||||
check "uninsane.org. DNS" nslookup uninsane.org.
|
||||
check "[1.1.1.1] uninsane.org. DNS" nslookup uninsane.org. 1.1.1.1
|
||||
|
|
Loading…
Reference in New Issue
Block a user