From 8cbadb61604667b407b53ee1258433994fa4765a Mon Sep 17 00:00:00 2001 From: coasteen Date: Thu, 9 Jul 2026 10:42:28 +0330 Subject: init --- local/bin/usbumount | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 local/bin/usbumount (limited to 'local/bin/usbumount') diff --git a/local/bin/usbumount b/local/bin/usbumount new file mode 100755 index 0000000..ffe68bc --- /dev/null +++ b/local/bin/usbumount @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys + +RED = "\033[0;31m" +RESET = "\033[0m" + +def run(cmd, fail_msg): + try: + subprocess.run(cmd, check=True) + except subprocess.CalledProcessError: + print(f"{RED}[!] {fail_msg}{RESET}") + sys.exit(1) + +def main(): + if os.geteuid() != 0: + print(f"{RED}[!] Superuser access is required{RESET}") + sys.exit(1) + + print(f"{RED}[*] Unmounting /mnt/usb...{RESET}") + run(["umount", "/mnt/usb"], "Failed to unmount /mnt/usb") + + print(f"{RED}[*] Closing encrypted device...{RESET}") + run(["cryptsetup", "close", "sda1_crypt"], "Failed to close mapper device") + + print(f"{RED}[*] Unmounted and closed successfully!{RESET}") + +if __name__ == "__main__": + main() -- cgit v1.2.3