09 July 2006

Script to download a tar and extract it if it has changed

#!/bin/bash
tarFile=bhavaya.tar.gz
sourceTarFile=http://files.parwy.net/it/builds/${tarFile}
downloadDir=/cygdrive/c/sekhonp/it/builds/bhavaya
extractDir=${downloadDir}/module
proxy="http://primary-proxy:8080"

export http_proxy=${proxy}

cd ${downloadDir}

modificationTime=`stat -c %y ${tarFile}`
wget -N --proxy=on --proxy-user=${1} --proxy-passwd=${2} --http-user=${3} --http-passwd=${4} ${sourceTarFile}
newModificationTime=`stat -c %y ${tarFile}`
echo "old modification time: ${modificationTime}, new modification time: ${newModificationTime}"

if [ "${modificationTime}" != "${newModificationTime}" ] ; then
echo "Extracting ${tarFile}..."
tar -C ${extractDir} -xzvf ${tarFile} 1>/dev/null
fi

No comments:

Post a Comment