almog
almog

Reputation: 51

Mac Installer : How to determine if pkg installation is intercative

Mac Installer: I want to do something (popup dialog) in the postinstall script ONLY if it is an interactive installation. (not through MDM or command line)

How can I determine in my postinstall script if the installation is interactive or not?

Upvotes: 1

Views: 1069

Answers (1)

almog
almog

Reputation: 51

Maybe will help to someone in the future:

There are 2 options: (one can combine those 2 options to have full solutions, depends on its needs)

  1. One of the environment variables set by macos installer is a flag COMMAND_LINE_INSTALL that is set to 1 in case of installer being executed from the terminal.

In my case I just had to check if COMMAND_LINE_INSTALL exists, if not - it means that this is interactive installation.

IMPORTANT: this environment variable exist and value=1 ONLY in case of installation from terminal(command line).

During installation from MDM this variable doesn't exist

=========================================================================

  1. Another solution (that helps me determine if installation is from MDM or not):

From the post install script: run ps and check the existence of "/System/Library/CoreServices/Installer.app/Contents/MacOS/Installer"

If it exists- it means the installation is interactive (via mac installer app).

The lines I used:

INSTALLER_APP_PATH ="/System/Library/CoreServices/Installer.app/Contents/MacOS/Installer"

if ps aux | grep -v grep | grep -q "$INSTALLER_APP_PATH"
then
     echo "Interactive installation"
else
    echo "Not an interactive installation"
fi

Upvotes: 1

Related Questions