From: Brian Flowers Date: Sun, 18 Sep 2016 21:58:08 +0000 (-0400) Subject: More bugfixes on recent additions X-Git-Url: http://git.slightlycyberpunk.com%2C%20git.slightlycyberpunk.com/git/?a=commitdiff_plain;h=20f671c3aa5cca0428260e13d7d374551caae11c;p=bdsm.git More bugfixes on recent additions --- diff --git a/bdsm.d/df.generic b/bdsm.d/df.generic index bf78a7c..45dc9c2 100755 --- a/bdsm.d/df.generic +++ b/bdsm.d/df.generic @@ -130,10 +130,13 @@ formatConfig() # SCRIPT START ############################################################################### +if [ ! -f /home/bdsm/.bsdm.conf.tmp ]; then + formatConfig +fi # Get a list of configured hosts -formatConfig -hosts=$(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1) +hosts=($(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1)) + if [ -z $1 ]; then help diff --git a/bdsm.d/sensors.generic b/bdsm.d/sensors.generic index 6007267..e3a0973 100755 --- a/bdsm.d/sensors.generic +++ b/bdsm.d/sensors.generic @@ -144,23 +144,22 @@ formatConfig() # SCRIPT START ############################################################################### +if [ ! -f /home/bdsm/.bsdm.conf.tmp ]; then + formatConfig +fi # Get a list of configured hosts -hosts=$(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1) +hosts=($(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1)) if [ -z $1 ]; then help elif [ $1 == "start" ]; then - formatConfig start elif [ $1 == "stop" ]; then - formatConfig stop elif [ $1 == "status" ]; then - formatConfig status elif [ $1 == "compatible" ]; then - formatConfig compatible elif [ $1 == "help" ]; then help diff --git a/bdsm.d/template.generic b/bdsm.d/template.generic index ffc0b03..4731fc7 100644 --- a/bdsm.d/template.generic +++ b/bdsm.d/template.generic @@ -89,17 +89,27 @@ compatible() # Check if this plugin is compatible with the given host } -# SCRIPT START +# UTILITY FUNCTIONS ############################################################################### -# Reformat config file to be more machine-readable -# Removes whitespace and adds semicolons after property values -cat /home/bdsm/bdsm.conf | sed "s/[[:space:]]//g" | tr '\n' ' ' | sed 's/}/}\ - /g' | sed 's/^;*//g' | sed 's/;\([{}]\)/\1/g' | sed 's/\([{}]\);/\1/g' \ +formatConfig() +{ + # Reformat config file to be more machine-readable + # Removes whitespace and adds semicolons after property values + cat /home/bdsm/bdsm.conf | tr '\n' ' ' | sed 's/}/}\ + /g' | sed 's/^;*//g' | sed "s/[[:space:]]//g"| \ + sed 's/;\([{}]\)/\1/g' | sed 's/\([{}]\);/\1/g' \ > /home/bdsm/.bdsm.conf.tmp - +} + +# SCRIPT START +############################################################################### +if [ ! -f /home/bdsm/.bsdm.conf.tmp ]; then + formatConfig +fi + # Get a list of configured hosts -hosts=$(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1) +hosts=($(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1)) if [ -z $1 ]; then help diff --git a/bdsm.d/vmstat.generic b/bdsm.d/vmstat.generic index d4ad1dd..c67d765 100755 --- a/bdsm.d/vmstat.generic +++ b/bdsm.d/vmstat.generic @@ -163,10 +163,12 @@ formatConfig() # SCRIPT START ############################################################################### +if [ ! -f /home/bdsm/.bsdm.conf.tmp ]; then + formatConfig +fi # Get a list of configured hosts -formatConfig -hosts=$(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1) +hosts=($(cat /home/bdsm/.bdsm.conf.tmp | cut -d'{' -f1)) if [ -z $1 ]; then help