Browse Source

shutil absolute path provided while creating wpsubdir site

bugfixes
harshadyeola 10 years ago
parent
commit
e33422970a
  1. 8
      ee/cli/plugins/site_functions.py
  2. 24
      ee/cli/plugins/stack.py
  3. 5
      ee/core/addswap.py
  4. 8
      ee/core/fileutils.py
  5. 9
      ee/core/shellexec.py

8
ee/cli/plugins/site_functions.py

@ -11,7 +11,6 @@ import string
import sys import sys
import getpass import getpass
import glob import glob
import pwd
def setupdomain(self, data): def setupdomain(self, data):
@ -197,7 +196,8 @@ def setupwordpress(self, data):
var2="" var2=""
"\n define('WPMU_ACCEL_REDIRECT', true);") "\n define('WPMU_ACCEL_REDIRECT', true);")
) )
EEFileUtils.mvfile(self, './wp-config.php', '../') EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
if not ee_wp_user: if not ee_wp_user:
ee_wp_user = EEVariables.ee_user ee_wp_user = EEVariables.ee_user
@ -309,8 +309,8 @@ def uninstallwp_plugin(self, plugin_name, data):
def setwebrootpermissions(self, webroot): def setwebrootpermissions(self, webroot):
Log.debug(self, "Setting up permissions") Log.debug(self, "Setting up permissions")
EEFileUtils.chown(self, webroot, pwd.getpwnam(EEVariables.ee_php_user)[2], EEFileUtils.chown(self, webroot, EEVariables.ee_php_user,
pwd.getpwnam(EEVariables.ee_php_user)[3], recursive=True) EEVariables.ee_php_user, recursive=True)
def sitebackup(self, data): def sitebackup(self, data):

24
ee/cli/plugins/stack.py

@ -531,9 +531,7 @@ class EEStackController(CementBaseController):
Log.debug(self, "Setting Privileges to dovecot ") Log.debug(self, "Setting Privileges to dovecot ")
# EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib" # EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib"
# "/dovecot") # "/dovecot")
EEFileUtils.chown(self, "/var/lig/dovecot", EEFileUtils.chown(self, "/var/lig/dovecot", 'vmail', 'vmail',
pwd.getpwnam('vmail')[2],
pwd.getpwnam('vmail')[3],
recursive=True) recursive=True)
EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/" EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/"
"default.sieve") "default.sieve")
@ -600,8 +598,8 @@ class EEStackController(CementBaseController):
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/db/pma') # '/var/www/22222/htdocs/db/pma')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '/var/www/22222',
pwd.getpwnam(EEVariables.ee_php_user)[2], EEVariables.ee_php_user,
pwd.getpwnam(EEVariables.ee_php_user)[3], EEVariables.ee_php_user,
recursive=True) recursive=True)
if any('/tmp/memcache.tar.gz' == x[1] if any('/tmp/memcache.tar.gz' == x[1]
for x in packages): for x in packages):
@ -614,8 +612,8 @@ class EEStackController(CementBaseController):
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/cache/memcache') # '/var/www/22222/htdocs/cache/memcache')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '/var/www/22222',
pwd.getpwnam(EEVariables.ee_php_user)[2], EEVariables.ee_php_user,
pwd.getpwnam(EEVariables.ee_php_user)[3], EEVariables.ee_php_user,
recursive=True) recursive=True)
if any('/tmp/webgrind.tar.gz' == x[1] if any('/tmp/webgrind.tar.gz' == x[1]
@ -634,8 +632,8 @@ class EEStackController(CementBaseController):
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data ' # EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/php/webgrind/') # '/var/www/22222/htdocs/php/webgrind/')
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '/var/www/22222',
pwd.getpwnam(EEVariables.ee_php_user)[2], EEVariables.ee_php_user,
pwd.getpwnam(EEVariables.ee_php_user)[3], EEVariables.ee_php_user,
recursive=True) recursive=True)
if any('/tmp/anemometer.tar.gz' == x[1] if any('/tmp/anemometer.tar.gz' == x[1]
@ -764,8 +762,8 @@ class EEStackController(CementBaseController):
"create") "create")
EEFileUtils.chown(self, '/var/www/22222', EEFileUtils.chown(self, '/var/www/22222',
pwd.getpwnam(EEVariables.ee_php_user)[2], EEVariables.ee_php_user,
pwd.getpwnam(EEVariables.ee_php_user)[3], EEVariables.ee_php_user,
recursive=True) recursive=True)
# Copy Dovecot and Postfix templates which are depednet on # Copy Dovecot and Postfix templates which are depednet on
@ -913,8 +911,8 @@ class EEStackController(CementBaseController):
EEFileUtils.remove(self, ["/var/www/roundcubemail" EEFileUtils.remove(self, ["/var/www/roundcubemail"
"/htdocs/installer"]) "/htdocs/installer"])
EEFileUtils.chown(self, '/var/www/roundcubemail', EEFileUtils.chown(self, '/var/www/roundcubemail',
pwd.getpwnam(EEVariables.ee_php_user)[2], EEVariables.ee_php_user,
pwd.getpwnam(EEVariables.ee_php_user)[3], EEVariables.ee_php_user,
recursive=True) recursive=True)
@expose(help="Install packages") @expose(help="Install packages")

