aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/rspamadm
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-22 15:29:12 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-22 15:29:12 +0000
commit0501e88b535dea34c093aea4c63e04cc4a148c18 (patch)
tree76b9d744089411395f4192dba513a98dde59db74 /lualib/rspamadm
parent232f42e120181033518d4e04445687407dcea161 (diff)
downloadrspamd-0501e88b535dea34c093aea4c63e04cc4a148c18.tar.gz
rspamd-0501e88b535dea34c093aea4c63e04cc4a148c18.zip
[Minor] Add modules to configwizard
Diffstat (limited to 'lualib/rspamadm')
-rw-r--r--lualib/rspamadm/configwizard.lua85
1 files changed, 69 insertions, 16 deletions
diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua
index 4b144b441..278202ffd 100644
--- a/lualib/rspamadm/configwizard.lua
+++ b/lualib/rspamadm/configwizard.lua
@@ -33,7 +33,8 @@ local rspamd_logo = [[
]]
local function printf(fmt, ...)
- print(string.format(fmt, ...))
+ io.write(string.format(fmt, ...))
+ io.write('\n')
end
local function highlight(str)
@@ -279,32 +280,84 @@ local function find_worker(cfg, wtype)
return nil
end
+
+
return function(args, cfg)
local changes = {
l = {}, -- local changes
o = {}, -- override changes
}
+ local interactive_start = true
+ local checks = {}
+ local all_checks = {
+ 'controller',
+ 'redis',
+ 'dkim',
+ 'statistic',
+ }
+
+ if #args > 0 then
+ interactive_start = false
+
+ for _,arg in ipairs(args) do
+ if arg == 'all' then
+ checks = all_checks
+ elseif arg == 'list' then
+ printf(highlight(rspamd_logo))
+ printf('Available modules')
+ for _,c in ipairs(all_checks) do
+ printf('- %s', c)
+ end
+ return
+ else
+ table.insert(checks, arg)
+ end
+ end
+ else
+ checks = all_checks
+ end
+
+ local function has_check(check)
+ for _,c in ipairs(checks) do
+ if c == check then
+ return true
+ end
+ end
+
+ return false
+ end
+
rspamd_util.umask('022')
- printf(highlight(rspamd_logo))
- printf("Welcome to the configuration tool")
- printf("We use %s configuration file, writing results to %s",
- highlight(cfg.config_path), highlight(local_conf))
- plugins_stat(nil, nil)
- if ask_yes_no("Do you wish to continue?", true) then
-
- local controller = find_worker(cfg, 'controller')
- if controller then
- setup_controller(controller, changes)
+ if interactive_start then
+ printf(highlight(rspamd_logo))
+ printf("Welcome to the configuration tool")
+ printf("We use %s configuration file, writing results to %s",
+ highlight(cfg.config_path), highlight(local_conf))
+ plugins_stat(nil, nil)
+ end
+
+ if not interactive_start or
+ ask_yes_no("Do you wish to continue?", true) then
+
+ if has_check('controller') then
+ local controller = find_worker(cfg, 'controller')
+ if controller then
+ setup_controller(controller, changes)
+ end
end
- if not cfg.redis or (not cfg.redis.servers and not cfg.redis.read_servers) then
- setup_redis(cfg, changes)
+ if has_check('redis') then
+ if not cfg.redis or (not cfg.redis.servers and not cfg.redis.read_servers) then
+ setup_redis(cfg, changes)
+ end
end
- if cfg.dkim_signing and not cfg.dkim_signing.domain then
- if ask_yes_no('Do you want to setup dkim signing feature?') then
- setup_dkim_signing(cfg, changes)
+ if has_check('dkim') then
+ if cfg.dkim_signing and not cfg.dkim_signing.domain then
+ if ask_yes_no('Do you want to setup dkim signing feature?') then
+ setup_dkim_signing(cfg, changes)
+ end
end
end