Running a sh script with -i as a parameter. Can this be done?

Bernard_Huang
Contributor III

Hi all,

I have a install.sh script, and to run it, I manually would have to do "sudo sh install.sh -i"

If I put it to JSS, I notice in the script options, there are parameter 4, parameter 5, etc.

Can I just add in my script, then have a policy that calls the script with parameter 4 = -i ?

1 ACCEPTED SOLUTION

m_entholzner
Contributor III

Hi @Bernard.Huang ,
you can wrap that install.sh in a installation package. Copy the install.sh to /private/tmp, add a post install script with the following content:

#!/bin/bash

sh /private/tmp/install.sh -i

exit 0

You don't need sudo in scripts executed as pre- or postinstall package scripts because they are already executed as root.

View solution in original post

4 REPLIES 4

m_entholzner
Contributor III

Hi @Bernard.Huang ,
you can wrap that install.sh in a installation package. Copy the install.sh to /private/tmp, add a post install script with the following content:

#!/bin/bash

sh /private/tmp/install.sh -i

exit 0

You don't need sudo in scripts executed as pre- or postinstall package scripts because they are already executed as root.

Bernard_Huang
Contributor III

Thanks for that.

I also thought of your solution, but when I saw the parameters, I thought, if it worked, would make it even easler.

cvgs
Contributor II

The parameter method will not work, because parameters 1 to 3 are hard-coded by the JSS to target volume, computer name and user name - so you would be issuing "install.sh / myComputer myUser -i" instead of "install.sh -i". Better repackage the script into a payload-free package.
Is it McAfee you are trying to install?

Bernard_Huang
Contributor III

@cvgs

Yes, you are correct. I am trying to install McAfee.
With the El Capitan > Sierra upgrade happening, our security team are providing us a new McAfee. So I need to push it to every Macbook.

With everyone's information, I'm about 50% through my scripting and testing, so thank you everyone :)