diff --git a/scripts/lib/install b/scripts/lib/install index 684200f17a..2e019a10a9 100755 --- a/scripts/lib/install +++ b/scripts/lib/install @@ -65,7 +65,7 @@ if [ "$has_nginx" = 0 ]; then fi 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 ln -nsf /etc/zulip/settings.py /root/zulip/zproject/prod_settings.py fi diff --git a/scripts/setup/generate_secrets.py b/scripts/setup/generate_secrets.py index 7d0b70777f..5cf448308b 100755 --- a/scripts/setup/generate_secrets.py +++ b/scripts/setup/generate_secrets.py @@ -15,7 +15,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.settings' from django.utils.crypto import get_random_string from six import text_type import six - +import argparse from zerver.lib.str_utils import force_str from zerver.lib.utils import generate_random_token @@ -96,10 +96,10 @@ def generate_secrets(development=False): if __name__ == '__main__': - development = False - extra_args = sys.argv[1:] + parser = argparse.ArgumentParser() + 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'): - development = True - - generate_secrets(development) + generate_secrets(results.development) diff --git a/tools/provision.py b/tools/provision.py index e05a403859..28b891e866 100755 --- a/tools/provision.py +++ b/tools/provision.py @@ -184,7 +184,7 @@ def main(): run(["tools/setup/install-phantomjs"]) run(["tools/setup/download-zxcvbn"]) 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: run(["sudo", "service", "rabbitmq-server", "restart"]) run(["sudo", "service", "redis-server", "restart"])