Passing Automation/Apple Events permissions to terminal through PPPC

kbreed27
Contributor

Hey All!

I've created a script that is supposed to mount our district's Private Network Folder and create  Desktop and Dock shortcuts for the share for the currently logged in user. I've been able to get my script to work locally, but whenever I try to pass the script through Jamf, it asks to give Terminal "Finder" access:

kbreed27_1-1707519166748.png

 

I believe this is what I need to give terminal access to:

kbreed27_0-1707519153787.png

I set up a PPPC profile as follows but it doesn't seem to have helped:

kbreed27_2-1707519276160.png

Any Guidance on what PPPC settings I need to pass to our computers so that end users don't get that prompt? I also tried uploading rtroutons config profile found here to no avail.

 

Bonus points if anyone wants/can help me figure out the best way to pass this script? I know I could send it in a Policy that runs at every login, but that seems like bad practice? Maybe a LaunchAgent? Disregard my sloppy code, it's cobbled together from what I kind of understood from the 400 and what ChatGPT helped me write...

 

I'm still getting the hang of this. THANKS!

 

#!/bin/bash

# define Variables
CURRENT_USER=$(ls -l /dev/console | awk '{print $3}')
CURRENT_USER_UID=$(id -u $CURRENT_USER)
userFirstInitial=$(echo $CURRENT_USER | cut -c 1 | tr '[:lower:]' '[:upper:]')
SHARE_NAME="$CURRENT_USER"
networkDrivePath="myorg.myorg.org/staffhome/$userFirstInitial/$CURRENT_USER"
USER_HOME_DIR=$(eval echo ~$CURRENT_USER)
desktopShortcut="/Users/$CURRENT_USER/Desktop/$SHARE_NAME."

sleep 7

#check to see if PNF is available and if it's not mounted. If not mounted... MOUNT!
if ping -c 1 myorg.myorg.org 2> /dev/null ; then
echo "Server is reachable... Continuing..."
else
echo "Server is not reachable Exiting."
exit 
fi

if [[  ! -d "/Volumes/$CURRENT_USER" ]] ; then 
echo "PNF not mounted... MOUNT!"

# Mount the SMB share

launchctl asuser $CURRENT_USER_UID osascript -e "mount volume \"smb://myorg.myorg.org/STAFFHOME/$userFirstInitial/$CURRENT_USER\""
fi

#check for desktop shortcut, if it doesn't exist... CREATE
if [[ -d "/Volumes/$CURRENT_USER" ]] && [[ ! -f /Users/$CURRENT_USER/Desktop/$SHARE_NAME ]] ; then
echo "Desktop Shortcut not found, creating"

launchctl asuser $CURRENT_USER_UID osascript -e "tell application \"Finder\" to make new alias file at (path to desktop folder) to (disk \"$SHARE_NAME\")"


else
echo "Desktop Shortcut exists... continuing"
fi




#check for dock item, if is not there... CREATE!
dockCheck=$(launchctl asuser $CURRENT_USER_UID defaults read com.apple.dock.plist | grep file:///Users/$CURRENT_USER/Desktop/$CURRENT_USER)

if [[ -z $dockCheck ]]; then
echo "Dock item does not exist, creating"

/usr/libexec/PlistBuddy -c "Add :persistent-others array" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0 dict" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0:tile-data dict" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0:tile-data:file-label string $CURRENT_USER" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0:tile-data:file-data dict" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0:tile-data:file-data:_CFURLString string file:///Users/$CURRENT_USER/Desktop/$CURRENT_USER" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0:tile-data:file-data:_CFURLStringType integer 15" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0:tile-data:file-type integer 38" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0:tile-data:is-beta integer 0" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist
/usr/libexec/PlistBuddy -c "Add :persistent-others:0:tile-type string file-tile" /Users/$CURRENT_USER/Library/Preferences/com.apple.dock.plist

sudo killall Dock

else
echo "Dock item exists, exiting"
fi

 

0 REPLIES 0