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 getpass
import glob
import pwd
def setupdomain(self, data):
@ -197,7 +196,8 @@ def setupwordpress(self, data):
var2=""
"\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:
ee_wp_user = EEVariables.ee_user
@ -309,8 +309,8 @@ def uninstallwp_plugin(self, plugin_name, data):
def setwebrootpermissions(self, webroot):
Log.debug(self, "Setting up permissions")
EEFileUtils.chown(self, webroot, pwd.getpwnam(EEVariables.ee_php_user)[2],
pwd.getpwnam(EEVariables.ee_php_user)[3], recursive=True)
EEFileUtils.chown(self, webroot, EEVariables.ee_php_user,
EEVariables.ee_php_user, recursive=True)
def sitebackup(self, data):

24
ee/cli/plugins/stack.py

@ -531,9 +531,7 @@ class EEStackController(CementBaseController):
Log.debug(self, "Setting Privileges to dovecot ")
# EEShellExec.cmd_exec(self, "chown -R vmail:vmail /var/lib"
# "/dovecot")
EEFileUtils.chown(self, "/var/lig/dovecot",
pwd.getpwnam('vmail')[2],
pwd.getpwnam('vmail')[3],
EEFileUtils.chown(self, "/var/lig/dovecot", 'vmail', 'vmail',
recursive=True)
EEShellExec.cmd_exec(self, "sievec /var/lib/dovecot/sieve/"
"default.sieve")
@ -600,8 +598,8 @@ class EEStackController(CementBaseController):
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/db/pma')
EEFileUtils.chown(self, '/var/www/22222',
pwd.getpwnam(EEVariables.ee_php_user)[2],
pwd.getpwnam(EEVariables.ee_php_user)[3],
EEVariables.ee_php_user,
EEVariables.ee_php_user,
recursive=True)
if any('/tmp/memcache.tar.gz' == x[1]
for x in packages):
@ -614,8 +612,8 @@ class EEStackController(CementBaseController):
# EEShellExec.cmd_exec(self, 'chown -R www-data:www-data '
# '/var/www/22222/htdocs/cache/memcache')
EEFileUtils.chown(self, '/var/www/22222',
pwd.getpwnam(EEVariables.ee_php_user)[2],
pwd.getpwnam(EEVariables.ee_php_user)[3],
EEVariables.ee_php_user,
EEVariables.ee_php_user,
recursive=True)
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 '
# '/var/www/22222/htdocs/php/webgrind/')
EEFileUtils.chown(self, '/var/www/22222',
pwd.getpwnam(EEVariables.ee_php_user)[2],
pwd.getpwnam(EEVariables.ee_php_user)[3],
EEVariables.ee_php_user,
EEVariables.ee_php_user,
recursive=True)
if any('/tmp/anemometer.tar.gz' == x[1]
@ -764,8 +762,8 @@ class EEStackController(CementBaseController):
"create")
EEFileUtils.chown(self, '/var/www/22222',
pwd.getpwnam(EEVariables.ee_php_user)[2],
pwd.getpwnam(EEVariables.ee_php_user)[3],
EEVariables.ee_php_user,
EEVariables.ee_php_user,
recursive=True)
# Copy Dovecot and Postfix templates which are depednet on
@ -913,8 +911,8 @@ class EEStackController(CementBaseController):
EEFileUtils.remove(self, ["/var/www/roundcubemail"
"/htdocs/installer"])
EEFileUtils.chown(self, '/var/www/roundcubemail',
pwd.getpwnam(EEVariables.ee_php_user)[2],
pwd.getpwnam(EEVariables.ee_php_user)[3],
EEVariables.ee_php_user,
EEVariables.ee_php_user,
recursive=True)
@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.fileutils import EEFileUtils
from ee.core.logging import Log
import pwd
class EESwap():
@ -20,9 +19,7 @@ class EESwap():
EEShellExec.cmd_exec(self, "dd if=/dev/zero of=/ee-swapfile "
"bs=1024 count=1048k")
EEShellExec.cmd_exec(self, "mkswap /ee-swapfile")
EEFileUtils.chown(self, "/ee-swapfile",
pwd.getpwnam("root")[2],
pwd.getpwnam("root")[3])
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:

8
ee/core/fileutils.py

@ -4,6 +4,7 @@ import os
import sys
import glob
import shutil
import pwd
import fileinput
from ee.core.logging import Log
@ -74,8 +75,9 @@ class EEFileUtils():
def mvfile(self, src, dst):
try:
Log.debug(self, "Moving file from {0} to {1}".format(src, dst))
shutil.move(src, dst)
except shutil.Error as e:
except Exception as e:
Log.debug(self, "{err}".format(err=e))
Log.error(self, 'Unable to move file from {0} to {1}'
.format(src, dst))
@ -87,7 +89,9 @@ class EEFileUtils():
Log.debug(self, "{err}".format(err=e.strerror))
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:
if recursive:
for root, dirs, files in os.walk(path):

9
ee/core/shellexec.py

@ -24,7 +24,14 @@ class EEShellExec():
if errormsg:
Log.error(self, errormsg)
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}"
.format(command))

Loading…
Cancel
Save