Fixups, added lowercase to ENV and a few minor quick options to napi

This commit is contained in:
2024-08-13 15:34:18 -04:00
parent 77c773b0dd
commit 323b639b23
3 changed files with 50 additions and 20 deletions
+6
View File
@@ -1,5 +1,7 @@
#!/bin/bash
[ "$1" = "set.txt" ] && . set.txt 2> /dev/null
varName="servicedesc"
varDefault=""
myDelim="[ :-]"
@@ -7,6 +9,7 @@ myField=""
myHost=""
myService=""
myContact=""
doLower=""
doUpper=""
doVerbose=""
doNCPA=""
@@ -26,6 +29,7 @@ Where:
field an awk-compatible field number (potentially to use with <delim>)
delim an awk-compatible field delimiter (defaults to space, dash, and colon)
-u Convert the output to uppercase
-l Convert the output to lowercase
suffix Take var result and use the it to get NAGIOS__[HOST|SERVICE|CONTACT]<result><suffix>
-v Be verbose (only for debugging)
-N Look for NAGIOS__HOSTNCPA<suffix> (defaults to TOKEN)
@@ -68,6 +72,7 @@ while [ -n "$1" ]; do
-C) myContact="$2"; shift 2;;
-N) doNCPA="true"; shift 1;;
-u) doUpper="true"; shift 1;;
-l) doLower="true"; shift 1;;
-v) doVerbose="true"; shift 1;;
*) shift 1;;
esac
@@ -99,6 +104,7 @@ varValue=`echo $varValue | sed -e "s/^[ \t]*//" -e "s/[ \t]*$//"`
do_debug "After processing varValue=$varValue"
[ -n "$doUpper" ] && varValue=`echo "$varValue" | tr "a-z" "A-Z"`
[ -n "$doLower" ] && varValue=`echo "$varValue" | tr "A-Z" "a-z"`
# Check for myHost
if [ -n "$myHost" ]; then