Posted on 11-10-2016 09:55 AM
I'm trying to evoke a policy in the post install phase of a payload free package. I created the postinstall script in Composer and entered the line:
#!/bin/sh
## postinstall
jamf policy -event sierra-postinstall
exit 0 ## Success
exit 1 ## Failure
But when I install the package it doesn't run the policy that I have set up with trigger "sierra-postinstall". I can run the policy just fine via terminal.
Is this not possible with Composer? Or am I missing something?
Solved! Go to Solution.
Posted on 11-10-2016 11:05 AM
You may be running into an issue with the PATH environment variables not correctly identifying the location of the
jamf
binary. Try running this:
#!/bin/sh
## postinstall
# This script runs a manual policy trigger to
# allow the policie(s) associated with that
# trigger to be executed.
trigger_name="$4"
CheckBinary (){
# Identify location of jamf binary.
jamf_binary=`/usr/bin/which jamf`
if [[ "$jamf_binary" == "" ]] && [[ -e "/usr/sbin/jamf" ]] && [[ ! -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/sbin/jamf"
elif [[ "$jamf_binary" == "" ]] && [[ ! -e "/usr/sbin/jamf" ]] && [[ -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/local/bin/jamf"
elif [[ "$jamf_binary" == "" ]] && [[ -e "/usr/sbin/jamf" ]] && [[ -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/local/bin/jamf"
fi
}
# Run the CheckBinary function to identify the location
# of the jamf binary for the jamf_binary variable.
CheckBinary
$jamf_binary policy -event sierra-postinstall
I have a post on PATH environment variables and how they can affect Casper, available via the link below:
https://derflounder.wordpress.com/2015/09/24/path-environment-variables-and-casper-9-8/
Posted on 11-10-2016 10:18 AM
Have you tried sudo jamf policy -event sierra-postinstall
?
Another thought, could you trigger the policy via Execute Command from a Files and Processes payload in the policy that's installing the package rather than in the package itself?
Posted on 11-10-2016 10:41 AM
Yeah no dice on adding SUDO. And while I could use the files and processes payload (maybe I will), ideally I would like to invoke it by a package. Thanks for your response!
Posted on 11-10-2016 11:05 AM
You may be running into an issue with the PATH environment variables not correctly identifying the location of the
jamf
binary. Try running this:
#!/bin/sh
## postinstall
# This script runs a manual policy trigger to
# allow the policie(s) associated with that
# trigger to be executed.
trigger_name="$4"
CheckBinary (){
# Identify location of jamf binary.
jamf_binary=`/usr/bin/which jamf`
if [[ "$jamf_binary" == "" ]] && [[ -e "/usr/sbin/jamf" ]] && [[ ! -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/sbin/jamf"
elif [[ "$jamf_binary" == "" ]] && [[ ! -e "/usr/sbin/jamf" ]] && [[ -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/local/bin/jamf"
elif [[ "$jamf_binary" == "" ]] && [[ -e "/usr/sbin/jamf" ]] && [[ -e "/usr/local/bin/jamf" ]]; then
jamf_binary="/usr/local/bin/jamf"
fi
}
# Run the CheckBinary function to identify the location
# of the jamf binary for the jamf_binary variable.
CheckBinary
$jamf_binary policy -event sierra-postinstall
I have a post on PATH environment variables and how they can affect Casper, available via the link below:
https://derflounder.wordpress.com/2015/09/24/path-environment-variables-and-casper-9-8/
Posted on 11-11-2016 06:15 AM
Removed..
Posted on 11-11-2016 07:31 AM
Hey @rtrouton that did it! Thank you so much. It just needed to know where the JAMF binary was. Well done. And a quick thank you for your blog and all that you have contributed. It has helped me more than I can count.