generate-secrets: Refactor to make development/production explicit.

generate-secrets.py now requires --development for development environment
setup or --production for production environment setup (and one of these
options is mandatory).

This solves the problem that it was somewhat easy to accidentally run
generate-secrets.py without the `-d` option while doing manual development
environment setup.

Fixes: #1911.
This commit is contained in:
Diptanshu8 2016-10-05 09:13:19 +00:00 committed by Tim Abbott
parent 01324f2afe
commit d7253b144c
3 changed files with 9 additions and 9 deletions

View File

@ -65,7 +65,7 @@ if [ "$has_nginx" = 0 ]; then
fi fi
if [ "$has_appserver" = 0 ]; then if [ "$has_appserver" = 0 ]; then
/root/zulip/scripts/setup/generate_secrets.py /root/zulip/scripts/setup/generate_secrets.py --production
cp -a /root/zulip/zproject/prod_settings_template.py /etc/zulip/settings.py cp -a /root/zulip/zproject/prod_settings_template.py /etc/zulip/settings.py
ln -nsf /etc/zulip/settings.py /root/zulip/zproject/prod_settings.py ln -nsf /etc/zulip/settings.py /root/zulip/zproject/prod_settings.py
fi fi

View File

@ -15,7 +15,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings'
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from six import text_type from six import text_type
import six import six
import argparse
from zerver.lib.str_utils import force_str from zerver.lib.str_utils import force_str
from zerver.lib.utils import generate_random_token from zerver.lib.utils import generate_random_token
@ -96,10 +96,10 @@ def generate_secrets(development=False):
if __name__ == '__main__': if __name__ == '__main__':
development = False parser = argparse.ArgumentParser()
extra_args = sys.argv[1:] group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--development', action='store_true', dest='development', help='For setting up the developer env for zulip')
group.add_argument('--production', action='store_false', dest='development', help='For setting up the production env for zulip')
results = parser.parse_args()
if len(extra_args) and extra_args[0] in ('-d', '--development'): generate_secrets(results.development)
development = True
generate_secrets(development)

View File

@ -184,7 +184,7 @@ def main():
run(["tools/setup/install-phantomjs"]) run(["tools/setup/install-phantomjs"])
run(["tools/setup/download-zxcvbn"]) run(["tools/setup/download-zxcvbn"])
run(["tools/setup/emoji_dump/build_emoji"]) run(["tools/setup/emoji_dump/build_emoji"])
run(["scripts/setup/generate_secrets.py", "-d"]) run(["scripts/setup/generate_secrets.py", "--development"])
if TRAVIS and not PRODUCTION_TRAVIS: if TRAVIS and not PRODUCTION_TRAVIS:
run(["sudo", "service", "rabbitmq-server", "restart"]) run(["sudo", "service", "rabbitmq-server", "restart"])
run(["sudo", "service", "redis-server", "restart"]) run(["sudo", "service", "redis-server", "restart"])