PKG vs DMG [CORRECTED TYPOS]

donmontalvo
Esteemed Contributor III

(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

--
https://donmontalvo.com
5 REPLIES 5

ryan_panning
New Contributor

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

Not applicable

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

donmontalvo
Esteemed Contributor III

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

--
https://donmontalvo.com

tlarkin
Honored Contributor

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

rmanly
Contributor III

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