Commandline non-interactive SiteSetting modification

(Ernesto Serrano) #1

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

(Jay Pfaffman) #2

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.

(Ernesto Serrano) #3

I found the solution!

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

(Jay Pfaffman) #4

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!