9 if test -x /usr
/bin
/printf; then
16 echo "$1 v$2 (@PACKAGE@ @VERSION@)"
17 $ECHO "@WARRANTY@" |
sed -e 's/\n/ /g'
21 $ECHO "@SUPPORT@" |
sed -e 's/\n/ /g'
25 # check_range takes a value and a range string, returning successfully if an
26 # alert should be raised based on the range. Range values are inclusive.
27 # Values may be integers or floats.
31 # Generating an exit code of 1:
34 # Generating an exit code of 0:
38 local v range
yes no err decimal start end
cmp match
42 # whether to raise an alert or not
47 # regex to match a decimal number
48 decimal
="-?([0-9]+\.?[0-9]*|[0-9]*\.[0-9]+)"
50 # compare numbers (including decimals), returning true/false
51 cmp() { awk "BEGIN{ if ($1) exit(0); exit(1)}"; }
53 # returns successfully if the string in the first argument matches the
55 match
() { echo "$1" |
grep -E -q -- "$2"; }
57 # make sure value is valid
58 if ! match
"$v" "^$decimal$"; then
59 echo "${0##*/}: check_range: invalid value" >&2
64 # make sure range is valid
65 if ! match
"$range" "^@?(~|$decimal)(:($decimal)?)?$"; then
66 echo "${0##*/}: check_range: invalid range" >&2
71 # check for leading @ char, which negates the range
72 if match
$range '^@'; then
78 # parse the range string
79 if ! match
"$range" ':'; then
87 # do the comparison, taking positive ("") and negative infinity ("~")
89 if [ "$start" != "~" ] && [ "$end" != "" ]; then
90 if cmp "$start <= $v" && cmp "$v <= $end"; then
97 elif [ "$start" != "~" ] && [ "$end" = "" ]; then
98 if cmp "$start <= $v"; then
105 elif [ "$start" = "~" ] && [ "$end" != "" ]; then
106 if cmp "$v <= $end"; then