From 482de3157e128b98fd658ce1f10af0a3b532b7d4 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Fri, 12 Jun 2015 13:01:56 +0000 Subject: [PATCH] Fixed setupnginx command bug --- TODO.md | 4 ++-- orchestra/contrib/accounts/management/__init__.py | 2 +- orchestra/management/commands/setupnginx.py | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index f840e6f0..e1b7f242 100644 --- a/TODO.md +++ b/TODO.md @@ -427,6 +427,6 @@ serailzer self.instance on create. # IF modsecurity... and Merge websites locations -# backend email error log with links to instances -# PHP backend multiple FPM directories support +# backend email error log with link to backend log on admin +# ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/home/orchestra/panel/orchestra.log' diff --git a/orchestra/contrib/accounts/management/__init__.py b/orchestra/contrib/accounts/management/__init__.py index c77b34aa..c67e98e4 100644 --- a/orchestra/contrib/accounts/management/__init__.py +++ b/orchestra/contrib/accounts/management/__init__.py @@ -8,7 +8,7 @@ from django.db import models def create_initial_superuser(**kwargs): - if '--noinput' not in sys.argv and '--fake' not in sys.argv and '--fake-initial' not in sys.argv and 'accounts' in sys.argv: + if '--noinput' not in sys.argv and '--fake' not in sys.argv and '--fake-initial' not in sys.argv: model = get_user_model() if not model.objects.filter(is_superuser=True).exists(): sys.stdout.write(textwrap.dedent(""" diff --git a/orchestra/management/commands/setupnginx.py b/orchestra/management/commands/setupnginx.py index fd910614..0ade3e44 100644 --- a/orchestra/management/commands/setupnginx.py +++ b/orchestra/management/commands/setupnginx.py @@ -220,12 +220,13 @@ class Command(BaseCommand): 'conf': uwsgi_conf } + interactive = options.get('interactive') for extra_context in (nginx, uwsgi): context.update(extra_context) - diff = run("echo '%(conf)s' | diff - %(file)s" % context, valid_codes=(0,1,2)) + diff = run("cat << 'EOF' | diff - %(file)s\n%(conf)s\nEOF" % context, valid_codes=(0,1,2)) if diff.exit_code == 2: # File does not exist - run("echo '%(conf)s' > %(file)s" % context, display=True) + run("cat << 'EOF' > %(file)s\n%(conf)s\nEOF" % context, display=True) elif diff.exit_code == 1: # File is different, save the old one if interactive: @@ -240,7 +241,7 @@ class Command(BaseCommand): return break run("cp %(file)s %(file)s.save" % context, display=True) - run("echo '%(conf)s' > %(file)s" % context, display=True) + run("cat << 'EOF' > %(file)s\n%(conf)s\nEOF" % context, display=True) self.stdout.write("\033[1;31mA new version of %(file)s has been installed.\n " "The old version has been placed at %(file)s.save\033[m" % context)