I need to programmatically detect if Linux is running on a ThinkPad.
A shell script would be ideal but I can programmatically generate any binary by downloading some source and compiling it on the machine if only a custom program will be able to reliably do that.
Focus is: reliability/accuracy. If in doubt, I prefer not to run the script.
I have a hunch this may be cleverly done using text parsing of things like dmesg or lshw
, but which method is the most reliable?
Restriction: run as a normal user, as part of a login script, no possibility of temporarily elevating privileges just to detect the machine model.
Permission: take as long as needed, speed is not a factor.
Environment: Ubuntu, but Linux generality is nice to have. Availability of developer-level build tools (GCC can be assumed to "just work"). The login script is run by bash so a code snippet in that syntax would be more directly usable.
uname -o # --operating-system
may help. I'm on Ubuntu 13.4 latest, and it reportsGNU/Linux
.dmesg
orlspci -v
and then grep (IBM|Lenovo) on their output.