diff --git a/resources/sys_patch/sys_patch.py b/resources/sys_patch/sys_patch.py index 5e2bd4238..4f7741aa0 100644 --- a/resources/sys_patch/sys_patch.py +++ b/resources/sys_patch/sys_patch.py @@ -279,6 +279,8 @@ class PatchSysVolume: if self.needs_kmutil_exemptions is True: logging.info("Note: Apple will require you to open System Preferences -> Security to allow the new kernel extensions to be loaded") self.constants.root_patcher_succeeded = True + return True + return False def _rebuild_kernel_collection(self) -> bool: @@ -417,9 +419,11 @@ class PatchSysVolume: """ Unmount root volume """ - - logging.info("- Unmounting Root Volume (Don't worry if this fails)") - utilities.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() + if self.root_mount_path: + logging.info("- Unmounting Root Volume (Don't worry if this fails)") + utilities.elevated(["diskutil", "unmount", self.root_mount_path], stdout=subprocess.PIPE).stdout.decode().strip().encode() + else: + logging.info("- Skipping Root Volume unmount") def _rebuild_dyld_shared_cache(self) -> None: diff --git a/resources/wx_gui/gui_settings.py b/resources/wx_gui/gui_settings.py index 071275456..8bf15fa16 100644 --- a/resources/wx_gui/gui_settings.py +++ b/resources/wx_gui/gui_settings.py @@ -4,8 +4,10 @@ import pprint import logging import py_sip_xnu import subprocess +import os from pathlib import Path +from resources.sys_patch.sys_patch import PatchSysVolume from resources.wx_gui import ( gui_support, @@ -814,6 +816,9 @@ class SettingsFrame(wx.Frame): }, }, "Developer": { + "Validation": { + "type": "title", + }, "Install latest nightly build ๐Ÿงช": { "type": "button", "function": self.on_nightly, @@ -839,6 +844,28 @@ class SettingsFrame(wx.Frame): "Export constants.py values to a txt file.", ], }, + "Developer Root Volume Patching": { + "type": "title", + }, + "Mount Root Volume": { + "type": "button", + "function": self.on_mount_root_vol, + "description": [ + "Life's too short to type 'sudo mount -o", + "nobrowse -t apfs /dev/diskXsY", + "/System/Volumes/Update/mnt1' every time.", + ], + }, + "wrap_around 2": { + "type": "wrap_around", + }, + "Save Root Volume": { + "type": "button", + "function": self.on_bless_root_vol, + "description": [ + "Rebuild kernel cache and bless snapshot ๐Ÿ™", + ], + }, }, } @@ -1274,4 +1301,24 @@ Hardware Information: def on_test_exception(self, event: wx.Event) -> None: - raise Exception("Test Exception") \ No newline at end of file + raise Exception("Test Exception") + + def on_mount_root_vol(self, event: wx.Event) -> None: + if os.geteuid() != 0: + wx.MessageDialog(self.parent, "Please relaunch as Root to mount the Root Volume", "Error", wx.OK | wx.ICON_ERROR).ShowModal() + else: + #Don't need to pass model as we're bypassing all logic + if PatchSysVolume("",self.constants)._mount_root_vol() == True: + wx.MessageDialog(self.parent, "Root Volume Mounted, remember to fix permissions before saving the Root Volume", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() + else: + wx.MessageDialog(self.parent, "Root Volume Mount Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() + + def on_bless_root_vol(self, event: wx.Event) -> None: + if os.geteuid() != 0: + wx.MessageDialog(self.parent, "Please relaunch as Root to save changes", "Error", wx.OK | wx.ICON_ERROR).ShowModal() + else: + #Don't need to pass model as we're bypassing all logic + if PatchSysVolume("",self.constants)._rebuild_root_volume() == True: + wx.MessageDialog(self.parent, "Root Volume saved, please reboot to apply changes", "Success", wx.OK | wx.ICON_INFORMATION).ShowModal() + else: + wx.MessageDialog(self.parent, "Root Volume update Failed, check terminal output", "Error", wx.OK | wx.ICON_ERROR).ShowModal() \ No newline at end of file