#!/bin/bash NAME="MBDash-current" MD51="$NAME.checksum.current" MD52="$NAME.checksum.downloaded" UPD_URL="http://update.mikbill.ru:9425/$NAME" DOWNLOAD_DIR="/var/mikbill/updates/mbplatform" WORK_DIR="/var/www/mikbill/admin" if [ ! -d $DOWNLOAD_DIR ]; then mkdir -p $DOWNLOAD_DIR fi cd $DOWNLOAD_DIR wget -O $MD52 -q $UPD_URL.checksum if [ $? -ne 0 ]; then echo "Download FAILED! please check DNS and connection to $UPD_URL.checksum" exit 0 fi if [ ! -f $MD51 ]; then echo 0 > $MD51 fi MD5_CURRENT=$(cat $MD51) MD5_DOWNLOADED=$(cat $MD52) if [ "$MD5_CURRENT" != "$MD5_DOWNLOADED" ]; then cd $WORK_DIR wget -O $NAME.tar.gz -q $UPD_URL.tar.gz if [ $? -ne 0 ]; then echo "Download FAILED! please check DNS and connection to $UPD_URL.tar.gz" exit 0 fi echo "$MD5_DOWNLOADED" > $DOWNLOAD_DIR/$MD51 if [ -d MBPlatform ]; then rm -rf MBPlatform/ fi tar -zxf $NAME.tar.gz rm -f $NAME.tar.gz fi