Skip to content

Instantly share code, notes, and snippets.

@rtrouton
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtrouton/10310659 to your computer and use it in GitHub Desktop.
Save rtrouton/10310659 to your computer and use it in GitHub Desktop.
Installer postinstall script that installs two Office 2011 installers (the Office 2011 14.3.0 full installer and the 14.4.1 update) and automatically fixes an issue with the volume license being wiped out by the 14.4.1 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.3.0 with Service Pack 3 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.4.1 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 [[ ! -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