Browse Source

Attempt to Fix #409, Python locale issue

bugfixes
gau1991 10 years ago
parent
commit
b3297c0c5e
  1. 19
      ee/cli/plugins/debug.py
  2. 7
      ee/cli/plugins/site.py
  3. 3
      ee/cli/plugins/site_functions.py
  4. 104
      ee/cli/plugins/stack.py
  5. 3
      ee/core/addswap.py
  6. 9
      ee/core/apt_repo.py
  7. 24
      ee/core/aptget.py
  8. 4
      ee/core/checkfqdn.py
  9. 2
      ee/core/fileutils.py
  10. 4
      ee/core/logwatch.py
  11. 85
      install

19
ee/cli/plugins/debug.py

@ -63,7 +63,7 @@ class EEDebugController(CementBaseController):
debug_address = ['0.0.0.0/0']
for ip_addr in debug_address:
if not ("debug_connection "+ip_addr in open('/etc/nginx/'
'nginx.conf').read()):
'nginx.conf', encoding='utf-8').read()):
Log.info(self, "Setting up Nginx debug connection"
" for "+ip_addr)
EEShellExec.cmd_exec(self, "sed -i \"/events {{/a\\ \\ \\ "
@ -79,7 +79,8 @@ class EEDebugController(CementBaseController):
# stop global debug
elif not self.start and not self.app.pargs.site_name:
if "debug_connection " in open('/etc/nginx/nginx.conf').read():
if "debug_connection " in open('/etc/nginx/nginx.conf',
encoding='utf-8').read():
Log.info(self, "Disabling Nginx debug connections")
EEShellExec.cmd_exec(self, "sed -i \"/debug_connection.*/d\""
" /etc/nginx/nginx.conf")
@ -146,7 +147,8 @@ class EEDebugController(CementBaseController):
data = dict(php="9001", debug="9001")
Log.info(self, 'Writting the Nginx debug configration to file '
'/etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'upstream.mustache', out=ee_nginx)
ee_nginx.close()
self.trigger_php = True
@ -165,7 +167,8 @@ class EEDebugController(CementBaseController):
data = dict(php="9000", debug="9001")
Log.debug(self, 'Writting the Nginx debug configration to file'
' /etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'upstream.mustache', out=ee_nginx)
ee_nginx.close()
self.trigger_php = True
@ -186,7 +189,8 @@ class EEDebugController(CementBaseController):
config.remove_option('global', 'include')
config['global']['log_level'] = 'debug'
config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf'
with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile:
with open('/etc/php5/fpm/php-fpm.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php5-FPM configuration into "
"/etc/php5/fpm/php-fpm.conf")
config.write(configfile)
@ -206,7 +210,8 @@ class EEDebugController(CementBaseController):
config.remove_option('global', 'include')
config['global']['log_level'] = 'notice'
config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf'
with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile:
with open('/etc/php5/fpm/php-fpm.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting php5 configuration into "
"/etc/php5/fpm/php-fpm.conf")
config.write(configfile)
@ -278,7 +283,7 @@ class EEDebugController(CementBaseController):
" grep true".format(wp_config)):
Log.info(self, "Starting WordPress debug")
open("{0}/htdocs/wp-content/debug.log".format(webroot),
'a').close()
encoding='utf-8', mode='a').close()
EEShellExec.cmd_exec(self, "chown {1}: {0}/htdocs/wp-"
"content/debug.log"
"".format(webroot,

7
ee/cli/plugins/site.py

@ -152,7 +152,8 @@ class EESiteController(CementBaseController):
.format(ee_domain)):
Log.info(self, "Display NGINX configuration for {0}"
.format(ee_domain))
f = open('/etc/nginx/sites-available/{0}'.format(ee_domain), "r")
f = open('/etc/nginx/sites-available/{0}'.format(ee_domain),
encoding='utf-8', mode='r')
text = f.read()
Log.info(self, Log.ENDC + text)
f.close()
@ -436,7 +437,7 @@ class EESiteCreateController(CementBaseController):
data = setupdatabase(self, data)
try:
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
'w')
encoding='utf-8', mode='w')
eedbconfig.write("<?php \ndefine('DB_NAME', '{0}');"
"\ndefine('DB_USER', '{1}'); "
"\ndefine('DB_PASSWORD', '{2}');"
@ -851,7 +852,7 @@ class EESiteUpdateController(CementBaseController):
data = setupdatabase(self, data)
try:
eedbconfig = open("{0}/ee-config.php".format(ee_site_webroot),
'w')
encoding='utf-8', mode='w')
eedbconfig.write("<?php \ndefine('DB_NAME', '{0}');"
"\ndefine('DB_USER', '{1}'); "
"\ndefine('DB_PASSWORD', '{2}');"

3
ee/cli/plugins/site_functions.py

@ -22,7 +22,8 @@ def setupdomain(self, data):
# write nginx config for file
try:
ee_site_nginx_conf = open('/etc/nginx/sites-available/{0}'
.format(ee_domain_name), 'w')
.format(ee_domain_name), encoding='utf-8',
mode='w')
self.app.render((data), 'virtualconf.mustache',
out=ee_site_nginx_conf)

