@ECHO OFF
SETLOCAL 


REM ----- Edit This Section --------

SET SNIFFER_PATH=\mdaemon\snf
SET AUTHENTICATION=authenticationxx
SET LICENSE_ID=licensid

REM --------------------------------

CD /d %SNIFFER_PATH%

if not exist UpdateReady.txt GOTO DONE

if exist UpdateReady.lck GOTO DONE

:DOWNLOAD
 
COPY UpdateReady.txt UpdateReady.lck
wget http://www.sortmonster.net/Sniffer/Updates/%LICENSE_ID%.snf -O %LICENSE_ID%.new.gz --header=Accept-Encoding:gzip --http-user=sniffer --http-passwd=ki11sp8m

if exist %LICENSE_ID%.new.gz gzip -d -f %LICENSE_ID%.new.gz

snf2check.exe %LICENSE_ID%.new %AUTHENTICATION%

if errorlevel 1 goto CLEANUP

if exist %LICENSE_ID%.old del %LICENSE_ID%.old

rename %LICENSE_ID%.snf %LICENSE_ID%.old
rename %LICENSE_ID%.new %LICENSE_ID%.snf

if exist UpdateReady.txt del UpdateReady.txt
if exist UpdateReady.lck del UpdateReady.lck

:CLEANUP

if exist %LICENSE_ID%.new del %LICENSE_ID%.new
if exist UpdateReady.lck del UpdateReady.lck 

:DONE

ENDLOCAL


