Browse Source

Better error handling

bugfixes
gau1991 10 years ago
parent
commit
1a6adcfd85
  1. 461
      ee/cli/plugins/stack.py

461
ee/cli/plugins/stack.py

@ -81,11 +81,16 @@ class EEStackController(CementBaseController):
"""Pre settings to do before installation packages""" """Pre settings to do before installation packages"""
if set(EEVariables.ee_postfix).issubset(set(apt_packages)): if set(EEVariables.ee_postfix).issubset(set(apt_packages)):
Log.debug(self, "Pre-seeding Postfix") Log.debug(self, "Pre-seeding Postfix")
EEShellExec.cmd_exec(self, "echo \"postfix postfix" try:
"/main_mailer_type string \'Internet Site\'\"" EEShellExec.cmd_exec(self, "echo \"postfix postfix"
" | debconf-set-selections") "/main_mailer_type string \'Internet Site"
EEShellExec.cmd_exec(self, "echo \"postfix postfix/mailname string" "\'\""
" $(hostname -f)\" | debconf-set-selections") " | debconf-set-selections")
EEShellExec.cmd_exec(self, "echo \"postfix postfix/mailname"
" string $(hostname -f)\" | "
"debconf-set-selections")
except CommandExecutionError as e:
Log.error(self, "Failed to intialize postfix package")
if set(EEVariables.ee_mysql).issubset(set(apt_packages)): if set(EEVariables.ee_mysql).issubset(set(apt_packages)):
Log.info(self, "Adding repository for MySQL, please wait ...") Log.info(self, "Adding repository for MySQL, please wait ...")
@ -105,20 +110,30 @@ class EEStackController(CementBaseController):
"mysql-server/root_password " "mysql-server/root_password "
"password \" | " "password \" | "
"debconf-set-selections") "debconf-set-selections")
EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 " try:
"mysql-server/root_password " EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 "
"password {chars}\" | " "mysql-server/root_password "
"debconf-set-selections".format(chars=chars), "password {chars}\" | "
log=False) "debconf-set-selections"
.format(chars=chars),
log=False)
except CommandExecutionError as e:
Log.error("Failed to initialize MySQL package")
Log.debug(self, "echo \"mariadb-server-10.0 " Log.debug(self, "echo \"mariadb-server-10.0 "
"mysql-server/root_password_again " "mysql-server/root_password_again "
"password \" | " "password \" | "
"debconf-set-selections") "debconf-set-selections")
EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 " try:
"mysql-server/root_password_again " EEShellExec.cmd_exec(self, "echo \"mariadb-server-10.0 "
"password {chars}\" | " "mysql-server/root_password_again "
"debconf-set-selections".format(chars=chars), "password {chars}\" | "
log=False) "debconf-set-selections"
.format(chars=chars),
log=False)
except CommandExecutionError as e:
Log.error("Failed to initialize MySQL package")
mysql_config = """ mysql_config = """
[client] [client]
user = root user = root
@ -152,17 +167,16 @@ class EEStackController(CementBaseController):
EERepo.add(self, ppa=EEVariables.ee_php_repo) EERepo.add(self, ppa=EEVariables.ee_php_repo)
if set(EEVariables.ee_mail).issubset(set(apt_packages)): if set(EEVariables.ee_mail).issubset(set(apt_packages)):
if EEVariables.ee_platform_codename == 'squeeze':
Log.info(self, "Adding repository for dovecot, "
"please wait ...")
EERepo.add(self, repo_url=EEVariables.ee_dovecot_repo)
Log.debug(self, 'Executing the command debconf-set-selections.') Log.debug(self, 'Executing the command debconf-set-selections.')
EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/" try:
"create-ssl-cert boolean yes\" " EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core/"
"| debconf-set-selections") "create-ssl-cert boolean yes\" "
EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core" "| debconf-set-selections")
"/ssl-cert-name string $(hostname -f)\"" EEShellExec.cmd_exec(self, "echo \"dovecot-core dovecot-core"
" | debconf-set-selections") "/ssl-cert-name string $(hostname -f)\""
" | debconf-set-selections")
except CommandExecutionError as e:
Log.error("Failed to initialize dovecot packages")
@expose(hide=True) @expose(hide=True)
def post_pref(self, apt_packages, packages): def post_pref(self, apt_packages, packages):
@ -174,8 +188,8 @@ class EEStackController(CementBaseController):
EEService.reload_service(self, 'postfix') EEService.reload_service(self, 'postfix')
if set(EEVariables.ee_nginx).issubset(set(apt_packages)): if set(EEVariables.ee_nginx).issubset(set(apt_packages)):
if ((not EEShellExec.cmd_exec(self, "grep -Hr EasyEngine " if ((not EEFileUtils.grep(self, "/etc/nginx", "EasyEngine"))
"/etc/nginx")) and os.path.isfile('/etc/nginx/nginx.conf')): and os.path.isfile('/etc/nginx/nginx.conf')):
nc = NginxConfig() nc = NginxConfig()
Log.debug(self, 'Loading file /etc/nginx/nginx.conf ') Log.debug(self, 'Loading file /etc/nginx/nginx.conf ')
nc.loadf('/etc/nginx/nginx.conf') nc.loadf('/etc/nginx/nginx.conf')
@ -307,11 +321,15 @@ class EEStackController(CementBaseController):
passwd = ''.join([random.choice passwd = ''.join([random.choice
(string.ascii_letters + string.digits) (string.ascii_letters + string.digits)
for n in range(6)]) for n in range(6)])
EEShellExec.cmd_exec(self, "printf \"easyengine:" try:
"$(openssl passwd -crypt " EEShellExec.cmd_exec(self, "printf \"easyengine:"
"{password} 2> /dev/null)\n\"" "$(openssl passwd -crypt "
"> /etc/nginx/htpasswd-ee 2>/dev/null" "{password} 2> /dev/null)\n\""
.format(password=passwd)) "> /etc/nginx/htpasswd-ee "
"2>/dev/null"
.format(password=passwd))
except CommandExecutionError as e:
Log.error(self, "Failed to save HTTP Auth")
# Create Symbolic link for 22222 # Create Symbolic link for 22222
EEFileUtils.create_symlink(self, ['/etc/nginx/' EEFileUtils.create_symlink(self, ['/etc/nginx/'
@ -351,40 +369,46 @@ class EEStackController(CementBaseController):
.format(EEVariables.ee_webroot)] .format(EEVariables.ee_webroot)]
) )
EEShellExec.cmd_exec(self, "openssl genrsa -out " try:
"{0}22222/cert/22222.key 2048" EEShellExec.cmd_exec(self, "openssl genrsa -out "
.format(EEVariables.ee_webroot)) "{0}22222/cert/22222.key 2048"
EEShellExec.cmd_exec(self, "openssl req -new -batch -subj " .format(EEVariables.ee_webroot))
"/commonName=127.0.0.1/ -key " EEShellExec.cmd_exec(self, "openssl req -new -batch "
"{0}22222/cert/22222.key " "-subj /commonName=127.0.0.1/ "
"-out {0}22222/cert/" "-key {0}22222/cert/22222.key "
"22222.csr" "-out {0}22222/cert/"
.format(EEVariables.ee_webroot)) "22222.csr"
.format(EEVariables.ee_webroot))
EEFileUtils.mvfile(self, "{0}22222/cert/22222.key"
.format(EEVariables.ee_webroot), EEFileUtils.mvfile(self, "{0}22222/cert/22222.key"
.format(EEVariables.ee_webroot),
"{0}22222/cert/"
"22222.key.org"
.format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "openssl rsa -in "
"{0}22222/cert/" "{0}22222/cert/"
"22222.key.org" "22222.key.org -out "
.format(EEVariables.ee_webroot)) "{0}22222/cert/22222.key"
.format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "openssl rsa -in " EEShellExec.cmd_exec(self, "openssl x509 -req -days "
"{0}22222/cert/" "3652 -in {0}22222/cert/"
"22222.key.org -out " "22222.csr -signkey {0}"
"{0}22222/cert/22222.key" "22222/cert/22222.key -out "
.format(EEVariables.ee_webroot)) "{0}22222/cert/22222.crt"
.format(EEVariables.ee_webroot))
except CommandExecutionError as e:
Log.error(self, "Failed to generate SSL for 22222")
EEShellExec.cmd_exec(self, "openssl x509 -req -days 3652 "
"-in {0}22222/cert/"
"22222.csr -signkey {0}"
"22222/cert/22222.key -out "
"{0}22222/cert/22222.crt"
.format(EEVariables.ee_webroot))
# Nginx Configation into GIT # Nginx Configation into GIT
EEGit.add(self, EEGit.add(self,
["/etc/nginx"], msg="Adding Nginx into Git") ["/etc/nginx"], msg="Adding Nginx into Git")
EEService.reload_service(self, 'nginx') EEService.reload_service(self, 'nginx')
self.msg = (self.msg + ["HTTP Auth User Name: easyengine"] self.msg = (self.msg + ["HTTP Auth User Name: easyengine"]
+ ["HTTP Auth Password : {0}".format(passwd)]) + ["HTTP Auth Password : {0}".format(passwd)])
if set(EEVariables.ee_php).issubset(set(apt_packages)): if set(EEVariables.ee_php).issubset(set(apt_packages)):
# Create log directories # Create log directories
if not os.path.exists('/var/log/php5/'): if not os.path.exists('/var/log/php5/'):
@ -521,32 +545,44 @@ class EEStackController(CementBaseController):
config_file.write(config) config_file.write(config)
config_file.close() config_file.close()
else: else:
EEShellExec.cmd_exec(self, "sed -i \"/#max_connections/a " try:
"wait_timeout = 30 \\n" EEShellExec.cmd_exec(self, "sed -i \"/#max_conn"
"interactive_timeout = 60 \\n" "ections/a wait_timeout = 30 \\n"
"performance_schema = 0\\n" "interactive_timeout = 60 \\n"
"query_cache_type = 1 \" " "performance_schema = 0\\n"
"/etc/mysql/my.cnf") "query_cache_type = 1 \" "
"/etc/mysql/my.cnf")
except CommandExecutionError as e:
Log.error(self, "Unable to update MySQL file")
EEGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git") EEGit.add(self, ["/etc/mysql"], msg="Adding MySQL into Git")
EEService.reload_service(self, 'mysql') EEService.reload_service(self, 'mysql')
if set(EEVariables.ee_mail).issubset(set(apt_packages)): if set(EEVariables.ee_mail).issubset(set(apt_packages)):
Log.debug(self, "Adding user") Log.debug(self, "Adding user")
EEShellExec.cmd_exec(self, "adduser --uid 5000 --home /var" try:
"/vmail --disabled-password --gecos ''" EEShellExec.cmd_exec(self, "adduser --uid 5000 --home /var"
" vmail") "/vmail --disabled-password --gecos "
EEShellExec.cmd_exec(self, "openssl req -new -x509 -days 3650 " "'' vmail")
"-nodes -subj /commonName={HOSTNAME}" except CommandExecutionError as e:
"/emailAddress={EMAIL} -out /etc/ssl" Log.error(self, "Unable to add vmail user for mail "
"/certs/dovecot." "server")
"pem -keyout /etc/ssl/private/dovecot.pem" try:
.format(HOSTNAME=EEVariables.ee_fqdn, EEShellExec.cmd_exec(self, "openssl req -new -x509 -days"
EMAIL=EEVariables.ee_email)) " 3650 "
"-nodes -subj /commonName={hostname}"
"/emailAddress={email} -out /etc/ssl"
"/certs/dovecot."
"pem -keyout "
"/etc/ssl/private/dovecot.pem"
.format(hostname=EEVariables.ee_fqdn,
email=EEVariables.ee_email))
except CommandExecutionError as e:
Log.error(self, "Unable to generate PEM key for "
"dovecot")
Log.debug(self, "Setting Privileges to " Log.debug(self, "Setting Privileges to "
"/etc/ssl/private/dovecot.pem file ") "/etc/ssl/private/dovecot.pem file ")
EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private" EEFileUtils.chmod(self, "/etc/ssl/private/dovecot.pem", "0600")
"/dovecot.pem")
# Custom Dovecot configuration by EasyEngine # Custom Dovecot configuration by EasyEngine
data = dict() data = dict()
@ -565,82 +601,95 @@ class EEStackController(CementBaseController):
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'dovecot.mustache', out=ee_dovecot) self.app.render((data), 'dovecot.mustache', out=ee_dovecot)
ee_dovecot.close() ee_dovecot.close()
try:
EEShellExec.cmd_exec(self, "sed -i \"s/\\!include " EEShellExec.cmd_exec(self, "sed -i \"s/\\!include "
"auth-system.conf.ext/#\\!include " "auth-system.conf.ext/#\\!include "
"auth-system.conf.ext/\" " "auth-system.conf.ext/\" "
"/etc/dovecot/conf.d/10-auth.conf") "/etc/dovecot/conf.d/10-auth.conf")
EEShellExec.cmd_exec(self, "sed -i \"s\'/etc/dovecot/" EEShellExec.cmd_exec(self, "sed -i \"s\'/etc/dovecot/"
"dovecot.pem\'/etc/ssl/certs/dovecot.pem" "dovecot.pem\'/etc/ssl/certs/"
"\'\" /etc/dovecot/conf.d/10-ssl.conf") "dovecot.pem"
EEShellExec.cmd_exec(self, "sed -i \"s\'/etc/dovecot/" "\'\" /etc/dovecot/conf.d/"
"private/dovecot.pem\'/etc/ssl/private" "10-ssl.conf")
"/dovecot.pem\'\" /etc/dovecot/conf.d/" EEShellExec.cmd_exec(self, "sed -i \"s\'/etc/dovecot/"
"10-ssl.conf") "private/dovecot.pem\'/etc/ssl/"
"private"
# Custom Postfix configuration needed with Dovecot "/dovecot.pem\'\" /etc/dovecot/"
# Changes in master.cf "conf.d/"
# TODO: Find alternative for sed in Python "10-ssl.conf")
EEShellExec.cmd_exec(self, "sed -i \'s/#submission/submission"
"/\'" # Custom Postfix configuration needed with Dovecot
" /etc/postfix/master.cf") # Changes in master.cf
EEShellExec.cmd_exec(self, "sed -i \'s/#smtps/smtps/\'" # TODO: Find alternative for sed in Python
" /etc/postfix/master.cf") EEShellExec.cmd_exec(self, "sed -i \'s/#submission/"
"submission/\'"
EEShellExec.cmd_exec(self, "postconf -e \"smtpd_sasl_type = " " /etc/postfix/master.cf")
"dovecot\"") EEShellExec.cmd_exec(self, "sed -i \'s/#smtps/smtps/\'"
EEShellExec.cmd_exec(self, "postconf -e \"smtpd_sasl_path = " " /etc/postfix/master.cf")
"private/auth\"")
EEShellExec.cmd_exec(self, "postconf -e \"" EEShellExec.cmd_exec(self, "postconf -e \"smtpd_sasl_type "
"smtpd_sasl_auth_enable = " "= dovecot\"")
"yes\"") EEShellExec.cmd_exec(self, "postconf -e \"smtpd_sasl_path "
EEShellExec.cmd_exec(self, "postconf -e \"" "= private/auth\"")
" smtpd_relay_restrictions =" EEShellExec.cmd_exec(self, "postconf -e \""
" permit_sasl_authenticated, " "smtpd_sasl_auth_enable = "
" permit_mynetworks, " "yes\"")
" reject_unauth_destination\"") EEShellExec.cmd_exec(self, "postconf -e \""
" smtpd_relay_restrictions ="
EEShellExec.cmd_exec(self, "postconf -e \"" " permit_sasl_authenticated, "
"smtpd_tls_mandatory_" " permit_mynetworks, "
"protocols = !SSLv2,!SSLv3\"") " reject_unauth_destination\"")
EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls_mandatory_"
"protocols = !SSLv2,!SSLv3\"") EEShellExec.cmd_exec(self, "postconf -e \""
EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_protocols " "smtpd_tls_mandatory_"
" = !SSLv2,!SSLv3\"") "protocols = !SSLv2,!SSLv3\"")
EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls_protocols " EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls_"
"= !SSLv2,!SSLv3\"") "mandatory_protocols = !SSLv2,"
EEShellExec.cmd_exec(self, "postconf -e \"mydestination " "!SSLv3\"")
"= localhost\"") EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls"
EEShellExec.cmd_exec(self, "postconf -e \"virtual_transport " "_protocols = !SSLv2,!SSLv3\"")
"= lmtp:unix:private/dovecot-lmtp\"") EEShellExec.cmd_exec(self, "postconf -e \"smtp_tls"
EEShellExec.cmd_exec(self, "postconf -e \"virtual_uid_maps " "_protocols = !SSLv2,!SSLv3\"")
"= static:5000\"") EEShellExec.cmd_exec(self, "postconf -e \"mydestination "
EEShellExec.cmd_exec(self, "postconf -e \"virtual_gid_maps " "= localhost\"")
"= static:5000\"") EEShellExec.cmd_exec(self, "postconf -e \"virtual"
EEShellExec.cmd_exec(self, "postconf -e \"" "_transport "
" virtual_mailbox_domains = " "= lmtp:unix:private/dovecot-lmtp\"")
"mysql:/etc/postfix/mysql/virtual_" EEShellExec.cmd_exec(self, "postconf -e \"virtual_uid_"
"domains_maps.cf\"") "maps = static:5000\"")
EEShellExec.cmd_exec(self, "postconf -e \"virtual_mailbox_maps" EEShellExec.cmd_exec(self, "postconf -e \"virtual_gid_"
" = mysql:/etc/postfix/mysql/virtual_" "maps = static:5000\"")
"mailbox_maps.cf\"") EEShellExec.cmd_exec(self, "postconf -e \""
EEShellExec.cmd_exec(self, "postconf -e \"virtual_alias_maps " " virtual_mailbox_domains = "
"= mysql:/etc/postfix/mysql/virtual_" "mysql:/etc/postfix/mysql/virtual_"
"alias_maps.cf\"") "domains_maps.cf\"")
EEShellExec.cmd_exec(self, "openssl req -new -x509 -days " EEShellExec.cmd_exec(self, "postconf -e \"virtual_mailbox"
" 3650 -nodes -subj /commonName=" "_maps"
"{HOSTNAME}/emailAddress={EMAIL}" " = mysql:/etc/postfix/mysql/virtual_"
" -out /etc/ssl/certs/postfix.pem" "mailbox_maps.cf\"")
" -keyout /etc/ssl/private/postfix.pem" EEShellExec.cmd_exec(self, "postconf -e \"virtual_alias"
.format(HOSTNAME=EEVariables.ee_fqdn, "_maps "
EMAIL=EEVariables.ee_email)) "= mysql:/etc/postfix/mysql/virtual_"
EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private" "alias_maps.cf\"")
"/postfix.pem") EEShellExec.cmd_exec(self, "openssl req -new -x509 -days "
EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_cert_file " " 3650 -nodes -subj /commonName="
"= /etc/ssl/certs/postfix.pem\"") "{hostname}/emailAddress={email}"
EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_key_file " " -out /etc/ssl/certs/postfix.pem"
"= /etc/ssl/private/postfix.pem\"") " -keyout /etc/ssl/private/"
"postfix.pem"
.format(hostname=EEVariables.ee_fqdn,
email=EEVariables.ee_email))
EEShellExec.cmd_exec(self, "chmod 0600 /etc/ssl/private"
"/postfix.pem")
EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_cert_"
"file = /etc/ssl/certs/postfix.pem\"")
EEShellExec.cmd_exec(self, "postconf -e \"smtpd_tls_key_"
"file = /etc/ssl/private/"
"postfix.pem\"")
except CommandExecutionError as e:
Log.Error(self, "Failed to update Dovecot configuration")
# Sieve configuration # Sieve configuration
if not os.path.exists('/var/lib/dovecot/sieve/'): if not os.path.exists('/var/lib/dovecot/sieve/'):
@ -664,8 +713,12 @@ class EEStackController(CementBaseController):
# "/dovecot") # "/dovecot")
EEFileUtils.chown(self, "/var/lib/dovecot", 'vmail', 'vmail', EEFileUtils.chown(self, "/var/lib/dovecot", 'vmail', 'vmail',
recursive=True) recursive=True)
EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/" try:
"default.sieve") EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/"
"/sieve/default.sieve")
except CommandExecutionError as e:
raise SiteError("Failed to compile default.sieve")
EEGit.add(self, ["/etc/postfix", "/etc/dovecot"], EEGit.add(self, ["/etc/postfix", "/etc/dovecot"],
msg="Installed mail server") msg="Installed mail server")
EEService.restart_service(self, 'dovecot') EEService.restart_service(self, 'dovecot')
@ -698,13 +751,17 @@ class EEStackController(CementBaseController):
vm_config.close() vm_config.close()
# Amavis postfix configuration # Amavis postfix configuration
EEShellExec.cmd_exec(self, "postconf -e \"content_filter = " try:
"smtp-amavis:[127.0.0.1]:10024\"") EEShellExec.cmd_exec(self, "postconf -e \"content_filter ="
EEShellExec.cmd_exec(self, "sed -i \"s/1 pickup/1 " " smtp-amavis:[127.0.0.1]:10024\"")
"pickup" EEShellExec.cmd_exec(self, "sed -i \"s/1 pickup/1 "
"\\n -o content_filter=\\n -o" " pickup"
" receive_override_options=no_header_body" "\\n -o content_filter=\\n "
"_checks/\" /etc/postfix/master.cf") " -o receive_override_options="
"no_header_body"
"_checks/\" /etc/postfix/master.cf")
except CommandExecutionError as e:
raise SiteError("Failed to update Amavis-Postfix config")
amavis_master = ("""smtp-amavis unix - - n - 2 smtp amavis_master = ("""smtp-amavis unix - - n - 2 smtp
-o smtp_data_done_timeout=1200 -o smtp_data_done_timeout=1200
@ -733,19 +790,22 @@ class EEStackController(CementBaseController):
encoding='utf-8', mode='a') as am_config: encoding='utf-8', mode='a') as am_config:
am_config.write(amavis_master) am_config.write(amavis_master)
# Amavis ClamAV configuration try:
Log.debug(self, "Adding new user clamav amavis") # Amavis ClamAV configuration
EEShellExec.cmd_exec(self, "adduser clamav amavis") Log.debug(self, "Adding new user clamav amavis")
Log.debug(self, "Adding new user amavis clamav") EEShellExec.cmd_exec(self, "adduser clamav amavis")
EEShellExec.cmd_exec(self, "adduser amavis clamav") Log.debug(self, "Adding new user amavis clamav")
Log.debug(self, "Setting Privileges to /var/lib/amavis/tmp ") EEShellExec.cmd_exec(self, "adduser amavis clamav")
EEShellExec.cmd_exec(self, "chmod -R 775 /var/lib/amavis/tmp") Log.debug(self, "Setting Privileges to /var/lib/amavis"
"/tmp")
# Update ClamAV database EEFileUtils.chmod(self, "/var/lib/amavis/tmp", "755")
Log.debug(self, "Updating database")
EEShellExec.cmd_exec(self, "freshclam") # Update ClamAV database
Log.debug(self, "Restarting clamav-daemon service") Log.debug(self, "Updating database")
EEShellExec.cmd_exec(self, "service clamav-daemon restart") EEShellExec.cmd_exec(self, "freshclam")
except CommandExecutionError as e:
raise SiteError(" Unable to update ClamAV-Amavis config")
EEGit.add(self, ["/etc/amavis"], msg="Adding Amavis into Git") EEGit.add(self, ["/etc/amavis"], msg="Adding Amavis into Git")
EEService.restart_service(self, 'dovecot') EEService.restart_service(self, 'dovecot')
EEService.reload_service(self, 'postfix') EEService.reload_service(self, 'postfix')
@ -754,7 +814,8 @@ class EEStackController(CementBaseController):
if len(packages): if len(packages):
if any('/usr/bin/wp' == x[1] for x in packages): if any('/usr/bin/wp' == x[1] for x in packages):
Log.debug(self, "Setting Privileges to /usr/bin/wp file ") Log.debug(self, "Setting Privileges to /usr/bin/wp file ")
EEShellExec.cmd_exec(self, "chmod +x /usr/bin/wp") EEFileUtils.chmod(self, "/usr/bin/wp", 007)
if any('/tmp/pma.tar.gz' == x[1] if any('/tmp/pma.tar.gz' == x[1]
for x in packages): for x in packages):
EEExtract.extract(self, '/tmp/pma.tar.gz', '/tmp/') EEExtract.extract(self, '/tmp/pma.tar.gz', '/tmp/')
@ -837,9 +898,13 @@ class EEStackController(CementBaseController):
'{0}22222/htdocs/db/anemometer' '{0}22222/htdocs/db/anemometer'
.format(EEVariables.ee_webroot)) .format(EEVariables.ee_webroot))
chars = ''.join(random.sample(string.ascii_letters, 8)) chars = ''.join(random.sample(string.ascii_letters, 8))
EEShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db' try:
'/anemometer/install.sql' EEShellExec.cmd_exec(self, 'mysql < {0}22222/htdocs/db'
.format(EEVariables.ee_webroot)) '/anemometer/install.sql'
.format(EEVariables.ee_webroot))
except CommandExecutionError as e:
raise SiteError("Unable to import Anemometer database")
EEMysql.execute(self, 'grant select on *.* to \'anemometer\'' EEMysql.execute(self, 'grant select on *.* to \'anemometer\''
'@\'{0}\''.format(self.app.config.get('mysql', '@\'{0}\''.format(self.app.config.get('mysql',
'grant-host'))) 'grant-host')))
@ -866,8 +931,7 @@ class EEStackController(CementBaseController):
if any('/usr/bin/pt-query-advisor' == x[1] if any('/usr/bin/pt-query-advisor' == x[1]
for x in packages): for x in packages):
EEShellExec.cmd_exec(self, "chmod +x /usr/bin/pt-query" EEFileUtils.chmod(self, "/usr/bin/pt-query-advisor", 007)
"-advisor")
if any('/tmp/vimbadmin.tar.gz' == x[1] for x in packages): if any('/tmp/vimbadmin.tar.gz' == x[1] for x in packages):
# Extract ViMbAdmin # Extract ViMbAdmin
@ -889,18 +953,23 @@ class EEStackController(CementBaseController):
# Donwload composer and install ViMbAdmin # Donwload composer and install ViMbAdmin
Log.debug(self, "Downloading composer " Log.debug(self, "Downloading composer "
"https://getcomposer.org/installer | php ") "https://getcomposer.org/installer | php ")
EEShellExec.cmd_exec(self, "cd {0}22222/htdocs" try:
"/vimbadmin; curl" EEShellExec.cmd_exec(self, "cd {0}22222/htdocs"
" -sS https://getcomposer.org/installer |" "/vimbadmin; curl"
" php".format(EEVariables.ee_webroot)) " -sS https://getcomposer.org/"
Log.debug(self, "installation of composer") "installer |"
EEShellExec.cmd_exec(self, "cd {0}22222/htdocs" " php".format(EEVariables.ee_webroot))
"/vimbadmin && " Log.debug(self, "Installating of composer")
"php composer.phar install --prefer-dist" EEShellExec.cmd_exec(self, "cd {0}22222/htdocs"
" --no-dev && rm -f {1}22222/htdocs" "/vimbadmin && "
"/vimbadmin/composer.phar" "php composer.phar install "
.format(EEVariables.ee_webroot, "--prefer-dist"
EEVariables.ee_webroot)) " --no-dev && rm -f {1}22222/htdocs"
"/vimbadmin/composer.phar"
.format(EEVariables.ee_webroot,
EEVariables.ee_webroot))
except CommandExecutionError as e:
raise SiteError("Failed to setup ViMbAdmin")
# Configure vimbadmin database # Configure vimbadmin database
vm_passwd = ''.join(random.sample(string.ascii_letters, 8)) vm_passwd = ''.join(random.sample(string.ascii_letters, 8))
@ -945,9 +1014,13 @@ class EEStackController(CementBaseController):
"{0}22222/htdocs/vimbadmin/bin" "{0}22222/htdocs/vimbadmin/bin"
"/doctrine2-cli.php orm:schema-tool:" "/doctrine2-cli.php orm:schema-tool:"
"create".format(EEVariables.ee_webroot)) "create".format(EEVariables.ee_webroot))
EEShellExec.cmd_exec(self, "{0}22222/htdocs/vimbadmin" try:
"/bin/doctrine2-cli.php orm:schema-tool:" EEShellExec.cmd_exec(self, "{0}22222/htdocs/vimbadmin"
"create".format(EEVariables.ee_webroot)) "/bin/doctrine2-cli.php "
"orm:schema-tool:create"
.format(EEVariables.ee_webroot))
except CommandExecutionError as e:
raise SiteError("Unable to create ViMbAdmin schema")
EEFileUtils.chown(self, '{0}22222' EEFileUtils.chown(self, '{0}22222'
.format(EEVariables.ee_webroot), .format(EEVariables.ee_webroot),

Loading…
Cancel
Save