* luci/app/statistics: fix syntax of collectd Exec plugin config
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 29 Oct 2008 01:12:49 +0000 (01:12 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 29 Oct 2008 01:12:49 +0000 (01:12 +0000)
applications/luci-statistics/root/usr/bin/stat-genconfig

index 7f0a05f5febdc8ae2c1bd22de7b6b3d5b05ed12c..b62005ce10e7bd3a54de2ff473b66f47f185fe43 100755 (executable)
@@ -94,11 +94,17 @@ function config_exec( c )
                for key, type in pairs({ Exec="collectd_exec_input", NotificationExec="collectd_exec_notify" }) do
                        if sections[s][".type"] == type then
 
-                               cmd   = sections[s].cmdline
-                               user  = sections[s].cmduser  or "nobody"
-                               group = sections[s].cmdgroup or "nogroup"
+                               cmd = sections[s].cmdline
 
-                               str = str .. "\t" .. key .. " " .. user .. ":" .. group .. ' "' .. cmd .. "\"\n"
+                if cmd then
+                    cmd   = cmd:gsub("^%s+", ""):gsub("%s+$", "")
+                    user  = sections[s].cmduser  or "nobody"
+                    group = sections[s].cmdgroup
+
+                    str = str .. "\t" .. key .. ' "' ..
+                        user .. ( group and ":" .. group or "" ) .. '" "' ..
+                        cmd:gsub('%s+', '" "') .. '"\n'
+                end
                        end
                end
        end