forked from kidsoncomputers/hw_detection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinuxHardwareDetection
executable file
·93 lines (68 loc) · 2.08 KB
/
LinuxHardwareDetection
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# GHC Open Source Day project 2011
# by Gabrielle Roth & Michelle Rowley
#based on:
# System Information Generator v1.1
# Tim Burgess 28.11.07
#TODO: add more robust paths
#more clarification...
#TODO: do we note anywhere that this may need to be run with sudo perms?
#Added If statement to check for root user. Some commands will not run without user being root.
#TODO: align our output with the windows script output
#TODO: verify outputs of USB check
#Does the test need to be more specific than just if the cd, dvd, or usb exist?
#TODO: deal with multiple processor output (eg, my thinkpad shows a ton of crap we don't want)
#I can't repro this. Can someone else?
#TODO: filter crap out of lspci output
#Same as above
if [[ $UID != 0 ]]; then echo 'Sorry, must be root. Exiting...'; exit; fi
MEMORY=`free -m | grep Mem | awk '{print $2}'`
if [ ${MEMORY} -le 500 ];
then
echo "Insufficient Memory for KOC project: ${MEMORY}M; exiting."
exit
fi
echo "Generating system stats; please wait."
DATE=`date`
SERIAL=`dmidecode -t system | grep -i serial | sed "s/^[ ]*//"`
VERSION=`uname -a`
OS=`uname -r`
PROC=`uname -p`
# TODO: can we count on egrep availability? Probably not.
# egrep is in ubuntu so I would assume this ok. I know other flavors of linux do as well.
PROC_DETAIL=`cat /proc/cpuinfo | egrep -i "processor|vendor_id|model name|mhz"`
HD=`fdisk -l | grep "Disk /"`
NETWORK=`lspci | egrep -i "ethernet|wireless|network"`
VIDEO=`lspci | egrep -i "vga|graphics|video"`
#TODO: put this in a loop
if ls /dev/cd* 1>/dev/null
then CD="Present"
else CD="Not present"
fi
if ls /dev/dvd* 1>/dev/null
then DVD="Present"
else DVD="Not present"
fi
if ls /dev/usb* 1>/dev/null
then USB="Present"
else USB="Not present"
fi
OFILE=$HOME/sysinfo.txt
cat /dev/null >${OFILE}
cat > ${OFILE} <<INFO
System Information - File generated on $DATE
$SERIAL
Version: $VERSION
OS: $OS
Processor: $PROC
$PROC_DETAIL
HD: $HD
RAM: $MEMORY M
CD: $CD
DVD: $DVD
USB: $USB
Network: $NETWORK
Video card: $VIDEO
INFO
cat ${OFILE}
echo "Finished! Your results have been stored in ${OFILE}"
exit 0