Add basic CLI support

This commit is contained in:
Mykola Grymalyuk
2021-04-15 21:07:53 -06:00
parent 6ae572f74f
commit 41a189444b
5 changed files with 230 additions and 10 deletions
+20 -10
View File
@@ -256,10 +256,12 @@ class PatchSysVolume:
subprocess.run(f"sudo bless --mount {self.mount_location} --bootefi --last-sealed-snapshot".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
def rebuild_snapshot(self):
input("Press [ENTER] to continue with cache rebuild")
if self.constants.gui_mode is False:
input("Press [ENTER] to continue with cache rebuild")
print("- Rebuilding Kernel Cache (This may take some time)")
subprocess.run(f"sudo kmutil install --volume-root {self.mount_location} --update-all".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
input("Press [ENTER] to continue with snapshotting")
if self.constants.gui_mode is False:
input("Press [ENTER] to continue with snapshotting")
print("- Creating new APFS snapshot")
subprocess.run(f"sudo bless --folder {self.mount_location}/System/Library/CoreServices --bootefi --create-snapshot".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode()
@@ -295,9 +297,12 @@ class PatchSysVolume:
def check_files(self):
if Path(self.constants.payload_apple_root_path).exists():
print("- Found Apple Binaries")
patch_input = input("Would you like to redownload?(y/n): ")
if patch_input in {"y", "Y", "yes", "Yes"}:
shutil.rmtree(Path(self.constants.payload_apple_root_path))
if self.constants.gui_mode is False:
patch_input = input("Would you like to redownload?(y/n): ")
if patch_input in {"y", "Y", "yes", "Yes"}:
shutil.rmtree(Path(self.constants.payload_apple_root_path))
self.download_files()
else:
self.download_files()
else:
print("- Apple binaries missing")
@@ -319,7 +324,8 @@ class PatchSysVolume:
os.rename(self.constants.payload_apple_root_path_unzip, self.constants.payload_apple_root_path)
print("- Binaries downloaded to:")
print(self.constants.payload_path)
input("Press [ENTER] to continue")
if self.constants.gui_mode is False:
input("Press [ENTER] to continue")
except zipfile.BadZipFile:
print("- Couldn't unzip")
os.remove(self.constants.payload_apple_root_path_zip)
@@ -342,7 +348,8 @@ class PatchSysVolume:
Utilities.cls()
if (self.sip_patch_status is False) and (self.smb_status is False):
print("- Detected SIP and SecureBootModel are disabled, continuing")
input("\nPress [ENTER] to continue")
if self.constants.gui_mode is False:
input("\nPress [ENTER] to continue")
self.check_files()
if self.constants.payload_apple_root_path.exists():
self.find_mount_root_vol(True)
@@ -362,7 +369,8 @@ class PatchSysVolume:
print("FileVault enabled, unable to patch!")
print("Please disable FileVault in System Preferences")
print("")
input("Press [Enter] to go exit.")
if self.constants.gui_mode is False:
input("Press [Enter] to go exit.")
def start_unpatch(self):
if self.constants.custom_model is not None:
@@ -374,7 +382,8 @@ class PatchSysVolume:
Utilities.cls()
if (self.sip_patch_status is False) and (self.smb_status is False):
print("- Detected SIP and SecureBootModel are disabled, continuing")
input("\nPress [ENTER] to continue")
if self.constants.gui_mode is False:
input("\nPress [ENTER] to continue")
self.find_mount_root_vol(False)
self.unmount_drive()
print("- Unpatching complete")
@@ -392,4 +401,5 @@ class PatchSysVolume:
print("FileVault enabled, unable to unpatch!")
print("Please disable FileVault in System Preferences")
print("")
input("Press [Enter] to go exit.")
if self.constants.gui_mode is False:
input("Press [Enter] to go exit.")