Packaging: Add files to each new account

Andixon
New Contributor III

Hi,

one of my clients has requested that I distribute some files so that they will be added not only to the currently existing accounts on the mac, but also to all that are created in the future. I think that should be possible by adding the files into the default file structure that is copied by macOS each time a new user is created, but I can not find them and I have had no luck with googling. Can anyone help me out or suggest a different solution to the problem? Much appreciated!

3 REPLIES 3

PaulHazelden
Valued Contributor

Default structure under Monterey is in /Library/User Template, then pick a language. I tend to throw stuff in them all, just to make sure, but in theory the Non_localized folder is supposed to apply to all although I never seem to have much success if I only put the stuff in there.

Older versions of the OS had the User Template folder in the /System/Library.

Hope this helps

AJPinto
Honored Contributor II

MacOS does not have the concept of the share desktop/documents space like Windows does. There is not a single place you can shove files for all users to see them within their user space. You can place stuff in /users/shared and everyone would have access to the files if they knew to check there. 

 

I think your best option is to use FEU:

  • Make a .dmg with the files in whatever path you prefer within your user profile
  • Upload it to JAMF and set the FEU option
  • Add it to a policy with a trigger of run once per user

FEU will replace your account with the logged in users account in the path path when the dmg installs. For example it will replace /users/andixon/desktop with /users/RandomLoggedInPerson/desktop when it installs.

 

Note, FUT and FEU only work with .dmg's, they will not work with .pkg's. 

AJPinto_0-1664972505066.png

AJPinto_1-1664973223225.png

 

You can also script all this out if you want to do it that way. You will need a function that can tell the script who the logged in user is, and put that information in to a variable. Something like this may work, but I still suggest using the FEU options above. You would need to place the files in a staging location with a package, then have a policy run this script to move the files to the users desktop (or wherever) after the 1st login. The resources could be installed at any point, but they could not be moved to the user profile until AFTER the user logs in.

 

 

 

#!/bin/bash

######################
# Script Name: 
# Author: 
# Date: 
# Enhancements
# Comments:
######################
 
 
 
#*=============================================================================
#* Define logged in user
#*=============================================================================
DIV1='echo ####################################################################'
DIV2='echo --------------------------------------------------------------------'
DIV3='echo ....................................................................'
ActiveUser=`/bin/ls -l /dev/console \
| /usr/bin/awk '{ print $3 }' \
| tr "[a-z]" "[A-Z]"`
ActiveUserRealName=`dscl . -read /Users/$ActiveUser \
| grep RealName: \
| cut -c11-`
if [[ -z $ActiveUserRealName ]]; then
ActiveUserRealName=`dscl . -read /Users/$ActiveUser \
| awk '/^RealName:/,/^RecordName:/' \
|sed -n 2p | cut -c 2-`
fi
 
userInfo () {
echo; $DIV1
echo "User Information:"
if [[ "$ActiveUserRealName" == "$ActiveUser" ]]; then
echo "$ActiveUserRealName (Local Admin)"
else
echo "$ActiveUserRealName ($ActiveUser)"
fi
$DIV1
}
userInfo
 
#*=============================================================================
#* Relocate files
#*=============================================================================
 
 
if [ -d "/Users/$ActiveUser/resources" ]
	then
		echo '/Users/$ActiveUser/resources exists. Moving files to resources directory'
		sudo mv /private/tmp/folder/files /Users/$ActiveUser/desktop/resources
	else
		echo '/Users/$ActiveUser/desktop/resources. Creating directory, moving files and setting permissions'
		sudo mkdir /Users/$ActiveUser/desktop/resources
		sudo mv /private/tmp/folder/files /Users/$ActiveUser/desktop/resources
		cd /Users/$ActiveUser/desktop/resources
		sudo chown "$ActiveUser" "backgrounds" #Grant ownership of the the files
fi

 

 

jpeters21
Contributor II

I feel like this should not be overly complicated.. create a package in composter with the needed files in tmp, have a "post install" script to copy those to the current users desktop in your language of choice  (or where ever you need them) . Upload that then make a policy to deploy once per user.