Skip to content

Commit 950cea0

Browse files
author
shital.rtcamp
committed
Merge branch 'python' of https://github.com/rtCamp/easyengine into python
2 parents 17d2cbd + 118f25a commit 950cea0

File tree

14 files changed

+138
-67
lines changed

14 files changed

+138
-67
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 rtCamp solutions private limited
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ IMPORTANT
1212

1313
[![Travis Build Status](https://travis-ci.org/rtCamp/easyengine.svg "Travis Build Status")] (https://travis-ci.org/rtCamp/easyengine)
1414

15-
EasyEngine (ee) is a linux shell-script collection, which makes it easy to manage your wordpress sites running on nginx web-server.
15+
EasyEngine (ee) is a python tool, which makes it easy to manage your wordpress sites running on nginx web-server.
1616

1717
**EasyEngine currently supports:**
1818

@@ -24,7 +24,7 @@ EasyEngine (ee) is a linux shell-script collection, which makes it easy to manag
2424
## Quick Start
2525

2626
```bash
27-
wget http://rt.cx/eebeta && sudo bash install # install easyengine 3.0.0-beta
27+
wget http://rt.cx/eebeta && sudo bash eebeta # install easyengine 3.0.0-beta
2828
sudo ee site create example.com --wp # Install required packages & setup WordPress on example.com
2929
```
3030

@@ -94,5 +94,4 @@ ee site create example.com --mysql # create example.com with php & mysql supp
9494
[![Donate](https://cloud.githubusercontent.com/assets/4115/5297691/c7b50292-7bd7-11e4-987b-2dc21069e756.png)] (https://rtcamp.com/donate/?project=easyengine)
9595

9696
## License
97-
98-
Same [GPL] (http://www.gnu.org/licenses/gpl-2.0.txt) that WordPress uses!
97+
[MIT] (http://opensource.org/licenses/MIT)

ee/cli/plugins/debug.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ def debug_wp(self):
279279
Log.info(self, "Starting WordPress debug")
280280
open("{0}/htdocs/wp-content/debug.log".format(webroot),
281281
'a').close()
282-
EEShellExec.cmd_exec(self, "chown www-data: {0}/htdocs/wp-"
283-
"content/debug.log".format(webroot))
282+
EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-"
283+
"content/debug.log"
284+
"".format(webroot,
285+
EEVariables.ee_php_user))
284286
EEShellExec.cmd_exec(self, "sed -i \"s/define(\'WP_DEBUG\'"
285287
".*/define(\'WP_DEBUG\', true);\\n"
286288
"define(\'WP_DEBUG_DISPLAY\', false);"
@@ -290,9 +292,10 @@ def debug_wp(self):
290292
EEShellExec.cmd_exec(self, "cd {0}/htdocs/ && wp"
291293
" plugin --allow-root install "
292294
"developer".format(webroot))
293-
EEShellExec.cmd_exec(self, "chown -R www-data: {0}/htdocs/"
295+
EEShellExec.cmd_exec(self, "chown -R {1}: {0}/htdocs/"
294296
"wp-content/plugins"
295-
.format(webroot))
297+
.format(webroot,
298+
EEVariables.ee_php_user))
296299
else:
297300
Log.info(self, "WordPress debug log already enabled")
298301

ee/cli/plugins/import_slow_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def default(self):
2424
.format(EEVariables.ee_webroot)):
2525
if os.path.isfile("/var/log/mysql/mysql-slow.log"):
2626
# Get Anemometer user name and password
27-
Log.error(self, "Importing MySQL slow log to Anemometer")
27+
Log.info(self, "Importing MySQL slow log to Anemometer")
2828
host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/"
2929
.format(EEVariables.ee_webroot)
3030
+ "db/anemometer/conf/config.inc.php "

ee/cli/plugins/site.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,25 @@ def default(self):
3939
@expose(help="Enable site example.com")
4040
def enable(self):
4141
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
42-
Log.info(self, "Enable domain {0:10}".format(ee_domain), end='')
42+
Log.info(self, "Enable domain {0:10} \t".format(ee_domain), end='')
4343
if os.path.isfile('/etc/nginx/sites-available/{0}'
4444
.format(ee_domain)):
4545
EEFileUtils.create_symlink(self,
4646
['/etc/nginx/sites-available/{0}'
4747
.format(ee_domain),
4848
'/etc/nginx/sites-enabled/{0}'
4949
.format(ee_domain)])
50+
5051
updateSiteInfo(self, ee_domain, enabled=True)
5152
Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
53+
EEService.reload_service(self, 'nginx')
5254
else:
5355
Log.error(self, " site {0} does not exists".format(ee_domain))
5456

5557
@expose(help="Disable site example.com")
5658
def disable(self):
5759
(ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)
58-
Log.info(self, "Disable domain {0:10}".format(ee_domain), end='')
60+
Log.info(self, "Disable domain {0:10} \t".format(ee_domain), end='')
5961
if os.path.isfile('/etc/nginx/sites-available/{0}'
6062
.format(ee_domain)):
6163
if not os.path.isfile('/etc/nginx/sites-enabled/{0}'
@@ -68,6 +70,7 @@ def disable(self):
6870
.format(ee_domain))
6971
updateSiteInfo(self, ee_domain, enabled=False)
7072
Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]")
73+
EEService.reload_service(self, 'nginx')
7174
else:
7275
Log.error(self, " site {0} does not exists".format(ee_domain))
7376

ee/cli/plugins/stack.py

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def default(self):
7575
def pre_pref(self, apt_packages):
7676
"""Pre settings to do before installation packages"""
7777
if set(EEVariables.ee_postfix).issubset(set(apt_packages)):
78-
Log.info(self, "Pre-seeding Postfix")
78+
Log.debug(self, "Pre-seeding Postfix")
7979
EEShellExec.cmd_exec(self, "echo \"postfix postfix"
8080
"/main_mailer_type string \'Internet Site\'\""
8181
" | debconf-set-selections")
@@ -90,7 +90,7 @@ def pre_pref(self, apt_packages):
9090
EERepo.add_key(self, '1C4CBDCDCD2EFD2A',
9191
keyserver="subkeys.pgp.net")
9292
chars = ''.join(random.sample(string.ascii_letters, 8))
93-
Log.info(self, "Pre-seeding MySQL")
93+
Log.debug(self, "Pre-seeding MySQL")
9494
EEShellExec.cmd_exec(self, "echo \"percona-server-server-5.6 "
9595
"percona-server-server/root_password "
9696
"password {chars}\" | "
@@ -203,7 +203,7 @@ def post_pref(self, apt_packages, packages):
203203
'/etc/nginx/common')
204204
os.makedirs('/etc/nginx/common')
205205

206-
data = dict()
206+
data = dict(webroot=EEVariables.ee_webroot)
207207
Log.debug(self, 'Writting the nginx configuration to '
208208
'file /etc/nginx/common/acl.conf')
209209
ee_nginx = open('/etc/nginx/common/acl.conf', 'w')
@@ -450,8 +450,9 @@ def post_pref(self, apt_packages, packages):
450450
myfile.write("<?php\nphpinfo();\n?>")
451451

452452
EEFileUtils.chown(self, "{0}22222"
453-
.format(EEVariables.ee_webroot), 'www-data',
454-
'www-data', recursive=True)
453+
.format(EEVariables.ee_webroot),
454+
EEVariables.ee_php_user,
455+
EEVariables.ee_php_user, recursive=True)
455456

456457
EEGit.add(self, ["/etc/php5"], msg="Adding PHP into Git")
457458
EEService.reload_service(self, 'php5-fpm')
@@ -640,10 +641,38 @@ def post_pref(self, apt_packages, packages):
640641
"smtp-amavis:[127.0.0.1]:10024\"")
641642
EEShellExec.cmd_exec(self, "sed -i \"s/1 pickup/1 "
642643
"pickup"
643-
"\\n -o content_filter=\\n -o"
644+
"\\n -o content_filter=\\n -o"
644645
" receive_override_options=no_header_body"
645646
"_checks/\" /etc/postfix/master.cf")
646647

648+
amavis_master = ("""smtp-amavis unix - - n - 2 smtp
649+
-o smtp_data_done_timeout=1200
650+
-o smtp_send_xforward_command=yes
651+
-o disable_dns_lookups=yes
652+
-o max_use=20
653+
127.0.0.1:10025 inet n - n - - smtpd
654+
-o content_filter=
655+
-o smtpd_delay_reject=no
656+
-o smtpd_client_restrictions=permit_mynetworks,reject
657+
-o smtpd_helo_restrictions=
658+
-o smtpd_sender_restrictions=
659+
-o smtpd_recipient_restrictions=permit_mynetworks,reject
660+
-o smtpd_data_restrictions=reject_unauth_pipelining
661+
-o smtpd_end_of_data_restrictions=
662+
-o smtpd_restriction_classes=
663+
-o mynetworks=127.0.0.0/8
664+
-o smtpd_error_sleep_time=0
665+
-o smtpd_soft_error_limit=1001
666+
-o smtpd_hard_error_limit=1000
667+
-o smtpd_client_connection_count_limit=0
668+
-o smtpd_client_connection_rate_limit=0
669+
-o receive_override_options=no_header_body_checks,""" +
670+
"""no_unknown_recipient_check
671+
-o local_header_rewrite_clients=""")
672+
673+
with open("/etc/postfix/master.cf", "a") as am_config:
674+
am_config.write(amavis_master)
675+
647676
# Amavis ClamAV configuration
648677
Log.debug(self, "Adding new user clamav amavis")
649678
EEShellExec.cmd_exec(self, "adduser clamav amavis")
@@ -681,11 +710,9 @@ def post_pref(self, apt_packages, packages):
681710
shutil.move('/tmp/phpmyadmin-STABLE/',
682711
'{0}22222/htdocs/db/pma/'
683712
.format(EEVariables.ee_webroot))
684-
Log.debug(self, 'Setting Privileges of www-data:www-data to '
713+
Log.debug(self, 'Setting Privileges of webroot permission to '
685714
'{0}22222/htdocs/db/pma file '
686715
.format(EEVariables.ee_webroot))
687-
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
688-
# '/var/www/22222/htdocs/db/pma')
689716
EEFileUtils.chown(self, '{0}22222'
690717
.format(EEVariables.ee_webroot),
691718
EEVariables.ee_php_user,
@@ -702,8 +729,6 @@ def post_pref(self, apt_packages, packages):
702729
Log.debug(self, "Setting Privileges to "
703730
"{0}22222/htdocs/cache/memcache file"
704731
.format(EEVariables.ee_webroot))
705-
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
706-
# '/var/www/22222/htdocs/cache/memcache')
707732
EEFileUtils.chown(self, '{0}22222'
708733
.format(EEVariables.ee_webroot),
709734
EEVariables.ee_php_user,
@@ -729,11 +754,9 @@ def post_pref(self, apt_packages, packages):
729754
"/usr/bin/dot\'\" {0}22222/htdocs/"
730755
"php/webgrind/config.php"
731756
.format(EEVariables.ee_webroot))
732-
Log.debug(self, "Setting Privileges of www-data:www-data to "
757+
Log.debug(self, "Setting Privileges of webroot permission to "
733758
"{0}22222/htdocs/php/webgrind/ file "
734759
.format(EEVariables.ee_webroot))
735-
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
736-
# '/var/www/22222/htdocs/php/webgrind/')
737760
EEFileUtils.chown(self, '{0}22222'
738761
.format(EEVariables.ee_webroot),
739762
EEVariables.ee_php_user,
@@ -830,7 +853,8 @@ def post_pref(self, apt_packages, packages):
830853

831854
# Custom Vimbadmin configuration by EasyEngine
832855
data = dict(salt=vm_salt, host=EEVariables.ee_mysql_host,
833-
password=vm_passwd)
856+
password=vm_passwd,
857+
php_user=EEVariables.ee_php_user)
834858
Log.debug(self, 'Writting the ViMbAdmin configuration to '
835859
'file {0}22222/htdocs/vimbadmin/application/'
836860
'configs/application.ini'
@@ -989,7 +1013,7 @@ def post_pref(self, apt_packages, packages):
9891013
static=False,
9901014
basic=True, wp=False, w3tc=False, wpfc=False,
9911015
wpsc=False, multisite=False, wpsubdir=False,
992-
webroot='/var/www', ee_db_name='',
1016+
webroot=EEVariables.ee_webroot, ee_db_name='',
9931017
ee_db_user='', ee_db_pass='', ee_db_host='',
9941018
rc=True)
9951019

@@ -1154,7 +1178,15 @@ def install(self, packages=[], apt_packages=[], disp_msg=True):
11541178
"Adminer"]]
11551179

11561180
if self.app.pargs.mailscanner:
1157-
apt_packages = (apt_packages + EEVariables.ee_mailscanner)
1181+
if not EEAptGet.is_installed(self, 'amavisd-new'):
1182+
if (EEAptGet.is_installed(self, 'dovecot-core') or
1183+
self.app.pargs.mail):
1184+
apt_packages = (apt_packages +
1185+
EEVariables.ee_mailscanner)
1186+
else:
1187+
Log.error(self, "Failed to find installed Dovecot")
1188+
else:
1189+
Log.error(self, "Mail scanner allready installed")
11581190

11591191
if self.app.pargs.utils:
11601192
Log.debug(self, "Setting packages variable for utils")
@@ -1238,7 +1270,8 @@ def remove(self):
12381270
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
12391271
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
12401272
(not self.app.pargs.phpmyadmin) and
1241-
(not self.app.pargs.adminer) and (not self.app.pargs.utils)):
1273+
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
1274+
(not self.app.pargs.mailscanner)):
12421275
self.app.pargs.web = True
12431276

12441277
if self.app.pargs.web:
@@ -1326,7 +1359,8 @@ def purge(self):
13261359
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
13271360
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
13281361
(not self.app.pargs.phpmyadmin) and
1329-
(not self.app.pargs.adminer) and (not self.app.pargs.utils)):
1362+
(not self.app.pargs.adminer) and (not self.app.pargs.utils) and
1363+
(not self.app.pargs.mailscanner)):
13301364
self.app.pargs.web = True
13311365

