# 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
# 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
# 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
# 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