Skip to content

Instantly share code, notes, and snippets.

@rtrouton
Created May 12, 2015 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rtrouton/3c1032e9454ceda0ad66 to your computer and use it in GitHub Desktop.
Save rtrouton/3c1032e9454ceda0ad66 to your computer and use it in GitHub Desktop.
Installer postinstall script that installs two Office 2011 installers (the Office 2011 14.4.2 full installer and the 14.5.0 update) and automatically fixes an issue with the volume license being wiped out by the 14.5.0 update
#!/bin/sh
# Determine working directory
install_dir=`dirname $0`
# Location of Microsoft Office Volume License file
office_license="$3/Library/Preferences/com.microsoft.office.licensing.plist"
# Backup location for Microsoft Office 2011 Volume License file
license_backup="$3/tmp/com.microsoft.office.licensing.plist"
/usr/sbin/installer -dumplog -verbose -pkg "$install_dir/Office 2011 14.4.2 with Service Pack 4 Installer.pkg" -target "$3"
# Copy a backup of the Microsoft Office 2011 Volume License file to /tmp. If the license file is
# not available as /Library/Preferences/com.microsoft.office.licensing.plist, restore from the
# backup license file included with this installer.
if [[ -f "$office_license" ]]; then
cp "$office_license" "$license_backup"
fi
if [[ ! -f "$office_license" ]]; then
cp "$install_dir/com.microsoft.office.licensing.plist" "$license_backup"
fi
/usr/sbin/installer -dumplog -verbose -pkg "$install_dir/Office 2011 14.5.0 Update.pkg" -target "$3"
# If the Microsoft Office 2011 Volume License file has been removed from its proper
# location, restore it using the backup file stored in /tmp and then set the correct
# permissions on the file. If it is not available in /tmp, restore from the backup included
# with this installer.
if [[ ! -f "$office_license" ]] && [[ -f "$license_backup" ]]; then
cp "$license_backup" "$office_license"
chown root:wheel "$office_license"
fi
# Remove the backup file from /tmp
if [[ -f "$license_backup" ]]; then
rm "$license_backup"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment