Home Forums Software InstaDMG Best way to determine Portable or Desktop?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #374813
    ldsmacguy
    Participant

    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?

    #374815
    Patrick Gallagher
    Participant

    MODEL=`/usr/sbin/sysctl -n hw.model 2> /dev/null`

    Then if the result contains “book”, it’s a laptop.

    #375015
    benfeea1
    Participant

    I use this bit of code.

    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

    #375020
    jasonpgignac
    Participant

    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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Comments are closed