Created
May 15, 2017 11:21
-
-
Save fuzzylogiq/360bf52224c6f6e79ed4c43afbf0627c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>RestartAction</key> | |
| <string>RequireRestart</string> | |
| <key>_metadata</key> | |
| <dict> | |
| <key>created_by</key> | |
| <string>ouit0354</string> | |
| <key>creation_date</key> | |
| <date>2017-05-12T10:15:20Z</date> | |
| <key>munki_version</key> | |
| <string>3.0.0.3316</string> | |
| <key>os_version</key> | |
| <string>10.11.5</string> | |
| </dict> | |
| <key>apple_item</key> | |
| <true/> | |
| <key>autoremove</key> | |
| <false/> | |
| <key>catalogs</key> | |
| <array> | |
| <string>unstable</string> | |
| </array> | |
| <key>category</key> | |
| <string>Operating System</string> | |
| <key>description</key> | |
| <string>Siri makes its debut on Mac, with new capabilities designed just for the desktop. And that’s not the only way your Mac is smarter. macOS Sierra helps you rediscover your best photos, shop faster and more conveniently online, and work more seamlessly between devices. It can also help free up valuable storage space. Now your Mac does even more for you, so you can do more with your Mac.</string> | |
| <key>developer</key> | |
| <string>Apple</string> | |
| <key>display_name</key> | |
| <string>Install macOS Sierra</string> | |
| <key>installed_size</key> | |
| <integer>9227469</integer> | |
| <key>installer_item_hash</key> | |
| <string>232c3cd9343587e2f7d52ef89bb807275528791a0d43403d1fd5d80b5c17a3fe</string> | |
| <key>installer_item_location</key> | |
| <string>OS_X/Install macOS Sierra-10.12.4.dmg</string> | |
| <key>installer_item_size</key> | |
| <integer>4841735</integer> | |
| <key>installer_type</key> | |
| <string>startosinstall</string> | |
| <key>minimum_munki_version</key> | |
| <string>3.0.0.3211</string> | |
| <key>minimum_os_version</key> | |
| <string>10.8</string> | |
| <key>name</key> | |
| <string>Install_macOS_Sierra</string> | |
| <key>preinstall_script</key> | |
| <string>#!/bin/bash | |
| # Creates two files: | |
| # | |
| # 1. A LaunchDaemon that executes a script (described next) at load. | |
| # | |
| # 2. A utility script that untars the Munki log tgz created by this script, then | |
| # removes itself and the LaunchDaemon (described previously). | |
| # | |
| # Copyright (C) 2014-2016 Oxford University | |
| # Robin Miller <robin.miller(at)it.ox.ac.uk> | |
| # Ben Goodstein <ben.goodstein(at)it.ox.ac.uk> | |
| # | |
| # This program is free software; you can redistribute it and/or modify it under | |
| # the terms of the GNU General Public License version 3 as published by the | |
| # Free Software Foundation. | |
| # | |
| # $HeadURL: https://svn.oucs.ox.ac.uk/groups/nsms/src/n/nsms-mmp-scripts/trunk/Preserve_Munki_Logs.sh $ | |
| # $LastChangedRevision: 20645 $ | |
| # $LastChangedDate: 2016-06-29 12:38:13 +0100 (Wed, 29 Jun 2016) $ | |
| # $LastChangedBy: ouit0354 $ | |
| TESTFILE=/Library/Orchard/testfile_preinstall | |
| # Testing that preinstall_script is running | |
| echo "Ran" > "${TESTFILE}" | |
| PATH=/usr/sbin:/usr/local/bin:/usr/local/jamf/bin:${PATH} | |
| Title='Preserve_Munki_Logs' | |
| Target=$1 | |
| Launchd_Plist="/Library/LaunchDaemons/uk.ac.ox.orchard.${Title}.plist" | |
| Utility_Title="Orchard_${Title}" | |
| Utility_Script_Location='/Library/Orchard/sbin' | |
| Utility_Script_Name="${Utility_Title}.sh" | |
| Utility_Script="${Utility_Script_Location}/${Utility_Script_Name}" | |
| Munki_Log_Dir="/private/var/log/munki" | |
| Munki_Log_Tgz="/Library/Managed Installs/munkilogs.tgz" | |
| # Tar and gzip the current munki logs (if they exist) | |
| if [ -d "${Munki_Log_Dir}" ]; then | |
| tar czf "${Munki_Log_Tgz}" "${Munki_Log_Dir}" | |
| fi | |
| # Launchd plist XML, with variable interpolation: | |
| read -r -d '' Plist_Content <<EOF | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>${Title}</string> | |
| <key>RunAtLoad</key> | |
| <true/> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>${Utility_Script}</string> | |
| </array> | |
| </dict> | |
| </plist> | |
| EOF | |
| # Create the launchd plist on the target: | |
| echo "$Plist_Content" > "${Target}${Launchd_Plist}" || { echo "ERROR: launchd plist could not be created at '${Target}${Launchd_Plist}'"; exit 1; } | |
| chown 0:0 "${Target}${Launchd_Plist}" || { echo "ERROR: Could not set ownership of '${Target}${Launchd_Plist}'"; exit 1; } | |
| chmod 0644 "${Target}${Launchd_Plist}" || { echo "ERROR: Could not set mode of '${Target}${Launchd_Plist}'"; exit 1; } | |
| # Success: | |
| echo "INFO: Successful creation of '${Target}${Launchd_Plist}'." | |
| # Utility Script: | |
| # NOTE: Parameter substitution is active, so variables that shouldn't be interpolated here must be escaped! | |
| read -r -d '' Script_Content <<EOF | |
| #!/bin/bash | |
| # Generated script to restore Munki tarred logs, created by | |
| # the script indicated in the SVN tag below: | |
| # | |
| # \$HeadURL: https://svn.oucs.ox.ac.uk/groups/nsms/src/n/nsms-mmp-scripts/trunk/Preserve_Munki_Logs.sh $ | |
| PATH=/usr/sbin:/usr/local/bin:/usr/local/jamf/bin:\${PATH} | |
| function Restore_Munki_Logs { | |
| logger "\${0}: INFO - Restoring munki logs..." | |
| if [ -f "${Munki_Log_Tgz}" ]; then | |
| cd / | |
| tar zxf "${Munki_Log_Tgz}" | |
| cd - | |
| logger "\{0}: INFO - Munki logs restored" | |
| else | |
| logger "\{0}: INFO - Munki logs not available in at ${Munki_Log_Tgz}" | |
| fi | |
| } | |
| function Remove_Self_and_Terminate { | |
| rm "${Launchd_Plist}" || { logger "\${0}: ERROR - '${Launchd_Plist}' could not be deleted."; exit 1; } | |
| rm "${Utility_Script}" || { logger "\${0}: ERROR - could not delete self."; exit 1; } | |
| logger "\${0}: INFO - Script and launchd plist file removed. Now removing parent launchd job, which will also terminate this script." | |
| launchctl remove "$Title" | |
| } | |
| Restore_Munki_Logs | |
| Remove_Self_and_Terminate | |
| EOF | |
| mkdir -p "${Target}${Utility_Script_Location}" || { echo "ERROR: could not create '${Target}${Utility_Script_Location}'"; exit 1; } | |
| echo "$Script_Content" > "${Target}${Utility_Script}" || { echo "ERROR: File could not be created at '${Target}${Utility_Script}'."; exit 1; } | |
| chown 0:0 "${Target}${Utility_Script}" || { echo "ERROR: Could not set ownership of '${Target}${Utility_Script}'"; exit 1; } | |
| chmod 0755 "${Target}${Utility_Script}" || { echo "ERROR: Could not set mode of '${Target}${Utility_Script}'"; exit 1; } | |
| # Success: | |
| echo "INFO: Successful creation of '${Target}${Utility_Script}'." | |
| exit 0</string> | |
| <key>unattended_install</key> | |
| <false/> | |
| <key>unattended_uninstall</key> | |
| <false/> | |
| <key>uninstallable</key> | |
| <false/> | |
| <key>version</key> | |
| <string>10.12.4</string> | |
| </dict> | |
| </plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment