Skip to content

Instantly share code, notes, and snippets.

@philcryer
Created October 13, 2010 20:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philcryer/624802 to your computer and use it in GitHub Desktop.
Save philcryer/624802 to your computer and use it in GitHub Desktop.
Get latest bhl.zip, rename it with the date, generate an md5 of it, move those files into a Dropbox directory, get the public Dropbox URL for that file, create a HTML file containing a link to that, and put that URL and put that HTML in on a webserver.
#!/bin/bash
DATE=`date +%Y%m%d`
TARGET_PATH=/home/phil/Dropbox/Public
WWW_USER=www-data
WWW_GROUP=www-data
WWW_PATH=/var/www/data
if [ ! -d ${WWW_PATH} ]; then
mkdir -p ${WWW_PATH}
chown -R ${WWW_USER}:${WWW_GROUP} ${WWW_PATH}
fi
cd /tmp
wget http://www.biodiversitylibrary.org/data/data.zip
mv data.zip bhldata-${DATE}.zip
echo "* created bhldata-${DATE}.zip"
md5sum bhldata-${DATE}.zip > bhldata-${DATE}.zip.md5
MD5="(md5: `cat bhldata-${DATE}.zip.md5 | cut -d" " -f1`)"
echo "* created bhldata-${DATE}.zip.md5"
mv bhldata-${DATE}.zip ${TARGET_PATH}
mv bhldata-${DATE}.zip.md5 ${TARGET_PATH}
echo "* moved files to ${TARGET_PATH}"
URL=`/usr/bin/dropbox puburl ${TARGET_PATH}/bhldata-${DATE}.zip`
echo "* public URL is ${URL}"
echo "<html><head> <title>BHL data download</title> <link rel="shortcut icon" href="images/favicon.ico"> <link rel="icon" href="images/favicon.ico" type="image/x-icon"> <body> <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> <center> <img src="images/bhl_logo.gif" alt="Biodiversity Heritage Library" border="0"></a><br /><br />" > ${WWW_PATH}/index.html
echo "<a href="${URL}">bhldata-${DATE}.zip</a> ${MD5}" >> ${WWW_PATH}/index.html
echo " </center> </body> </html>" > ${WWW_PATH}/index.html
chown -R ${WWW_USER}:${WWW_GROUP} ${WWW_PATH}
echo "* Created/updated webpage at: ${WWW_PATH}"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment