Posted on 05-01-2019 07:08 PM
I have two options for the Application, DMG and PKG.
What I need to do is ensure that the application is deployed to the currently logged in user's Applications folder (or all local user's Applications folder). At the moment, having just put the package in the Repository, and having created a policy with a Package inside it, it is being installed to "/".
I know that this is because I haven't changed the Target Drive. I was hoping I could use "/Users/$USERNAME/Applications" to do some kind of variable substitution, but it creates a literal "$USERNAME" folder.
How do I get a package onto an Apple device using JAMF that installs to the user's Applications folder?
Thanks :)
Posted on 05-02-2019 06:14 AM
In the package, is it just a .app?
Posted on 05-02-2019 06:39 AM
If you're building your PKG via Composer, just drop your .app in a folder named "Applications". Also, make sure the permissions are configured correctly before finalizing it.
Posted on 05-02-2019 07:08 AM
You probably ought to use a postinstall script for the package or a script that runs after the package installs via policy. The script could go through every user home directory and copy the app from a central, temporary location to the Applications directory within. Something like this:
#!/bin/bash
# Identify the name of the app
APP_NAME="AppName.app"
# Identify the path to where the package places the app
TEMP_APP_PATH="/path/to/$APP_NAME"
# Loop through all home directories in /Users/
for user_home in "/Users/"*; do
# Get the username for the current home directory
username="$(/usr/bin/basename "$user_home")"
# Skip the Shared directory. Duplicate this line and substitue Shared
# for other user home directories you know you need to skip.
[ "$user" = "Shared" ] && continue
# Identify the user's Applications directory
user_app_dir="$user_home/Applications"
# Create the user's Applications directory if it does not exist
if [ ! -d "$user_app_dir" ]; then
/bin/mkdir "$user_app_dir"
/bin/chmod 755 "$user_app_dir"
/usr/sbin/chown "$username" "$user_app_dir"
fi
# Copy the app from the temp location to the user's Application directory
/bin/cp "$TEMP_APP_PATH" "$user_app_dir/$APP_NAME"
done
exit 0
Posted on 06-25-2019 08:13 AM
Is it possible to use @ChrisCox script above and pull parameter values from a policy for the app name and app path? This would allow for one script that can be used in multiple policies to install different applications in the user directory Applications folder. If so, what changes would need to be made to pull those values in for the app name and app path variables?
Posted on 06-25-2019 10:21 AM
@Gascolator, if I understand your question, you can definitely do this with just a little modification. Just assign the script parameters to variables instead of hardcoding in the name and path. Then you could use this script for several different apps in several different policies with different script parameters for each.
#!/bin/bash
# Parse Jamf Pro script parameters
APP_NAME="$4"
TEMP_APP_DIR="$5"
PERM_APP_DIR="$6"
# Identify the temporary and permamant paths for the app
TEMP_APP_PATH="$TEMP_APP_DIR/$APP_NAME"
PERM_APP_PATH="$PERM_APP_DIR/$APP_NAME"
# Loop through all home directories in /Users/
for user_home in "/Users/"*; do
# Get the username for the current home directory
username="$(/usr/bin/basename "$user_home")"
# Skip the Shared directory. Duplicate this line and substitue Shared
# for other user home directories you know you need to skip.
[ "$user" = "Shared" ] && continue
# Identify the permanent path to the app in the user's home directory
user_app_dir="$user_home$PERM_APP_DIR"
# Create the directory if it does not exist
if [ ! -d "$user_app_dir" ]; then
/bin/mkdir "$user_app_dir"
/bin/chmod 755 "$user_app_dir"
/usr/sbin/chown "$username" "$user_app_dir"
fi
# Copy the app from the temporary location to the permanent one
/bin/cp "$TEMP_APP_PATH" "$user_app_dir/$APP_NAME"
done
exit 0
Posted on 06-25-2019 01:43 PM
@ChrisCox that's exactly what I'm looking for. That's where I was headed in my mind but wasn't sure if it was the correct way to proceed. I'll give that a try. I have several drag and drop .app files I want to install in the Applications folder in the user's home directory instead of root Applications folder. This should allow me to do that. Thanks.
Posted on 06-25-2019 01:48 PM
No problem. Looking back at it I noticed I made a couple mistakes on lines 23 and 33. I already went back in and edited it, so make sure you get the updated version.