Help with deploying file to all users

jwells_Box
New Contributor II

I need to package and deploy a file to all users on a system.
lets call the file 'Awesome.txt'.

I need to send that out as a package file and then have 'Awesome.txt' copied to every local users ~/Library directory (to be clear /Users/USERNAME/Library/Awesome.txt)
I also need it to overwrite the file if its already there.
What is the best way to achieve this result?

Thanks in advance to all!

1 ACCEPTED SOLUTION

AdamCraig
Contributor III

I would create a .dmg in composer and use the Fill Existing Users (FEU) option when you deploy it.
So with this method if you create a file in the filepath /Users/USERNAME/Library/Awesome.txt then FEU will drop it into ever user account in the /Users/ directory.

I use this method with a few .plists for our new user setup.

View solution in original post

5 REPLIES 5

PaulHazelden
Valued Contributor

This depends a bit on what Awesome.txt really is, and how often you want to update it. Also the resources you have available will make a difference too.

For me, if it is something I will want to change often, I would store the file on a Sharepoint that I can auto mount via script. I have one of these and a script that runs at regular intervals, that I use for this very thing to update scripts and Apps that may need to be updated often. I would just add in a line to copy the file into place. This will just get the file to a location for access by a script.

Without a Sharepoint, I would set up a safe store point location on the Mac, put the file in there and run a post install script to put it in place in all existing accounts, and set permissions for the file to be correct. Use Composer for this.

Now comes your problem, how to sort out new accounts that don’t yet exist. You have a couple of options here…
1. Add the file to the UserTemplate - not recommended by Apple, and possibly will run into a SIP issue It might work for now if you try it, but may stop working at some point.
2. Create a LaunchAgent to copy the file across at login for each user. Put in a simple check for the copy of the file existing already. The Agent runs a script which will check for the file and then copy it across if required. This is my preferred method and I run a LaunchAgent at log in for for all accounts.

AdamCraig
Contributor III

I would create a .dmg in composer and use the Fill Existing Users (FEU) option when you deploy it.
So with this method if you create a file in the filepath /Users/USERNAME/Library/Awesome.txt then FEU will drop it into ever user account in the /Users/ directory.

I use this method with a few .plists for our new user setup.

Chris_Hafner
Valued Contributor II

Just a note. If using composer for FEU, make sure you use .dmg. You could use .pkg but would need to utilize an installer script to get the file into the user library.

All of the above answers can be reasonable for different uses. Like anything, it all depends.

jwells_Box
New Contributor II

Thanks @strayer

Besides DMG package deployment, another option to deploy a text file is to use a script.

#!/bin/bash

# Find the loggedInUser
LOGGED_IN_USER=$(stat -f %Su /dev/console)

cat << EOF > "/Users/${LOGGED_IN_USER}/Library/Awesome.txt"

your-awesome-txt-file-content-here

EOF

#Fix permissions
chown "$LOGGED_IN_USER" /Users/${LOGGED_IN_USER}/Library/Awesome.txt