Posted on 10-16-2017 01:55 PM
It appears that with High Sierra, Apple has moved the recovery drive from listing under disk0 when diskutil list is run, to disk1. As a result the current extension attribute in the JSS does not work for reporting the presence of the recovery drive.
I am trying to re write the script to do an OS check then run the necessary command in the interest of only having one extension attribute for this instead of one for less than 10.13 and 10.13 or greater.
However, I am running into some sytax issues. Does anyone see what I have got wrong? Admittedly I am borrowing from other scripts...
#!/bin/sh
# Get the OS we're on
OSversion=`sw_vers | grep ProductVersion`
case $OSversion in
*10.11*)
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery" | grep disk0`
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
;;
*10.12*)
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery" | grep disk0`
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
;;
*10.13*)
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery" | grep disk1`
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
esac
Posted on 10-16-2017 02:11 PM
you haven't closed the if statements with a fi.
recoveryHDPresent=/usr/sbin/diskutil list | grep "Recovery" | grep disk0
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
fi
Posted on 10-16-2017 02:26 PM
That was it, thank you!
Posted on 10-16-2017 02:31 PM
I am pretty sure this will fail on a fusion drive or any other 10.13 configuration that doesn't use APFS.
I'd look for the presence of an Apple_APFS volume and if it's not present I think you can default back to the process for 10.12 or similar.
Posted on 10-17-2017 04:23 AM
This is what I have currently setup:
#!/bin/sh
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery HD"`
recoveryVolumePresent=`/usr/sbin/diskutil list | grep "APFS Volume Recovery"`
if [[ "$recoveryHDPresent" != "" ]] || [[ "$recoveryVolumePresent" != "" ]] ; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
fi
Posted on 03-13-2019 10:58 AM
Just so everyone has the most recent version with some foresight to 10.15 (unless apple changes something) and the correction with the 'fi' statements
#!/bin/sh
# Get the OS we're on
OSversion=`sw_vers | grep ProductVersion`
case $OSversion in
*10.11*)
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery" | grep disk0`
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
fi
;;
*10.12*)
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery" | grep disk0`
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
fi
;;
*10.13*)
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery" | grep disk1`
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
fi
;;
*10.14*)
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery" | grep disk1`
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
fi
;;
*10.15*)
recoveryHDPresent=`/usr/sbin/diskutil list | grep "Recovery" | grep disk1`
if [ "$recoveryHDPresent" != "" ]; then
echo "<result>Present</result>"
else
echo "<result>Not Present</result>"
fi
;;
esac