104
ee/cli/plugins/stack.py

@ -109,7 +109,8 @@ class EEStackController(CementBaseController):
config = configparser.ConfigParser()
config.read_string(mysql_config)
Log.debug(self, 'Writting configuration into MySQL file')
with open(os.path.expanduser("~")+'/.my.cnf', 'w') as configfile:
with open(os.path.expanduser("~")+'/.my.cnf', encoding='utf-8',
mode='w') as configfile:
config.write(configfile)
if set(EEVariables.ee_nginx).issubset(set(apt_packages)):
@ -174,7 +175,8 @@ class EEStackController(CementBaseController):
data = dict(version=EEVariables.ee_version)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/ee-nginx.conf ')
ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf', 'w')
ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'nginx-core.mustache',
out=ee_nginx)
ee_nginx.close()
@ -182,20 +184,23 @@ class EEStackController(CementBaseController):
data = dict()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/blockips.conf')
ee_nginx = open('/etc/nginx/conf.d/blockips.conf', 'w')
ee_nginx = open('/etc/nginx/conf.d/blockips.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'blockips.mustache', out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/fastcgi.conf')
ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf', 'w')
ee_nginx = open('/etc/nginx/conf.d/fastcgi.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'fastcgi.mustache', out=ee_nginx)
ee_nginx.close()
data = dict(php="9000", debug="9001")
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/conf.d/upstream.conf ')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf', 'w')
ee_nginx = open('/etc/nginx/conf.d/upstream.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'upstream.mustache', out=ee_nginx)
ee_nginx.close()
@ -208,56 +213,64 @@ class EEStackController(CementBaseController):
data = dict(webroot=EEVariables.ee_webroot)
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/acl.conf')
ee_nginx = open('/etc/nginx/common/acl.conf', 'w')
ee_nginx = open('/etc/nginx/common/acl.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'acl.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/locations.conf')
ee_nginx = open('/etc/nginx/common/locations.conf', 'w')
ee_nginx = open('/etc/nginx/common/locations.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'locations.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/ php.conf')
ee_nginx = open('/etc/nginx/common/php.conf', 'w')
ee_nginx = open('/etc/nginx/common/php.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'php.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/w3tc.conf')
ee_nginx = open('/etc/nginx/common/w3tc.conf', 'w')
ee_nginx = open('/etc/nginx/common/w3tc.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'w3tc.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpcommon.conf')
ee_nginx = open('/etc/nginx/common/wpcommon.conf', 'w')
ee_nginx = open('/etc/nginx/common/wpcommon.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpcommon.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpfc.conf')
ee_nginx = open('/etc/nginx/common/wpfc.conf', 'w')
ee_nginx = open('/etc/nginx/common/wpfc.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpfc.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsc.conf')
ee_nginx = open('/etc/nginx/common/wpsc.conf', 'w')
ee_nginx = open('/etc/nginx/common/wpsc.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsc.mustache',
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpsubdir.conf')
ee_nginx = open('/etc/nginx/common/wpsubdir.conf', 'w')
ee_nginx = open('/etc/nginx/common/wpsubdir.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wpsubdir.mustache',
out=ee_nginx)
ee_nginx.close()
@ -267,7 +280,7 @@ class EEStackController(CementBaseController):
'file /etc/nginx/sites-available/'
'22222.conf')
ee_nginx = open('/etc/nginx/sites-available/22222.conf',
'w')
encoding='utf-8', mode='w')
self.app.render((data), '22222.mustache',
out=ee_nginx)
ee_nginx.close()
@ -369,7 +382,8 @@ class EEStackController(CementBaseController):
config['PHP']['upload_max_filesize'] = '100M'
config['PHP']['max_execution_time'] = '300'
config['PHP']['date.timezone'] = time.tzname[time.daylight]
with open('/etc/php5/fpm/php.ini', 'w') as configfile:
with open('/etc/php5/fpm/php.ini',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "Writting php configuration into "
"/etc/php5/fpm/php.ini")
config.write(configfile)
@ -381,7 +395,8 @@ class EEStackController(CementBaseController):
config.remove_option('global', 'include')
config['global']['log_level'] = 'notice'
config['global']['include'] = '/etc/php5/fpm/pool.d/*.conf'
with open('/etc/php5/fpm/php-fpm.conf', 'w') as configfile:
with open('/etc/php5/fpm/php-fpm.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting php5 configuration into "
"/etc/php5/fpm/php-fpm.conf")
config.write(configfile)
@ -399,7 +414,8 @@ class EEStackController(CementBaseController):
config['www']['request_terminate_timeout'] = '300'
config['www']['pm'] = 'ondemand'
config['www']['listen'] = '127.0.0.1:9000'
with open('/etc/php5/fpm/pool.d/www.conf', 'w') as configfile:
with open('/etc/php5/fpm/pool.d/www.conf',
encoding='utf-8', mode='w') as configfile:
Log.debug(self, "writting PHP5 configuration into "
"/etc/php5/fpm/pool.d/www.conf")
config.write(configfile)
@ -412,12 +428,14 @@ class EEStackController(CementBaseController):
config = configparser.ConfigParser()
config.read('/etc/php5/fpm/pool.d/debug.conf')
config['debug']['listen'] = '127.0.0.1:9001'
with open('/etc/php5/fpm/pool.d/debug.conf', 'w') as confifile:
with open('/etc/php5/fpm/pool.d/debug.conf',
encoding='utf-8', mode='w') as confifile:
Log.debug(self, "writting PHP5 configuration into "
"/etc/php5/fpm/pool.d/debug.conf")
config.write(confifile)
with open("/etc/php5/fpm/pool.d/debug.conf", "a") as myfile:
with open("/etc/php5/fpm/pool.d/debug.conf",
encoding='utf-8', mode='a') as myfile:
myfile.write("php_admin_value[xdebug.profiler_output_dir] "
"= /tmp/ \nphp_admin_value[xdebug.profiler_"
"output_name] = cachegrind.out.%p-%H-%R "
@ -434,9 +452,11 @@ class EEStackController(CementBaseController):
os.makedirs('{0}22222/htdocs/fpm/status/'
.format(EEVariables.ee_webroot))
open('{0}22222/htdocs/fpm/status/debug'
.format(EEVariables.ee_webroot), 'a').close()
.format(EEVariables.ee_webroot),
encoding='utf-8', mode='a').close()
open('{0}22222/htdocs/fpm/status/php'
.format(EEVariables.ee_webroot), 'a').close()
.format(EEVariables.ee_webroot),
encoding='utf-8', mode='a').close()
# Write info.php
if not os.path.exists('{0}22222/htdocs/php/'
@ -448,7 +468,8 @@ class EEStackController(CementBaseController):
.format(EEVariables.ee_webroot))
with open("{0}22222/htdocs/php/info.php"
.format(EEVariables.ee_webroot), "w") as myfile:
.format(EEVariables.ee_webroot),
encoding='utf-8', mode='w') as myfile:
myfile.write("<?php\nphpinfo();\n?>")
EEFileUtils.chown(self, "{0}22222"
@ -471,7 +492,8 @@ class EEStackController(CementBaseController):
if not os.path.isfile("/etc/mysql/my.cnf"):
config = ("[mysqld]\nwait_timeout = 30\n"
"interactive_timeout=60\nperformance_schema = 0")
config_file = open("/etc/mysql/my.cnf", "w")
config_file = open("/etc/mysql/my.cnf",
encoding='utf-8', mode='w')
config_file.write(config)
config_file.close()
else:
@ -505,7 +527,8 @@ class EEStackController(CementBaseController):
data = dict(email=EEVariables.ee_email)
Log.debug(self, "Writting configuration into file"
"/etc/dovecot/conf.d/99-ee.conf ")
ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf', 'w')
ee_dovecot = open('/etc/dovecot/conf.d/99-ee.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'dovecot.mustache', out=ee_dovecot)
ee_dovecot.close()
@ -595,7 +618,8 @@ class EEStackController(CementBaseController):
data = dict()
Log.debug(self, "Writting configuration of EasyEngine into "
"file /var/lib/dovecot/sieve/default.sieve")
ee_sieve = open('/var/lib/dovecot/sieve/default.sieve', 'w')
ee_sieve = open('/var/lib/dovecot/sieve/default.sieve',
encoding='utf-8', mode='w')
self.app.render((data), 'default-sieve.mustache',
out=ee_sieve)
ee_sieve.close()
@ -619,7 +643,7 @@ class EEStackController(CementBaseController):
Log.debug(self, "Configuring file /etc/amavis/conf.d"
"/15-content_filter_mode")
ee_amavis = open('/etc/amavis/conf.d/15-content_filter_mode',
'w')
encoding='utf-8', mode='w')
self.app.render((data), '15-content_filter_mode.mustache',
out=ee_amavis)
ee_amavis.close()
@ -634,7 +658,8 @@ class EEStackController(CementBaseController):
"$3 }\' | tr -d '\\n'").read()
data = dict(host=vm_host, password=vm_pass)
vm_config = open('/etc/amavis/conf.d/50-user', 'w')
vm_config = open('/etc/amavis/conf.d/50-user',
encoding='utf-8', mode='w')
self.app.render((data), '50-user.mustache', out=vm_config)
vm_config.close()
@ -670,7 +695,8 @@ class EEStackController(CementBaseController):
-o smtpd_client_connection_rate_limit=0
-o local_header_rewrite_clients=""")
with open("/etc/postfix/master.cf", "a") as am_config:
with open("/etc/postfix/master.cf",
encoding='utf-8', mode='a') as am_config:
am_config.write(amavis_master)
# Amavis ClamAV configuration
@ -795,7 +821,8 @@ class EEStackController(CementBaseController):
user='anemometer', password=chars)
ee_anemometer = open('{0}22222/htdocs/db/anemometer'
'/conf/config.inc.php'
.format(EEVariables.ee_webroot), 'w')
.format(EEVariables.ee_webroot),
encoding='utf-8', mode='w')
self.app.render((data), 'anemometer.mustache',
out=ee_anemometer)
ee_anemometer.close()
@ -861,7 +888,8 @@ class EEStackController(CementBaseController):
.format(EEVariables.ee_webroot))
ee_vmb = open('{0}22222/htdocs/vimbadmin/application/'
'configs/application.ini'
.format(EEVariables.ee_webroot), 'w')
.format(EEVariables.ee_webroot),
encoding='utf-8', mode='w')
self.app.render((data), 'vimbadmin.mustache',
out=ee_vmb)
ee_vmb.close()
@ -900,7 +928,7 @@ class EEStackController(CementBaseController):
host=EEVariables.ee_mysql_host)
vm_config = open('/etc/postfix/mysql/virtual_alias_maps.cf',
'w')
encoding='utf-8', mode='w')
self.app.render((data), 'virtual_alias_maps.mustache',
out=vm_config)
vm_config.close()
@ -909,7 +937,7 @@ class EEStackController(CementBaseController):
"/etc/postfix/mysql"
"/virtual_domains_maps.cf file")
vm_config = open('/etc/postfix/mysql/virtual_domains_maps.cf',
'w')
encoding='utf-8', mode='w')
self.app.render((data), 'virtual_domains_maps.mustache',
out=vm_config)
vm_config.close()
@ -918,7 +946,7 @@ class EEStackController(CementBaseController):
"/etc/postfix/mysql"
"/virtual_mailbox_maps.cf file")
vm_config = open('/etc/postfix/mysql/virtual_mailbox_maps.cf',
'w')
encoding='utf-8', mode='w')
self.app.render((data), 'virtual_mailbox_maps.mustache',
out=vm_config)
vm_config.close()
@ -926,7 +954,7 @@ class EEStackController(CementBaseController):
Log.debug(self, "Writting configration"
" to /etc/dovecot/dovecot-sql.conf.ext file ")
vm_config = open('/etc/dovecot/dovecot-sql.conf.ext',
'w')
encoding='utf-8', mode='w')
self.app.render((data), 'dovecot-sql-conf.mustache',
out=vm_config)
vm_config.close()
@ -935,7 +963,7 @@ class EEStackController(CementBaseController):
# Amvis settings
if set(EEVariables.ee_mailscanner).issubset(set(apt_packages)):
vm_config = open('/etc/amavis/conf.d/50-user',
'w')
encoding='utf-8', mode='w')
self.app.render((data), '50-user.mustache',
out=vm_config)
vm_config.close()
@ -1024,7 +1052,8 @@ class EEStackController(CementBaseController):
Log.debug(self, 'Writting the nginx configuration for '
'RoundCubemail')
ee_rc = open('/etc/nginx/sites-available/webmail.conf', 'w')
ee_rc = open('/etc/nginx/sites-available/webmail.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'virtualconf.mustache',
out=ee_rc)
ee_rc.close()
@ -1053,8 +1082,7 @@ class EEStackController(CementBaseController):
.format(EEVariables.ee_webroot)])
# Remove roundcube installer
EEService.reload_service(self, 'nginx')
EEFileUtils.remove(self, ["{0}roundcubemail"
"/htdocs/installer"
EEFileUtils.remove(self, ["{0}roundcubemail/htdocs/installer"
.format(EEVariables.ee_webroot)])
EEFileUtils.chown(self, '{0}roundcubemail'
.format(EEVariables.ee_webroot),

3
ee/core/addswap.py

@ -23,5 +23,6 @@ class EESwap():
EEFileUtils.chown(self, "/ee-swapfile", "root", "root")
EEFileUtils.chmod(self, "/ee-swapfile", 0o600)
EEShellExec.cmd_exec(self, "swapon /ee-swapfile")
with open("/etc/fstab", "a") as swap_file:
with open("/etc/fstab",
encoding='utf-8', mode='a') as swap_file:
swap_file.write("/ee-swapfile\tnone\tswap\tsw\t0 0")

9
ee/core/apt_repo.py

@ -26,12 +26,15 @@ class EERepo():
+ EEVariables().ee_repo_file)
try:
if not os.path.isfile(repo_file_path):
with open(repo_file_path, "a") as repofile:
with open(repo_file_path,
encoding='utf-8', mode='a') as repofile:
repofile.write(repo_url)
repofile.write('\n')
repofile.close()
elif repo_url not in open(repo_file_path).read():
with open(repo_file_path, "a") as repofile:
elif repo_url not in open(repo_file_path,
encoding='utf-8').read():
with open(repo_file_path,
encoding='utf-8', mode='a') as repofile:
repofile.write(repo_url)
repofile.write('\n')
repofile.close()

24
ee/core/aptget.py

@ -17,7 +17,8 @@ class EEAptGet():
apt_cache = apt.cache.Cache()
import sys
orig_out = sys.stdout
sys.stdout = open(self.app.config.get('log.logging', 'file'), 'a')
sys.stdout = open(self.app.config.get('log.logging', 'file'),
encoding='utf-8', mode='a')
apt_cache.update(apt.progress.text.AcquireProgress())
sys.stdout = orig_out
# success = (apt_cache.commit(
@ -43,7 +44,7 @@ class EEAptGet():
success = (apt_cache.commit(
apt.progress.text.AcquireProgress(),
apt.progress.base.InstallProgress()))
#apt_cache.close()
# apt_cache.close()
return success
except AttributeError as e:
Log.error(self, 'AttributeError: ' + str(e))
@ -64,11 +65,11 @@ class EEAptGet():
pkg = apt_cache[package_name.strip()]
if package_name.strip() in apt_cache:
if pkg.is_installed:
#apt_pkg.PkgSystemUnLock()
# apt_pkg.PkgSystemUnLock()
Log.debug(self, 'Trying to install a package that '
'is already installed (' +
package_name.strip() + ')')
#apt_cache.close()
# apt_cache.close()
return False
else:
try:
@ -78,7 +79,7 @@ class EEAptGet():
Log.debug(self, str(e))
Log.error(self, str(e))
else:
#apt_cache.close()
# apt_cache.close()
Log.error(self, 'Unknown package selected (' +
package_name.strip() + ')')
@ -88,19 +89,19 @@ class EEAptGet():
if apt_cache.install_count > 0:
try:
#apt_pkg.PkgSystemUnLock()
# apt_pkg.PkgSystemUnLock()
orig_out = sys.stdout
sys.stdout = open(self.app.config.get('log.logging', 'file'),
'a')
encoding='utf-8', mode='a')
result = apt_cache.commit(apt.progress.text.AcquireProgress(),
apt.progress.base.InstallProgress())
sys.stdout = orig_out
#apt_cache.close()
# apt_cache.close()
return result
except SystemError as e:
Log.debug(self, 'SystemError: ' + str(e))
Log.error(self, 'SystemError: ' + str(e))
#apt_cache.close()
# apt_cache.close()
except Exception as e:
Log.debug(self, str(e))
Log.error(self, str(e))
@ -145,7 +146,7 @@ class EEAptGet():
# apt_pkg.PkgSystemUnLock()
orig_out = sys.stdout
sys.stdout = open(self.app.config.get('log.logging', 'file'),
'a')
encoding='utf-8', mode='a')
result = apt_cache.commit(apt.progress.text.AcquireProgress(),
apt.progress.base.InstallProgress())
sys.stdout = orig_out
@ -165,7 +166,8 @@ class EEAptGet():
"""
try:
orig_out = sys.stdout
sys.stdout = open(self.app.config.get('log.logging', 'file'), 'a')
sys.stdout = open(self.app.config.get('log.logging', 'file'),
encoding='utf-8', mode='a')
apt_get.autoclean("-y")
sys.stdout = orig_out
except ErrorReturnCode as e:

4
ee/core/checkfqdn.py

@ -5,10 +5,10 @@ import os
def check_fqdn(self, ee_host):
"""FQDN check with EasyEngine, for mail server hostname must be FQDN"""
#ee_host=os.popen("hostname -f | tr -d '\n'").read()
# ee_host=os.popen("hostname -f | tr -d '\n'").read()
if '.' in ee_host:
EEVariables.ee_fqdn = ee_host
with open('/etc/hostname', 'w') as hostfile:
with open('/etc/hostname', encoding='utf-8', mode='w') as hostfile:
hostfile.write(ee_host)
EEShellExec.cmd_exec(self, "sed -i \"1i\\127.0.0.1 {0}\" /etc/hosts"

2
ee/core/fileutils.py

@ -196,7 +196,7 @@ class EEFileUtils():
Searches for string in file and returns the matched line.
"""
try:
for line in open(fnm):
for line in open(fnm, encoding='utf-8'):
if sstr in line:
return line
except OSError as e:

4
ee/core/logwatch.py

@ -96,7 +96,7 @@ class LogWatcher(object):
def tail(fname, window):
"""Read last N lines from file fname."""
try:
f = open(fname, 'r')
f = open(fname, encoding='utf-8', mode='r')
except IOError as err:
if err.errno == errno.ENOENT:
return []
@ -166,7 +166,7 @@ class LogWatcher(object):
def watch(self, fname):
try:
file = open(fname, "r")
file = open(fname, encoding='utf-8', mode='r')
fid = self.get_file_id(os.stat(fname))
except EnvironmentError as err:
if err.errno != errno.ENOENT:

85
install

@ -34,22 +34,20 @@ function ee_lib_error()
function install_dep()
{
# Execute: apt-get update
ee_lib_echo "Executing apt-get update"
apt-get update &>> /dev/null
# Install Python3 on users system
ee_lib_echo "Installing pre depedencies"
apt-get -y install python3 python3-apt python3-setuptools python3-dev sqlite3 git
if [[ $? -ne 0 ]]; then
ee_lib_echo_fail "Unable to install pre depedencies"
exit 1
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then
apt-get -y install python-software-properties software-properties-common python3 python3-apt python3-setuptools python3-dev sqlite3 git || ee_lib_error "Unable to install pre depedencies, exit status " 1
elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then
apt-get -y install graphviz python-software-properties python3 python3-apt python3-setuptools python3-dev sqlite3 git || ee_lib_error "Unable to pre depedencies, exit status " 1
fi
}
function sync_db()
{
mkdir /var/lib/ee
mkdir -p /var/lib/ee
# Sqlite query to create table `sites` into ee.db which will be used by ee.3.0
echo "CREATE TABLE sites (
@ -194,7 +192,7 @@ function update_to_ee3()
rm -rf /etc/bash_completion.d/ee /etc/easyengine/ /usr/share/easyengine/ /usr/local/lib/easyengine /usr/local/sbin/easyengine /usr/local/sbin/ee /var/log/easyengine
# Softlink to fix command not found error
ln -s /usr/local/bin/ee /usr/local/sbin/ee
ln -s /usr/local/bin/ee /usr/local/sbin/ee || ee_lib_error "Unable to create softlink to old EasyEngine, exit status " 1
}
@ -217,28 +215,73 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
# Execute: apt-get update
ee_lib_echo "Executing apt-get update"
apt-get update &>> /dev/null
# Checking lsb_release package
if [ ! -x /usr/bin/lsb_release ]; then
ee_lib_echo "Installing lsb-release, please wait..."
apt-get -y install lsb-release &>> /dev/null
fi
# Define variables for later use
readonly EE_LOG_DIR=/var/log/ee/
readonly EE_INSTALL_LOG=/var/log/ee/install.log
readonly EE_LINUX_DISTRO=$(lsb_release -i | awk '{print $3}')
readonly EE_DEBIAN_VERSION=$(lsb_release -sc)
# Checking linux distro
if [ "$EE_LINUX_DISTRO" != "Ubuntu" ] && [ "$EE_LINUX_DISTRO" != "Debian" ]; then
ee_lib_echo_fail "EasyEngine (ee) is made for Ubuntu and Debian only as of now"
ee_lib_echo_fail "You are free to fork EasyEngine (ee): https://github.com/rtCamp/easyengine/fork"
ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04 and Debian 7.x"
exit 100
fi
# EasyEngine (ee) only support all Ubuntu/Debian distro except the distro reached EOL
lsb_release -d | egrep -e "12.04|14.04|wheezy" &>> /dev/null
if [ "$?" -ne "0" ]; then
exit 100
fi
# Pre checks to avoid later screw ups
# Checking EasyEngine (ee) log directory
if [ ! -d $EE_LOG_DIR ]; then
ee_lib_echo "Creating EasyEngine log directory, please wait..."
mkdir -p $EE_LOG_DIR || ee_lib_error "Creating log directory failed, exit status " 1
# Create EasyEngine log files
touch /var/log/ee/{ee.log,install.log}
# Keep EasyEngine log folder accessible to root only
chmod -R 700 /var/log/ee || ee_lib_error "Unable to setup log directory permissions , exit status " 1
fi
if [ -f /usr/local/sbin/easyengine ]; then
# Check old EasyEngine version
ee version | grep ${old_ee_version} &>> /dev/null
if [[ $? -ne 0 ]]; then
ee_lib_echo "EasyEngine $old_ee_version not found on your system"
ee_lib_echo "Updating your EasyEngine to $old_ee_version for compability"
wget -q https://raw.githubusercontent.com/rtCamp/easyengine/old-stable/bin/update && bash update
ee_lib_echo "EasyEngine $old_ee_version not found on your system" | tee -ai $EE_INSTALL_LOG
ee_lib_echo "Updating your EasyEngine to $old_ee_version for compability" | tee -ai $EE_INSTALL_LOG
wget -q https://raw.githubusercontent.com/rtCamp/easyengine/old-stable/bin/update && bash update | tee -ai $EE_INSTALL_LOG
if [[ $? -ne 0 ]]; then
ee_lib_echo_info "Unbale to update EasyEngine2 to $old_ee_version"
exit 1
fi
fi
install_dep
sync_db
install_ee3
update_to_ee3
git_init
install_dep | tee -ai $EE_INSTALL_LOG
sync_db | tee -ai $EE_INSTALL_LOG
install_ee3 | tee -ai $EE_INSTALL_LOG
update_to_ee3 | tee -ai $EE_INSTALL_LOG
git_init | tee -ai $EE_INSTALL_LOG
elif [ ! -f /usr/local/bin/ee ]; then
install_dep
install_ee3
git_init
install_dep | tee -ai $EE_INSTALL_LOG
install_ee3 | tee -ai $EE_INSTALL_LOG
git_init | tee -ai $EE_INSTALL_LOG
else
ee_lib_echo_fail "EasyEngine 3 allready installed on your system"
ee_lib_echo_fail "EasyEngine 3 allready installed on your system" | tee -ai $EE_INSTALL_LOG
exit 1
fi

Loading…
Cancel
Save