Improve broken symlink removal
This commit is contained in:
@@ -757,7 +757,7 @@ def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
|
||||
def setwebrootpermissions(self, webroot):
|
||||
Log.debug(self, "Setting up permissions")
|
||||
try:
|
||||
WOFileUtils.findBrokenSymlink(self, '/var/www/')
|
||||
WOFileUtils.findBrokenSymlink(self, f'{webroot}')
|
||||
WOFileUtils.chown(self, webroot, WOVar.wo_php_user,
|
||||
WOVar.wo_php_user, recursive=True)
|
||||
except Exception as e:
|
||||
|
||||
@@ -66,7 +66,7 @@ class WOSiteUpdateController(CementBaseController):
|
||||
action='store', nargs='?')),
|
||||
(['--subsiteof'],
|
||||
dict(help="create a subsite of a multisite install",
|
||||
action='store', nargs='?')),
|
||||
action='store', nargs='?')),
|
||||
(['-le', '--letsencrypt'],
|
||||
dict(help="configure letsencrypt ssl for the site",
|
||||
action='store' or 'store_const',
|
||||
@@ -327,7 +327,7 @@ class WOSiteUpdateController(CementBaseController):
|
||||
data["wpce"] = parent_site_info.cache_type == 'wpce'
|
||||
data["wpredis"] = parent_site_info.cache_type == 'wpredis'
|
||||
data["wpsubdir"] = parent_site_info.site_type == 'wpsubdir'
|
||||
data["wo_php"] = ("php" + parent_site_info.php_version).replace(".", "")
|
||||
data["wo_php"] = ("php" + parent_site_info.php_version).replace(".", "")
|
||||
data['subsite'] = True
|
||||
data['subsiteof_name'] = subsiteof_name
|
||||
data['subsiteof_webroot'] = parent_site_info.site_path
|
||||
@@ -722,15 +722,20 @@ class WOSiteUpdateController(CementBaseController):
|
||||
'hsts.conf.disabled'
|
||||
.format(wo_site_webroot))
|
||||
# find all broken symlinks
|
||||
sympath = "/var/www"
|
||||
sympath = (f'{wo_site_webroot}/conf')
|
||||
WOFileUtils.findBrokenSymlink(self, sympath)
|
||||
|
||||
elif (pargs.letsencrypt == "clean" or
|
||||
pargs.letsencrypt == "purge"):
|
||||
WOAcme.removeconf(self, wo_domain)
|
||||
# find all broken symlinks
|
||||
sympath = "/var/www"
|
||||
WOFileUtils.findBrokenSymlink(self, sympath)
|
||||
allsites = getAllsites(self)
|
||||
for site in allsites:
|
||||
if not site:
|
||||
pass
|
||||
sympath = "{0}/conf".format(site.site_path)
|
||||
WOFileUtils.findBrokenSymlink(self, sympath)
|
||||
|
||||
if not WOService.reload_service(self, 'nginx'):
|
||||
Log.error(self, "service nginx reload failed. "
|
||||
"check issues with `nginx -t` command")
|
||||
|
||||
@@ -253,8 +253,7 @@ class WOAcme:
|
||||
for dir in acmedir:
|
||||
if os.path.exists('{0}'.format(dir)):
|
||||
WOFileUtils.rm(self, '{0}'.format(dir))
|
||||
# find all broken symlinks
|
||||
WOFileUtils.findBrokenSymlink(self, "/var/www")
|
||||
|
||||
else:
|
||||
if os.path.islink("{0}".format(sslconf)):
|
||||
WOFileUtils.remove_symlink(self, "{0}".format(sslconf))
|
||||
|
||||
@@ -318,10 +318,9 @@ class WOFileUtils():
|
||||
"""
|
||||
links = []
|
||||
broken = []
|
||||
ignored_dirs = ['./.git', './htdocs']
|
||||
|
||||
for root, dirs, files in os.walk(sympath):
|
||||
if any(root.startswith(ignore_dir) for ignore_dir in ignored_dirs):
|
||||
if root.startswith('./.git'):
|
||||
# Ignore the .git directory.
|
||||
continue
|
||||
for filename in files:
|
||||
|
||||
Reference in New Issue
Block a user