Created
February 20, 2012 15:52
-
-
Save talkingmoose/1869808 to your computer and use it in GitHub Desktop.
Shell script to ditto Apple package payload to user home folders and user template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## postflight | |
copyPayloadToAllUsers() { | |
# Enter a path to a logfile. | |
LOGFILE="/path/to/file.log" | |
# Copy the payload file(s) to all existing user folders. | |
cd /Users | |
for AUSER in * | |
do | |
if [ ! $AUSER = "Shared" ] ; then | |
ditto /path/to/file.txt /Users/$AUSER/path/to/folder/ | |
if [ $? = 0 ] ; then | |
date "+%A %m/%d/%Y %H:%M:%S Payload copied to user folder $AUSER." >> $LOGFILE | |
else | |
date "+%A %m/%d/%Y %H:%M:%S ERROR! Unable to copy payload to user folder $AUSER." >> $LOGFILE | |
fi | |
fi | |
done | |
} | |
copyPayloadToUserTemplate() { | |
# Copy the payload file(s) to the User Template folder. | |
ditto /path/to/file.txt /System/Library/User\ Template/English.lproj/path/to/folder/ | |
if [ $? = 0 ] ; then | |
date "+%A %m/%d/%Y %H:%M:%S Payload copied to User Template folder." >> $LOGFILE | |
else | |
date "+%A %m/%d/%Y %H:%M:%S ERROR! Unable to copy payload to User Template folder." >> $LOGFILE | |
fi | |
} | |
copyPayloadToAllUsers | |
copyPayloadToUserTemplate | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions: