Create a package that puts a file on the desktop

vwebb
New Contributor

I really thought this would be easy, and i'm probably doing something wrong. I'm trying to deliver a image file (for usb boot sticks for my techs) to the desktop via Self Service. So they select my policy 'Download USB Image' from Self Service and the end result is they have usb.dmg on their desktop. I've tried using Composer to just package a file on the desktop, having it populate to the user home directories, etc. However this hasn't worked, and it seems that it's actually trying to launch this .dmg file and 'run' it or something.. which in turn kills the machine I try it on.. heh. I tried zipping the .dmg file and placing that on the desktop in the same fashion with no luck. This should be easy right?

19 REPLIES 19

Sandy
Valued Contributor II

hmm, well you're trying to make a .dmg of a .dmg.
How about if you put your original in a folder and then use composer to make a .dmg package of that?

vwebb
New Contributor

I tried that, but it seems it's trying to launch the .dmg that i'm trying to copy after it copies the file.

vwebb
New Contributor

I tried that, but it seems it's trying to launch the .dmg that i'm trying to copy after it copies the file.

stevewood
Honored Contributor II
Honored Contributor II

Try using Packages instead. I just created a PKG file with a DMG inside of it and was able to deploy that to /Users/Shared without it trying to open the DMG file. Of course, this means that in order for you to move it to the current user's desktop you'd need a postinstall script to handle the move. Unless someone else has another idea. Using this method you could do something like:

#!/bin/sh

# get logged in user
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`

# move the file to the desktop of logged in user
mv /tmp/<yourdmgfile> /Users/$loggedInUser/Desktop

Test, test, test! I just threw that together off the top of my head. But if you put something like that in as a postinstall script in Packages, that should do the trick. And using /tmp as your holding location would make sure the file is deleted on restart if the move failed.

vwebb
New Contributor

Thanks so much Steve, I'll give this a shot!

Matt
Valued Contributor

Couldn't you also just do:

cp "file location" "~/Desktop/filename"

Since the user will be logged in already and using self service.

JPDyson
Valued Contributor

~ is evaluated for the user running the script (in this case, root)

I'd do a package/script combo. Compose the DMG in some arbitrary location (let's say /Users/Shared/usb.dmg) and then have the script put it on the logged-in user's desktop.

#!/bin/bash

currentUser=`ls -l /dev/console | awk '{ print $3 }'`
mv /Users/Shared/usb.dmg /Users/$currentUser/Desktop/usb.dmg

mm2270
Legendary Contributor III

Ditto to the above suggestions. Drop the DMG into a spot on disk, then script copying/moving it to the logged in user's Desktop in a postinstall script. Done.

dderusha
Contributor

What about creating a DMG with the USB.dmg in it?

Put the USB.dmg on the desktop. Build a DMG with Composer. Right click on a existing package in composer, find in finder and dupe the package.
now name the folder above root USB. Quit composer and re-open.
look for the USB composer, drag in the DMG that is located on your desktop, and make it a DMG.

Copy it to casper admin, and make sure you Fill Existing Users Home Directories.

obi-k
Valued Contributor III
  1. Using Composer, put your desired .dmg file in the Users/shared directory or in private/tmp folder
  2. Create a package
  3. Create a script to move your desired .dmg file to the desktop
  4. Upload the script and package with Casper Admin
  5. Create a policy to push down the package, then set the script to run after

* This might not work for you, but you can create a .dmg instead of a package (for #2), then check off fill user templates, fill existing user home directories. You won't need to create a script. But the policy will push this .dmg to all users and new users accounts.

donmontalvo
Esteemed Contributor III

@JPDyson The $3 variable will be translated to the current user, as long as users are logging in with their domain account in Self Service.

https://jamfnation.jamfsoftware.com/article.html?id=146

#!/bin/bash

mv /Users/Shared/usb.dmg /Users/$3/Desktop/usb.dmg
--
https://donmontalvo.com

stevewood
Honored Contributor II
Honored Contributor II

If you go back and look at the first two posts by the OP, he's already tried using Composer to capture the DMG file and it has failed.

vwebb
New Contributor

Yeah i've tried the dmg in a dmg etc. and for some reason I think Casper is trying to then install that usb.dmg. I appreciate all the responses

vwebb
New Contributor

I'm gonna try it as a package and see if I have better results. Thanks again for all the feedback. :)

dderusha
Contributor

Right, but I didn't capture the package using composer, I made a manual package with composer.
If you place a DMG on your desktop and then drag it to composer it will try to create a source for it. Which you don't want.

Just uploaded a .dmg containing a .dmg to my server, configured it in self service and it dropped the DMG to my desktop. works for me
dd

donmontalvo
Esteemed Contributor III

Policy might be able to curl it down and drop it on the current user's Desktop?

curl -o /Users/$3/Desktop/LatestImage.DMG http://host.domain.com/LatestImage.DMG
--
https://donmontalvo.com

scottb
Honored Contributor

OK, if I understand you, I just did this with Composer.

Built a new DMG and put some random stuff into it.
Placed the DMG into a folder and zip'd it.
Opened Composer and dropped the zip'd file into the Sources on the left.
Built as a DMG.
Uploaded to JSS and ticked off FEU and FUT, save.
Created a policy for Self Service.
Ran the policy and it installed the zip'd filed on the desktop.
Un-zip'd and opened the folder.
Mounted the DMG.
Content inside was intact.

Only difference is that this was not an OS image, but just random data. Should work the same, no?

vwebb
New Contributor

I think the key is that I was not creating the package manually. I'm trying that now and hoping it fixes the weirdness I was experiencing.

vwebb
New Contributor

That did it. Creating it manually works fine. Thanks for the hand holding guys. :)