From d8db457ced22b73cfe7bd84189e294f090153f36 Mon Sep 17 00:00:00 2001 From: Brian Flowers Date: Fri, 16 Sep 2016 13:45:12 -0400 Subject: [PATCH] Added compatibility checking --- bdsm.d/sensors.generic | 3 +++ bdsm.d/template.generic | 2 ++ bdsm.d/vmstat.generic | 3 +++ bdsm.sh | 22 +++++++++++++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/bdsm.d/sensors.generic b/bdsm.d/sensors.generic index d92d496..6007267 100755 --- a/bdsm.d/sensors.generic +++ b/bdsm.d/sensors.generic @@ -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 diff --git a/bdsm.d/template.generic b/bdsm.d/template.generic index abe8273..ffc0b03 100644 --- a/bdsm.d/template.generic +++ b/bdsm.d/template.generic @@ -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 diff --git a/bdsm.d/vmstat.generic b/bdsm.d/vmstat.generic index 6947ab4..e47df22 100755 --- a/bdsm.d/vmstat.generic +++ b/bdsm.d/vmstat.generic @@ -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 --- 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"` -- 1.8.3.1