83 lines
2.9 KiB
Bash
83 lines
2.9 KiB
Bash
#!/bin/zsh
|
|
#######################
|
|
#
|
|
# Benjamin Buchheim - b.buchheim@eos-ts.com 13th April 2022
|
|
# Michelle Tembaak - m.tembaak.extern@eos-ts.com
|
|
# Script is used to rerun the macOS setup assistant due re-MDM-Enrollment
|
|
#
|
|
########################
|
|
|
|
#remove quarantine flag
|
|
xattr -r -d com.apple.quarantine /Library/Application\ Support/EOS/DEPNotify/DEPNotify.app
|
|
|
|
# defining Log-Files
|
|
DNLOG=/var/tmp/depnotify.log
|
|
CountDown=60
|
|
|
|
rm $DNLOG
|
|
touch $DNLOG
|
|
|
|
# Get the currently logged in user.
|
|
currentUser=$(/usr/bin/stat -f "%Su" /dev/console)
|
|
|
|
#Create help bubble
|
|
mv /Library/Application\ Support/EOS/menu.nomad.depnotify.plist /Users/$currentUser/Library/Preferences/
|
|
chown "$currentUser":"EOS\Domain Users" /Users/$currentUser/Library/Preferences/menu.nomad.depnotify.plist
|
|
|
|
# Since this is running as root, run the DEPNotify process as the currently logged in user instead
|
|
/usr/bin/sudo -u $currentUser /usr/bin/open -a /Library/Application\ Support/EOS/DEPNotify/DEPNotify.app/Contents/MacOS/DEPNotify --args
|
|
|
|
# echo "Command: Help: servicedesk@eos-ts.com +49-40-2850-1010 " >> $DNLOG
|
|
echo "Command: Image: /Library/Application Support/EOS/DEPNotify/EOS.png" >> $DNLOG
|
|
echo "Command: MainTitle: Migrating your Mac" >> $DNLOG
|
|
echo "Command: MainText: Please stand by, your mac is getting prepared for the migration.." >> $DNLOG
|
|
echo "Status: Cleaning up jamf" >> $DNLOG
|
|
|
|
sleep 10
|
|
echo "Command: Video: /Library/Application Support/EOS/DEPNotify/Enrollment.mp4" >> $DNLOG
|
|
|
|
|
|
# removing Jamf Framework - since the MDM Profile and other profiles need to be removed, this is will do everything in one step
|
|
echo "Status: Removing Jamf binary.." >> $DNLOG
|
|
/usr/local/jamf/bin/jamf removeFramework
|
|
|
|
# waiting till jamf removeFramework is completly done
|
|
sleep 60
|
|
|
|
# Preparing ReRun of the Setupassistant
|
|
echo "Status: Preparing Systemfiles for migration" >> $DNLOG
|
|
|
|
rm /var/db/.AppleSetupDone
|
|
sleep 10
|
|
touch /var/db/.RunLanguageChooserToo
|
|
sleep 10
|
|
rm /Library/Keychains/apsd.keychain
|
|
sleep 10
|
|
rm -rf /var/db/ConfigurationProfiles/
|
|
sleep 60
|
|
|
|
echo "Status: Enrolling device to Jamf Cloud" >> $DNLOG
|
|
# Ensure that the DEP-Settings are updated
|
|
profiles renew -type enrollment
|
|
|
|
# wait again till sync is completly done
|
|
sleep 60
|
|
|
|
echo "MigrationFromJSS" > "/Library/Application Support/EOS/EnrollmentMethod"
|
|
|
|
# Restarting
|
|
# echo "Command: MainText: All prepared, now we need to restart this Mac. Please continue and click on 'Restart' or wait a few seconds for automatic restart." >> $DNLOG
|
|
echo "Command: MainText: All prepared! Your mac needs to get restarted. Please wait for automatic restart." >> $DNLOG
|
|
# echo "Command: ContinueButtonRestart: Restart" >> $DNLOG
|
|
while [[ $CountDown -ge 0 ]]; do
|
|
echo "Status: Automatic restart in $CountDown" >> $DNLOG
|
|
echo "Command: MainTitle: Restart in $CountDown" >> $DNLOG
|
|
(( CountDown = $CountDown - 1 ))
|
|
sleep 1
|
|
done
|
|
echo "Command: RestartNow: Restarting.." >> $DNLOG && sleep 10
|
|
echo "Command: Quit" >> $DNLOG
|
|
shutdown -r now -k && exit 0
|
|
|
|
|