From 7c903a9da9a0ac9f298582c8843bd01b29fd2ea9 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 18:56:37 +0530 Subject: [PATCH 1/2] Removed more hardcoded values --- ee/cli/plugins/debug.py | 11 +++++++---- ee/cli/plugins/stack.py | 30 +++++++++++++---------------- ee/cli/templates/22222.mustache | 12 ++++++------ ee/cli/templates/vimbadmin.mustache | 4 ++-- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/ee/cli/plugins/debug.py b/ee/cli/plugins/debug.py index 4d346347..0e384246 100644 --- a/ee/cli/plugins/debug.py +++ b/ee/cli/plugins/debug.py @@ -279,8 +279,10 @@ class EEDebugController(CementBaseController): Log.info(self, "Starting WordPress debug") open("{0}/htdocs/wp-content/debug.log".format(webroot), 'a').close() - EEShellExec.cmd_exec(self, "chown www-data: {0}/htdocs/wp-" - "content/debug.log".format(webroot)) + EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-" + "content/debug.log" + "".format(webroot, + EEVariables.ee_php_user)) EEShellExec.cmd_exec(self, "sed -i \"s/define(\'WP_DEBUG\'" ".*/define(\'WP_DEBUG\', true);\\n" "define(\'WP_DEBUG_DISPLAY\', false);" @@ -290,9 +292,10 @@ class EEDebugController(CementBaseController): EEShellExec.cmd_exec(self, "cd {0}/htdocs/ && wp" " plugin --allow-root install " "developer".format(webroot)) - EEShellExec.cmd_exec(self, "chown -R www-data: {0}/htdocs/" + EEShellExec.cmd_exec(self, "chown -R {1}: {0}/htdocs/" "wp-content/plugins" - .format(webroot)) + .format(webroot, + EEVariables.ee_php_user)) else: Log.info(self, "WordPress debug log already enabled") diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 38553767..8e2bab44 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -203,7 +203,7 @@ class EEStackController(CementBaseController): '/etc/nginx/common') os.makedirs('/etc/nginx/common') - data = dict() + data = dict(webroot=EEVariables.ee_webroot) Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/acl.conf') ee_nginx = open('/etc/nginx/common/acl.conf', 'w') @@ -450,8 +450,9 @@ class EEStackController(CementBaseController): myfile.write("") EEFileUtils.chown(self, "{0}22222" - .format(EEVariables.ee_webroot), 'www-data', - 'www-data', recursive=True) + .format(EEVariables.ee_webroot), + EEVariables.ee_php_user, + EEVariables.ee_php_user, recursive=True) EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git") EEService.reload_service(self, 'php5-fpm') @@ -644,7 +645,7 @@ class EEStackController(CementBaseController): " receive_override_options=no_header_body" "_checks/\" /etc/postfix/master.cf") - amavis_master = """smtp-amavis unix - - n - 2 smtp + amavis_master = ("""smtp-amavis unix - - n - 2 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes @@ -665,9 +666,9 @@ class EEStackController(CementBaseController): -o smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 - -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks - -o local_header_rewrite_clients= -""" + -o receive_override_options=no_header_body_checks,""" + + """no_unknown_recipient_check + -o local_header_rewrite_clients=""") with open("/etc/postfix/master.cf", "a") as am_config: am_config.write(amavis_master) @@ -709,11 +710,9 @@ class EEStackController(CementBaseController): shutil.move('/tmp/phpmyadmin-STABLE/', '{0}22222/htdocs/db/pma/' .format(EEVariables.ee_webroot)) - Log.debug(self, 'Setting Privileges of www-data:www-data to ' + Log.debug(self, 'Setting Privileges of webroot permission to ' '{0}22222/htdocs/db/pma file ' .format(EEVariables.ee_webroot)) - # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - # '/var/www/22222/htdocs/db/pma') EEFileUtils.chown(self, '{0}22222' .format(EEVariables.ee_webroot), EEVariables.ee_php_user, @@ -730,8 +729,6 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting Privileges to " "{0}22222/htdocs/cache/memcache file" .format(EEVariables.ee_webroot)) - # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - # '/var/www/22222/htdocs/cache/memcache') EEFileUtils.chown(self, '{0}22222' .format(EEVariables.ee_webroot), EEVariables.ee_php_user, @@ -757,11 +754,9 @@ class EEStackController(CementBaseController): "/usr/bin/dot\'\" {0}22222/htdocs/" "php/webgrind/config.php" .format(EEVariables.ee_webroot)) - Log.debug(self, "Setting Privileges of www-data:www-data to " + Log.debug(self, "Setting Privileges of webroot permission to " "{0}22222/htdocs/php/webgrind/ file " .format(EEVariables.ee_webroot)) - # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' - # '/var/www/22222/htdocs/php/webgrind/') EEFileUtils.chown(self, '{0}22222' .format(EEVariables.ee_webroot), EEVariables.ee_php_user, @@ -858,7 +853,8 @@ class EEStackController(CementBaseController): # Custom Vimbadmin configuration by EasyEngine data = dict(salt=vm_salt, host=EEVariables.ee_mysql_host, - password=vm_passwd) + password=vm_passwd, + php_user=EEVariables.ee_php_user) Log.debug(self, 'Writting the ViMbAdmin configuration to ' 'file {0}22222/htdocs/vimbadmin/application/' 'configs/application.ini' @@ -1017,7 +1013,7 @@ class EEStackController(CementBaseController): static=False, basic=True, wp=False, w3tc=False, wpfc=False, wpsc=False, multisite=False, wpsubdir=False, - webroot='/var/www', ee_db_name='', + webroot=EEVariables.ee_webroot, ee_db_name='', ee_db_user='', ee_db_pass='', ee_db_host='', rc=True) diff --git a/ee/cli/templates/22222.mustache b/ee/cli/templates/22222.mustache index ab6d6a5c..c0897d54 100644 --- a/ee/cli/templates/22222.mustache +++ b/ee/cli/templates/22222.mustache @@ -7,13 +7,13 @@ server { access_log /var/log/nginx/22222.access.log rt_cache; error_log /var/log/nginx/22222.error.log; - ssl_certificate /var/www/22222/cert/22222.crt; - ssl_certificate_key /var/www/22222/cert/22222.key; + ssl_certificate {{webroot}}22222/cert/22222.crt; + ssl_certificate_key {{webroot}}22222/cert/22222.key; # Force HTTP to HTTPS error_page 497 =200 https://$host:22222$request_uri; - root /var/www/22222/htdocs; + root {{webroot}}22222/htdocs; index index.php index.htm index.html; # Turn on directory listing @@ -45,16 +45,16 @@ server { } location ~* \.(js|css|jpg|gif|png)$ { - root /var/www/22222/htdocs/; + root {{webroot}}22222/htdocs/; } location ~* /vimbadmin/public/(.*)/(.*) { - root /var/www/22222/htdocs/vimbadmin/public; + root {{webroot}}22222/htdocs/vimbadmin/public; try_files $uri $uri/ /vimbadmin/public/index.php?$args; } location ~* /vimbadmin/public/(.*) { - root /var/www/22222/htdocs/vimbadmin/public; + root {{webroot}}22222/htdocs/vimbadmin/public; try_files $uri $uri/ /vimbadmin/public/index.php?$args; } diff --git a/ee/cli/templates/vimbadmin.mustache b/ee/cli/templates/vimbadmin.mustache index 16f54d51..808d57ce 100644 --- a/ee/cli/templates/vimbadmin.mustache +++ b/ee/cli/templates/vimbadmin.mustache @@ -628,8 +628,8 @@ resources.session.remember_me_seconds = 3600 resources.session.name = 'VIMBADMIN3' ondemand_resources.logger.writers.stream.path = APPLICATION_PATH "/../var/log" -ondemand_resources.logger.writers.stream.owner = www-data -ondemand_resources.logger.writers.stream.group = www-data +ondemand_resources.logger.writers.stream.owner = {{php_user}} +ondemand_resources.logger.writers.stream.group = {{php_user}} ondemand_resources.logger.writers.stream.mode = single ondemand_resources.logger.writers.stream.logname = vimbadmin.log From fa7040d77a7f5479695cec9791869bfaee2a3db2 Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 5 Feb 2015 19:30:16 +0530 Subject: [PATCH 2/2] EMail validation on setup.py --- setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/setup.py b/setup.py index 87d6a385..88863ee6 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ import sys import os import glob import configparser +import re conf = [] templates = [] @@ -39,6 +40,12 @@ except Exception as e: ee_user = input("Enter your name: ") ee_email = input("Enter your email: ") + + while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", + ee_email): + print("EMail not Valid, Please enter again") + ee_email = input("Enter your email: ") + os.system("git config --global user.name {0}".format(ee_user)) os.system("git config --global user.email {0}".format(ee_email))