Set forum settings either before or after install

(SnipersCode) #1

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?

(Sam Saffron) #2

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

rails run 'SiteSetting.SomeSetting = "value"'

(SnipersCode) #3

Cool. Just for completeness sake, I assume I can use the setting names found here: discourse/site_settings.yml at master · discourse/discourse · GitHub (main), discourse-oauth2-basic/settings.yml at master · discourse/discourse-oauth2-basic · GitHub (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.

(Brett Bendickson) #4

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.