Minor Fixes
This commit is contained in:
+34
-21
@@ -21,7 +21,7 @@ done
|
||||
|
||||
loginput() {
|
||||
echo "$*" >&3;
|
||||
echo "[INPUT] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
echo "[INPUT] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
}
|
||||
|
||||
logresponse() {
|
||||
@@ -30,17 +30,17 @@ logresponse() {
|
||||
|
||||
loginfo() {
|
||||
echo "$*" >&3;
|
||||
echo "[INFO] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
echo "[INFO] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
}
|
||||
|
||||
logwarn() {
|
||||
echo "$*" >&3;
|
||||
echo "[WARNING] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
echo "[WARNING] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
}
|
||||
|
||||
logerror() {
|
||||
echo "$*" >&3;
|
||||
echo "[ERROR] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
echo "[ERROR] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
}
|
||||
|
||||
confirm_message () {
|
||||
@@ -77,14 +77,11 @@ cleanup () {
|
||||
umount "/mnt/reinstallbackups"
|
||||
umount "/mnt/decs"
|
||||
fi
|
||||
if [[ ! $ticket_number =~ ^\s*$ ]];
|
||||
then
|
||||
umount /mnt/"$ticket_number"
|
||||
else
|
||||
umount "/mnt/UNKNWN"
|
||||
umount /mnt/"$ticket_number"
|
||||
rm /tmp/"$ticket_number"/SOFTWARE
|
||||
rm /tmp/"$ticket_number"/SYSTEM
|
||||
trap - EXIT
|
||||
trap - INT
|
||||
fi
|
||||
}
|
||||
|
||||
trap catch_sigint SIGINT
|
||||
@@ -94,13 +91,12 @@ get_netid () {
|
||||
netid=
|
||||
while [[ $netid =~ ^\s*$ ]];
|
||||
do
|
||||
loginput "Enter r-account netid: "
|
||||
loginput "Enter account netid: "
|
||||
read -r netid
|
||||
logresponse "$netid"
|
||||
if [[ $netid =~ ^\s*$ ]];
|
||||
then
|
||||
logwarn "Your netid cannot be blank."
|
||||
loginfo "Enter r-account netid: "
|
||||
else
|
||||
local ret_value=$(kinit "$netid"@EGR.MSU.EDU >&3; echo $?)
|
||||
if [[ ! $ret_value = "0" ]]
|
||||
@@ -149,7 +145,7 @@ mount_remote () {
|
||||
if mount -t cifs -o user="$netid",sec=krb5i "//decs/decs/support/dban_logs" /mnt/decs
|
||||
then
|
||||
if [ ! -w "//decs/decs/support/dban_logs" ]; then
|
||||
logerror "Insufficient permissions to write in //decs/decs/support/dban_logs"
|
||||
logwarning "Insufficient permissions to write in //decs/decs/support/dban_logs"
|
||||
exit
|
||||
fi
|
||||
if [[ ! $ticket_number =~ ^\s*$ ]];
|
||||
@@ -235,14 +231,18 @@ get_devicetype () {
|
||||
|
||||
get_device () {
|
||||
device=
|
||||
echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan >/dev/null
|
||||
|
||||
loginfo "Listing current attached devices..."
|
||||
loginfo ""
|
||||
if [[ $devicetype = "HDD_SATA" ]] || [[ $devicetype = "SSD_SATA" ]];
|
||||
then
|
||||
echo 1 | sudo tee /sys/class/block/sd?/device/rescan >/dev/null
|
||||
loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|sd[a-z]')"
|
||||
elif [[ $devicetype = "SSD_NVME" ]];
|
||||
then
|
||||
pcie_enable
|
||||
echo 1 | sudo tee /sys/class/block/nvme?/device/rescan >/dev/null
|
||||
loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|nvme[0-9]')"
|
||||
fi
|
||||
loginfo ""
|
||||
@@ -320,7 +320,7 @@ make_infolog () {
|
||||
echo "DEVICE DETAILS"
|
||||
lsblk -o NAME,LABEL,PARTLABEL,FSTYPE,SIZE,MODEL,VENDOR,UUID,SERIAL | grep "NAME\|$device"
|
||||
echo ""
|
||||
smartctl -i /dev/"$device"
|
||||
smartctl -i -A /dev/"$device"
|
||||
echo ""
|
||||
echo "PARTITION DETAILS"
|
||||
echo "Count: $(lsblk -n -l -o TYPE /dev/"$device" | grep -c "part")"
|
||||
@@ -351,7 +351,7 @@ make_infolog () {
|
||||
echo "Hostname: $(cat "$(find /mnt/"$ticket_number" -maxdepth 3 -ipath "*/etc/hostname")")"
|
||||
cat "$(find /mnt/"$ticket_number" -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 -a -L 1 -D "$(find /mnt/"$ticket_number" -maxdepth 3 -type d -ipath "*/home")"
|
||||
tree -r -a -t -L 1 -D "$(find /mnt/"$ticket_number" -maxdepth 3 -type d -ipath "*/home")"
|
||||
echo ""
|
||||
} >> "$infolog"
|
||||
else
|
||||
@@ -376,15 +376,17 @@ make_infolog () {
|
||||
mkdir -p /mnt/"$ticket_number"
|
||||
if mount -t "$fstype" /dev/"$device""$i" /mnt/"$ticket_number"
|
||||
then
|
||||
if find /mnt/"$ticket_number"-maxdepth 4 -ipath "*System32/config" -not -ipath "*Windows.old*" | grep "."
|
||||
if find /mnt/"$ticket_number" -maxdepth 3 -ipath "*System32/config" -not -ipath "*Windows.old*" | grep "."
|
||||
then
|
||||
winpath=$(find /mnt/"$ticket_number" -maxdepth 3 -ipath "*System32/config" -not -ipath "*Windows.old*")
|
||||
loginfo "Windows install detected on $device$i."
|
||||
echo "Windows install detected on $device$i." >> "$infolog"
|
||||
echo "" >> "$infolog"
|
||||
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*")
|
||||
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')
|
||||
@@ -405,9 +407,18 @@ 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" -o -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | head -1)"
|
||||
if find /mnt/UNKNWN -maxdepth 2 -type d -ipath "*/Users" -not -ipath "*Windows.old*" | grep "."
|
||||
then
|
||||
tree -r -a -t -L 1 -D "$(find /mnt/UNKNWN/ -maxdepth 2 -type d -ipath "*/Users" -not -ipath "*Windows.old*" | head -1)"
|
||||
fi
|
||||
if find /mnt/UNKNWN -maxdepth 2 -type d -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | grep "."
|
||||
then
|
||||
tree -r -a -t -L 1 -D "$(find /mnt/UNKNWN/ -maxdepth 2 -type d -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | head -1)"
|
||||
fi
|
||||
echo ""
|
||||
} >> "$infolog"
|
||||
} >> "$infolog"
|
||||
rm /tmp/"$ticket_number"/SOFTWARE
|
||||
rm /tmp/"$ticket_number"/SYSTEM
|
||||
else
|
||||
loginfo "Non Windows NTFS partition detected on $device$i."
|
||||
echo "Non Windows NTFS partition detected on $device$i." >> "$infolog"
|
||||
@@ -462,7 +473,9 @@ make_infolog () {
|
||||
|
||||
if [[ $print = "true" ]];
|
||||
then
|
||||
cat "$infolog" >&3;
|
||||
echo "" >&3
|
||||
cat "$infolog" >&3
|
||||
echo "" >&3
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
+31
-12
@@ -19,7 +19,7 @@ done
|
||||
|
||||
loginput() {
|
||||
echo "$*" >&3;
|
||||
echo "[INPUT] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
echo "[INPUT] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
}
|
||||
|
||||
logresponse() {
|
||||
@@ -28,17 +28,17 @@ logresponse() {
|
||||
|
||||
loginfo() {
|
||||
echo "$*" >&3;
|
||||
echo "[INFO] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
echo "[INFO] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
}
|
||||
|
||||
logwarn() {
|
||||
echo "$*" >&3;
|
||||
echo "[WARNING] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
echo "[WARNING] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
}
|
||||
|
||||
logerror() {
|
||||
echo "$*" >&3;
|
||||
echo "[ERROR] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
echo "[ERROR] $(date '+%H:%M:%S') $*" >> "$log";
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2329
|
||||
@@ -65,6 +65,8 @@ cleanup () {
|
||||
umount "/mnt/decs"
|
||||
fi
|
||||
umount "/mnt/UNKNWN"
|
||||
rm /tmp/UNKNWN/SOFTWARE
|
||||
rm /tmp/UNKNWN/SYSTEM
|
||||
trap - EXIT
|
||||
trap - INT
|
||||
}
|
||||
@@ -82,7 +84,6 @@ get_netid () {
|
||||
if [[ $netid =~ ^\s*$ ]];
|
||||
then
|
||||
logwarn "Your netid cannot be blank."
|
||||
loginfo "Enter netid: "
|
||||
else
|
||||
local ret_value=$(kinit "$netid"@EGR.MSU.EDU >&3; echo $?)
|
||||
if [[ ! $ret_value = "0" ]]
|
||||
@@ -102,6 +103,10 @@ mount_remote () {
|
||||
mkdir -p /mnt/decs
|
||||
if mount -t cifs -o user="$netid",sec=krb5i "//decs/decs/support/dban_logs" /mnt/decs
|
||||
then
|
||||
if [ ! -w "//decs/decs/support/dban_logs" ]; then
|
||||
logwarning "Insufficient permissions to write in //decs/decs/support/dban_logs"
|
||||
exit
|
||||
fi
|
||||
logdir=/mnt/decs/UNKNWN-"$start_time"
|
||||
mkdir -p "$logdir"
|
||||
cp "$log" "$logdir"/log_UNKNWN_"$start_time".log
|
||||
@@ -157,14 +162,18 @@ get_devicetype () {
|
||||
|
||||
get_device () {
|
||||
device=
|
||||
echo "- - -" | sudo tee /sys/class/scsi_host/host*/scan >/dev/null
|
||||
|
||||
loginfo "Listing current attached devices..."
|
||||
loginfo ""
|
||||
if [[ $devicetype = "HDD_SATA" ]] || [[ $devicetype = "SSD_SATA" ]];
|
||||
then
|
||||
echo 1 | sudo tee /sys/class/block/sd?/device/rescan >/dev/null
|
||||
loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|sd[a-z]')"
|
||||
elif [[ $devicetype = "SSD_NVME" ]];
|
||||
then
|
||||
pcie_enable
|
||||
echo 1 | sudo tee /sys/class/block/nvme?/device/rescan >/dev/null
|
||||
loginfo "$(lsblk -o NAME,SIZE,MODEL,VENDOR,ROTA | grep -E '^NAME|nvme[0-9]')"
|
||||
fi
|
||||
loginfo ""
|
||||
@@ -238,7 +247,7 @@ make_infolog () {
|
||||
echo "DEVICE DETAILS"
|
||||
lsblk -o NAME,LABEL,PARTLABEL,FSTYPE,SIZE,MODEL,VENDOR,UUID,SERIAL | grep "NAME\|$device"
|
||||
echo ""
|
||||
smartctl -i /dev/"$device"
|
||||
smartctl -i -A /dev/"$device"
|
||||
echo ""
|
||||
echo "PARTITION DETAILS"
|
||||
echo "Count: $(lsblk -n -l -o TYPE /dev/"$device" | grep -c "part")"
|
||||
@@ -269,7 +278,7 @@ make_infolog () {
|
||||
echo "Hostname: $(cat "$(find /mnt/UNKNWN -maxdepth 3 -ipath "*/etc/hostname")")"
|
||||
cat "$(find /mnt/UNKNWN -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 -a -L 1 -D "$(find /mnt/UNKNWN -maxdepth 3 -type d -ipath "*/home")"
|
||||
tree -r -a -t -L 1 -D "$(find /mnt/UNKNWN -maxdepth 3 -type d -ipath "*/home")"
|
||||
echo ""
|
||||
} >> "$infolog"
|
||||
else
|
||||
@@ -294,13 +303,14 @@ make_infolog () {
|
||||
mkdir -p /mnt/UNKNWN
|
||||
if mount -t "$fstype" /dev/"$device""$i" /mnt/UNKNWN
|
||||
then
|
||||
if find /mnt/UNKNWN -maxdepth 4 -ipath "*System32/config" -not -ipath "*Windows.old*" | grep "."
|
||||
if find /mnt/UNKNWN -maxdepth 3 -ipath "*System32/config" -not -ipath "*Windows.old*" | grep "."
|
||||
then
|
||||
winpath=$(find /mnt/UNKNWN -maxdepth 3 -ipath "*System32/config" -not -ipath "*Windows.old*")
|
||||
loginfo "Windows install detected on $device$i."
|
||||
echo "Windows install detected on $device$i." >> "$infolog"
|
||||
echo "" >> "$infolog"
|
||||
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*")
|
||||
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/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')
|
||||
@@ -323,9 +333,18 @@ 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" -o -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | head -1)"
|
||||
if find /mnt/UNKNWN -maxdepth 2 -type d -ipath "*/Users" -not -ipath "*Windows.old*" | grep "."
|
||||
then
|
||||
tree -r -a -t -L 1 -D "$(find /mnt/UNKNWN/ -maxdepth 2 -type d -ipath "*/Users" -not -ipath "*Windows.old*" | head -1)"
|
||||
fi
|
||||
if find /mnt/UNKNWN -maxdepth 2 -type d -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | grep "."
|
||||
then
|
||||
tree -r -a -t -L 1 -D "$(find /mnt/UNKNWN/ -maxdepth 2 -type d -ipath "*/Documents and Settings" -not -ipath "*Windows.old*" | head -1)"
|
||||
fi
|
||||
echo ""
|
||||
} >> "$infolog"
|
||||
} >> "$infolog"
|
||||
rm /tmp/UNKNWN/SOFTWARE
|
||||
rm /tmp/UNKNWN/SYSTEM
|
||||
else
|
||||
loginfo "Non Windows NTFS partition detected on $device$i."
|
||||
echo "Non Windows NTFS partition detected on $device$i." >> "$infolog"
|
||||
|
||||
Reference in New Issue
Block a user