Skip to content

Commit

Permalink
fixup! Add a preliminary checker to ensure the mount points in /etc/f…
Browse files Browse the repository at this point in the history
…stab are in the correct order
  • Loading branch information
Mikhail Sandakov committed Nov 26, 2024
1 parent 3b10ded commit fc2bdf6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pleskdistup/actions/common_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,10 @@ def _do_check(self) -> bool:
# Might be a problem, but it is not something we checking in scope of this check
return True

missorderings = mounts.get_fstab_configuration_misorderings(self.FSTAB_PATH)
misorderings = mounts.get_fstab_configuration_misorderings(self.FSTAB_PATH)

if len(missorderings) == 0:
if len(misorderings) == 0:
return True

self.description = self.description.format("\n\t- ".join([f"Mount point {mount_point} should be placed after {parent_dir}" for parent_dir, mount_point in missorderings]))
self.description = self.description.format("\n\t- ".join([f"Mount point {mount_point} should be placed after {parent_dir}" for parent_dir, mount_point in misorderings]))
return False
8 changes: 4 additions & 4 deletions pleskdistup/common/src/mounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ def get_fstab_configuration_misorderings(configpath: str) -> typing.List[typing.
mount_point = line.split()[1]
mount_points_order[mount_point] = iter

missorderings = []
misorderings = []
for mount_point in mount_points_order.keys():
if mount_point == "/":
continue

if mount_points_order["/"] > mount_points_order[mount_point]:
missorderings.append(("/", mount_point))
misorderings.append(("/", mount_point))

leading_paths = mount_point.split("/")[:-1]
for i in range(1, len(leading_paths) + 1):
parent_dir = "/".join(leading_paths[:i])
if parent_dir in mount_points_order and mount_points_order[parent_dir] > mount_points_order[mount_point]:
missorderings.append((parent_dir, mount_point))
misorderings.append((parent_dir, mount_point))

return missorderings
return misorderings

0 comments on commit fc2bdf6

Please sign in to comment.