2424import os
2525import pwd
2626import grp
27+ import codecs
2728from ee .cli .plugins .stack_services import EEStackStatusController
2829from ee .core .logging import Log
2930
@@ -93,14 +94,24 @@ def pre_pref(self, apt_packages):
9394 keyserver = "keyserver.ubuntu.com" )
9495 chars = '' .join (random .sample (string .ascii_letters , 8 ))
9596 Log .debug (self , "Pre-seeding MySQL" )
97+ Log .debug (self , "echo \" percona-server-server-5.6 "
98+ "percona-server-server/root_password "
99+ "password \" | "
100+ "debconf-set-selections" )
96101 EEShellExec .cmd_exec (self , "echo \" percona-server-server-5.6 "
97102 "percona-server-server/root_password "
98103 "password {chars}\" | "
99- "debconf-set-selections" .format (chars = chars ))
104+ "debconf-set-selections" .format (chars = chars ),
105+ log = False )
106+ Log .debug (self , "echo \" percona-server-server-5.6 "
107+ "percona-server-server/root_password_again "
108+ "password \" | "
109+ "debconf-set-selections" )
100110 EEShellExec .cmd_exec (self , "echo \" percona-server-server-5.6 "
101111 "percona-server-server/root_password_again "
102112 "password {chars}\" | "
103- "debconf-set-selections" .format (chars = chars ))
113+ "debconf-set-selections" .format (chars = chars ),
114+ log = False )
104115 mysql_config = """
105116 [client]
106117 user = root
@@ -366,7 +377,6 @@ def post_pref(self, apt_packages, packages):
366377 EEService .reload_service (self , 'nginx' )
367378 self .msg = (self .msg + ["HTTP Auth User Name: easyengine" ]
368379 + ["HTTP Auth Password : {0}" .format (passwd )])
369-
370380 if set (EEVariables .ee_php ).issubset (set (apt_packages )):
371381 # Create log directories
372382 if not os .path .exists ('/var/log/php5/' ):
@@ -390,20 +400,24 @@ def post_pref(self, apt_packages, packages):
390400
391401 # Prase /etc/php5/fpm/php-fpm.conf
392402 config = configparser .ConfigParser ()
393- config .read ('/etc/php5/fpm/php-fpm.conf' )
403+ Log .debug (self , "configuring php file"
404+ "/etc/php5/fpm/php-fpm.conf" )
405+ config .read_file (codecs .open ("/etc/php5/fpm/php-fpm.conf" ,
406+ "r" , "utf8" ))
394407 config ['global' ]['error_log' ] = '/var/log/php5/fpm.log'
395408 config .remove_option ('global' , 'include' )
396409 config ['global' ]['log_level' ] = 'notice'
397410 config ['global' ]['include' ] = '/etc/php5/fpm/pool.d/*.conf'
398- with open ('/etc/php5/fpm/php-fpm.conf' ,
399- encoding = 'utf-8' , mode = 'w' ) as configfile :
411+ with codecs . open ('/etc/php5/fpm/php-fpm.conf' ,
412+ encoding = 'utf-8' , mode = 'w' ) as configfile :
400413 Log .debug (self , "writting php5 configuration into "
401414 "/etc/php5/fpm/php-fpm.conf" )
402415 config .write (configfile )
403416
404417 # Parse /etc/php5/fpm/pool.d/www.conf
405418 config = configparser .ConfigParser ()
406- config .read ('/etc/php5/fpm/pool.d/www.conf' )
419+ config .read_file (codecs .open ('/etc/php5/fpm/pool.d/www.conf' ,
420+ "r" , "utf8" ))
407421 config ['www' ]['ping.path' ] = '/ping'
408422 config ['www' ]['pm.status_path' ] = '/status'
409423 config ['www' ]['pm.max_requests' ] = '500'
@@ -414,8 +428,8 @@ def post_pref(self, apt_packages, packages):
414428 config ['www' ]['request_terminate_timeout' ] = '300'
415429 config ['www' ]['pm' ] = 'ondemand'
416430 config ['www' ]['listen' ] = '127.0.0.1:9000'
417- with open ('/etc/php5/fpm/pool.d/www.conf' ,
418- encoding = 'utf-8' , mode = 'w' ) as configfile :
431+ with codecs . open ('/etc/php5/fpm/pool.d/www.conf' ,
432+ encoding = 'utf-8' , mode = 'w' ) as configfile :
419433 Log .debug (self , "writting PHP5 configuration into "
420434 "/etc/php5/fpm/pool.d/www.conf" )
421435 config .write (configfile )
@@ -628,7 +642,7 @@ def post_pref(self, apt_packages, packages):
628642 Log .debug (self , "Setting Privileges to dovecot " )
629643 # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib"
630644 # "/dovecot")
631- EEFileUtils .chown (self , "/var/lig /dovecot" , 'vmail' , 'vmail' ,
645+ EEFileUtils .chown (self , "/var/lib /dovecot" , 'vmail' , 'vmail' ,
632646 recursive = True )
633647 EEShellExec .cmd_exec (self , "sievec /var/lib/dovecot/sieve/"
634648 "default.sieve" )
@@ -809,11 +823,14 @@ def post_pref(self, apt_packages, packages):
809823 EEMysql .execute (self , 'grant select on *.* to \' anemometer\' '
810824 '@\' {0}\' ' .format (self .app .config .get ('mysql' ,
811825 'grant-host' )))
826+ Log .debug (self , "grant all on slow-query-log.*"
827+ " to anemometer@root_user IDENTIFIED BY password " )
812828 EEMysql .execute (self , 'grant all on slow_query_log.* to'
813829 '\' anemometer\' @\' {0}\' IDENTIFIED'
814830 ' BY \' {1}\' ' .format (self .app .config .get (
815831 'mysql' , 'grant-host' ),
816- chars ))
832+ chars ),
833+ errormsg = "cannot grant privillages" , log = False )
817834
818835 # Custom Anemometer configuration
819836 Log .debug (self , "configration Anemometer" )
@@ -870,11 +887,14 @@ def post_pref(self, apt_packages, packages):
870887 Log .debug (self , "Creating vimbadmin database if not exist" )
871888 EEMysql .execute (self , "create database if not exists"
872889 " vimbadmin" )
873- Log .debug (self , "Granting all privileges on vimbadmin " )
890+ Log .debug (self , "Granting all privileges on vimbadmin.* to "
891+ "vimbadmin@root IDENTIFIED BY password " )
874892 EEMysql .execute (self , "grant all privileges on vimbadmin.* to"
875893 " vimbadmin@{0} IDENTIFIED BY"
876894 " '{1}'" .format (self .app .config .get ('mysql' ,
877- 'grant-host' ), vm_passwd ))
895+ 'grant-host' ), vm_passwd ),
896+ errormsg = "Cannot grant "
897+ "user privileges" , log = False )
878898 vm_salt = ('' .join (random .sample (string .ascii_letters +
879899 string .ascii_letters , 64 )))
880900
0 commit comments