Added compatibility checking
authorBrian Flowers <git-admn@bsflowers.net>
Fri, 16 Sep 2016 17:45:12 +0000 (13:45 -0400)
committerBrian Flowers <git-admn@bsflowers.net>
Fri, 16 Sep 2016 17:45:12 +0000 (13:45 -0400)
bdsm.d/sensors.generic
bdsm.d/template.generic
bdsm.d/vmstat.generic
bdsm.sh

index d92d496..6007267 100755 (executable)
@@ -159,6 +159,9 @@ elif [ $1 == "stop" ]; then
 elif [ $1 == "status" ]; then
   formatConfig
   status
+elif [ $1 == "compatible" ]; then
+    formatConfig
+    compatible
 elif [ $1 == "help" ]; then
   help
 fi
index abe8273..ffc0b03 100644 (file)
@@ -109,6 +109,8 @@ elif [ $1 == "stop" ]; then
   stop
 elif [ $1 == "status" ]; then
   status
+elif [ $1 == "compatible" ]; then
+    compatible
 elif [ $1 == "help" ]; then
   help
 fi
index 6947ab4..e47df22 100755 (executable)
@@ -178,6 +178,9 @@ elif [ $1 == "stop" ]; then
 elif [ $1 == "status" ]; then
   formatConfig
   status
+elif [ $1 == "compatible" ]; then
+    formatConfig
+    compatible
 elif [ $1 == "help" ]; then
   help
 fi
diff --git a/bdsm.sh b/bdsm.sh
index 2528cf9..096f54b 100755 (executable)
--- a/bdsm.sh
+++ b/bdsm.sh
@@ -306,7 +306,27 @@ configure()
     done
     
     header "Configuring $host"
-    availServices=$(ls /home/bdsm/bdsm.d | cut -d'.' -f1 | sort -u)
+    # TODO:
+    # Make availServices a null array; pass this value to a loop
+    # Check compatibility, add compatible ones to the array
+    #availServices=$(ls /home/bdsm/bdsm.d | cut -d'.' -f1 | sort -u)
+    
+    availServices=()
+    ls /home/bdsm/bdsm.d | cut -d'.' -f1 | sort -u | while read service; do
+        svc=`echo $service | sed 's/(.*)$//g'`
+        if [ -f /home/bdsm/bdsm.d/$svc.$type ]; then
+          serviceFile="$svc.$type"
+        elif [ -f /home/bdsm/bdsm.d/$svc.generic ]; then
+          serviceFile="$svc.generic"
+        else
+          error "$service plugin not found!"
+        fi
+        
+        if [ "`/home/bdsm/bdsm.d/$serviceFile compatible`" -eq 1 ]; then
+            availServices+=($service)
+        fi
+    done
+    
     services=$(cat /home/bdsm/.bdsm.conf.tmp | grep ":$host{" | \
       sed 's/.*{\(.*\)}/\1/g' | tr ';' ' ')
     service=`selector "Select a service to configure" $services "Add a service..." "Done"`