Browse Source

Merge branch 'python' of github.com:rtCamp/easyengine into python

bugfixes
shital.rtcamp 10 years ago
parent
commit
624f8ed996
  1. 83
      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. 24
      ee/core/variables.py

83
ee/cli/plugins/stack.py

@ -166,7 +166,7 @@ class EEStackController(CementBaseController):
nc.savef('/etc/nginx/nginx.conf')
# Custom Nginx configuration by EasyEngine
data = dict(version='EasyEngine 3.0.1')
data = dict(version=EEVariables.ee_version)
Log.debug(self, 'writting the nginx configration to '
'file /etc/nginx/conf.d/ee-nginx.conf ')
ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w')
@ -647,15 +647,18 @@ class EEStackController(CementBaseController):
EEShellExec.cmd_exec(self, 'mysql < /var/www/22222/htdocs/db'
'/anemometer/install.sql')
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'
'\'anemometer\'@\'localhost\' IDENTIFIED'
' BY \''+chars+'\'')
'\'anemometer\'@\'{0}\' IDENTIFIED'
' BY \'{1}\''.format(self.app.config.get(
'mysql', 'grant-host'),
chars))
# Custom Anemometer configuration
Log.debug(self, "configration Anemometer")
data = dict(host='localhost', port='3306', user='anemometer',
password=chars)
data = dict(host=EEVariables.ee_mysql_host, port='3306',
user='anemometer', password=chars)
ee_anemometer = open('/var/www/22222/htdocs/db/anemometer'
'/conf/config.inc.php', 'w')
self.app.render((data), 'anemometer.mustache',
@ -700,8 +703,9 @@ class EEStackController(CementBaseController):
" vimbadmin")
Log.debug(self, "Granting all privileges on vimbadmin ")
EEMysql.execute(self, "grant all privileges on vimbadmin.* to"
" vimbadmin@localhost IDENTIFIED BY"
" '{password}'".format(password=vm_passwd))
" vimbadmin@{0} IDENTIFIED BY"
" '{1}'".format(self.app.config.get('mysql',
'grant-host'), vm_passwd))
# Configure ViMbAdmin settings
config = configparser.ConfigParser(strict=False)
@ -719,7 +723,7 @@ class EEStackController(CementBaseController):
config['user']['resources.doctrine2.connection.'
'options.password'] = vm_passwd
config['user']['resources.doctrine2.connection.'
'options.host'] = 'localhost'
'options.host'] = EEVariables.ee_mysql_host
config['user']['defaults.mailbox.password_scheme'] = 'md5'
config['user']['securitysalt'] = (''.join(random.sample
(string.ascii_letters
@ -765,7 +769,7 @@ class EEStackController(CementBaseController):
Log.debug(self, "Creating directory "
"/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',
'w')
self.app.render((data), 'virtual_alias_maps.mustache',
@ -832,8 +836,10 @@ class EEStackController(CementBaseController):
Log.debug(self, "Grant all privileges on roundcubemail")
EEMysql.execute(self, "grant all privileges"
" on roundcubemail.* to "
" roundcube@localhost IDENTIFIED BY "
"'{password}'".format(password=rc_passwd))
" roundcube@{0} IDENTIFIED BY "
"'{1}'".format(self.app.config.get(
'mysql', 'grant-host'),
rc_passwd))
EEShellExec.cmd_exec(self, "mysql roundcubemail < /var/www/"
"roundcubemail/htdocs/SQL/mysql"
".initial.sql")
@ -844,10 +850,12 @@ class EEStackController(CementBaseController):
"config.inc.php")
EEShellExec.cmd_exec(self, "sed -i \"s\'mysql://roundcube:"
"pass@localhost/roundcubemail\'mysql://"
"roundcube:{password}@localhost/"
"roundcube:{0}@{1}/"
"roundcubemail\'\" /var/www/roundcubemail"
"/htdocs/config/config."
"inc.php".format(password=rc_passwd))
"inc.php"
.format(rc_passwd,
EEVariables.ee_mysql_host))
# Sieve plugin configuration in roundcube
EEShellExec.cmd_exec(self, "bash -c \"sed -i \\\"s:\$config\["
@ -905,6 +913,15 @@ class EEStackController(CementBaseController):
def install(self, packages=[], apt_packages=[]):
self.msg = []
try:
# Default action for stack installation
if ((not self.app.pargs.web) and (not self.app.pargs.admin) and
(not self.app.pargs.mail) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils)):
self.app.pargs.web = True
if self.app.pargs.web:
Log.debug(self, "Setting apt_packages variable for Nginx ,PHP"
" ,MySQL ")
@ -932,12 +949,14 @@ class EEStackController(CementBaseController):
Log.debug(self, "Setting apt_packages variable for mail")
apt_packages = apt_packages + EEVariables.ee_mail
packages = packages + [["https://github.com/opensolutions/"
"ViMbAdmin/archive/3.0.10.tar.gz",
"ViMbAdmin/archive/{0}.tar.gz"
.format(EEVariables.ee_vimbadmin),
"/tmp/vimbadmin.tar.gz",
"ViMbAdmin"],
["https://github.com/roundcube/"
"roundcubemail/releases/download/"
"1.0.4/roundcubemail-1.0.4.tar.gz",
"{0}/roundcubemail-{0}.tar.gz"
.format(EEVariables.ee_roundcube),
"/tmp/roundcube.tar.gz",
"Roundcube"]]
@ -975,8 +994,10 @@ class EEStackController(CementBaseController):
Log.debug(self, "Setting packages variable for WPCLI")
if not EEShellExec.cmd_exec(self, "which wp"):
packages = packages + [["https://github.com/wp-cli/wp-cli/"
"releases/download/v0.17.1/"
"wp-cli.phar", "/usr/bin/wp",
"releases/download/v{0}/"
"wp-cli-{0}.phar"
"".format(EEVariables.ee_wp_cli),
"/usr/bin/wp",
"WP_CLI"]]
else:
Log.info(self, "WP-CLI is allready installed")
@ -989,7 +1010,8 @@ class EEStackController(CementBaseController):
if self.app.pargs.adminer:
Log.debug(self, "Setting packages variable for Adminer ")
packages = packages + [["http://downloads.sourceforge.net/"
"adminer/adminer-4.1.0.php",
"adminer/adminer-{0}.php"
"".format(EEVariables.ee_adminer),
"/var/www/22222/"
"htdocs/db/adminer/index.php",
"Adminer"]]
@ -1043,11 +1065,12 @@ class EEStackController(CementBaseController):
EESwap.add(self)
Log.debug(self, "Updating apt-cache")
EEAptGet.update(self)
Log.debug(self, "Installing all apt_packages")
Log.debug(self, "Installing following: {0}"
.format(apt_packages))
print(apt_packages)
EEAptGet.install(self, apt_packages)
if len(packages):
Log.debug(self, "Downloading all packages")
Log.debug(self, "Downloading following: {0}".format(packages))
EEDownload.download(self, packages)
Log.debug(self, "Calling post_pref")
self.post_pref(apt_packages, packages)
@ -1061,6 +1084,15 @@ class EEStackController(CementBaseController):
apt_packages = []
packages = []
# Default action for stack remove
if ((not self.app.pargs.web) and (not self.app.pargs.admin) and
(not self.app.pargs.mail) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils)):
self.app.pargs.web = True
if self.app.pargs.web:
self.app.pargs.nginx = True
self.app.pargs.php = True
@ -1126,6 +1158,15 @@ class EEStackController(CementBaseController):
apt_packages = []
packages = []
# Default action for stack purge
if ((not self.app.pargs.web) and (not self.app.pargs.admin) and
(not self.app.pargs.mail) and (not self.app.pargs.nginx) and
(not self.app.pargs.php) and (not self.app.pargs.mysql) and
(not self.app.pargs.postfix) and (not self.app.pargs.wpcli) and
(not self.app.pargs.phpmyadmin) and
(not self.app.pargs.adminer) and (not self.app.pargs.utils)):
self.app.pargs.web = True
if self.app.pargs.web:
self.app.pargs.nginx = True
self.app.pargs.php = True

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

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

