Minor Typos

This commit is contained in:
2026-07-13 12:42:28 -04:00
parent 18011e8865
commit 2941ddbece
2 changed files with 213 additions and 1 deletions
+1 -1
View File
@@ -175,7 +175,7 @@ get_eraselevel () {
then then
loginfo "Level 0 / Baseline: clears the partitions of the drive. Data can still be recovered but this is the optimal level for simple reuse." loginfo "Level 0 / Baseline: clears the partitions of the drive. Data can still be recovered but this is the optimal level for simple reuse."
loginfo "Level 1 / Secure Erase: HDD: Scrambles the data on the drive over 3 passes. SSD: Sends a signal to the drive to forget the encryption key, making it unreadrable." loginfo "Level 1 / Secure Erase: HDD: Scrambles the data on the drive over 3 passes. SSD: Sends a signal to the drive to forget the encryption key, making it unreadrable."
loginfo "Level 2 / decommission: Scrambles the data on the drive over 7 passes. Afterward, put the drive in the bin near the Hardware office to have it destroyed." loginfo "Level 2 / Decommission: Scrambles the data on the drive over 7 passes. Afterward, put the drive in the bin near the Hardware office to have it destroyed."
else else
logwarn "Invalid level, correct values can be 0, 1, or 2" logwarn "Invalid level, correct values can be 0, 1, or 2"
fi fi
+212
View File
@@ -0,0 +1,212 @@
#!/bin/bash
#!/usr/bin/env bash
start_time="$(date '+%Y-%m-%d_%H.%M.%S')"
logdir=/tmp
log="$logdir"/log_"$start_time".log
log_x="$logdir"/log_x_"$start_time".log
exec 3>&1 1>>"$log_x" 2>&1
set -x
loginput() {
echo "$*" >&3;
echo "[INPUT] $(date '+%H:%M:%S') $*" >> "$log";
}
logresponse() {
echo "[RESPONSE] $(date '+%H:%M:%S') $*" >> "$log";
}
loginfo() {
echo "$*" >&3;
echo "[INFO] $(date '+%H:%M:%S') $*" >> "$log";
}
logwarn() {
echo "$*" >&3;
echo "[WARNING] $(date '+%H:%M:%S') $*" >> "$log";
}
logerror() {
echo "$*" >&3;
echo "[ERROR] $(date '+%H:%M:%S') $*" >> "$log";
}
# shellcheck disable=SC2329
catch_sigint () {
logwarn "Signal Interrupt initiated. Stopping script."
cleanup
kill -INT "$$"
}
# shellcheck disable=SC2329
catch_exit () {
cleanup
kill -INT "$$"
}
# shellcheck disable=SC2329
cleanup () {
loginfo "Cleaning up."
loginfo "Unmounting drives."
exec 1>/dev/null 2>&1
umount /mnt/"$ticket_number"
rm -rf /tmp/"$ticket_number"/SOFTWARE
rm -rf /tmp/"$ticket_number"/SYSTEM
trap - EXIT
trap - INT
}
trap catch_sigint SIGINT
trap catch_exit EXIT
get_netid () {
netid=
while [[ $netid =~ ^\s*$ ]];
do
loginput "Enter R account netid: "
read -r netid
logresponse "$netid"
if [[ $netid =~ ^\s*$ ]];
then
logwarn "Your netid cannot be blank."
else
local ret_value=$(kinit "$netid"@EGR.MSU.EDU >&3; echo $?)
if [[ ! $ret_value = "0" ]]
then
kdestroy
netid=
logwarn "Error when authenticating netid $netid."
else
clear
loginfo "Authenticated as user $netid."
fi
fi
done
}
get_ticket () {
ticket_number=
while [[ $ticket_number =~ ^\s*$ ]];
do
loginput "Enter ticket number: "
read -r ticket_number
logresponse "$ticket_number"
if [[ $ticket_number =~ ^\s*$ ]];
then
logwarn "Ticket number cannot be blank."
else
mkdir -p /mnt/"$ticket_number"
if ! mount -t cifs -o user="$netid",sec=krb5i //reinstallbackups/reinstallbackups/"$ticket_number" /mnt/"$ticket_number"
then
logerror "Failed to mount reinstallbackups. Directory does likely not exist"
exit
fi
fi
done
}
make_infolog () {
loginfo "Reading backup to create a log."
backupdir=/mnt/"$ticket_number"
infolog="$logdir"/info_"$ticket_number"_"$start_time".log
{
echo "DETAILS"
echo "Start Time: $start_time"
echo "NetID: $netid"
echo ""
echo "PARTITION DETAILS"
echo "Count: $(find "$backupdir"/* -maxdepth 0 -type d | wc -l)"
} >> "$infolog"
if [[ ! "$(find "$backupdir"/* -maxdepth 0 -type d | wc -l)" = 0 ]];
then
for dir in "$backupdir"/*/;
do
if find "$dir" -maxdepth 3 -ipath "*/etc/os-release" | grep "."
then
loginfo "Linux install detected on in $dir."
echo "Linux install detected on in $dir." >> "$infolog"
echo "" >> "$infolog"
{
echo "LINUX DETAILS"
cat "$(find "$dir" -maxdepth 3 -ipath "*/etc/os-release")"
echo "Hostname: $(cat "$(find "$dir" -maxdepth 3 -ipath "*/etc/hostname")")"
cat "$(find "$dir" -maxdepth 3 -ipath "*/etc/passwd")" | grep -E '.+:x:[0-9]{4,}:[0-9]{4,}:.+,,,.*' | sed -E 's/.+:x:[0-9]{4,}:[0-9]{4,}:(.+),,,.*/User: \1/'
echo ""
tree -r -a -t -L 1 -D "$(find "$dir" -maxdepth 3 -type d -ipath "*/home")"
echo ""
} >> "$infolog"
loginfo "Reading $dir"
echo "" >> "$infolog"
elif find "$dir" -maxdepth 3 -ipath "*System32/config" -not -ipath "*Windows.old*" | grep "."
then
winpath=$(find "$dir" -maxdepth 3 -ipath "*System32/config" -not -ipath "*Windows.old*")
loginfo "Windows install detected on in $dir."
echo "Windows install detected on in $dir." >> "$infolog"
echo "" >> "$infolog"
winsoftwarepath=$(find "$winpath" -maxdepth 2 -ipath "*System32/config/SOFTWARE" -not -ipath "*Windows.old*")
winsystempath=$(find "$winpath" -maxdepth 2 -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')
LogonUI=$(hivexregedit --export --unsafe-printable-strings --max-depth 1 --prefix \\HKEY_LOCAL_MACHINE\\SOFTWARE /tmp/"$ticket_number"/SOFTWARE '\Microsoft\Windows\CurrentVersion\Authentication\LogonUI')
ProfileList=$(hivexregedit --export --unsafe-printable-strings --max-depth 2 --prefix \\HKEY_LOCAL_MACHINE\\SOFTWARE /tmp/"$ticket_number"/SOFTWARE '\Microsoft\Windows NT\CurrentVersion\ProfileList')
{
echo "WINDOWS DETAILS"
echo ""
echo "$ComputerName" | grep -E '"ComputerName"=str\(1\):".+"' | sed -E 's/"ComputerName"=str\(1\):"(.+)"/Host Name: \1/'
echo "$CurrentVersion" | grep -E '"DisplayVersion"=str\(1\):".+"' | sed -E 's/"DisplayVersion"=str\(1\):"(.+)"/Windows Version: \1/'
echo "$CurrentVersion" | grep -E '"CurrentBuild"=str\(1\):".+"' | sed -E 's/"CurrentBuild"=str\(1\):"(.+)"/Current Build: \1/'
echo "$CurrentVersion" | grep -E '"EditionID"=str\(1\):".+"' | sed -E 's/"EditionID"=str\(1\):"(.+)"/Windows Edition: \1/'
echo "$CurrentVersion" | grep -E '"ProductName"=str\(1\):".+"' | sed -E 's/"ProductName"=str\(1\):"(.+)"/Product Name: \1/'
echo "$CurrentVersion" | grep -E '"RegisteredOrganization"=str\(1\):".+"' | sed -E 's/"RegisteredOrganization"=str\(1\):"(.+)"/Registered Organization: \1/'
echo "$CurrentVersion" | grep -E '"RegisteredOwner"=str\(1\):".+"' | sed -E 's/"RegisteredOwner"=str\(1\):"(.+)"/Registered Owner: \1/'
echo "$Parameters" | grep -E '"Domain"=str\(1\):".+"' | sed -E 's/"Domain"=str\(1\):"(.+)"/Domain: \1/'
echo "$LogonUI" | grep -E '"LastLoggedOnUser"=str\(1\):".+"' | sed -E 's/"LastLoggedOnUser"=str\(1\):"(.+)"/Last Logged On User: \1/'
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 ""
if find "$dir" -maxdepth 2 -type d -ipath "*/Users" -not -ipath "*Windows.old*" | grep "."
then
tree -r -a -t -L 1 -D "$(find "$dir"/ -maxdepth 2 -type d -ipath "*/Users" -not -ipath "*Windows.old*" | head -1)"
fi
if find "$dir" -maxdepth 2 -type d -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | grep "."
then
tree -r -a -t -L 1 -D "$(find "$dir"/ -maxdepth 2 -type d -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | head -1)"
fi
echo ""
} >> "$infolog"
else
tree -a -R -D "$dir" >> "$infolog"
fi
done
else
logwarn "No partitions detected, device is likely empty."
fi
echo "END OF LOG" >> "$infolog"
echo "" >&3
cat "$infolog" >&3
echo "" >&3
cp "$infolog" /mnt/"$ticket_number"
}
main (){
loginfo ""
get_netid
get_ticket
mount_remote
loginfo ""
make_infolog #Logs a bunch of details to a info log file from the system.
loginfo ""
loginfo "Finished gathering logs of $ticket_number."
cleanup
}
main