Copy files to a user folder

yarin
New Contributor II

Hey guys.
I need to create a guide for our customers how to use Jamf and copy/Push files.
The only way I know how to achieve this is by using Jamf composer and create a package.
but the location I need to deploy to is ~/Library/Application Support/Mozilla/ManagedStorage/WalkmeExtension@walkme.com.json
How can I deploy to a location that is depended by User name?

Also if you have an idea for alternative solution I'll be happy to hear.

3 REPLIES 3

blackholemac
Valued Contributor III

Here's a script that purports to copy data to the user folders:

https://www.jamf.com/jamf-nation/discussions/8308/script-to-copy-preference-file-to-all-users-profiles-and-to-the-default-template

Copying files to the User Template (for users who have never logged in on a Mac before) is fairly easy:

cp -R -f /path/to/your/file/here /System/Library/User Template/non_localized/path/to/your/file/here

Getting it to all the users that have already logged in requires either a script such as the ones contained above or using Composer and making a DMG with user template data. (don't forget to use FUT and FEU options).

smithjw
New Contributor III

You could accomplish this via several different methods, if you're just wanting to add one text file to a location, you could do it entirely via a script like so

#!/bin/sh

# Find the currently logged in user
loggedInUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
# Location of the extension
extension="/Users/"$loggedInUser"/Library/Application Support/Mozilla/ManagedStorage/WalkmeExtension@walkme.com.json"

# File Contents
echo "Contents
Of
Text
File" > $extension

exit 0

If you were wanting to move multiple files, I would suggest using a pkg to drop the files into /tmp then using a postinstall script that utilises the same $loggedInUser variable and move the files from /tmp/ into the required directory in the User's folder.

Hope this helps @yarin

exno
Contributor

Easy Peasy method? Build a DMG in Composer that drops the file and sets the proper file permissions. i tend to change the account to the local admin, and set permissions based on that user ( any easy visual way that lets me know i checked everything...) then create dmg and add to the jamf pro server. setting the default for the dmg to FEU (Fill existing Users) and FUT (Fill User Template) then just make sure the policy keeps the FEU/FUT options checked and you have pushed a firefox extension to all users...

The more fun way is what @smithjw Shared.

- I am @exno or @exnozero on almost everything that exists.