MLBZ521 / MacAdmin

A collection of scripts and tools for managing Apple Devices
MIT License
166 stars 33 forks source link

check_ram_upgradeable future-proofing #12

Closed tantonw closed 2 years ago

tantonw commented 2 years ago

First, thanks for developing and maintaining this script! I was fiddling with RAM numbers to explore how the script worked and noticed that the check_ram_upgradeable function might not be behaving as desired on newer Macs. This isn't causing a bug presently, but it will if Apple increases memory requirements. From some very brief testing it seems that M1 Macs don't return the "Upgradeable Memory:" line from "system_profiler SPMemoryDataType", so the check_ram_upgradeable function returns blank. I think a band-aid like this might suffice:

check_ram_upgradeable() {
    ram_upgradeable=$( /usr/sbin/system_profiler SPMemoryDataType | /usr/bin/awk -F "Upgradeable Memory: " '{print $2}' | /usr/bin/xargs 2&> /dev/null )
    if [ -z $ram_upgradeable ]; then
        ram_upgradeable="No"
    fi
    echo "${ram_upgradeable}"
}
MLBZ521 commented 2 years ago

@tantonw No problem.

I've confirmed the same on a MBP 13" and a Mac Mini with ARM chipsets.

If you want to submit a PR with this improvement, that would be great.

Thanks for contributing!

tantonw commented 2 years ago

Submitted PR #13

Thanks!

MLBZ521 commented 2 years ago

PRs #13 and #14 have both been merged.

I also thought of an additional piece that I just added in 6be6665 to help prevent needless cycles.

Thanks!