Jump to content

How to check if two profiles are loaded before an install

Recommended Posts

Is anyone checking to see if two profiles are loaded before running an installer package?

I know how to use a requirements script to check for one profile.  What is a best practice to check for two and only run the installer if both profiles are loaded.

Can I just have two requirements scripts? or do I need to modify my current script to look for both profiles and only exit with '0' if both are there.

Link to comment
Share on other sites

  • Moderators

You could use the one requirement script and where it checks for the one profile just use an OR condition in the script to say profile A or profile B if present is ok. If you wanted both then AND can do it. That's how I'd approach it. 2 scripts can also work I imagine but I've just not done that though I can't see why it wouldn't work if you are trying to say BOTH should be there because each script would have an exit code allowing things to run or not run. Single script would give you the ability to say this OR that. 

Link to comment
Share on other sites

I am going to try both ways.  Using multiple scripts sounds simpler and I can put together a test fileset pretty easily.

I have been working on a script to check for both but it's not working as expected yet.  

I'll let you know what I ultimately use.  Thanks.

  • Like 1
Link to comment
Share on other sites

Multiple Requirement Script will increase the traffic back to server, so I'd keep to one if possible.  Try the following:



while [ $# -gt 0 ]
	find_this="profileIdentifier: $1"
	found_profile=$(profiles list all | awk -v search=$find_this  '$0 ~ search {print $NF}')
	if [ ! -z $found_profile ]
		counter=$(( $counter + 1 ))

if [ $counter -ne $total ]
	exit 1

exit 0

Add each required profile ID, of each profile to be located, as individual Launch Arguments in the scripts Get Info > Executable.  Doesn't matter how many you add, script should only exit 0 if all added Launch Arguments are found.

  • Like 3
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
  • Create New...