13321366
if self.app.pargs.web:

ee/cli/templates/22222.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ server {
77
access_log /var/log/nginx/22222.access.log rt_cache;
88
error_log /var/log/nginx/22222.error.log;
99
10-
ssl_certificate /var/www/22222/cert/22222.crt;
11-
ssl_certificate_key /var/www/22222/cert/22222.key;
10+
ssl_certificate {{webroot}}22222/cert/22222.crt;
11+
ssl_certificate_key {{webroot}}22222/cert/22222.key;
1212

1313
# Force HTTP to HTTPS
1414
error_page 497 =200 https://$host:22222$request_uri;
1515

16-
root /var/www/22222/htdocs;
16+
root {{webroot}}22222/htdocs;
1717
index index.php index.htm index.html;
1818

1919
# Turn on directory listing
@@ -45,16 +45,16 @@ server {
4545
}
4646

4747
location ~* \.(js|css|jpg|gif|png)$ {
48-
root /var/www/22222/htdocs/;
48+
root {{webroot}}22222/htdocs/;
4949
}
5050

5151
location ~* /vimbadmin/public/(.*)/(.*) {
52-
root /var/www/22222/htdocs/vimbadmin/public;
52+
root {{webroot}}22222/htdocs/vimbadmin/public;
5353
try_files $uri $uri/ /vimbadmin/public/index.php?$args;
5454
}
5555

5656
location ~* /vimbadmin/public/(.*) {
57-
root /var/www/22222/htdocs/vimbadmin/public;
57+
root {{webroot}}22222/htdocs/vimbadmin/public;
5858
try_files $uri $uri/ /vimbadmin/public/index.php?$args;
5959
}
6060

ee/cli/templates/anemometer.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ $conf['plugins'] = array(
125125
$conn['db'] = $sample['db_max'];
126126
}
127127

128-
$conn['user'] = 'root';
129-
$conn['password'] = '';
128+
$conn['user'] = '{{user}}';
129+
$conn['password'] = '{{password}}';
130130

131131
return $conn;
132132
},

ee/cli/templates/vimbadmin.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,8 @@ resources.session.remember_me_seconds = 3600
628628
resources.session.name = 'VIMBADMIN3'
629629

630630
ondemand_resources.logger.writers.stream.path = APPLICATION_PATH "/../var/log"
631-
ondemand_resources.logger.writers.stream.owner = www-data
632-
ondemand_resources.logger.writers.stream.group = www-data
631+
ondemand_resources.logger.writers.stream.owner = {{php_user}}
632+
ondemand_resources.logger.writers.stream.group = {{php_user}}
633633
ondemand_resources.logger.writers.stream.mode = single
634634
ondemand_resources.logger.writers.stream.logname = vimbadmin.log
635635

0 commit comments

Comments
 (0)