copy files and folders out of dmg and inherit new ownership?

jhuls
Contributor III

I'm needing to automate mounting a dmg and then copying specific files and folders from it to the current user's profile. Copying seems to the easy part. The hard part(for me anyways) is finding a way to do this that will inherit the ownership and group of the destination. I've looked at cp and rsync and am not seeing any way to do this although I'm willing to admit it's quite likely staring me in the face. I know this can't be some stupid, impossible task so what am I missing?

Note that this will be done with Casper in a policy with a script so the copy process would be done as root I believe.

4 REPLIES 4

Asnyder
Contributor III

Why not create a package to install files where they need to go? or Write a script to download and place them?

jhuls
Contributor III

A script to place them is exactly what I'm trying to do. I'm just not downloading but pulling the files from a mounted dmg.

Here's what I'm trying to do...

I have an instructor who has custom settings for various Adobe applications that are designed for a few labs. I currently have them captured in a dmg where they are configured to deploy to a workstation with FUT and FEU when a lab machine is built. The lab computers are multiuser systems and should a student, logged in with their own account, mess up their settings for an application like Photoshop then I'm looking to provide a means in Self Service where they could mount the needed dmg and copy the necessary setting files to the correct location in ~/Library.

I can't think of another method to use to deal with this at the moment. If you have other ideas, I'm all ears.

Hugonaut
Valued Contributor II

@jhuls

@Asnyder is right on the money, thats what I would do.

rsync is the way to go in this situation. chmod and chown the files via script, you can even have the script call on the local user of the machine and chown/chmod it to that so the script can be versatile no matter where you place it.

applescript it, curl disk image from where ever, mount it, rsync to where you need it, chmod/chown it how you want, etc.. seems like a good plan!

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

jhuls
Contributor III

@Hugonaut Thanks. I think I have a better method that I'm in the middle of testing now. I'm running rsync as the local user. I would have thought it wouldn't be hard to copy files to a location even if it's as root and let it inherit the ownership and group info but I never found a way unless I add more code to use chown. It seems easier to just su with the local user logged in and run the script. So far so good.