Closed mudrd8mz closed 9 years ago
+1 for this, i'm keen for it too.
Have discussed something similar with Fred in the past (probably putting $CFG->debug in confg.php) and he didn't like it (I am not doing his argument justice) because its not something you'd get in an out of the box Moodle install and he didn't want MDK to do magic. So interested to see what he makes of this option.
I asked Fred for his opinion too and he suggested to put such things into my own post-install.sh script. I would be happy with that if and only if there was a file that is automatically run after installation (so that I don't need to remember to execute it manually).
Right now, my ~/.moodle-sdk/config.json
contains a section like
"forceCfg": {
"debug": 32767,
"debugdisplay": 1,
"divertallemailsto": "root@localhost.local"
}
and it seems to work pretty well. I had this covered in my pre-mdk setup so I was missing this behaviour.
Ah, found the issue: #21
As much as I can I am trying to keep Moodle instances intact unless the developer requests for it.
I think that explicitly added mdk-config setting is clean sign that the developer requested it :-)
What I tried to explain what that I was trying to keep Moodle as clean as possible upon creation. For instance, when you have to test a clean installation, it is more annoying to remember that you have to undo something than remembering doing it, IMHO.
While defining the config values in the config file can meet your expectations, I can already think in the future that you would like the dev script to run by default, or running another custom one to create courses after successful install, etc... and so I think that the default config are not enough.
How would you guys feel about hooks? We could start creating hooks, that would have to be added to the scripts folder, and in which you can define any logic you want, including adding default config values. The win here is that you can do whatever you like, as you have access to MDK from the hook script, for instance _postinstall.sh.
The hooks would have to be defined one by one, but that one seems a good start.
I agree that hooks would be more robust solution. I would suggest to keep them in a dedicated folder so it's explicit that they are called as hooks (automatically). Something like scripts/hooks/ maybe.
You might also want to run them manually at times. It's the same to me really. But if they cannot be run by mdk run
then another folder called hooks
might be more appropriate.
Thanks for the patch David, I reconsidered this and found that it is probably the easiest option for those who want it. The important bit is that this setting should not contain anything by default. I have added 508d552 to document it in config-dist, all the config should be in there with a default value, even empty.
Cheers! Fred
:revolving_hearts:
There are some additional $CFG variables that the mdk user may want to always set in all config.php created. In my case, it is $CFG->divertallemailsto to prevent accidental mails sent out from my local installations.
The patch adds support for the new mdk-config items grouped under
forceCfg
. If the setting forceCfg.foobar is found, it's value will be put into $CFG->foobar right after the installation process.