篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh OS X 10.10 Yosemite升级检查相关的知识,希望对你有一定的参考价值。
#!/bin/bash
# OS X 10.10 Yosemite Upgrade
#
# Prerequisites for this upgrade:
# (this computer already checked and passed)
# - OS X 10.6.8+ already installed
# - 2 GB or more of memory
# - 8 GB or more of available disk space
# - 64-bit CPU
# - Supported Mac hardware model
os_upgrade_version="OS X 10.10 Yosemite"
######################
# Check Operating System Version
######################
product_version=$(sw_vers -productVersion)
os_vers=$(echo $product_version | cut -d "." -f1)
os_vers_major=$(echo $product_version | cut -d "." -f2)
os_vers_minor=$(echo $product_version | cut -d "." -f3)
echo "Current OS: ${os_vers}.${os_vers_major}.${os_vers_minor}"
if [ $os_vers==10 ] && [ ${os_vers_major} -ge 10 ]; then
echo "Current Operating System is ${os_upgrade_version} or newer already. Quitting."
exit 1
fi
case $os_vers_major in
[7-9])
echo "Current Operating System is eligible for an upgrade to ${os_upgrade_version}."
;;
6)
if [[ $os_vers_minor == 8 ]]; then
echo "Current Operating System is eligible for an upgrade to ${os_upgrade_version}."
else
echo "Current Operating System is too old to upgrade to ${os_upgrade_version}."
exit 1
fi
;;
*)
echo "Unable to determine if your system is eligible for an upgrade to ${os_upgrade_version}"
exit 1
;;
esac
# Check CPU Architecture
# Only 64-bit is Supported
hwcpu64bit=$(sysctl -n hw.cpu64bit_capable)
if [[ $hwcpu64bit ]]; then
echo "64-bit processor detected."
else
echo "64-bit processor not detected. Quitting."
exit 1
fi
######################
# Check hardware model
######################
hwmodel=$(sysctl -n hw.model)
hwmodel_name=$(echo ${hwmodel} | sed 's/[[:digit:]].*//')
hwmodel_num=$(echo ${hwmodel} | sed 's/[^[:digit:]]*//' | cut -d, -f1)
hwmodel_rev=$(echo ${hwmodel} | sed 's/[^[:digit:]]*//' | cut -d, -f2)
hwmodel_pass=0
# iMac
# Macmini
# MacPro
# MacBook
# MacBookPro
# MacBookAir
# Xserve
# http://www.everymac.com/mac-answers/os-x-yosemite-faq/os-x-yosemite-compatible-macs-system-requirements.html
if [[ "${hwmodel_name}" == "iMac" ]]; then
if [[ ${hwmodel_num} -ge 7 ]]; then
hwmodel_pass=1
fi
elif [[ "${hwmodel_name}" == "MacBook" ]]; then
if [[ ${hwmodel_num} -ge 5 ]]; then
hwmodel_pass=1
fi
elif [[ "${hwmodel_name}" == "MacBookAir" ]]; then
if [[ ${hwmodel_num} -ge 2 ]]; then
hwmodel_pass=1
fi
elif [[ "${hwmodel_name}" == "MacBookPro" ]]; then
if [[ ${hwmodel_num} -ge 3 ]]; then
hwmodel_pass=1
fi
elif [[ "${hwmodel_name}" == "Macmini" ]]; then
if [[ ${hwmodel_num} -ge 3 ]]; then
hwmodel_pass=1
fi
elif [[ "${hwmodel_name}" == "MacPro" ]]; then
if [[ ${hwmodel_num} -ge 3 ]]; then
hwmodel_pass=1
fi
fi
if [[ ${hwmodel_pass} ]]; then
echo "Model Identifier: ${hwmodel}"
else
echo "This computer does not meet the hardware model requirements for ${os_upgrade_version}. Quitting."
exit 1
fi
######################
# Check system specs
######################
# RAM
hwmemsize=$(sysctl -n hw.memsize)
# 1024**3 = GB
ramsize=$(expr $hwmemsize / $((1024**3)))
if [[ ${ramsize} -ge "2" ]]; then
echo "System Memory: ${ramsize} GB"
hwmemsize_pass=1
else
echo "Less than 2GB of RAM detected. Quitting."
exit 1
fi
# Disk Space
diskutil_plist="$(mktemp -t "diskutil").plist"
diskutil info -plist / > ${diskutil_plist}
freespace=$(defaults read "${diskutil_plist}" FreeSpace)
rm "${diskutil_plist}"
# 1024**3 = GB
freespace=$(expr $freespace / $((1024**3)))
if [[ $freespace -ge "8" ]]; then
echo "Free Space: ${freespace} GB"
else
echo "Less than 8GB of free disk space detected. Quitting."
exit 1
fi
echo "This computer has passed all checks and is eligible for an upgrade to ${os_upgrade_version}."
exit 0
以上是关于sh OS X 10.10 Yosemite升级检查的主要内容,如果未能解决你的问题,请参考以下文章