Hi all! I am working on something pretty simple, but I have gotten myself stuck and promise to give myself 5 lashes with a wet noodle for my oversight....
What I am trying to do is display a message to the user to clear the web cache or cancel the operation, if the user chooses to continue my script should run then display the completed message. If the user selects cancel the script should exit. I feel like I am missing something pretty basic. Thoughts?
#!/bin/sh
# the purpose of this script is to delete all browser caches.
#
#
# created by Pat B 11/3/14
CLEARCACHE='/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Internet Browser Web Cache" -heading "Please exit all web pages before continuing" -alignHeading center -description "You web browser cache will be cleared when you click the button below. This may take several minutes and you will be notified when the process completes. Thank you for your patience!" -icon /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarInfo.icns -button1 "Erase Cache" -button2 "Cancel" -defaultButton 1 -cancelButton 2'
USER=`who | grep console | awk '{print $1}'`
# If the user clicks Erase Cache
if [ "$CLEARCACHE" == "0" ]; then
echo "Clearing Cache"
sleep 2
rm -R /Users/$USER/Library/Caches/Google
rm -R /Users/$USER/Library/Caches/Firefox
rm -R /Users/$USER/Library/Caches/com.apple.Safari
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -title "Internet Browser Web Cache" -heading "Process Complete" -alignHeading center -description "Your web browser caches have been cleared for Firefox, Safari, and Google Chrome." -icon /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarSitesFolderIcon.icns -button1 " Exit " -defaultButton 1
exit 1
# if the user clicks cancel
elif [ "$CLEARCACHE" == "2" ]; then
echo "User canceled cache clear";
exit 1
fi