2
ee/cli/templates/virtual_alias_maps.mustache

@ -1,5 +1,5 @@
user = vimbadmin
password = {{password}}
hosts = 127.0.0.1
hosts = {{host}}
dbname = vimbadmin
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
password = {{password}}
hosts = 127.0.0.1
hosts = {{host}}
dbname = vimbadmin
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
password = {{password}}
hosts = 127.0.0.1
hosts = {{host}}
dbname = vimbadmin
table = mailbox
select_field = maildir

24
ee/core/variables.py

@ -13,6 +13,16 @@ class EEVariables():
config = configparser.ConfigParser()
config.read(os.path.expanduser("~")+'/.gitconfig')
# EasyEngine version
ee_version = "3.0.0"
# EasyEngine packages versions
ee_wp_cli = "0.18.0"
ee_adminer = "4.1.0"
ee_roundcube = "1.0.4"
ee_vimbadmin = "3.0.10"
# Current date and time of System
ee_date = datetime.datetime.now().strftime('%d%b%Y%H%M%S')
# EasyEngine core variables
@ -23,8 +33,10 @@ class EEVariables():
# Get FQDN of system
ee_fqdn = socket.getfqdn()
# EasyEngien default webroot path
ee_webroot = '/var/www/'
# PHP5 user
ee_php_user = 'www-data'
# Get git user name and EMail
@ -39,6 +51,18 @@ class EEVariables():
ee_ram = psutil.virtual_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
# Nginx repo and packages
if ee_platform_distro == 'Ubuntu':

Loading…
Cancel
Save