Skip to content

Instantly share code, notes, and snippets.

@zwnk
Created May 2, 2018 13:42
# bash script that checks for new version of lastools
# the actual version is saved as LAStools_act.zip
# after downloading the latest version md5 of
# both archives are checked against each other.
#download latest LAStools version
# -O for overwritting LAStools.zip
# -L for following any redirect
# go to home folder for script execution
cd /home/dmcl/
curl -O -L http://lastools.org/download/LAStools.zip
# set temp filename and webserver path
file="LAStools_act.zip"
wwwpath="/var/www/html/intra/LAStools.zip"
{
# check first run
# if LAStools_act.zip does not exist
# download and copy it
if [ -f "$file" ];then
echo "$file found."
# check for new version with md5 sum
if [ $(md5sum LAStools.zip | awk '{print $1}') == $(md5sum LAStools_act.zip | awk '{print $1}') ]; then
echo "no new version found"
# remove LAStools.zip
rm LAStools.zip
else
echo "new version found"
# remove the old version
rm LAStools_act.zip
# rename latest vesion
mv LAStools.zip LAStools_act.zip
# copy latest version to public webserver path
cp LAStools_act.zip $wwwpath
fi
else
echo "$file not found. FIRST RUN."
# rename latest vesion
mv LAStools.zip LAStools_act.zip
# copy latest version to public webserver path
cp LAStools_act.zip $wwwpath
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment