diff --git a/construct/construct.cc b/construct/construct.cc index 3fdf95a24..3d5fb28e8 100644 --- a/construct/construct.cc +++ b/construct/construct.cc @@ -38,6 +38,7 @@ bool write_avoid; bool soft_assert; bool nomatrix; bool matrix {true}; // matrix server by default. +bool defaults; std::vector execute; std::array smoketest; @@ -68,6 +69,7 @@ lgetopt opts[] { "sassert", &soft_assert, lgetopt::BOOL, "Softens assertion effects in debug mode."}, { "nomatrix", &nomatrix, lgetopt::BOOL, "Prevent loading the matrix application module."}, { "matrix", &matrix, lgetopt::BOOL, "Allow loading the matrix application module."}, + { "defaults", &defaults, lgetopt::BOOL, "Use configuration defaults without database load for this execution."}, { nullptr, nullptr, lgetopt::STRING, nullptr }, }; @@ -455,6 +457,9 @@ applyargs() cmdline = true; } + if(defaults) + ircd::defaults.set("true"); + if(read_only) ircd::read_only.set("true"); diff --git a/doc/TROUBLESHOOTING.md b/doc/TROUBLESHOOTING.md index e7e13f93c..8781ac041 100644 --- a/doc/TROUBLESHOOTING.md +++ b/doc/TROUBLESHOOTING.md @@ -27,6 +27,13 @@ this simply replace the '.' characters with '_' in the name of the item when setting it in the environment. The name is otherwise the same, including its lower case. +Otherwise, the program can be run with the option `-defaults`. This will +prevent initial loading of the configuration from the database. It will +not prevent environmental variable overrides (as mentioned above). Values +will not be written back to the database unless they are explicitly set by +the user in the console. + + ##### Recovering from database corruption In very rare cases after a hard crash the journal cannot completely restore diff --git a/include/ircd/ircd.h b/include/ircd/ircd.h index c42a2cad1..5bbeeeb13 100644 --- a/include/ircd/ircd.h +++ b/include/ircd/ircd.h @@ -111,6 +111,7 @@ namespace ircd extern conf::item read_only; extern conf::item write_avoid; extern conf::item soft_assert; + extern conf::item defaults; // Informational seconds uptime(); diff --git a/ircd/conf.cc b/ircd/conf.cc index fda84bfc8..161225ef9 100644 --- a/ircd/conf.cc +++ b/ircd/conf.cc @@ -16,6 +16,14 @@ decltype(ircd::conf::on_init) ircd::conf::on_init {}; +decltype(ircd::defaults) +ircd::defaults +{ + { "name", "ircd.defaults" }, + { "default", false }, + { "persist", false }, +}; + size_t ircd::conf::reset() { diff --git a/matrix/homeserver.cc b/matrix/homeserver.cc index 40598008d..49f44dfae 100644 --- a/matrix/homeserver.cc +++ b/matrix/homeserver.cc @@ -256,7 +256,7 @@ ircd::m::homeserver::homeserver(const struct opts *const &opts) if(primary == this) vm = std::make_shared(); - if(primary == this && conf) + if(primary == this && conf && !ircd::defaults) conf->load(); if(primary == this && dbs::events && sequence(*dbs::events) == 0)