Tuesday
Hello
We have started to enroll our macbooks for our employees without adminrights. Yes we have the privilege access configured in jamf connect, but don't want use it for everyone :)
So i started to configure what is necessary for our employees that they can work without adminrights.
So far so good. Now i am actually helpless with this one problem about creating a symlink via jamf pro policy after installation of Visual Studio code.
What i need is:
A symlink in the directory /usr/local/bin/code which points to /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code
So i am able to create it, but it isnt working. Checking it on a testmachine the symlink shows me in the "get info" as "Original" the path /usr/local/bin/code
instead of
/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code
So its not the first symlink i create but its the first in this location /usr/local/bin/code so maybe i am doing something wrong.
I am using this short script
#!/bin/bash
set -x
# Get the current user's home directory
loggedInUser=$(stat -f "%Su" /dev/console)
USER_HOME="/Users/$loggedInUser"
open -a /Applications/Visual\ Studio\ Code.app
# Set symlink
ln -snf "$USER_HOME/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code
exit 0
Running the command locally on a machine:
ln -snf "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code is working fine, but i am not able to do this via jamf policy and script
Somehow an idea what i am doing wrong here?
I appreciate for every tipp, suggestion and help
THX in Advance
J
Solved! Go to Solution.
Wednesday
I got it, it was how i remembered from my jamf course.
So the applications visible in the user Finder are not installed under user directory. They are all installed in /Applications
Tuesday
So it looks that i was able to create it, but can someone help me understand why the first script isnt working and the second is working?
#!/bin/bash
# Get the current user's home directory
loggedInUser=$(stat -f "%Su" /dev/console)
USER_HOME="/Users/$loggedInUser"
echo $USER_HOME
echo $loggedInUser
# Path to Visual Studio Code binary
VSCODE_BIN="/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"
# Target symlink location
TARGET_SYMLINK="/usr/local/bin/code"
# Create the symlink
ln -snf "$VSCODE_BIN" "$TARGET_SYMLINK"
echo "Symlink created: $TARGET_SYMLINK -> $VSCODE_BIN"
exit 0
thank you in advance
Wednesday
Your first script is trying to create a symlink to an app in /Users/{UserID}/Applications/... which isn't where the app was installed if the 2nd script works which links to an app in /Applications/...
Wednesday - last edited Wednesday
@sdagley I also tested a few other paths with the first script.
So for example i commented out the loggedin user part and tested only with the
ln -snf "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code
sudo ln -snf "Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code
ln -s"~/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code
I tested it with script and also only with the "files and processes" in a policy.
So i dont know a lot about symlinks, but they seem not the be really complicated to create and if i follow the guide:
┌── ln(1) link, ln -- make links
│ ┌── Create a symbolic link.
│ │ ┌── the optional path to the intended symlink
│ │ │ if omitted, symlink is in . named as destination
│ │ │ can use . or ~ or other relative paths
│ │ ┌─────┴────────┐
ln -s /path/to/original /path/to/symlink
└───────┬───────┘
└── the path to the original file/folder
can use . or ~ or other relative paths
the command:
ln -s "Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code via a policy should work.
From my understanding (but i am not very good in scripting) i am not do anything else with the second script as combine the absolut path with two variables.
Please correct me if am wrong
BR
Wednesday
I got it, it was how i remembered from my jamf course.
So the applications visible in the user Finder are not installed under user directory. They are all installed in /Applications
yesterday
Which is what I said in my previous post...