Skip to main content
Question

How to deploy a file to every user's folder

  • October 22, 2012
  • 3 replies
  • 11 views

Forum|alt.badge.img+3

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

Forum|alt.badge.img+24
  • Valued Contributor
  • October 22, 2012

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


Forum|alt.badge.img+12
  • Contributor
  • October 22, 2012

@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/*

Forum|alt.badge.img+5
  • Contributor
  • March 19, 2015

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.