Commandline non-interactive SiteSetting modification

I’m writing a migration script and I want to set the s3_upload_bucket site setting programmatically. I found a method to set it when inside the docker instance:

echo 'SiteSetting.s3_upload_bucket="mybucket"' | bundle exec rails c

But last contains a pipe so I chaining it with docker exec -it app <command> results in an error

There is a way to do this?

Thank you in advance

Just add that SiteSetting like to your importer. I’ve added similar code to disable outgoing mail to several importers. You can help grep the importer directory for "Site* for examples.

I found the solution!

echo "SiteSetting.sso_url='newurl'" | docker exec -w /var/www/discourse -i app bundle exec rails c

3 Likes

I’m not clear what kind of migration script you’re writing. I do then in ruby and it’s easy to change site settings there.

This is a great trick, though!

1 Like