I have been trying to get a script working that will run jamf Helper and if the user agrees to the upgrade it will open Self Service at the policy and either view or install the app. So far I have the below which works.
#!/bin/zsh
###
msg="$4 $singleApp "
singleApp="$5"
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
currentuser=$(stat -f "%Su" /dev/console)
policyid="$6"
action="$7"
timeout="$8"
title="Application Update"
iconLoc="/private/var/tva/casper/scripts/mickey.png"
userResponse=`$jamfHelper -windowType utility -title "$title" -description "$msg" -icon $iconLoc -button1 "Dismiss" -button2 "Upgrade Now" -defaultButton 0 -cancelButton 1 -countdown $timeout -timeout $timeout`
#Self Service = 2
#OK = 0
if [[ $userResponse = "2" ]]; then
su "$currentuser" -c 'open "jamfselfservice://content?entity=policy&id=1234&action=view"'
exit 0
else
exit 0
fi
fi
exit 0
jamf recon
exit 0
But when I try to substitute the open command with the parameters it launches Self Service and takes me to a login screen.
#!/bin/zsh
###
msg="$4 $singleApp "
singleApp="$5"
jamfHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
currentuser=$(stat -f "%Su" /dev/console)
policyid="$6"
action="$7"
timeout="$8"
title="Application Update"
iconLoc="/private/var/tva/casper/scripts/mickey.png"
userResponse=`$jamfHelper -windowType utility -title "$title" -description "$msg" -icon $iconLoc -button1 "Dismiss" -button2 "Upgrade Now" -defaultButton 0 -cancelButton 1 -countdown $timeout -timeout $timeout`
#Self Service = 2
#OK = 0
if [[ $userResponse = "2" ]]; then
su "$currentuser" -c 'open "jamfselfservice://content?entity=policy&id=$6&action=$7"'
exit 0
else
exit 0
fi
fi
exit 0
jamf recon
exit 0
I found this online but I don't know how to make it work.
When using variables in shell, you can only use doubles quotes, not single quotes : the variables inside single quotes are not expanded.
When I do this I see the following
Script exit code: 2
Script result: /Library/Application Support/JAMF/tmp/JamfHelper_Sierra_Upgrade:29: parse error near `&'
Error running script: return code was 2.
Checking for patches...