From dc6995322660c0b853a23ba5a1276fb0b8b55e2a Mon Sep 17 00:00:00 2001 From: meyerast Date: Fri, 10 Apr 2026 10:29:54 -0400 Subject: [PATCH] Minor Fixes --- erase_drive.sh | 21 ++++++++++++++------- log_drive_info.sh | 16 ++++++++++------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/erase_drive.sh b/erase_drive.sh index d094bf1..9ec7b08 100644 --- a/erase_drive.sh +++ b/erase_drive.sh @@ -80,6 +80,12 @@ cleanup () { umount "/mnt/reinstallbackups" umount "/mnt/decs" fi + if [[ ! $ticket_number =~ ^\s*$ ]]; + then + umount /mnt/"$ticket_number" + else + umount "/mnt/UNKNWN" + fi } trap catch_sigint SIGINT @@ -226,15 +232,15 @@ get_devicetype () { get_device () { device= - loginfo "Listing current attached devices..." + loginfo "Listing current attached devices..." loginfo "" if [[ $devicetype = "HDD_SATA" ]] || [[ $devicetype = "SSD_SATA" ]]; then - loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|sda')" + loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|sd[a-z]')" elif [[ $devicetype = "SSD_NVME" ]]; then pcie_enable - loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|nvme')" + loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|nvme[0-9]')" fi loginfo "" loginput "Which is the device from this list? (Type 'help' for help.)" @@ -378,9 +384,10 @@ make_infolog () { loginfo "Windows install detected on $device$i." echo "Windows install detected on $device$i." >> "$infolog" echo "" >> "$infolog" - winpath=$(find /mnt/"$ticket_number" -maxdepth 4 -ipath "*System32/config" -not -ipath "*Windows.old*") - cp "$winpath/SOFTWARE" /tmp/"$ticket_number"/SOFTWARE - cp "$winpath/SYSTEM" /tmp/"$ticket_number"/SYSTEM + winsoftwarepath=$(find /mnt/"$ticket_number" -maxdepth 4 -ipath "*System32/config/SOFTWARE" -not -ipath "*Windows.old*") + winsystempath=$(find /mnt/"$ticket_number" -maxdepth 4 -ipath "*System32/config/SYSTEM" -not -ipath "*Windows.old*") + cp "$winsoftwarepath" /tmp/"$ticket_number"/SOFTWARE + cp "$winsystempath" /tmp/"$ticket_number"/SYSTEM CurrentVersion=$(hivexregedit --export --unsafe-printable-strings --max-depth 1 --prefix \\HKEY_LOCAL_MACHINE\\SOFTWARE /tmp/"$ticket_number"/SOFTWARE '\Microsoft\Windows NT\CurrentVersion') ComputerName=$(hivexregedit --export --unsafe-printable-strings --max-depth 1 --prefix \\HKEY_LOCAL_MACHINE\\SYSTEM /tmp/"$ticket_number"/SYSTEM '\ControlSet001\Control\ComputerName\ComputerName') Parameters=$(hivexregedit --export --unsafe-printable-strings --max-depth 1 --prefix \\HKEY_LOCAL_MACHINE\\SYSTEM /tmp/"$ticket_number"/SYSTEM '\ControlSet001\Services\Tcpip\Parameters') @@ -401,7 +408,7 @@ make_infolog () { echo "$LogonUI" | grep -E '"LastLoggedOnDisplayName"=str\(1\):".+"' | sed -E 's/"LastLoggedOnDisplayName"=str\(1\):"(.+)"/Last Logged On User: \1/' echo "$ProfileList" | grep -E '"ProfileImagePath"=str\(2\):".+"' | sed -E 's/"ProfileImagePath"=str\(2\):"(.+)"/User: \1/' echo "" - tree -a -L 1 -D "$(find /mnt/"$ticket_number"/ -maxdepth 2 -type d -ipath "*/Users" -not -ipath "*Windows.old*")" + tree -a -L 1 -D "$(find /mnt/"$ticket_number"/ -maxdepth 2 -type d -ipath "*/Users" -o -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | head -1)" echo "" } >> "$infolog" else diff --git a/log_drive_info.sh b/log_drive_info.sh index 27f8373..069c756 100644 --- a/log_drive_info.sh +++ b/log_drive_info.sh @@ -67,6 +67,7 @@ cleanup () { then umount "/mnt/decs" fi + umount "/mnt/UNKNWN" } trap catch_sigint SIGINT @@ -161,11 +162,11 @@ get_device () { loginfo "" if [[ $devicetype = "HDD_SATA" ]] || [[ $devicetype = "SSD_SATA" ]]; then - loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|sda')" + loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|sd[a-z]')" elif [[ $devicetype = "SSD_NVME" ]]; then pcie_enable - loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|nvme')" + loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|nvme[0-9]')" fi loginfo "" loginput "Which is the device from this list? (Type 'help' for help.)" @@ -305,9 +306,10 @@ make_infolog () { loginfo "Windows install detected on $device$i." echo "Windows install detected on $device$i." >> "$infolog" echo "" >> "$infolog" - winpath=$(find /mnt/UNKNWN -maxdepth 4 -ipath "*System32/config" -not -ipath "*Windows.old*") - cp "$winpath/SOFTWARE" /tmp/UNKNWN/SOFTWARE - cp "$winpath/SYSTEM" /tmp/UNKNWN/SYSTEM + winsoftwarepath=$(find /mnt/UNKNWN -maxdepth 4 -ipath "*System32/config/SOFTWARE" -not -ipath "*Windows.old*") + winsystempath=$(find /mnt/UNKNWN -maxdepth 4 -ipath "*System32/config/SYSTEM" -not -ipath "*Windows.old*") + cp "$winsoftwarepath" /tmp/UNKNWN/SOFTWARE + cp "$winsystempath" /tmp/UNKNWN/SYSTEM CurrentVersion=$(hivexregedit --export --unsafe-printable-strings --max-depth 1 --prefix \\HKEY_LOCAL_MACHINE\\SOFTWARE /tmp/UNKNWN/SOFTWARE '\Microsoft\Windows NT\CurrentVersion') ComputerName=$(hivexregedit --export --unsafe-printable-strings --max-depth 1 --prefix \\HKEY_LOCAL_MACHINE\\SYSTEM /tmp/UNKNWN/SYSTEM '\ControlSet001\Control\ComputerName\ComputerName') Parameters=$(hivexregedit --export --unsafe-printable-strings --max-depth 1 --prefix \\HKEY_LOCAL_MACHINE\\SYSTEM /tmp/UNKNWN/SYSTEM '\ControlSet001\Services\Tcpip\Parameters') @@ -328,7 +330,7 @@ make_infolog () { echo "$LogonUI" | grep -E '"LastLoggedOnDisplayName"=str\(1\):".+"' | sed -E 's/"LastLoggedOnDisplayName"=str\(1\):"(.+)"/Last Logged On User: \1/' echo "$ProfileList" | grep -E '"ProfileImagePath"=str\(2\):".+"' | sed -E 's/"ProfileImagePath"=str\(2\):"(.+)"/User: \1/' echo "" - tree -a -L 1 -D "$(find /mnt/UNKNWN/ -maxdepth 2 -type d -ipath "*/Users" -not -ipath "*Windows.old*")" + tree -a -L 1 -D "$(find /mnt/UNKNWN/ -maxdepth 2 -type d -ipath "*/Users" -o -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | head -1)" echo "" } >> "$infolog" else @@ -384,7 +386,9 @@ make_infolog () { echo "END OF LOG" >> "$infolog" if [[ ! $logtofile = "true" ]] then + echo "" >&3 cat "$infolog" >&3 + echo "" >&3 fi }