mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-19 19:40:41 +01:00
For auto-generated configs, it is useful to have the ability to disable some config constructs even though they may be specified inside the config. This can now be done via the ```config.disable``` parameter, applicable to all script objects. If set to ```on``` or not specified, the construct will be used, if set to any other value, it will be ignored. This can be used together with the backtick functionality to configure enable and disable from either a file or environment variable. Example: Let's say we want to conditionally load a module. Environment variable ```LOAD_IMPTCP```will be either unset or ```off``` . Then we can use this config construct: ``` module(load="imptcp" config.enabled=`echo $LOAD_IMPTCP`) ``` It the variable is set to ```off```, the module will **not** be loaded. closes https://github.com/rsyslog/rsyslog/issues/2431
25 lines
825 B
Bash
Executable File
25 lines
825 B
Bash
Executable File
#!/bin/bash
|
|
# tests 'config.enabled="on"' -- default value is implicitely check
|
|
# in all testbench tests and does not need its individual test
|
|
# (actually it is here tested via template() and action() as well...
|
|
# added 2018-01-22 by Rainer Gerhards; Released under ASL 2.0
|
|
. $srcdir/diag.sh init
|
|
export DO_STOP=on
|
|
. $srcdir/diag.sh generate-conf
|
|
. $srcdir/diag.sh add-conf '
|
|
template(name="outfmt" type="string" string="%msg:F,58:2%\n")
|
|
|
|
if $msg contains "msgnum:" then {
|
|
if $msg contains "msgnum:00000000" then {
|
|
include(text="stop" config.enabled=`echo $DO_STOP`)
|
|
}
|
|
action(type="omfile" template="outfmt" file="rsyslog.out.log")
|
|
}
|
|
'
|
|
. $srcdir/diag.sh startup
|
|
. $srcdir/diag.sh injectmsg 0 10
|
|
. $srcdir/diag.sh shutdown-when-empty
|
|
. $srcdir/diag.sh wait-shutdown
|
|
. $srcdir/diag.sh seq-check 1 9
|
|
. $srcdir/diag.sh exit
|