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 sudo
  • sudo_gid -- gid of user ran sudo
  • sudo_uid -- uid of user ran sudo
  • sudo_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

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -