How to deploy a file to every user's folder

Verducci
New Contributor

I've been having much success with this and thought I would share it since it took me awhile to work through. I create a policy which first delivers one copy of the file to a central location on the Mac (in this case, a folder named /TEMP). Setting up the following shell script to "Run After" causes that file to get copied to each user's private documents folder :

#!/bin/bash
myUSERS=$(ls /Users)
for i in $(echo $myUSERS)
do
#
# This will copy a text file from a TEMP folder into each user's Documents folder
# if [[ $i != "."* ]] then cp /TEMP/MasterTemplate.txt /users/$i/Documents/Template.txt fi
done

3 REPLIES 3

jarednichols
Honored Contributor

Outside of using a pkg installer instead, why use this instead of the FEU/FUT options?

acdesigntech
Contributor II

@jared - is FEU fixed now with non-standard home folder locations?

@Verducci - that will only copy to specific paths in the home folder, so if you have multiple items that need to go in multiple places, you'll be editing that code a lot!

This script will copy any item it finds to the relevant location in each users' home. All you need to do is make sure to simulate the uses' homefolder structure:

#!/bin/sh


for PREF_ITEM in /Applications/Utilities/ISD/Installs/User Settings/*; 
do
    for USER_HOME in /Users/*;
    do
        USER_ID=`basename "${USER_HOME}"`
        if [ "${USER_ID}" != "Shared" ]; then
            rsync -avE "${PREF_ITEM}" ${USER_HOME}
        fi
    done    
done

for PREF_ITEM in /Applications/Utilities/ISD/Installs/User Settings/*; 
do
    rsync -avE "${PREF_ITEM}"  /System/Library/User Template/English.lproj/
done
    chown -R root:wheel /System/Library/User Template/English.lproj/*
    chmod -R 700 /System/Library/User Template/English.lproj/*

ksanborn
New Contributor III

We are new to Casper, how did you accomplish the first part "I created a policy which first delivers one copy of the file to a central location on the Mac (in this case, a folder named /TEMP)."? We would like to do the same.