Off Site Downloading

billystanton
New Contributor II

Hi All,

Our File Dist Point is hosted onsite and users cannot get access to this unless they are on our internal network.

I have to change the wallpaper of our machines all at the same time and planned to upload this is a web server and then have our Mac's silently download the file to their hard drive. (To the shared folder on the hard drive)

I would then push out the settings to change the wallpaper via a second policy/profile.

I believe I would setup the silent download by using the "Curl" command, but i'm not sure on how to write this.

Does anybody have any examples?

Thanks in advance

3 REPLIES 3

davidacland
Honored Contributor II

The basic command would be curl http://webserver.address.com --output desktoppic.png. You would then add a few other commands to put in the right place and set permissions etc.

The curl command would change depending on whether its a https server, self signed cert etc, but this is the basic command.

thoule
Valued Contributor II

If it needed to be done on a certain date/time, I wouldn't rely on a JSS policy. How about building a launchD and script? You can put this script in a directory. Add in a launchD and you should be good.

#!/bin/sh                                  
#SetDesktopImage                               
#this file is                                
#/usr/local/todd/sss.sh                     

#number of seconds since 01-01-1970 UTC  
today=`date +%s`

#only run if later than 22Feb2016.  Change that number to the epoch time you want it to change on.  Google Epoch time for more info.

if [ $today > 1456149780 ]; then
    mkdir -p /usr/local/todd
    curl  http://mywebsite.com/media/toddiscool.png --output /usr/local/todd/toddiscool.png
    osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/usr/local/todd/toddiscool.png"'

   #uncomment below lines to make it a one-time event.  Else it'll set the desktop 25200 seconds.
    #launchctl unload -w /Library/LaunchDaemons/com.mycorp.sss.plist
   # rm /Library/LaunchDaemons/com.mycorp.sss.plist
   # rm /usr/local/todd/sss.sh

fi

And a LaunchD

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.mycorp.sss.plist</string>
        <key>ProgramArguments</key>
        <array>
                <string>sh</string>
                <string>/usr/local/todd/sss.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StartInterval</key>
        <integer>25200</integer>
</dict>
</plist>

This is totally untested, and just written quickly, but should get you enough for what you need. BTW, didn't there used to be a setting in the JSS to cache a policy for offline use? I didn't see that anywhere.

jjones
Contributor II

@thoule The caching option is only when you have the trigger set to ongoing. It has been asked before to have it accessible outside that trigger.