#!/bin/bash ### CONFIGURATION ### # tell me where the NASA images should be stored to (it is created atomatically) USERDIR="$HOME/.NASA-blue-marble-collection" # where to download monthly images from; provide a full URL with [[[MONTH]]] as a placeholder for the months number MONTHURL="http://gridportal-ws01.hep.ph.ic.ac.uk/bluemarble_all_year/world.topo.bathy.2004[[[MONTH]]].3x5400x2700.jpg" # if you have a special topography file insert the URL here TOPOGRAPHY="http://ia600506.us.archive.org/10/items/VE-IMG-8391/srtm_ramp2.world.5400x2700.jpg" # if you have a special night map, insert URL here NIGHTMAP="https://netfiles.uiuc.edu/cmampre2/www/Pictures/Desktopables/earth_lights_lrg.jpg" # copy the monthly image to this location: TARGETTEXTURE="$HOME/.xplanetFX/base/earth.jpg" # copy the bump map to this location (if you have one): TARGETTOPOGRAPHY="$HOME/.xplanetFX/base/earth_bump.jpg" # copy the nightly image to this location (if you have one): TARGETNIGHTMAP="$HOME/.xplanetFX/base/earth_night.jpg" # the final resolution of the images: TARGETSIZE="2500x1250" # Options for wget WGETOPTIONS="--user-agent=\"Mozilla/5.0\" --referer=\"http://google.com\" --header=\"Accept:text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\" --header=\"Accept-Language:en-us,en;q=0.5\" --header=\"Accept-Encoding:gzip,deflate\" --header=\"Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7\" --header=\"Keep-Alive:300\"" function copyimages() { convert $USERDIR/`date +%m`.jpg -resize $TARGETSIZE $TARGETTEXTURE if [ "$TOPOGRAPHY" != "" -a -f $USERDIR/topo.jpg ]; then convert $USERDIR/topo.jpg -resize $TARGETSIZE $TARGETTOPOGRAPHY fi if [ "$NIGHTMAP" != "" -a -f $USERDIR/night.jpg ]; then convert $USERDIR/night.jpg -resize $TARGETSIZE $TARGETNIGHTMAP fi echo `date +%m` > $USERDIR/monthid echo `date -r $TARGETTEXTURE +%F\ %H:%M:%S` > $USERDIR/timestamp } ### CLEANUP FOR REFRESHING IMAGES ### if [ "$1" == "--refresh" -o "$1" == "-r" ]; then rm -r $USERDIR fi ### FORCE COPYING ### if [ "$1" == "--force" -o "$1" == "-f" ]; then rm $USERDIR/timestamp $USERDIR/monthid fi ### SETUP AND DOWNLOAD ### if [ ! -d $USERDIR ]; then mkdir -p $USERDIR MONTH=1 while [ $MONTH -lt 13 ]; do M=`printf %.2d $MONTH` U=`echo $MONTHURL | sed "s#\[\[\[MONTH\]\]\]#$M#"` wget $WGETOPTIONS --output-document $USERDIR/$M.jpg $U let MONTH=$MONTH+1 done if [ "$TOPOGRAPHY" != "" ]; then wget $WGETOPTIONS --output-document="$USERDIR/topo.jpg" $TOPOGRAPHY fi if [ "$NIGHTMAP" != "" ]; then wget $WGETOPTIONS --output-document="$USERDIR/night.jpg" $NIGHTMAP fi fi ### CREATE TIMESTAMP ### if [ ! -f $USERDIR/timestamp ]; then touch $USERDIR/timestamp fi ### CREATE MONTHID ### if [ ! -f $USERDIR/monthid ]; then touch $USERDIR/monthid fi ### UPDATE IMAGE IF NECESSARY ### LASTDATE=`date -r $TARGETTEXTURE +%F\ %H:%M:%S` ACTMONTH=`date +%m` if [ "$LASTDATE" != "`cat $USERDIR/timestamp`" -o "$ACTMONTH" != "`cat $USERDIR/monthid`" ]; then copyimages fi