There are two ways this script can be run: When the user opens the pkg
file and goes through the normal GUI setup, or when an admin (or savvy user) runs sudo installer -pkg /path/to/Installer.pkg -target /
. For the second one, I want to know when the script was run in this mode so I can make more admin-friendly decisions like not opening another GUI. How do I know when my pkg
is installed via the command line?
I'm hoping for some environment variable or something similar.
Since this was being run by the installer
command, the COMMAND_LINE_INSTALL
environment variable is set to 1
. When opening the pkg
normally, this variable is not set at all.
So:
if [ $COMMAND_LINE_INSTALL ]; then
# Do stuff for CLI land
else
# Do stuff for GUI land
fi