Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catalina changes diskinfo again. Suggested fix included. #130

Open
FyrbyAdditive opened this issue Oct 5, 2019 · 5 comments
Open

Catalina changes diskinfo again. Suggested fix included. #130

FyrbyAdditive opened this issue Oct 5, 2019 · 5 comments

Comments

@FyrbyAdditive
Copy link

FyrbyAdditive commented Oct 5, 2019

## 10.13.4 or later, diskutil info command output changes key from 'AvailableSpace' to 'Free Space' about disk space.
## 10.15 or later changes it to 'APFSContainerFree'

os_ver=$(sw_vers -productVersion)
IFS='.' read -r -a ver <<< "$os_ver"

if [[ "${ver[1]}" -ge 15 ]]; then
        # Is 10.15 or newer
        di_check="APFSContainerFree"
elif [[ "${ver[1]}" -ge 13 ]] && [[ "${ver[2]}" -ge 4 ]]; the
        # Is 10.13.4 - 10.14.latest
        di_check="FreeSpace"
else
        # Is a blatant security risk
        di_check="AvailableSpace"
fi

diskInfoPlist=$(/usr/sbin/diskutil info -plist /)
freeSpace=$(
        /usr/libexec/PlistBuddy -c "Print :${di_check}" /dev/stdin <<< "$diskInfoPlist" 2>/dev/null
)
@kenchan0130
Copy link
Collaborator

@timtimellis
Thank you for you feedback. I'll update our script after this weekend.
Please wait for a little while longer.

@ckostovny
Copy link

ckostovny commented Oct 22, 2019

This logic didn't seem to work for me on 10.14-- and testing the logic with 10.14.1-10.14.3 as os_ver all result in report of null Freespace, as they're falling into the else statement and checking the plist for "AvailableSpace".

if [[ "${ver[1]}" -ge 15 ]]; then
		# Is 10.15 or newer
		di_check="APFSContainerFree"
elif [[ "${ver[1]}" -eq 14 ]]; then
		# Is 10.14.x
		di_check="FreeSpace"
elif [[ "${ver[1]}" -eq 13 ]] && [[ "${ver[2]}" -ge 4 ]]; then
		# Is 10.13.4 - 10.13.6
		di_check="FreeSpace"
else
		# Is a blatant security risk
		di_check="AvailableSpace"
fi

This appears to work correctly for the above versions, perhaps this will help others.

@marckerr
Copy link

marckerr commented Nov 4, 2019

I'll confirm I've used the noted modifications for upgrading from Mojave to Catalina as well as erase install over Mojave and Catalina.

@ckostovny
Copy link

This logic didn't seem to work for me on 10.14-- and testing the logic with 10.14.1-10.14.3 as os_ver all result in report of null Freespace, as they're falling into the else statement and checking the plist for "AvailableSpace".

if [[ "${ver[1]}" -ge 15 ]]; then
		# Is 10.15 or newer
		di_check="APFSContainerFree"
elif [[ "${ver[1]}" -eq 14 ]]; then
		# Is 10.14.x
		di_check="FreeSpace"
elif [[ "${ver[1]}" -eq 13 ]] && [[ "${ver[2]}" -ge 4 ]]; then
		# Is 10.13.4 - 10.13.6
		di_check="FreeSpace"
else
		# Is a blatant security risk
		di_check="AvailableSpace"
fi

This appears to work correctly for the above versions, perhaps this will help others.

The di_check for older than 10.13.4 isn't working for me with 10.12.6-- I ended up changing the else statement to use di_check="FreeSpace" and I was able to upgrade 10.12.6 successfully. I don't have anything older to test on, nor a 10.13.3--- is the di_check="AvailableSpace" actually needed?

@nc-keopraseuths
Copy link

nc-keopraseuths commented Nov 14, 2019

## 10.13.4 or later, diskutil info command output changes key from 'AvailableSpace' to 'Free Space' about disk space.
## 10.15 or later changes it to 'APFSContainerFree'

os_ver=$(sw_vers -productVersion)
IFS='.' read -r -a ver <<< "$os_ver"

if [[ "${ver[1]}" -ge 15 ]]; then
        # Is 10.15 or newer
        di_check="APFSContainerFree"
elif [[ "${ver[1]}" -ge 13 ]] && [[ "${ver[2]}" -ge 4 ]]; the
        # Is 10.13.4 - 10.14.latest
        di_check="FreeSpace"
else
        # Is a blatant security risk
        di_check="AvailableSpace"
fi

diskInfoPlist=$(/usr/sbin/diskutil info -plist /)
freeSpace=$(
        /usr/libexec/PlistBuddy -c "Print :${di_check}" /dev/stdin <<< "$diskInfoPlist" 2>/dev/null
)

This is missing the letter 'n' for the elif statement for 'then'. If anyone else is having trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants