@@ -0,0 +1,2179 @@
+#!/usr/bin/env python%0A# This tools generates local_settings_generated.py using the template%0A%0Aimport sys, os, os.path%0A%0Asys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))%0Aos.environ%5B'DJANGO_SETTINGS_MODULE'%5D = 'zproject.settings'%0A%0Afrom django.utils.crypto import get_random_string%0Afrom zerver.lib.utils import generate_random_token%0A%0ASETTINGS_FILENAME = %22zproject/local_settings_template.py%22%0AOUTPUT_SETTINGS_FILENAME = %22zproject/local_settings_generated.py%22%0ACAMO_CONFIG_FILENAME = '/etc/defaults/camo'%0A%0Aif not os.path.exists(SETTINGS_FILENAME):%0A    print %22Unable to find settings file at %25s%22 %25 (SETTINGS_FILENAME,)%0A%0AAUTOGENERATED_SETTINGS = %5B'SHARED_SECRET', 'HASH_SALT', 'AVATAR_SALT', 'RABBITMQ_PASSWORD'%5D%0A%0Adef generate_camo_config_file(camo_key):%0A    camo_config = %22%22%22ENABLED=yes%0APORT=9292%0ACAMO_KEY=%25s%0A%22%22%22 %25 (camo_key,)%0A    with open(CAMO_CONFIG_FILENAME, 'w') as camo_file:%0A        camo_file.write(camo_config)%0A    print %22Generated Camo config file %25s%22 %25 (CAMO_CONFIG_FILENAME,)%0A%0Adef generate_django_secretkey():%0A    # Secret key generation taken from Django's startproject.py%0A    chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%25%5E&*(-_=+)'%0A    return get_random_string(50, chars)%0A%0Aif __name__ == '__main__':%0A    f = open(SETTINGS_FILENAME, 'r')%0A    lines = f.readlines()%0A%0A    for idx, line in enumerate(lines):%0A        parts = %5Bpart.strip() for part in line.split('=')%5D%0A        if len(parts) != 2:%0A            continue%0A%0A        def config_line(var, value):%0A            return %22%25s = '%25s'%5Cn%22 %25 (var, value)%0A%0A        if parts%5B0%5D in AUTOGENERATED_SETTINGS:%0A            lines%5Bidx%5D = config_line(parts%5B0%5D, generate_random_token(64))%0A        elif parts%5B0%5D == 'SECRET_KEY':%0A            lines%5Bidx%5D = config_line(%22SECRET_KEY%22, generate_django_secretkey())%0A        elif parts%5B0%5D == 'CAMO_KEY':%0A            camo_key = get_random_string(64)%0A            lines%5Bidx%5D = config_line(parts%5B0%5D, camo_key)%0A            # Write the Camo config file directly%0A            generate_camo_config_file(camo_key)%0A%0A    out = open(OUTPUT_SETTINGS_FILENAME, 'w')%0A    out.write(%22%22.join(lines))%0A    out.close()%0A%0A    print %22Generated %25s with auto-generated secrets!%22 %25 (OUTPUT_SETTINGS_FILENAME,)%0A

Add a generate_localserver_secrets.py script that populates local_settings.py