@@ -144,6 +144,10 @@ def info(self):
144144 ee_db_host = siteinfo .db_host
145145 if sitetype != "html" :
146146 hhvm = ("enabled" if siteinfo .is_hhvm else "disabled" )
147+ if sitetype == "proxy" :
148+ access_log = "/var/log/nginx/{0}.access.log" .format (ee_domain )
149+ error_log = "/var/log/nginx/{0}.error.log" .format (ee_domain )
150+ ee_site_webroot = ''
147151
148152 pagespeed = ("enabled" if siteinfo .is_pagespeed else "disabled" )
149153
@@ -338,19 +342,45 @@ class Meta:
338342 dict (help = "create HHVM site" , action = 'store_true' )),
339343 (['--pagespeed' ],
340344 dict (help = "create pagespeed site" , action = 'store_true' )),
345+ (['--user' ],
346+ dict (help = "provide user for wordpress site" )),
347+ (['--email' ],
348+ dict (help = "provide email address for wordpress site" )),
349+ (['--pass' ],
350+ dict (help = "provide password for wordpress user" ,
351+ dest = 'wppass' )),
352+ (['--proxy' ],
353+ dict (help = "create proxy for site" , nargs = '+' ))
341354 ]
342355
343356 @expose (hide = True )
344357 def default (self ):
345358 # self.app.render((data), 'default.mustache')
346359 # Check domain name validation
347360 data = dict ()
361+ host , port = None , None
348362 try :
349363 stype , cache = detSitePar (vars (self .app .pargs ))
350364 except RuntimeError as e :
351365 Log .debug (self , str (e ))
352366 Log .error (self , "Please provide valid options to creating site" )
353367
368+ if stype is None and self .app .pargs .proxy :
369+ stype , cache = 'proxy' , ''
370+ proxyinfo = self .app .pargs .proxy [0 ].strip ()
371+ if not proxyinfo :
372+ Log .error (self , "Please provide proxy server host information" )
373+ proxyinfo = proxyinfo .split (':' )
374+ host = proxyinfo [0 ].strip ()
375+ port = '80' if len (proxyinfo ) < 2 else proxyinfo [1 ].strip ()
376+ elif stype is None and not self .app .pargs .proxy :
377+ stype , cache = 'html' , 'basic'
378+ elif stype and self .app .pargs .proxy :
379+ Log .error (self , "proxy should not be used with other site types" )
380+ if (self .app .pargs .proxy and (self .app .pargs .pagespeed
381+ or self .app .pargs .hhvm )):
382+ Log .error (self , "Proxy site can not run on pagespeed or hhvm" )
383+
354384 if not self .app .pargs .site_name :
355385 try :
356386 while not self .app .pargs .site_name :
@@ -377,6 +407,14 @@ def default(self):
377407 Log .error (self , "Nginx configuration /etc/nginx/sites-available/"
378408 "{0} already exists" .format (ee_domain ))
379409
410+ if stype == 'proxy' :
411+ data ['site_name' ] = ee_domain
412+ data ['www_domain' ] = ee_www_domain
413+ data ['proxy' ] = True
414+ data ['host' ] = host
415+ data ['port' ] = port
416+ ee_site_webroot = ""
417+
380418 if stype in ['html' , 'php' ]:
381419 data = dict (site_name = ee_domain , www_domain = ee_www_domain ,
382420 static = True , basic = False , wp = False , w3tc = False ,
@@ -386,6 +424,7 @@ def default(self):
386424 if stype == 'php' :
387425 data ['static' ] = False
388426 data ['basic' ] = True
427+
389428 elif stype in ['mysql' , 'wp' , 'wpsubdir' , 'wpsubdomain' ]:
390429
391430 data = dict (site_name = ee_domain , www_domain = ee_www_domain ,
@@ -399,10 +438,15 @@ def default(self):
399438 data ['wp' ] = True
400439 data ['basic' ] = False
401440 data [cache ] = True
441+ data ['wp-user' ] = self .app .pargs .user
442+ data ['wp-email' ] = self .app .pargs .email
443+ data ['wp-pass' ] = self .app .pargs .wppass
402444 if stype in ['wpsubdir' , 'wpsubdomain' ]:
403445 data ['multisite' ] = True
404446 if stype == 'wpsubdir' :
405447 data ['wpsubdir' ] = True
448+ else :
449+ pass
406450
407451 if stype == "html" and self .app .pargs .hhvm :
408452 Log .error (self , "Can not create HTML site with HHVM" )
@@ -421,13 +465,12 @@ def default(self):
421465 data ['pagespeed' ] = False
422466 pagespeed = 0
423467
424- if not data :
425- self .app .args .print_help ()
426- self .app .close (1 )
468+ # if not data:
469+ # self.app.args.print_help()
470+ # self.app.close(1)
427471
428472 # Check rerequired packages are installed or not
429473 ee_auth = site_package_check (self , stype )
430-
431474 try :
432475 try :
433476 # setup NGINX configuration, and webroot
@@ -442,12 +485,23 @@ def default(self):
442485 Log .error (self , "Check logs for reason "
443486 "`tail /var/log/ee/ee.log` & Try Again!!!" )
444487
488+ if 'proxy' in data .keys () and data ['proxy' ]:
489+ addNewSite (self , ee_domain , stype , cache , ee_site_webroot )
490+ # Service Nginx Reload
491+ EEService .reload_service (self , 'nginx' )
492+ if ee_auth and len (ee_auth ):
493+ for msg in ee_auth :
494+ Log .info (self , Log .ENDC + msg , log = False )
495+ Log .info (self , "Successfully created site"
496+ " http://{0}" .format (ee_domain ))
497+ return
445498 # Update pagespeed config
446499 if self .app .pargs .pagespeed :
447500 operateOnPagespeed (self , data )
448501
449502 addNewSite (self , ee_domain , stype , cache , ee_site_webroot ,
450503 hhvm = hhvm , pagespeed = pagespeed )
504+
451505 # Setup database for MySQL site
452506 if 'ee_db_name' in data .keys () and not data ['wp' ]:
453507 try :
@@ -605,6 +659,8 @@ class Meta:
605659 dict (help = 'Use PageSpeed for site' ,
606660 action = 'store' or 'store_const' ,
607661 choices = ('on' , 'off' ), const = 'on' , nargs = '?' )),
662+ (['--proxy' ],
663+ dict (help = "update to prxy site" , nargs = '+' )),
608664 (['--all' ],
609665 dict (help = "update all sites" , action = 'store_true' )),
610666 ]
@@ -652,6 +708,21 @@ def doupdatesite(self, pargs):
652708 Log .error (self , "Please provide valid options combination for"
653709 " site update" )
654710
711+ if stype is None and pargs .proxy :
712+ stype , cache = 'proxy' , ''
713+ proxyinfo = pargs .proxy [0 ].strip ()
714+ if not proxyinfo :
715+ Log .error (self , "Please provide proxy server host information" )
716+ proxyinfo = proxyinfo .split (':' )
717+ host = proxyinfo [0 ].strip ()
718+ port = '80' if len (proxyinfo ) < 2 else proxyinfo [1 ].strip ()
719+ elif stype is None and not pargs .proxy :
720+ stype , cache = 'html' , 'basic'
721+ elif stype and pargs .proxy :
722+ Log .error (self , "--proxy can not be used with other site types" )
723+ if (pargs .proxy and (pargs .pagespeed or pargs .hhvm )):
724+ Log .error (self , "Proxy site can not run on pagespeed or hhvm" )
725+
655726 if not pargs .site_name :
656727 try :
657728 while not pargs .site_name :
@@ -685,14 +756,21 @@ def doupdatesite(self, pargs):
685756 Log .info (self , "Password Unchanged." )
686757 return 0
687758
759+ if ((stype == "proxy" and stype == oldsitetype and self .app .pargs .hhvm )
760+ or (stype == "proxy" and
761+ stype == oldsitetype and self .app .pargs .pagespeed )):
762+ Log .info (self , Log .FAIL +
763+ "Can not update proxy site to HHVM or Pagespeed" )
764+ return 1
688765 if stype == "html" and stype == oldsitetype and self .app .pargs .hhvm :
689766 Log .info (self , Log .FAIL + "Can not update HTML site to HHVM" )
690767 return 1
691768
692- if ((stype == 'php' and oldsitetype != 'html' ) or
693- (stype == 'mysql' and oldsitetype not in ['html' , 'php' ]) or
769+ if ((stype == 'php' and oldsitetype not in ['html' , 'proxy' ]) or
770+ (stype == 'mysql' and oldsitetype not in ['html' , 'php' ,
771+ 'proxy' ]) or
694772 (stype == 'wp' and oldsitetype not in ['html' , 'php' , 'mysql' ,
695- 'wp' ]) or
773+ 'proxy' , ' wp' ]) or
696774 (stype == 'wpsubdir' and oldsitetype in ['wpsubdomain' ]) or
697775 (stype == 'wpsubdomain' and oldsitetype in ['wpsubdir' ]) or
698776 (stype == oldsitetype and cache == oldcachetype ) and
@@ -701,6 +779,18 @@ def doupdatesite(self, pargs):
701779 format (oldsitetype , oldcachetype , stype , cache ))
702780 return 1
703781
782+ if stype == 'proxy' :
783+ data ['site_name' ] = ee_domain
784+ data ['www_domain' ] = ee_www_domain
785+ data ['proxy' ] = True
786+ data ['host' ] = host
787+ data ['port' ] = port
788+ pagespeed = False
789+ hhvm = False
790+ data ['webroot' ] = ee_site_webroot
791+ data ['currsitetype' ] = oldsitetype
792+ data ['currcachetype' ] = oldcachetype
793+
704794 if stype == 'php' :
705795 data = dict (site_name = ee_domain , www_domain = ee_www_domain ,
706796 static = False , basic = True , wp = False , w3tc = False ,
@@ -736,8 +826,7 @@ def doupdatesite(self, pargs):
736826
737827 stype = oldsitetype
738828 cache = oldcachetype
739-
740- if oldsitetype == 'html' :
829+ if oldsitetype == 'html' or oldsitetype == 'proxy' :
741830 data ['static' ] = True
742831 data ['wp' ] = False
743832 data ['multisite' ] = False
@@ -871,6 +960,13 @@ def doupdatesite(self, pargs):
871960 "`tail /var/log/ee/ee.log` & Try Again!!!" )
872961 return 1
873962
963+ if 'proxy' in data .keys () and data ['proxy' ]:
964+ updateSiteInfo (self , ee_domain , stype = stype , cache = cache ,
965+ hhvm = hhvm , pagespeed = pagespeed )
966+ Log .info (self , "Successfully updated site"
967+ " http://{0}" .format (ee_domain ))
968+ return 0
969+
874970 # Update pagespeed config
875971 if pargs .pagespeed :
876972 operateOnPagespeed (self , data )
@@ -917,7 +1013,7 @@ def doupdatesite(self, pargs):
9171013 return 1
9181014
9191015 # Setup WordPress if old sites are html/php/mysql sites
920- if data ['wp' ] and oldsitetype in ['html' , 'php' , 'mysql' ]:
1016+ if data ['wp' ] and oldsitetype in ['html' , 'proxy' , ' php' , 'mysql' ]:
9211017 try :
9221018 ee_wp_creds = setupwordpress (self , data )
9231019 except SiteError as e :
0 commit comments