forked from laurentpertois/High-Sierra-Compatibility-Checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHigh_Sierra_Compatibility_Checker.sh
executable file
·124 lines (108 loc) · 5.92 KB
/
High_Sierra_Compatibility_Checker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Copyright (c) 2017 Jamf. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the Jamf nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY JAMF SOFTWARE, LLC "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL JAMF SOFTWARE, LLC BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This script was designed to be used as an Extension Attribute to ensure specific
# requirements have been met to deploy macOS High Sierra.
#
# General Requirements:
# - OS X 10.7.5 or later
# - 4GB of memory (Apple says 2GB for 10.12, I prefer having a minimum of 4GB)
# - 15GB of available storage (Apple says 8.8GB for 10.12, I prefer more space)
#
# These last 2 requirements can be modified in the first 2 variables (MINIMUMRAM
# and MINIMUMSPACE).
# - REQUIREDMINIMUMRAM: minimum RAM required, in GB
# - REQUIREDMINIMUMSPACE: minimum disk space available, in GB
#
#
# Mac Hardware Requirements and equivalent as minimum Model Identifier
# - MacBook (Late 2009 or newer), ie MacBook6,1
# - MacBook Pro (Mid 2010 or newer), ie MacBookPro7,1
# - MacBook Air (Late 2010 or newer), ie MacBookAir3,1
# - Mac mini (Mid 2010 or newer), ie Macmini4,1
# - iMac (Late 2009 or newer), ie iMac10,1
# - Mac Pro (Mid 2010 or newer), ie MacPro5,1
#
# Default compatibility is set to False if no test pass (variable COMPATIBILITY)
#
# Written by: Laurent Pertois | Senior Professional Services Engineer | Jamf
#
# Created On: 2017-08-27
# Updated On: 2017-08-31
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Minimum RAM and Disk Space required (4GB and 15GB here)
REQUIREDMINIMUMRAM=4
REQUIREDMINIMUMSPACE=15
#########################################################################################
############### DO NOT CHANGE UNLESS NEEDED
#########################################################################################
# Default values for Compatibility is false
COMPATIBILITY="False"
#########################################################################################
############### Let's go!
#########################################################################################
# Checks minimum version of the OS before upgrade (10.7.5)
OSVERSIONMAJOR=$(sw_vers -productVersion | awk -F"." '{ print $2 }')
OSVERSIONMINOR=$(sw_vers -productVersion | awk -F"." '{ print $3 }')
# Checks if computer meets pre-requisites for High Sierra
if [[ "$OSVERSIONMAJOR" -ge 8 && "$OSVERSIONMAJOR" -lt 13 || "$OSVERSIONMAJOR" -eq 7 && "OSVERSIONMINOR" -eq 5 ]]; then
# Transform GB into Bytes
GIGABYTES=$((1024 * 1024 * 1024))
MINIMUMRAM=$(($REQUIREDMINIMUMRAM * $GIGABYTES))
MINIMUMSPACE=$(($REQUIREDMINIMUMSPACE * $GIGABYTES))
# Gets the Model Identifier, splits name and major version
MODELIDENTIFIER=$(/usr/sbin/sysctl -n hw.model)
MODELNAME=$(echo "$MODELIDENTIFIER" | sed 's/[^a-zA-Z]//g')
MODELVERSION=$(echo "$MODELIDENTIFIER" | sed 's/[^0-9,]//g' | awk -F, '{print $1}')
# Gets amount of memory installed
MEMORYINSTALLED=$(/usr/sbin/sysctl -n hw.memsize)
# Gets free space on the boot drive
FREESPACE=$(diskutil info / | awk -F'[()]' '/Free Space|Available Space/ {print $2}' | sed -e 's/\ Bytes//')
# Checks if computer meets pre-requisites for High Sierra
if [[ "$MODELNAME" == "iMac" && "$MODELVERSION" -ge 10 && "$MEMORYINSTALLED" -ge "$MINIMUMRAM" && "$FREESPACE" -ge "$MINIMUMSPACE" ]]; then
COMPATIBILITY="True"
elif [[ "$MODELNAME" == "Macmini" && "$MODELVERSION" -ge 4 && "$MEMORYINSTALLED" -ge "$MINIMUMRAM" && "$FREESPACE" -ge "$MINIMUMSPACE" ]]; then
COMPATIBILITY="True"
elif [[ "$MODELNAME" == "MacPro" && "$MODELVERSION" -ge 5 && "$MEMORYINSTALLED" -ge "$MINIMUMRAM" && "$FREESPACE" -ge "$MINIMUMSPACE" ]]; then
COMPATIBILITY="True"
elif [[ "$MODELNAME" == "MacBook" && "$MODELVERSION" -ge 6 && "$MEMORYINSTALLED" -ge "$MINIMUMRAM" && "$FREESPACE" -ge "$MINIMUMSPACE" ]]; then
COMPATIBILITY="True"
elif [[ "$MODELNAME" == "MacBookAir" && "$MODELVERSION" -ge 3 && "$MEMORYINSTALLED" -ge "$MINIMUMRAM" && "$FREESPACE" -ge "$MINIMUMSPACE" ]]; then
COMPATIBILITY="True"
elif [[ "$MODELNAME" == "MacBookPro" && "$MODELVERSION" -ge 7 && "$MEMORYINSTALLED" -ge "$MINIMUMRAM" && "$FREESPACE" -ge "$MINIMUMSPACE" ]]; then
COMPATIBILITY="True"
fi
# Outputs result
echo "<result>$COMPATIBILITY</result>"
else
echo "<result>$COMPATIBILITY</result>"
exit $?
fi