There exists in moodle the cfg.php script which can get and set config values, and the replace.php script which can do a whole-database find and replace. However, these have limitations, so I ended up writing a new CLI script to which you pass a JSON file that defines a set of config changes to make. You can either define absolute values to set, or find/replace operations for each setting. Unfortunately, I don't think it's generic enough for me to share publicly right now.
Re: One-way configuration synchronization between production and development servers
by Mark Johnson -
Number of replies: 2
In reply to Mark Johnson
Re: One-way configuration synchronization between production and development servers
by Eric Phetteplace -
Interesting, I can see how that would work, you're using `php admin/cli/cfg.php --json` to get the JSON configuration object and then overriding certain properties? This seems better than a bunch of CLI processing and sed edits. I will look into it!
In reply to Eric Phetteplace
Re: One-way configuration synchronization between production and development servers
by Mark Johnson -
Not quite, we have a per-environment JSON file that looks something like this:
{
"config_values": [
{"name": "debug", "value": "32767"},
...
],
"config_plugin_values": [
{"plugin": "auth_saml2", "name": "logdir", "value": "/var/log/saml2/", "wherenot": ""},
...
],
"config_value_replacements": [
{"name": "example", "find": "Live", "replace": "Test"},
...
]
}
The script then uses each of those values or find/replace lines to construct a query that updates the config value in the database. If it includes a property like "wherenot" "wherelike" etc then the update is conditional based on the current value.