Created
November 9, 2011 04:33
-
-
Save acidprime/1350393 to your computer and use it in GitHub Desktop.
BASH Hardware Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -x awk="/usr/bin/awk" | |
declare -x ioreg="/usr/sbin/ioreg" | |
declare -x sysctl="/usr/sbin/sysctl" | |
# Intel and future systems test | |
declare IOREG="$($ioreg -l | | |
$awk 'BEGIN {FS="[<>]"} | |
/.*\"system-type\".=./{ | |
systype=$2 | |
if ( systype == 1 ) | |
{ print "D" ; exit 0 } | |
# System type 1 is a Desktop | |
else if ( systype == 2 ) | |
{ print "L" ; exit 0 } | |
# System type 2 is a Laptop | |
}')" | |
# PowerPC test , hopefully can go aways some day | |
declare SYSCTL="$($sysctl hw.model | | |
$awk 'BEGIN {} | |
$2~/.*(b|B)ook.*/{ | |
# RegEx any thing with Book,basic but works | |
print "L" ; exit 0 } | |
# If we did not exit then desktop | |
{print "D" ;exit}')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment