Shell script and AppleScript in Postflight script for an installer package

Not applicable

I've written quite a few Mac installers, distributed to users who ran them as administrators, but now I'm trying to customize an MS Office 2011 installer in a more managed environment where users may not have admin permissions.

My goal is to push out the installer with ARD or Casper and have it warn users to quit any Word applications, run a custom install and clean up Dock icons if possible. The installer is moved to /private/tmp/, along with a "ChoiceChanges.xml" file, and the postflight script runs /usr/bin/installer on the package, applying the xml file to unselect Entourage and other stuff. That much works fine, but I'm having two other problems with the postflight (/bin/sh) script.

  1. The script has a line to check whether the Finder is running, and if so to clean up Office Dock icons. Here's the code:

    # run ps, see if Finder is running and if it is, grab the UID of the process owner for setting permissions later. FinderUID=`/bin/ps -axfc | /usr/bin/grep Finder | /usr/bin/sed 's/^ *//' | cut -d -f1`

    # DEBUGGING... LINE_FinderUID=/bin/ps -axfc | /usr/bin/grep Finder /bin/echo "DEBUG THIS ps -axfc output: $LINE_FinderUID" >> /var/log/Office2011Install.log

    #

    # remove dock items if if [ $FinderUID ]; then # log the result /bin/echo "Finder is RUNNING with UID= $FinderUID" >> /var/log/Office2011Install.log

This works fine if the logged-in user runs the installer themselves on the target machine, OR when I push the installer out with Casper or ARD to an OS 10.6.8 machine, but when I push it to a Leopard machine it does not work, and the debugging line returns nothing. (If I ssh in from another machine and sudo to root, I get the correct UID, and, again, the log entry always is correct on Snow Leopard test machines).

Any ideas on what might be happening on Leopard machines? What might have changed in Snow Leopard or how to fix?

  1. My second question is about user interaction. I've written an AppleScript to prompt the user to close any open Windows applications before the installer forces their window to close with without warning (potentially losing work). The script works if the user launches the installer themselves, but I can't find a way to launch it interactively, even if I launch it as the current user:

    /usr/bin/sudo -u $FinderUsername /usr/bin/open /private/tmp/QuitOfficeProcesses_warning.app

Is there no way to run display dialog in an AppleScript in an postflight script that I push it out with Casper or ARD? (I tried to use osascript: osascript -e 'display dialog "Warning!" '
...but that gives me an execution error "no user interaction allowed".

If not, I can figure out how to detect open Office applications with a shell script, but how do I communicate to the user that they need to quit? Do I need to use iHook?

thanks for any help,

Rick Horlick

0 REPLIES 0