- Add network_logging.py module with Discord webhook integration - Log session start with unique session ID and mode (MOCK/PRODUCTION) - Log all page navigations when clicking Next - Log all user selections (disk, install mode, modules, user info) - Log installation progress through each step - Send install completion/failure logs - Auto-flush logs every 2 seconds and immediately on critical events TESTING BRANCH ONLY - Remove before merging to main
112 lines
3.8 KiB
Python
112 lines
3.8 KiB
Python
import argparse
|
|
import sys
|
|
import logging
|
|
|
|
# Configure logging
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
# Initialize network logging (TESTING BRANCH ONLY)
|
|
from .backend.network_logging import init_network_logging, add_discord_handler
|
|
|
|
init_network_logging(enabled=True)
|
|
add_discord_handler(logging.getLogger("iridium_installer"))
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Iridium OS Installer")
|
|
parser.add_argument(
|
|
"--mock",
|
|
action="store_true",
|
|
help="Run in mock mode (no actual changes to disk)",
|
|
)
|
|
parser.add_argument(
|
|
"--partition-disk",
|
|
help="Automatically partition the specified disk (WARNING: DESTROYS DATA)",
|
|
)
|
|
parser.add_argument(
|
|
"--full-install",
|
|
help="Run a full minimal installation on the specified disk (WARNING: DESTROYS DATA)",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
if args.partition_disk or args.full_install:
|
|
from .backend.disk import auto_partition_disk, mount_partitions
|
|
from .backend.os_install import install_minimal_os, configure_system
|
|
|
|
target = args.partition_disk or args.full_install
|
|
logger.info(f"INSTALLER_START: Starting installation on {target}")
|
|
try:
|
|
print(f"Starting installation on {target}...")
|
|
|
|
print("Step 1: Partitioning...")
|
|
logger.info(f"INSTALLER_PARTITION: Partitioning disk {target}")
|
|
parts = auto_partition_disk(target)
|
|
logger.info(f"INSTALLER_PARTITION_COMPLETE: Created partitions {parts}")
|
|
|
|
if args.full_install:
|
|
print("Step 2: Mounting...")
|
|
logger.info("INSTALLER_MOUNT: Mounting partitions")
|
|
mount_root = "/mnt"
|
|
mount_partitions(parts, mount_root)
|
|
|
|
print("Step 3: Installing OS (this may take a while)...")
|
|
logger.info("INSTALLER_OS_INSTALL: Installing minimal OS")
|
|
install_minimal_os(mount_root)
|
|
logger.info("INSTALLER_OS_INSTALL_COMPLETE: OS installed successfully")
|
|
|
|
print("Step 4: Configuring Bootloader...")
|
|
logger.info("INSTALLER_GRUB: Configuring GRUB bootloader")
|
|
configure_system(mount_root, parts)
|
|
logger.info("INSTALLER_GRUB_COMPLETE: Bootloader configured")
|
|
|
|
print("Installation complete! You can now reboot.")
|
|
logger.info(
|
|
"INSTALLER_COMPLETE: Full installation finished successfully"
|
|
)
|
|
else:
|
|
print("Partitioning successful!")
|
|
print(f"EFI: {parts['efi']}")
|
|
print(f"Swap: {parts['swap']}")
|
|
print(f"Root: {parts['root']}")
|
|
|
|
return 0
|
|
except Exception as e:
|
|
error_msg = str(e)
|
|
print(f"Installation failed: {e}", file=sys.stderr)
|
|
logger.error(f"INSTALLER_ERROR: {error_msg}")
|
|
import traceback
|
|
|
|
traceback.print_exc()
|
|
logger.error(f"INSTALLER_TRACEBACK: {traceback.format_exc()}")
|
|
return 1
|
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "4.0")
|
|
gi.require_version("Adw", "1")
|
|
|
|
from gi.repository import Adw, Gio
|
|
from .ui.window import InstallerWindow
|
|
|
|
class IridiumInstallerApp(Adw.Application):
|
|
def __init__(self, mock_mode=False):
|
|
super().__init__(
|
|
application_id="org.iridium.Installer",
|
|
flags=Gio.ApplicationFlags.FLAGS_NONE,
|
|
)
|
|
self.mock_mode = mock_mode
|
|
|
|
def do_activate(self):
|
|
win = self.props.active_window
|
|
if not win:
|
|
win = InstallerWindow(application=self, mock_mode=self.mock_mode)
|
|
win.present()
|
|
|
|
app = IridiumInstallerApp(mock_mode=args.mock)
|
|
return app.run(sys.argv)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|