How do I make a script to run in the terminal after installing an application?

XMY7250
New Contributor II

How do I make a script to run in the terminal after installing an application?

After installing the Google File Drive Stream PKG, the following command is invoked in terminal.

/Applications/Google Drive File Stream.app/Contents/MacOS/Google Drive File Stream force-browser-auth

3 REPLIES 3

mm2270
Legendary Contributor III

You don't usually make scripts run "in the Terminal" when talking about either silent deployments, or something run in Self Service, etc. You can run the script command in the shell. Terminal is really just a tool for interacting with the shell, but in most cases you don't want to have Terminal come up to run anything since it's unnecessary and distracting.

For your use case, you could handle it a couple of different ways.
One simple way would be to take the exact line you have above there (but maybe with a file extension added?) and drop it into the Files and Processes payload's Execute Command line. That tells the policy to run that command, or a series of them, after all other actions in the policy, like installing the application, have completed.

Another way is to create a script that would run that command, and add it to the same policy under Scripts, run as "After". The main advantage a script has is that it's easier to test for conditions to make sure commands aren't being run unnecessarily.

But either way should work, generally speaking.

wmehilos
Contributor

You can either add it to a postinstall script in Composer (click the drop down arrow next to the pkg root, then open the scripts folder), or you can import the script to your Jamf Pro Server and run it via the same policy that is installing the Drive Stream.pkg with an "After" priority.

tnielsen
Valued Contributor

Use composer and add a "post-install" shell script. Add your one liner in there, build it, done.