Posted on 12-22-2010 09:36 AM
(fixed some typos...sorry, posted from memory. Of course test on spare Mac and tweak as needed... Don)
Hi Nick,
Sure, here's a sample:
Snapshot shows we need to deploy user level stuff:
/Users/jdoe/Library/Preferences/crap1 /Users/jdoe/Library/Application Support/crap2
So we set up the pkg to dump the above here:
/tmp/usercrap/Library/Preferences/crap1 /tmp/usercrap/Library/Application Support/crap2
Using a postflight script to copy the stuff to existing/future users:
#!/bin/sh # # Copy from /tmp to existing/future users.
# Copy to User Template and set owner to root. /usr/bin/ditto /tmp/usercrap /System/Library/User Template/English.lproj /usr/sbin/chown -R root:wheel /System/Library/User Template/English.lproj
# Loop to populate existing user directories, set owner and group too. for i in $(/bin/ls /Users) do /usr/bin/ditto /tmp/usercrap /Users/$i/ /usr/sbin/chown -R $i:staff /Users/$i/ done exit 0
The /tmp directory purges on reboot. Tweak as needed.
Hmmm...bonus points to anyone who can tell us what to do the script to have it IGNORE the /Users/Shared directory? :)
(this is where Steve/Thomas usually chime in with the golden nugget answer!)
We used input from the usual suspects on this list (Steve Wood, Thomas Larkin, etc.)...
Don
Posted on 12-22-2010 09:58 AM
For the bonus points, I believe you'll want to add something right after
do:
if $i == 'Shared'; then
continue
fi
I didn't test this so there might be some slight syntax changes needed.
~ Ryan
Posted on 12-22-2010 10:37 AM
Might want to toss in a:
rm -R /tmp/usercrap
at the end of the script if your users, like mine, are notorious for not
restarting as often as they should. Otherwise that temp directory could
get pretty heavy.
Also, if push a couple packages in a row where this applies, you'd be
copying information over in duplicate.
Maybe it's my OCD. Just like things to be cleaned up as soon as they can
be.
Bob
Posted on 12-22-2010 10:50 AM
Hi Bob,
Yep, for Adobe Acrobat Pro 9, we named the temp directory:
/tmp/AcrobatPro9
I like your idea, why not clean up as you go. :)
Don
Posted on 01-03-2011 06:51 AM
DMGs will block copy to the client, thus give you better performance
over installing it via a mounted network share. Which is why I use
DMGs. As for user specific stuff. I either do it via MCX these days,
or I simply capture the full file path of the plist in question by drag
in drop in Composer, then use Casper to FEU and self heal if need be.
As to remove the /Users/Shared directory from the loop in your script
and simple inverted grep will do it
example:
for USER in `/bin/ls /Users | /usr/bin/grep -v "Shared" ; do
Posted on 01-05-2011 11:06 AM
forgot final backtick :P
for USER in `/bin/ls /Users | /usr/bin/grep -v "Shared"` ; do
*THREAD HIJACKED* This is now a scripting thread :D I have been watching
progress bars all day and inspired by Larkin's earlier postings to do a
bit-o-learnin' / practice
I have been trying to use shell builtins and globbing where possible and get
away from `` and ls /foo/ so after thinking about it for a minute I would
do:
for username in /Users/*; do
if [[ $username != /Users/Shared ]]; then
do something
do other stuff
fi
done
I have been converted to the idea that $( ... ) looks prettier than ` ... `
and also getting in the habit of using globbing saves you from annoying
quoting situations like:
for dir in $(ls /Users/ryan/Library/); do
echo $dir
done
Acrobat
User
Data
Address
Book
Plug-Ins
Application
Support
....
VS.
for dir in /Users/ryan/Library/*; do
echo $dir
done
/Users/ryan/Library/Acrobat User Data
/Users/ryan/Library/Address Book Plug-Ins
/Users/ryan/Library/Application Support
...
Which is what you actually want...unless you are doing something really
wacky. To do the first example without wordsplitting you need quotes in two
places:
for dir in "$(ls /Users/ryan/Library/)"; do
echo "$dir"
done
I also don't use USER as a variable anymore in scripts after getting burned
once by accidentally forgetting to set it in the script thus pulling in my
current, logged in user from the global $USER when testing :(
I ALWAYS use username now.
Ryan Manly
Glenbrook High Schools