From fb78db54065358b6fccc65452a6368fc13825571 Mon Sep 17 00:00:00 2001 From: davidnewhall2 Date: Thu, 2 Jan 2020 15:24:49 -0800 Subject: [PATCH] fixes --- dashboards.sh | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/dashboards.sh b/dashboards.sh index 8f453b8..164cb97 100755 --- a/dashboards.sh +++ b/dashboards.sh @@ -25,19 +25,26 @@ DASHMAP[10418]="UniFi-Poller_ Client Insights - InfluxDB.json" DASHMAP[11310]="UniFi-Poller_ Client DPI - Prometheus.json" DASHMAP[10419]="UniFi-Poller_ Client DPI - InfluxDB.json" +SAVEIFS=$IFS +# unobtainium +IFS=$(echo -en "\n\b") # Simple function to make sure no stray files got uploaded. function check { echo -n "Checking dashboards in: " pushd "${WHERE}" - SAVEIFS=$IFS - # unobtainium - IFS=$(echo -en "\n\b") for file in *; do found=0 [ "$file" != "README.md" ] || continue + isChanged "${WHERE}${DASHMAP[$i]}" + if [ "$?" = "1" ]; then + echo "Not changed: ${WHERE}${DASHMAP[$i]}" + else + echo "Changed: ${WHERE}${DASHMAP[$i]}" + fi + # Check for this file's existence in the DASHMAP variable. for i in ${!DASHMAP[@]}; do if [ "${DASHMAP[$i]}" = "$file" ]; then @@ -48,7 +55,6 @@ function check { done if [ "$found" = "0" ]; then - IFS=$SAVEIFS echo "uh oh. file not found in DASHMAP: $file" popd >> /dev/null exit 2 @@ -56,7 +62,6 @@ function check { done popd >> /dev/null - IFS=$SAVEIFS } # Simple function to make sure no expected files are missing. @@ -66,10 +71,6 @@ function check2 { files=$(ls) popd >> /dev/null - SAVEIFS=$IFS - # unobtainium - IFS=$(echo -en "\n\b") - for i in ${!DASHMAP[@]}; do found=0 @@ -82,22 +83,16 @@ function check2 { done if [ "$found" = "0" ]; then - IFS=$SAVEIFS echo "uh oh. configured DASHMAP file missing: ${DASHMAP[$i]}" exit 2 fi done - - IFS=$SAVEIFS } function isChanged { local changed=false local filename=$1 - SAVEIFS=$IFS - # unobtainium - IFS=$(echo -en "\n\b") for file in $CHANGES; do if [ "$file" = "$filename" ]; then changed=true