Posted on 05-19-2021 06:58 AM
A very simple script to add the Movies folder to the sidebar upon login does not work even though the policy logs return a completed status.
#!/bin/zsh
#
# Add the logged in user's "Movies" folder to the Finder Sidebar
# Get the HOME value for the user that's logging in;
# The username is passed as script argument 3
HOMEDIR=$(sudo -u $3 echo $HOME)
# Use the `mysides` command to add the alias/shortcut
/usr/local/bin/mysides add Movies file:///$HOMEDIR/Movies
Mysides is installed on the client via Policy and various iterations of the script "work" according to the logs but the folder does not actually append to the sidebar unless it is executed locally. Very curious where the hangup may be in Jamf...
Posted on 05-19-2021 07:29 AM
When you say locally, do you mean the current logged in user runs the commands?
If it is, then the policy is running the command as root, and the locally is running the command as the current user. Try setting the last line to sudo $3 in the front of it, to run the line as the logged in user...
sudo -u $3 /usr/local/bin/mysides add Movies file:///$HOMEDIR/Movies
Posted on 05-19-2021 01:49 PM
Although mysides is not guaranteed to work any longer you should try to use this:
#!/bin/zsh
loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' )
loggedInUserHome=$(/usr/bin/dscl . -read "/users/$loggedInUser" NFSHomeDirectory | cut -d " " -f 2)
if [[ -n "$loggedInUser" ]]; then
if [[ -n "$loggedInUserHome" ]]; then
echo "Adding Movies to $loggedInUser's Finder Sidebar..."
/usr/local/bin/mysides add Movies "file:///$loggedInUserHome/Movies"
else
echo "Error: Could not determine $loggedInUser's home folder."
exit 1
fi
else
echo "Nobody is logged in; skipping."
fi
exit 0
Posted on 05-20-2021 01:51 PM
@PaulHazelden sorry I forgot to mention that I've tried that iteration already to no avail.
@ryan.ball no luck with that script.
Posted on 05-21-2021 09:16 AM
@user-VrNMiDTLrF I don't think it is the script syntax is causing you the issue. I think that mysides
is not supported with later macOS versions like I mentioned initially. Check out the issues created on the mysides github.
Posted on 05-21-2021 10:32 AM
@ryan.ball Yeah, with that in mind I'm going to try deploying a LaunchAgent instead. Thanks for your help.