diff --git a/enrollment-cleanup.sh b/enrollment-cleanup.sh new file mode 100644 index 0000000..a80340b --- /dev/null +++ b/enrollment-cleanup.sh @@ -0,0 +1,63 @@ +#!/bin/bash +##################################################################################################### +# +# ABOUT THIS PROGRAM +# +# NAME +# EnrollmentProcessCleanUp.sh -- Removes the enrollmentProfile from downloads folder if present and then kill Safari +# +# SYNOPSIS +# sudo EnrollmentProcessCleanUp.sh +# +#################################################################################################### +# +# HISTORY +# +# Version: 1.1 +# +# - v.1.0 Martyn Watts, 05.07.2021 - Initial Build +# - v.1.1 Martyn Watts, 07.07.2021 - Added the process to kill off safari to ensure that it doesn't interfere with Acrobat install +# - v.1.2 Martyn Watts, 08.07.2021 - Added DEPNotify Updates +# +# +#################################################################################################### +deplog="/var/tmp/depnotify.log" + +/bin/echo "Status: Cleaning up the Enrollment Process" >> ${deplog} +sleep 2 + +loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' ) +fileLocation="/Users/${loggedInUser}/Downloads/enrollmentProfile.mobileconfig" + +logfile="/Library/Logs/EnrollmentProcessCleanUp.log" + + /bin/echo "`date`: Forcing Safari to quit if open" >> ${logfile} + /bin/echo "Status: Forcing Safari to quit if open" >> ${deplog} + /bin/echo "Forcing Safari to quit if open" + killall Safari + + /bin/echo "`date`: Closing System Preferences if open" >> ${logfile} + /bin/echo "Status: Closing System Preferences if open" >> ${deplog} + /bin/echo "Closing System Preferences if open" + +osascript <> ${deplog} + /bin/echo "`date`: ${fileLocation} found - Deleting" >> ${logfile} + /bin/rm -rf "${fileLocation}" + /bin/echo "--" >> ${logfile} + else + /bin/echo "${fileLocation} not present - Exiting" + /bin/echo "Status: ${fileLocation} not present - Exiting" >> ${deplog} + /bin/echo "`date`: ${fileLocation} not present - Exiting" >> ${logfile} + /bin/echo "--" >> ${logfile} + fi + + /bin/echo "Command: DeterminateManualStep: 1" >> ${deplog} +exit 0