|
1 | 1 | __author__ = 'desultory' |
2 | | -__version__ = '1.2.0' |
| 2 | +__version__ = '1.2.1' |
3 | 3 |
|
4 | 4 | from pathlib import Path |
5 | 5 |
|
@@ -39,6 +39,8 @@ def _process_mounts_multi(self, mount_name: str, mount_config) -> None: |
39 | 39 |
|
40 | 40 | # Set defaults |
41 | 41 | mount_config['destination'] = Path(mount_config.get('destination', mount_name)) |
| 42 | + if not mount_config['destination'].is_absolute(): |
| 43 | + mount_config['destination'] = '/' / mount_config['destination'] |
42 | 44 | mount_config['base_mount'] = mount_config.get('base_mount', False) |
43 | 45 | mount_config['options'] = set(mount_config.get('options', '')) |
44 | 46 |
|
@@ -163,18 +165,14 @@ def mount_fstab(self) -> list[str]: |
163 | 165 | out += ["read -sr"] |
164 | 166 |
|
165 | 167 | out += ["mount -a || (echo 'Failed to mount fstab. Please ensure mounts are made and then exit.' && bash)"] |
166 | | - |
167 | 168 | return out |
168 | 169 |
|
169 | 170 |
|
170 | 171 | def _get_mounts_source_device(self, mountpoint: str) -> Path: |
171 | 172 | """ |
172 | 173 | Returns the source device of a mountpoint on /proc/mounts |
173 | 174 | """ |
174 | | - # Make the mount a string and ensure it starts with a / |
175 | 175 | mountpoint = str(mountpoint) |
176 | | - if not mountpoint.startswith('/') and not mountpoint.startswith(' /'): |
177 | | - mountpoint = '/' + mountpoint |
178 | 176 |
|
179 | 177 | self.logger.debug("Getting source device path for: %s" % mountpoint) |
180 | 178 | # Add space padding to the mountpoint |
@@ -265,6 +263,12 @@ def clean_mounts(self) -> list[str]: |
265 | 263 | """ |
266 | 264 | Generates init lines to unmount all mounts |
267 | 265 | """ |
| 266 | + umounts = [f"umount {mount['destination']}" for mount in self.config_dict['mounts'].values() if not mount.get('skip_unmount')] |
| 267 | + # Ensure /proc is unmounted last |
| 268 | + if 'umount /proc' in umounts and umounts[-1] != 'umount /proc': |
| 269 | + umounts.remove('umount /proc') |
| 270 | + umounts.append('umount /proc') |
| 271 | + |
268 | 272 | return [f"umount {mount['destination']}" for mount in self.config_dict['mounts'].values() if not mount.get('skip_unmount')] |
269 | 273 |
|
270 | 274 |
|
0 commit comments