# 命令行非交互式 SiteSetting 修改

**URL:** https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050
**Category:** Migration
**Created:** [2018年一月15日 11:35 UTC](https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050 "2018-01-15T11:35:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![erseco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erseco/32/87424_2.png) [@erseco](https://meta.discourse.org/u/erseco)
#### Post date: [2018年一月15日 11:35 UTC](https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050/1 "2018-01-15T11:35:59Z")

</div>

我正在编写一个迁移脚本，想要通过编程方式设置 `s3_upload_bucket` 站点设置。我找到了一个在 Docker 实例内部设置它的方法：

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

但后者包含管道符，因此将其与 `docker exec -it app <command>` 链式使用时会导致错误。

有办法解决这个问题吗？

提前感谢。

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2018年一月15日 12:21 UTC](https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050/2 "2018-01-15T12:21:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![erseco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erseco/32/87424_2.png) [@erseco](https://meta.discourse.org/u/erseco)
#### Post date: [2018年一月15日 13:38 UTC](https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050/3 "2018-01-15T13:38:37Z")

</div>

I found the solution!

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2018年一月15日 13:46 UTC](https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050/4 "2018-01-15T13:46:45Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2020年四月3日 02:40 UTC](https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050/5 "2020-04-03T02:40:03Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2024年四月20日 17:16 UTC](https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050/6 "2024-04-20T17:16:50Z")

</div>



---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2024年四月20日 20:15 UTC](https://meta.discourse.org/t/commandline-non-interactive-sitesetting-modification/78050/7 "2024-04-20T20:15:04Z")

</div>


