Created
August 5, 2016 08:57
-
-
Save MiqViq/645c0d70022f0df9bb0f241a25e15707 to your computer and use it in GitHub Desktop.
Tries to find the first internal Recovery HD and set the computer to boot from it on the next boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# set_boot_recovery_hd.sh | |
# | |
# tries to find the first internal Recovery HD and set the computer to boot from it on the next boot | |
# | |
# | |
# actions | |
listRecoveryHDs=$(diskutil list | grep 'Apple_Boot Recovery HD' | awk '{print $NF}') | |
if [ "$listRecoveryHDs" == "" ] | |
then | |
echo "ERROR: No Recovery HD partitions available." | |
exit 1 | |
fi | |
IFS=$'\n' | |
for recoPart in $listRecoveryHDs | |
do | |
if diskutil info "$recoPart" | grep -woq 'Internal' | |
then | |
/usr/sbin/bless --device /dev/$recoPart --setBoot --nextonly && \ | |
echo "Set computer to boot from internal Recovery HD /dev/$recoPart" | |
exit 0 | |
fi | |
done | |
echo "ERROR: No INTERNAL Recovery HD partitions available." | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment