#!/bin/sh
set -e
if [[ $EUID -ne 0 ]]; then
exec sudo "$0"
exit 1
fi
REC_DEV=$(diskutil info `df /|awk '/disk/ {print $1}'`|awk '/Recovery Disk:/ {print $3}')
diskutil mount ${REC_DEV}
cd /Volumes/Recovery\ HD/com.apple.recovery.boot/
CURRENT_DARWIN_VER=$(uname -a|awk '{print $7}'|sed 's/://g')
ORIG_DARWIN_VER=$(strings prelinkedkernel|egrep -o "Kernel Version \S+"|egrep -o "\d[0-9.]+\d")
if [[ $CURRENT_DARWIN_VER != $ORIG_DARWIN_VER ]]
then
echo "System Darwin Version does NOT match Recovery Darwin Version!!!"
echo "Aborting script."
exit 1
fi