I have the following in a script on Jamf Pro. When I deploy the script and it runs this I can see on the test Mac it has "Attempt 1 to bootout com.Daemon" in the log file.
However, it fails to continue with the rest of the script. I tried adding
|| echo "bootout error"
after the bootout command but that didn't help either. When I run the launchctl list | grep "com.Daemon" command I can also see it has successfully booted out the Daemon.
Why won't it continue to then trigger the jamf policy?
I've tried
/usr/local/bin/jamf policy -event 'Trigger'
I've tried with sudo and without. I've also tried to have it trigger the jamf policy first which works but if I put a delay in the policy so I wait until bootout is complete it doesn't progress to attempt bootout (it waits on policy completing). I tried adding & to then end (/usr/local/bin/jamf policy -event 'Trigger' &) and that resulted in bootout command running but jamf policy did not.
When I run the script as sudo locally it works but not when it is launched via another script. I have another script which if a condition is met it runs
sudo /usr/local/.Hidden/Bootout1.zsh
cat <<"EOF"> /usr/local/.Hidden/Bootout1.zsh
#!/bin/zsh --no-rcs
# Jamf binary
jamf="/usr/local/bin/jamf"
bootlog_file=/usr/local/.Hidden/BootoutLogFile.log
exec >> $bootlog_file 2>&1
Counter2=0
while launchctl list | grep -q "com.Daemon1" && [ $Counter2 -lt 5 ]; do
(( Counter2 ++ ))
echo "Attempt $Counter2 to bootout com.Daemon"
sudo /bin/launchctl bootout system /Library/LaunchDaemons/com.Daemon1.plist
sleep 2
done
$jamf policy -event 'Trigger'
EOF