### Description
I am trying to configure some "default" settings in Kamailio that would be independent of the configuration file. The command-line options `--loadmodule` and `--modparam` seemed to be exactly what I was looking for.
However, I noticed that these options are processed **before** the configuration file is loaded. As a result, the `--modparam` option cannot be used separately, because the module for the specified parameter has not yet been loaded:
``` # kamailio -E -DD --modparam=corex:alias_subdomains:s:kamailio.org 0(653) ERROR: <core> [core/modparam.c:199]: set_mod_param_regex(): No module matching <corex> found 0(653) ERROR: <core> [main.c:2584]: main(): failed to set modparam: corex:alias_subdomains:s:kamailio.org
``` To address this, the module needs to be loaded first using the `--loadmodule` option. However, this causes an error if the same module is also loaded in the configuration file:
``` # kamailio -E -DD --loadmodule=corex --modparam=corex:alias_subdomains:s:kamailio.org 0(654) WARNING: <core> [core/sr_module.c:611]: ksr_load_module(): attempting to load the same module twice (/usr/lib/x86_64-linux-gnu/kamailio/modules/corex.so) 0(654) CRITICAL: <core> [core/cfg.y:4014]: yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 283, column 12-21: failed to load module ```
### Possible Solutions
Would it be possible to move the processing of these command-line options **after** the configuration file is loaded? And could the `--loadmodule` option ignore loading a module if it has already been loaded via the configuration file?
Another potential solution could be introducing new options, such as `--loadmodule-after` and `--modparam-after`, to specify parameters that should only be applied once the configuration file has been loaded.
What do you think about these suggestions?
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.8.4 (x86_64/linux) ```
* **Operating System**:
``` Linux 010a217cd09a 6.12.10-orbstack-00297-gf8f6e015b993 #42 SMP Sun Jan 19 03:00:07 UTC 2025 x86_64 GNU/Linux ```
These cli parameters were designed indeed to be used before loading the config, one of the aims was that the loaded modules could be useful for processing the input for config file.
When a module is loaded, a define is set for it, like `MOD_corex`, I haven't checked the code if it also done for the cli option, but you can try to add to your config:
``` #!ifndef MOD_corex loadmodule "corex.so" #!endif ```
You can leverage further `-A ...` to control what modparams are set in config.
For future, a variant would be to extend load module with a new option like `o` to skip loading if the module was already loaded.
* https://www.kamailio.org/wikidocs/cookbooks/devel/core/#loadmodule
miconda left a comment (kamailio/kamailio#4126)
I just added option `o` for `loadmodule`. Closing this one.
Closed #4126 as completed.