Redid Linux infogathering, changed exit behavior
This commit is contained in:
+11
-20
@@ -45,15 +45,12 @@ logerror() {
|
||||
catch_sigint () {
|
||||
logwarn "Signal Interrupt initiated. Stopping script."
|
||||
cleanup
|
||||
trap - INT
|
||||
kill -INT "$$"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2329
|
||||
catch_exit () {
|
||||
cleanup
|
||||
trap - EXIT
|
||||
trap - INT
|
||||
kill -INT "$$"
|
||||
}
|
||||
|
||||
@@ -68,6 +65,8 @@ cleanup () {
|
||||
umount "/mnt/decs"
|
||||
fi
|
||||
umount "/mnt/UNKNWN"
|
||||
trap - EXIT
|
||||
trap - INT
|
||||
}
|
||||
|
||||
trap catch_sigint SIGINT
|
||||
@@ -267,22 +266,16 @@ make_infolog () {
|
||||
{
|
||||
echo "LINUX DETAILS"
|
||||
cat "$(find /mnt/UNKNWN -maxdepth 3 -ipath "*/etc/os-release")"
|
||||
echo ""
|
||||
echo "HOSTNAME"
|
||||
cat "$(find /mnt/UNKNWN -maxdepth 3 -ipath "*/etc/hostname")"
|
||||
echo ""
|
||||
echo "LOGON DETAILS"
|
||||
w
|
||||
echo ""
|
||||
cat "$(find /mnt/UNKNWN -maxdepth 3 -ipath "*/etc/passwd")"
|
||||
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")"
|
||||
echo ""
|
||||
} >> "$infolog"
|
||||
else
|
||||
echo "Non Linux OS device detected on $device$i." >> "$infolog"
|
||||
loginfo "Non Linux OS device detected on $device$i."
|
||||
tree -a -L 3 -D /mnt/UNKNWN/ >> "$infolog"
|
||||
echo "Non Linux Unix partition detected on $device$i." >> "$infolog"
|
||||
loginfo "Non Linux Unix partition detected on $device$i."
|
||||
tree -a -L 2 -D /mnt/UNKNWN/ >> "$infolog"
|
||||
fi
|
||||
umount /mnt/UNKNWN
|
||||
else
|
||||
@@ -334,9 +327,9 @@ make_infolog () {
|
||||
echo ""
|
||||
} >> "$infolog"
|
||||
else
|
||||
loginfo "Non Windows NTFS device detected on $device$i."
|
||||
echo "Non Windows NTFS device detected on $device$i." >> "$infolog"
|
||||
tree -a -L 3 -D /mnt/UNKNWN/ >> "$infolog"
|
||||
loginfo "Non Windows NTFS partition detected on $device$i."
|
||||
echo "Non Windows NTFS partition detected on $device$i." >> "$infolog"
|
||||
tree -a -L 2 -D /mnt/UNKNWN/ >> "$infolog"
|
||||
fi
|
||||
umount /mnt/UNKNWN
|
||||
else
|
||||
@@ -419,11 +412,9 @@ main (){
|
||||
|
||||
make_infolog #Logs a bunch of details to a info log file from the system.
|
||||
|
||||
sleep 3
|
||||
|
||||
loginfo "Finished gathering logs of $devicetype : $device."
|
||||
|
||||
exit
|
||||
cleanup
|
||||
}
|
||||
|
||||
main
|
||||
Reference in New Issue
Block a user