# Scripted setting of default\_trust\_level not working: results in "1" vs expected setting

**URL:** https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519
**Category:** Support
**Created:** [1 במאי,‏ 2016,‏ 6:46am UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519 "2016-05-01T06:46:20Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ckamps](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ckamps](https://meta.discourse.org/u/ckamps)
#### Post date: [1 במאי,‏ 2016,‏ 6:46am UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/1 "2016-05-01T06:46:20Z")

</div>

We script the installation of Discourse in support of a series of internal community sites in which we want all users to default to trust level 3. However, the following approach doesn’t work for the `default_trust_level` setting. We set many other site settings in this manner successfully including `default_invitee_trust_level`, but using this approach results in a “1” for the `default_trust_level`.

We’re on: v1.6.0.beta2 +102

```plaintext
    - exec:
        cmd:
          - su discourse -c 'RAILS_ENV=production /var/www/discourse/bin/rails r "SiteSetting.default_trust_level='"'3'"' "'
          - su discourse -c 'RAILS_ENV=production /var/www/discourse/bin/rails r "SiteSetting.default_invitee_trust_level='"'3'"' "'

```

Result:

 ![](https://global.discourse-cdn.com/meta/original/3X/5/2/527fab4ba604ce9c2eb4043fc6f22741b3113e19.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2 במאי,‏ 2016,‏ 3:50am UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/2 "2016-05-02T03:50:40Z")

</div>

This should work. perhaps

```plaintext
 - su discourse -c 'RAILS_ENV=production /var/www/discourse/bin/rails r "SiteSetting.default_trust_level=3"'

```

---

<div class="post-metadata">

### Author: ![ckamps](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ckamps](https://meta.discourse.org/u/ckamps)
#### Post date: [3 במאי,‏ 2016,‏ 5:36am UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/3 "2016-05-03T05:36:38Z")

</div>

> [@sam](#):
>
> - su discourse -c ‘RAILS\_ENV=production /var/www/discourse/bin/rails r “SiteSetting.default\_trust\_level=3”’

Thanks for the streamlining tip, but that wasn’t the cause of the issue. The default is still stuck at 1.

I was skeptical about the tip making a difference given that we have many other examples that are successfully using the overly verbose syntax. (Although the quoting is needed for strings that have spaces).

I might dig into the code to see if I can locate the cause of the issue.

 ![](https://global.discourse-cdn.com/meta/original/3X/a/1/a1697f8d5526cd462ea18091aeeb56cb9b9a36dd.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3 במאי,‏ 2016,‏ 6:56am UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/4 "2016-05-03T06:56:34Z")

</div>

Ahh perhaps this is the bootstrapping mode @techAPJ added?

Perhaps set: `bootstrap mode min users` to 0 as well.

@techAPJ bootstrap mode should not be amending any settings that are not in default state.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [4 במאי,‏ 2016,‏ 11:22am UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/5 "2016-05-04T11:22:13Z")

</div>

> [@sam](#):
>
> bootstrap mode should not be amending any settings that are not in default state.

Okay, fixed via:

[https://github.com/discourse/discourse/commit/9427e0c732195a5d74a54020b5c3b3259c6db10a](https://github.com/discourse/discourse/commit/9427e0c732195a5d74a54020b5c3b3259c6db10a)

---

<div class="post-metadata">

### Author: ![ckamps](https://avatars.discourse-cdn.com/v4/letter/c/e95f7d/32.png) [@ckamps](https://meta.discourse.org/u/ckamps)
#### Post date: [4 במאי,‏ 2016,‏ 2:27pm UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/6 "2016-05-04T14:27:20Z")

</div>

Awesome. That fixed the issue I originally reported.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [4 במאי,‏ 2016,‏ 2:29pm UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/7 "2016-05-04T14:29:24Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [4 במאי,‏ 2016,‏ 11:56pm UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/8 "2016-05-04T23:56:37Z")

</div>

Just to confirm, if someone sets it to 1, will it be reverted to 0 when bootstrap kicks out

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [5 במאי,‏ 2016,‏ 2:16am UTC](https://meta.discourse.org/t/scripted-setting-of-default-trust-level-not-working-results-in-1-vs-expected-setting/43519/9 "2016-05-05T02:16:14Z")

</div>

Yes, when the bootstrap kicks out it will change the setting back to default (0) _only if_ the value matches bootstrap setting value (1). Here is the relevant logic:

```plaintext
SiteSetting.set_and_log('default_trust_level', TrustLevel[0]) if SiteSetting.send('default_trust_level') == TrustLevel[1]
SiteSetting.set_and_log('default_email_digest_frequency', 10080) if SiteSetting.send('default_email_digest_frequency') == 1440        

```

If the user changed `default_trust_level` to `3` then it will not be reverted to original value.
