Example Jamf Scripts
Basic script
Section titled “Basic script”This script can be added to your jamf pro instance and used as a generic script to call basic dialogs
Paramaters
Section titled “Paramaters”- Parameter 4: Title
- Parameter 5: Message
- Parameter 6: Icon
- Parameter 7: Overlay
- Parameter 8: Button 1 Text
- Parameter 9: Button 2 Text
- Parameter 10: Info Button Text
- Parameter 11: Additional. Can be one of any of the following:
--moveable--ontop--big--small--ignorednd
#!/bin/zsh
dialog="/usr/local/bin/dialog"
if [[ -n ${4} ]]; then titleoption="--title"; title="${4}"; fiif [[ -n ${5} ]]; then messageoption="--message"; message="${5}"; fiif [[ -n ${6} ]]; then iconoption="--icon"; icon="${6}"; fiif [[ -n ${7} ]]; then overlayoption="--overlayicon"; overlayicon="${7}"; fiif [[ -n ${8} ]]; then button1option="--button1text"; button1text="${8}"; fiif [[ -n ${9} ]]; then button2option="--button2text"; button2text="${9}"; fiif [[ -n ${10} ]]; then infobuttonoption="--infobuttontext"; infobuttontext="${10}"; fiextraflag=${11}
${dialog} \ ${titleoption} "${title}" \ ${messageoption} "${message}" \ ${iconoption} "${icon}" \ ${overlayoption} "${overlayicon}" \ ${button1option} "${button1text}" \ ${button2option} "${button2text}" \ ${infobuttonoption} "${infobuttontext}" \ ${extraflag}
returncode=$?
case ${returncode} in 0) echo "Pressed Button 1" ## Process exit code 0 scenario here ;;
2) echo "Pressed Button 2" ## Process exit code 2 scenario here ;;
3) echo "Pressed Button 3" ## Process exit code 3 scenario here ;;
*) echo "Something else happened. exit code ${returncode}" ## Catch all processing ;;esac
# make sure script exits cleanly otherwise Self Service will complain if it's anything other than 0exit 0