bash - When my pkg runs its Post-installation script, how can I know how that happened? -
there 2 ways script can run: when user opens pkg
file , goes through normal gui setup, or when admin (or savvy user) runs sudo installer -pkg /path/to/installer.pkg -target /
. second one, want know when script run in mode can make more admin-friendly decisions not opening gui. how know when pkg
installed via command line?
i'm hoping environment variable or similar.
running script via sudo change values of variables , add others in. script check existence of variables (or values) make determination whether installer run via sudo.
values updated:
home
logname
mail
values set:
sudo_command
-- command run via sudosudo_gid
-- gid of user ran sudosudo_uid
-- uid of user ran sudosudo_user
-- username of user ran sudo
my recommendation check existence of sudo_command
environment variable; unlikely set non-sudo installation, , set sudo-based installation.
reference: sudo 1.8.20 manual - environment section
Comments
Post a Comment