Improve Discord logging for errors and further fix UEFI mount robustness
This commit is contained in:
@@ -35,6 +35,14 @@ def log_to_discord(level: str, message: str, module: str = "general"):
|
|||||||
with QUEUE_LOCK:
|
with QUEUE_LOCK:
|
||||||
FULL_LOG.append(log_entry)
|
FULL_LOG.append(log_entry)
|
||||||
|
|
||||||
|
# If it's an error, try to send it immediately as a message too
|
||||||
|
if level.upper() in ["ERROR", "CRITICAL"]:
|
||||||
|
threading.Thread(
|
||||||
|
target=send_discord_message,
|
||||||
|
args=(f"**[{level.upper()}] [{module}]** {message[:1900]}",),
|
||||||
|
daemon=True
|
||||||
|
).start()
|
||||||
|
|
||||||
|
|
||||||
def flush_logs():
|
def flush_logs():
|
||||||
# Deprecated: No partial flushing anymore
|
# Deprecated: No partial flushing anymore
|
||||||
|
|||||||
@@ -97,9 +97,14 @@ def mount_pseudo_fs(mount_root):
|
|||||||
target = os.path.join(mount_root, "sys/firmware/efi/efivars")
|
target = os.path.join(mount_root, "sys/firmware/efi/efivars")
|
||||||
os.makedirs(target, exist_ok=True)
|
os.makedirs(target, exist_ok=True)
|
||||||
try:
|
try:
|
||||||
# Use --bind if already mounted, or mount -t efivarfs
|
# Try bind mount first
|
||||||
run_command(["mount", "--bind", efivars_path, target])
|
run_command(["mount", "--bind", efivars_path, target])
|
||||||
mounted_paths.append(target)
|
mounted_paths.append(target)
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
# Fallback to direct mount
|
||||||
|
run_command(["mount", "-t", "efivarfs", "efivarfs", target])
|
||||||
|
mounted_paths.append(target)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to mount efivarfs: {e}")
|
logger.warning(f"Failed to mount efivarfs: {e}")
|
||||||
|
|
||||||
@@ -287,8 +292,17 @@ def configure_system(mount_root, partition_info, user_info=None, disk_device=Non
|
|||||||
f.write('GRUB_TIMEOUT=5\nGRUB_DISTRIBUTOR="$(sed \'s, release .*$,,g\' /etc/system-release)"\nGRUB_DEFAULT=saved\nGRUB_DISABLE_SUBMENU=true\nGRUB_TERMINAL_OUTPUT="console"\nGRUB_CMDLINE_LINUX="rhgb quiet"\nGRUB_DISABLE_RECOVERY="true"\nGRUB_ENABLE_BLSCFG=true\n')
|
f.write('GRUB_TIMEOUT=5\nGRUB_DISTRIBUTOR="$(sed \'s, release .*$,,g\' /etc/system-release)"\nGRUB_DEFAULT=saved\nGRUB_DISABLE_SUBMENU=true\nGRUB_TERMINAL_OUTPUT="console"\nGRUB_CMDLINE_LINUX="rhgb quiet"\nGRUB_DISABLE_RECOVERY="true"\nGRUB_ENABLE_BLSCFG=true\n')
|
||||||
|
|
||||||
if uefi:
|
if uefi:
|
||||||
run_command(["chroot", mount_root, "grub2-install", "--target=x86_64-efi", "--efi-directory=/boot/efi", "--bootloader-id=iridium", "--recheck"])
|
efi_dir = "/boot/efi"
|
||||||
run_command(["chroot", mount_root, "grub2-mkconfig", "-o", "/boot/efi/EFI/iridium/grub.cfg"])
|
# Re-verify mount inside chroot if possible, but we already mounted it outside
|
||||||
|
|
||||||
|
logger.info("Installing GRUB2 for UEFI...")
|
||||||
|
# Using --removable can help on some systems that don't like efibootmgr entries
|
||||||
|
# but for now let's stick to standard and add --recheck
|
||||||
|
run_command(["chroot", mount_root, "grub2-install", "--target=x86_64-efi", f"--efi-directory={efi_dir}", "--bootloader-id=iridium", "--recheck"])
|
||||||
|
|
||||||
|
config_path = "/boot/efi/EFI/iridium/grub.cfg"
|
||||||
|
run_command(["chroot", mount_root, "grub2-mkconfig", "-o", config_path])
|
||||||
|
|
||||||
# Fedora compatibility link
|
# Fedora compatibility link
|
||||||
fedora_dir = os.path.join(mount_root, "boot/efi/EFI/fedora")
|
fedora_dir = os.path.join(mount_root, "boot/efi/EFI/fedora")
|
||||||
os.makedirs(fedora_dir, exist_ok=True)
|
os.makedirs(fedora_dir, exist_ok=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user