Skip to content

Commit 11dbb04

Browse files
committed
cleaned up failure handling
Signed-off-by: Zen <[email protected]>
1 parent d794285 commit 11dbb04

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

ugrd/crypto/cryptsetup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '1.1.1'
2+
__version__ = '1.1.2'
33

44
_module_name = 'ugrd.crypto.cryptsetup'
55

@@ -101,7 +101,7 @@ def get_crypt_sources(self) -> list[str]:
101101

102102
check_command = [f'if [ -z "$CRYPTSETUP_SOURCE_{name}" ]; then',
103103
f' echo "Unable to resolve device source for {name}"',
104-
' exec /init',
104+
' _mount_fail',
105105
'else',
106106
f' echo "Resolved device source: $CRYPTSETUP_SOURCE_{name}"',
107107
'fi']

ugrd/fs/mounts.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '1.2.2'
2+
__version__ = '1.3.0'
33

44
from pathlib import Path
55

@@ -173,7 +173,7 @@ def mount_fstab(self) -> list[str]:
173173
else:
174174
out += ["read -sr"]
175175

176-
out += ["mount -a || (echo 'Failed to mount fstab' ; echo 'Loaded modules:' ; lsmod ; echo 'Block devices:' ; blkid ; mount_fstab)"]
176+
out += ["mount -a || (echo 'Failed to mount fstab' ; _mount_fail)"]
177177
return out
178178

179179

@@ -281,3 +281,19 @@ def clean_mounts(self) -> list[str]:
281281
return ['umount -a'] + umounts
282282

283283

284+
def _mount_fail(self) -> list[str]:
285+
"""
286+
Generates init lines to run if the mount fails
287+
"""
288+
return ['echo "Loaded modules:"',
289+
'lsmod',
290+
'echo "Block devices:"',
291+
'blkid',
292+
'echo "Mounts:"',
293+
'mount',
294+
'echo -e "\n\n\nPress enter to restart init\n\n\n"',
295+
'read -sr',
296+
'clean_mounts',
297+
'exec /init']
298+
299+

ugrd/fs/mounts.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mount_wait = false
3131
"ugrd.fs.mounts" = [ "mount_root" ]
3232

3333
[imports.functions]
34-
"ugrd.fs.mounts" = [ "clean_mounts" ]
34+
"ugrd.fs.mounts" = [ "clean_mounts", "_mount_fail" ]
3535

3636
[custom_parameters]
3737
mounts = "dict" # Add the mounts property, used to define the mounts to be made in the fstab

ugrd/initramfs_generator.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
__author__ = "desultory"
3+
__version__ = "0.11.2"
4+
35

46
from tomllib import load
57
from typing import Union
@@ -11,10 +13,6 @@
1113

1214
from ugrd.initramfs_dict import InitramfsConfigDict
1315

14-
from importlib.metadata import version
15-
16-
__version__ = version(__package__)
17-
1816

1917
@loggify
2018
class InitramfsGenerator:

0 commit comments

Comments
 (0)