Some time ago I wrote Scriptorium
to keep the scripts on your Mac in sync with the same scripts on your Jamf Pro server.
Thanks to the excellent tool jctl
from the people at the Marriot Library of the University of Utah I have a simple solution using their tool and git hooks so when you push to your repo the script is updated in Jamf Pro.
Install jctl from their repo at https://github.com/univ-of-utah-marriott-library-apple/jctl/wiki/Installing. Once you have done that you need the hook in .git/hooks
in your repo. Call it pre_push
#!/bin/bash
if [[ $(git diff origin/main@{1} origin/main --name-status | grep -c ${name_of_script}) > 0 ]]; then
var=$(cat "${path_of_script}")
/opt/homebrew/bin/jctl scripts -i ${id_of_script} -u script_contents="${var}" --use-the-force-luke
fi
pre-push
means that the hook runs after you have typed git push
and before the actual push occurs. If you want to you can stop the push from happening by returning non-zero from your script. I don’t do that as I’m not doing any testing in the hook.
name_of_script
is, of course, the name of the script. path_of_script
is the name of, and path to, the script. id_of_script
is the ID in Jamf Pro of the script, you can find it in the URL of the script.
I use direnv to set the variables. You could hard code them but that seems like actual work. Now every time you do a git push
the script is sent to your server.
Let me know if you find this useful.