5
ee/core/addswap.py

@ -3,7 +3,6 @@ from ee.core.variables import EEVariables
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.fileutils import EEFileUtils from ee.core.fileutils import EEFileUtils
from ee.core.logging import Log from ee.core.logging import Log
import pwd
class EESwap(): class EESwap():
@ -20,9 +19,7 @@ class EESwap():
EEShellExec.cmd_exec(self, "dd if=/dev/zero of=/ee-swapfile " EEShellExec.cmd_exec(self, "dd if=/dev/zero of=/ee-swapfile "
"bs=1024 count=1048k") "bs=1024 count=1048k")
EEShellExec.cmd_exec(self, "mkswap /ee-swapfile") EEShellExec.cmd_exec(self, "mkswap /ee-swapfile")
EEFileUtils.chown(self, "/ee-swapfile", EEFileUtils.chown(self, "/ee-swapfile", "root", "root")
pwd.getpwnam("root")[2],
pwd.getpwnam("root")[3])
EEFileUtils.chmod(self, "/ee-swapfile", 0o600) EEFileUtils.chmod(self, "/ee-swapfile", 0o600)
EEShellExec.cmd_exec(self, "swapon /ee-swapfile") EEShellExec.cmd_exec(self, "swapon /ee-swapfile")
with open("/etc/fstab", "a") as swap_file: with open("/etc/fstab", "a") as swap_file:

8
ee/core/fileutils.py

@ -4,6 +4,7 @@ import os
import sys import sys
import glob import glob
import shutil import shutil
import pwd
import fileinput import fileinput
from ee.core.logging import Log from ee.core.logging import Log
@ -74,8 +75,9 @@ class EEFileUtils():
def mvfile(self, src, dst): def mvfile(self, src, dst):
try: try:
Log.debug(self, "Moving file from {0} to {1}".format(src, dst))
shutil.move(src, dst) shutil.move(src, dst)
except shutil.Error as e: except Exception as e:
Log.debug(self, "{err}".format(err=e)) Log.debug(self, "{err}".format(err=e))
Log.error(self, 'Unable to move file from {0} to {1}' Log.error(self, 'Unable to move file from {0} to {1}'
.format(src, dst)) .format(src, dst))
@ -87,7 +89,9 @@ class EEFileUtils():
Log.debug(self, "{err}".format(err=e.strerror)) Log.debug(self, "{err}".format(err=e.strerror))
Log.error(self, 'Unable to Change Directory {0}'.format(path)) Log.error(self, 'Unable to Change Directory {0}'.format(path))
def chown(self, path, userid, groupid, recursive=False): def chown(self, path, user, group, recursive=False):
userid = pwd.getpwnam(user)[2]
groupid = pwd.getpwnam(user)[3]
try: try:
if recursive: if recursive:
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):

9
ee/core/shellexec.py

@ -24,7 +24,14 @@ class EEShellExec():
if errormsg: if errormsg:
Log.error(self, errormsg) Log.error(self, errormsg)
else: else:
Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to execute command {0}"
.format(command))
except Exception as e:
if errormsg:
Log.error(self, errormsg)
else:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to execute command {0}" Log.error(self, "Unable to execute command {0}"
.format(command)) .format(command))

Loading…
Cancel
Save