-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcoreconfig-install-macos10.13.sh
141 lines (108 loc) · 4.98 KB
/
coreconfig-install-macos10.13.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
###################################################################
#
# Enable macOS re-install for Macs not on 10.13
#
# Date: Thu 20 Feb 2020 15:06:23 GMT
# Version: 0.1.9
# Creator: ganders1
#
##################################################################
# # # # # #
# SYSTEM CHECKS
# # # # # #
# Check the install process isn't underway
if [ -e /macOS\ Install\ Data ]
then
# Install process already underway
exit 0
fi
if ! [ -e "/Library/Application Support/JAMF/Receipts/Install_macOS_High_Sierra-13.6.02-1.sig.pkg" ]
then
rm -fR "/Applications/Install macOS High Sierra.app"
fi
osversion=`sw_vers -productVersion | awk -F . '{print $2}'`
if [ $osversion == "13" ]; then
# Delete the login banner and receipt as OS is already on the one we want.
rm -fR /Library/Security/PolicyBanner.rtfd
rm -dfR "/Library/Application Support/JAMF/Receipts/SavingPolicyBanner*.pkg"
# Do a recon
/usr/local/bin/jamf recon
fi
# Check if free space > 15GB
bootDisk=`diskutil info / | grep "Device Node:" | awk '{print $3}'`
freeSpace=`df -g | grep "${bootDisk}" | awk '{print $4}'`
if [[ ${freeSpace%.*} -ge 15 ]]; then
/bin/echo "Disk Check: OK - ${freeSpace%.*} Free Space Detected"
else
/bin/echo "Disk Check: ERROR - ${freeSpace%.*} Free Space Detected"
# Trigger Yo notification on low disk space pointing users to https://edin.ac/mac-low-disk-space
/usr/local/bin/jamf policy -event low-disk-space
exit 1;
fi
username=$( python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");' )
if [ -z $username ]; then
NoUser=True
else
NoUser=False
fi
sleep 2
##Heading to be used for jamfHelper
heading=' Preparing for macOS install '
# Title to be used for jamfHelper
description='Please wait as we prepare your computer for macOS High Sierra...
This process will take approximately 10-15 minutes.
Once completed your computer will reboot and begin the install.'
##Icon to be used for jamfHelper
if [ -f /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/InstallAssistant.icns ]; then
icon=/Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/InstallAssistant.icns
else
icon=/System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns
fi
##Launch jamfHelper
if [ $NoUser == False ]; then
/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType hud -title "" -icon "$icon" -heading "$heading" -description "$description" &
jamfHelperPID=$(echo $!)
fi
##Start macOS Upgrade
macOS_app_vers=`defaults read "/Applications/Install macOS High Sierra.app/Contents/Info" CFBundleShortVersionString | awk -F "." '{print $1$2}'`
echo $macOS_app_vers
if [ -z $macOS_app_vers ]; then
macOS_app_vers=126
fi
if [ $macOS_app_vers -ge 136 ]; then
# delete the login banner as we are updating macOS
rm -fR /Library/Security/PolicyBanner.rtfd
#For Labs, remove receipt for the login banner so it gets put back after upgrade.
rm -dfR "/Library/Application Support/JAMF/Receipts/SavingPolicyBanner*.pkg"
# Create the upgrade flag to ensure a recon after the upgrade.
touch /Library/MacSD/SUDONE
if [ $NoUser == True ]; then
echo "No user present, starting osinstall"
/Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/startosinstall --applicationpath /Applications/Install\ macOS\ High\ Sierra.app --nointeraction --agreetolicense
else
echo "User present, starting osinstall"
/Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/startosinstall --applicationpath /Applications/Install\ macOS\ High\ Sierra.app --nointeraction --agreetolicense --pidtosignal $jamfHelperPID &
killall "Self Service"
fi
else
# Do a delete incase an older version is there
rm -fR "/Applications/Install macOS High Sierra.app"
# Add the installer
/usr/local/bin/jamf policy -event OS-Installer-13
# Delete the login banner as we are updating macOS
rm -fR /Library/Security/PolicyBanner.rtfd
#For Labs, remove receipt for the login banner so it gets put back after upgrade.
rm -dfR "/Library/Application Support/JAMF/Receipts/SavingPolicyBanner*.pkg"
# Create the upgrade flag to ensure a recon after the upgrade.
touch /Library/MacSD/SUDONE
if [ $NoUser == True ]; then
echo "No user present, starting osinstall"
/Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/startosinstall --applicationpath /Applications/Install\ macOS\ High\ Sierra.app --nointeraction --agreetolicense
else
echo "User present, starting osinstall"
/Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/startosinstall --applicationpath /Applications/Install\ macOS\ High\ Sierra.app --nointeraction --agreetolicense --pidtosignal $jamfHelperPID &
killall "Self Service"
fi
fi
exit 0;