Browse Source

Fixed MySQL remote connectivity

bugfixes
gau1991 10 years ago
parent
commit
fff4574318
  1. 34
      ee/cli/plugins/stack.py
  2. 2
      ee/cli/templates/dovecot-sql-conf.mustache
  3. 2
      ee/cli/templates/virtual_alias_maps.mustache
  4. 2
      ee/cli/templates/virtual_domains_maps.mustache
  5. 2
      ee/cli/templates/virtual_mailbox_maps.mustache
  6. 12
      ee/core/variables.py

34
ee/cli/plugins/stack.py

@ -647,15 +647,18 @@ class EEStackController(CementBaseController):
EEShellExec.cmd_exec(self, 'mysql < /var/www/22222/htdocs/db' EEShellExec.cmd_exec(self, 'mysql < /var/www/22222/htdocs/db'
'/anemometer/install.sql') '/anemometer/install.sql')
EEMysql.execute(self, 'grant select on *.* to \'anemometer\'' EEMysql.execute(self, 'grant select on *.* to \'anemometer\''
'@\'localhost\'') '@\'{0}\''.format(self.app.config.get('mysql',
'grant-host')))
EEMysql.execute(self, 'grant all on slow_query_log.* to' EEMysql.execute(self, 'grant all on slow_query_log.* to'
'\'anemometer\'@\'localhost\' IDENTIFIED' '\'anemometer\'@\'{0}\' IDENTIFIED'
' BY \''+chars+'\'') ' BY \'{1}\''.format(self.app.config.get(
'mysql', 'grant-host'),
chars))
# Custom Anemometer configuration # Custom Anemometer configuration
Log.debug(self, "configration Anemometer") Log.debug(self, "configration Anemometer")
data = dict(host='localhost', port='3306', user='anemometer', data = dict(host=EEVariables.ee_mysql_host, port='3306',
password=chars) user='anemometer', password=chars)
ee_anemometer = open('/var/www/22222/htdocs/db/anemometer' ee_anemometer = open('/var/www/22222/htdocs/db/anemometer'
'/conf/config.inc.php', 'w') '/conf/config.inc.php', 'w')
self.app.render((data), 'anemometer.mustache', self.app.render((data), 'anemometer.mustache',
@ -700,8 +703,9 @@ class EEStackController(CementBaseController):
" vimbadmin") " vimbadmin")
Log.debug(self, "Granting all privileges on vimbadmin ") Log.debug(self, "Granting all privileges on vimbadmin ")
EEMysql.execute(self, "grant all privileges on vimbadmin.* to" EEMysql.execute(self, "grant all privileges on vimbadmin.* to"
" vimbadmin@localhost IDENTIFIED BY" " vimbadmin@{0} IDENTIFIED BY"
" '{password}'".format(password=vm_passwd)) " '{1}'".format(self.app.config.get('mysql',
'grant-host'), vm_passwd))
# Configure ViMbAdmin settings # Configure ViMbAdmin settings
config = configparser.ConfigParser(strict=False) config = configparser.ConfigParser(strict=False)
@ -719,7 +723,7 @@ class EEStackController(CementBaseController):
config['user']['resources.doctrine2.connection.' config['user']['resources.doctrine2.connection.'
'options.password'] = vm_passwd 'options.password'] = vm_passwd
config['user']['resources.doctrine2.connection.' config['user']['resources.doctrine2.connection.'
'options.host'] = 'localhost' 'options.host'] = EEVariables.ee_mysql_host
config['user']['defaults.mailbox.password_scheme'] = 'md5' config['user']['defaults.mailbox.password_scheme'] = 'md5'
config['user']['securitysalt'] = (''.join(random.sample config['user']['securitysalt'] = (''.join(random.sample
(string.ascii_letters (string.ascii_letters
@ -765,7 +769,7 @@ class EEStackController(CementBaseController):
Log.debug(self, "Creating directory " Log.debug(self, "Creating directory "
"/etc/postfix/mysql/") "/etc/postfix/mysql/")
os.makedirs('/etc/postfix/mysql/') os.makedirs('/etc/postfix/mysql/')
data = dict(password=vm_passwd) data = dict(password=vm_passwd, host=EEVariables.ee_mysql)
vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf', vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf',
'w') 'w')
self.app.render((data), 'virtual_alias_maps.mustache', self.app.render((data), 'virtual_alias_maps.mustache',
@ -832,8 +836,10 @@ class EEStackController(CementBaseController):
Log.debug(self, "Grant all privileges on roundcubemail") Log.debug(self, "Grant all privileges on roundcubemail")
EEMysql.execute(self, "grant all privileges" EEMysql.execute(self, "grant all privileges"
" on roundcubemail.* to " " on roundcubemail.* to "
" roundcube@localhost IDENTIFIED BY " " roundcube@{0} IDENTIFIED BY "
"'{password}'".format(password=rc_passwd)) "'{1}'".format(self.app.config.get(
'mysql', 'grant-host'),
rc_passwd))
EEShellExec.cmd_exec(self, "mysql roundcubemail < /var/www/" EEShellExec.cmd_exec(self, "mysql roundcubemail < /var/www/"
"roundcubemail/htdocs/SQL/mysql" "roundcubemail/htdocs/SQL/mysql"
".initial.sql") ".initial.sql")
@ -844,10 +850,12 @@ class EEStackController(CementBaseController):
"config.inc.php") "config.inc.php")
EEShellExec.cmd_exec(self, "sed -i \"s\'mysql://roundcube:" EEShellExec.cmd_exec(self, "sed -i \"s\'mysql://roundcube:"
"pass@localhost/roundcubemail\'mysql://" "pass@localhost/roundcubemail\'mysql://"
"roundcube:{password}@localhost/" "roundcube:{0}@{1}/"
"roundcubemail\'\" /var/www/roundcubemail" "roundcubemail\'\" /var/www/roundcubemail"
"/htdocs/config/config." "/htdocs/config/config."
"inc.php".format(password=rc_passwd)) "inc.php"
.format(rc_passwd,
EEVariables.ee_mysql_host))
# Sieve plugin configuration in roundcube # Sieve plugin configuration in roundcube
EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\[" EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\["

2
ee/cli/templates/dovecot-sql-conf.mustache

@ -1,5 +1,5 @@
driver = mysql driver = mysql
connect = host=localhost user=vimbadmin password={{password}} dbname=vimbadmin connect = host={{host}} user=vimbadmin password={{password}} dbname=vimbadmin
default_pass_scheme = MD5 default_pass_scheme = MD5
password_query = SELECT username as user, password as password, \ password_query = SELECT username as user, password as password, \
homedir AS home, maildir AS mail, \ homedir AS home, maildir AS mail, \

2
ee/cli/templates/virtual_alias_maps.mustache

@ -1,5 +1,5 @@
user = vimbadmin user = vimbadmin
password = {{password}} password = {{password}}
hosts = 127.0.0.1 hosts = {{host}}
dbname = vimbadmin dbname = vimbadmin
query = SELECT goto FROM alias WHERE address = '%s' AND active = '1' query = SELECT goto FROM alias WHERE address = '%s' AND active = '1'

2
ee/cli/templates/virtual_domains_maps.mustache

@ -1,5 +1,5 @@
user = vimbadmin user = vimbadmin
password = {{password}} password = {{password}}
hosts = 127.0.0.1 hosts = {{host}}
dbname = vimbadmin dbname = vimbadmin
query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1' query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1'

2
ee/cli/templates/virtual_mailbox_maps.mustache

@ -1,6 +1,6 @@
user = vimbadmin user = vimbadmin
password = {{password}} password = {{password}}
hosts = 127.0.0.1 hosts = {{host}}
dbname = vimbadmin dbname = vimbadmin
table = mailbox table = mailbox
select_field = maildir select_field = maildir

12
ee/core/variables.py

@ -51,6 +51,18 @@ class EEVariables():
ee_ram = psutil.virtual_memory().total / (1024 * 1024) ee_ram = psutil.virtual_memory().total / (1024 * 1024)
ee_swap = psutil.swap_memory().total / (1024 * 1024) ee_swap = psutil.swap_memory().total / (1024 * 1024)
# MySQL hostname
ee_mysql_host = ""
config = configparser.RawConfigParser()
cnfpath = os.path.expanduser("~")+"/.my.cnf"
if [cnfpath] == config.read(cnfpath):
try:
ee_mysql_host = config.get('client', 'host')
except configparser.NoOptionError as e:
ee_mysql_host = "localhost"
else:
ee_mysql_host = "localhost"
# EasyEngine stack installation varibales # EasyEngine stack installation varibales
# Nginx repo and packages # Nginx repo and packages
if ee_platform_distro == 'Ubuntu': if ee_platform_distro == 'Ubuntu':

Loading…
Cancel
Save