Set forum settings either before or after install

Background: I’m currently creating a solution that automatically deploys the nginx, uwsgi, flask, and discourse containers using docker-compose. My flask application has an oauth2 endpoint that discourse uses (using the discourse-oauth2-basic plugin) to authenticate users.

Question: Is there a way to automatically update settings pre/post install such as custom plugin settings like “oauth2 user id path”, default settings like “login required”, or creating/setting an api?

You can introduce a hook after you are done installing that calls rails run and sets the settings

rails run 'SiteSetting.SomeSetting = "value"'
2 Likes

Cool. Just for completeness sake, I assume I can use the setting names found here: https://github.com/discourse/discourse/blob/master/config/site_settings.yml (main), https://github.com/discourse/discourse-oauth2-basic/blob/master/config/settings.yml (plugin) and put the hook in the yaml used to bootstrap discourse.

I assume it would also be valid to add
- exec: rails r "SiteSetting.SomeSetting='value'"
to the yaml under “run:” as well? Or should this run in the after_code or after_bundle_exec hooks? I can’t seem to find documentation or the file that shows the valid hooks.

1 Like

Did you have any success with this? I just restored a backup to another server and was effectively locked out due to the oauth2 hostname checking. I logged into the app and postgres directly to alter the setting, but being able to set it in the yaml would be much more appealing.