From 0501e88b535dea34c093aea4c63e04cc4a148c18 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 22 Feb 2018 15:29:12 +0000 Subject: [PATCH] [Minor] Add modules to configwizard --- lualib/rspamadm/configwizard.lua | 85 ++++++++++++++++++++++------ src/libstat/backends/redis_backend.c | 4 ++ 2 files changed, 73 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 diff --git a/src/libstat/backends/redis_backend.c b/src/libstat/backends/redis_backend.c index df631f722..f191dc974 100644 --- a/src/libstat/backends/redis_backend.c +++ b/src/libstat/backends/redis_backend.c @@ -1352,6 +1352,10 @@ rspamd_redis_parse_classifier_opts (struct redis_stat_ctx *backend, } else { backend->new_schema = FALSE; + + msg_warn_config ("you are using old bayes schema for redis statistics, " + "please consider converting it to a new one " + "by using 'rspamadm configwizard statistics'"); } elt = ucl_object_lookup (obj, "signatures"); -- 2.39.5