I have some scripts that I need to run on first boot based on whether it is running on a Desktop system or a Portable system. Does anyone have any suggestions the best way to determine this? I can use system_profiler to grep for the Model Identifier and figure it out from there based on what I find. Are there easier ways to do this, or a “right way” to do this?
hardwaretype=`/usr/sbin/system_profiler SPHardwareDataType | grep Model`
if echo $hardwaretype | grep -i Book;
then
echo This is a Mac Portable
else
echo this is NOT a Mac Portable
fi
Just as an added note – we actually keep a hash of system types versus model name – this gives us some flexibility if we, for instance, want to have some scripts only apply to XServes, some to Laptops, etc. Otherwise, teh methodology is pretty much the same, except instead of just grepping for ‘Book’ we strip out the model, and look it up in a hash. YMMV
Comments are closed