Author: nextgens
Date: 2007-05-13 11:07:49 +0000 (Sun, 13 May 2007)
New Revision: 13224

Modified:
   trunk/apps/installer/installclasspath/windows/update.cmd
Log:
new_instaler: commit Juiceman's new update.cmd script for windows

Modified: trunk/apps/installer/installclasspath/windows/update.cmd
===================================================================
--- trunk/apps/installer/installclasspath/windows/update.cmd    2007-05-12 
16:36:37 UTC (rev 13223)
+++ trunk/apps/installer/installclasspath/windows/update.cmd    2007-05-13 
11:07:49 UTC (rev 13224)
@@ -3,21 +3,37 @@
 ::If you want to debug this script by adding pauses and stuff, please do it 
from another batch file, because
 ::if you modify this script in any way it will be detected as outdated and 
will be overwritten on the next run.
 ::To force a re-download of the latest Freenet.jar, simply delete 
freenet-%RELEASE%-latest.jar.url before running this script.
+
+::The default behavior is to fetch the latest stable release.  Run this script 
with the testing flag for the latest SVN build.
+::  e.g. C:\Freenet\update.cmd testing
+
+Title Freenet Update Over HTTP Script
 echo -----
 echo - Freenet Windows update script 1.6 by Zero3Cool (zero3cool at 
zerosplayground.dk)
-echo - Freenet Windows update script 1.8 by Juiceman (juiceman69 at gmail.com)
+echo - Freenet Windows update script 1.7 to 2.4 by Juiceman (juiceman69 at 
gmail.com)
 echo - Thanks to search4answers, Michael Schierl and toad for help and 
feedback.
 echo - This script will automatically update your Freenet installation.
 echo - In case of an unrecoverable error, this script will pause.
 echo -----
 echo -----------------------------------------------------------
-echo - Please try to use the update over freenet feature of your
+echo - Please try to use the update over Freenet feature of your
 echo - node to reduce traffic on our servers, thanks!!!
-echo - FYI, updating over freenet is more secure and better for
-echo - your anonymity
+echo - FYI, updating over Freenet is more secure and better for
+echo - your anonymity.
 echo -----------------------------------------------------------
 echo -----

+
+::CHANGELOG:
+:: 2.4 - Test downloaded jar after making sure it is not empty.  Copy over 
freenet.jar after testing for integrity.
+:: 2.3 - Reduce retries to 5.  Turn on file resuming.  Clarify text.
+:: 2.2 - Reduce retry delay and time between retries. 
+:: 2.1 - Title, comments, hide "Please ignore, it is a side effect of a 
work-around" echo unless its needed.
+:: 2.0 - Warn user not to abort script.
+:: 1.9 - Cosmetic fixes (Spacing, typos)
+:: 1.8 - Loop stop script until Node is stopped.
+:: 1.7 - Retry downloads on timeout.
+
 ::Initialize some stuff
 set MAGICSTRING=INDO
 set RESTART=0
@@ -42,7 +58,8 @@
 ::Download latest updater and verify it
 if exist update.new.cmd del update.new.cmd
 echo - Checking for newer version of update script...
-bin\wget.exe -o NUL --timeout=10 --waitretry=20 
http://downloads.freenetproject.org/alpha/update/update.cmd -O update.new.cmd
+bin\wget.exe -o NUL -c --timeout=5 --tries=5 --waitretry=10 
http://downloads.freenetproject.org/alpha/update/update.cmd -O update.new.cmd
+Title Freenet Update Over HTTP Script

 if not exist update.new.cmd goto error1
 find "FREENET W%MAGICSTRING%WS UPDATE SCRIPT" update.new.cmd > NUL
@@ -102,11 +119,12 @@

 ::Check for sha1test and download if needed.
 if not exist lib mkdir lib
-if not exist lib\sha1test.jar bin\wget.exe -o NUL --timeout=10 --waitretry=20  
http://downloads.freenetproject.org/alpha/installer/sha1test.jar -O 
lib\sha1test.jar
+if not exist lib\sha1test.jar bin\wget.exe -o NUL -c --timeout=5 --tries=5 
--waitretry=10  
http://downloads.freenetproject.org/alpha/installer/sha1test.jar -O 
lib\sha1test.jar
 if not errorlevel 0 goto error3

 if exist freenet-%RELEASE%-latest.jar.new.url del 
freenet-%RELEASE%-latest.jar.new.url
-bin\wget.exe -o NUL --timeout=10 --waitretry=20 
http://downloads.freenetproject.org/alpha/freenet-%RELEASE%-latest.jar.url -O 
freenet-%RELEASE%-latest.jar.new.url
+bin\wget.exe -o NUL -c --timeout=5 --tries=5 --waitretry=10 
http://downloads.freenetproject.org/alpha/freenet-%RELEASE%-latest.jar.url -O 
freenet-%RELEASE%-latest.jar.new.url
+Title Freenet Update Over HTTP Script

 if not exist freenet-%RELEASE%-latest.jar.new.url goto error3
 FOR %%I IN ("%LOCATION%freenet-%RELEASE%-latest.jar.url") DO if %%~zI==0 goto 
error3
@@ -127,15 +145,19 @@
 net start | find "Freenet" > NUL
 if errorlevel 1 goto update2 > NUL
 set RESTART=1
-
-echo - Shutting down Freenet...
+::Tell the user not to abort script, it gets very messy.
+echo - Shutting down Freenet...   (This may take a moment, please don't abort)
+call bin\stop.cmd > NUL
+net start | find "Freenet" > NUL
+if errorlevel 1 goto update2 > NUL
+:: Uh oh, this may take a few tries.  Better tell the user not to panic.
 echo -
-echo - If you see an error message about 
+echo - If you see an error message about: 
 echo - "The service could not be controlled in its present state."
 echo - Please ignore, it is a side effect of a work-around 
 echo - to make sure the node is stopped before we copy files.
-
-
+echo -
+::Keep trying until service is stopped for sure.
 :safetycheck
 net start | find "Freenet" > NUL
 if errorlevel 1 goto update2 > NUL
@@ -143,49 +165,59 @@
 goto safetycheck


+::Ok Freenet is stopped, it is safe to copy files.
 :update2
 echo -----
 echo - Downloading new version and updating local installation...

+::Backup last version of Freenet-%RELEASE%-latest.jar file, we will need it if 
update fails.
 if exist freenet-%RELEASE%-latest.jar.bak del freenet-%RELEASE%-latest.jar.bak
 if exist freenet-%RELEASE%-latest.jar ren freenet-%RELEASE%-latest.jar 
freenet-%RELEASE%-latest.jar.bak
-bin\wget.exe -o NUL --timeout=10 --waitretry=20 -i 
freenet-%RELEASE%-latest.jar.new.url -O freenet-%RELEASE%-latest.jar
-copy freenet-%RELEASE%-latest.jar freenet.jar > NUL
-
+::Download new jar file
+bin\wget.exe -o NUL -c --timeout=5 --tries=5 --waitretry=10 -i 
freenet-%RELEASE%-latest.jar.new.url -O freenet-%RELEASE%-latest.jar
+:: Make sure it got downloaded successfully
 if not exist freenet-%RELEASE%-latest.jar goto error4
 FOR %%I IN ("%LOCATION%freenet-%RELEASE%-latest.jar") DO if %%~zI==0 goto 
error4
+::Test the new jar file for integrity.
 java -cp lib\sha1test.jar Sha1Test freenet-%RELEASE%-latest.jar > NUL
 if not errorlevel 0 goto error4
+::Everything looks good, lets install it
+copy freenet-%RELEASE%-latest.jar freenet.jar > NUL
+::Prepare shortcut file for next run.
 if exist freenet-%RELEASE%-latest.jar.url del freenet-%RELEASE%-latest.jar.url
 ren freenet-%RELEASE%-latest.jar.new.url freenet-%RELEASE%-latest.jar.url
-
+Title Freenet Update Over HTTP Script
+::Tell user the good news.
 echo -
-echo - Freenet-%RELEASE%-snapshot.jar verified and updated.
+echo - Freenet-%RELEASE%-snapshot.jar verified and copied to freenet.jar
 goto end


+::No update needed
 :noupdate
 echo - Freenet is up to date.
 goto end


+::Server gave us a damaged version of the update script, tell user to try 
again later.
 :error1
 echo - Error! Downloaded update script is invalid. Try again later.
 goto end


+::Can't find Freenet installation
 :error2
 echo - Error! Please run this script from a working Freenet installation.
 echo -----
 pause
 goto veryend

-
+::Server may be down.
 :error3
 echo - Error! Could not download latest Freenet update information. Try again 
later.
 goto end

-
+::Corrupt file was downloaded, restore from backup.
 :error4
 echo - Error! Freenet update failed, trying to restore backup...
 if exist freenet-%RELEASE%-latest.jar del freenet-%RELEASE%-latest.jar
@@ -193,17 +225,17 @@
 if exist freenet-%RELEASE%-latest.jar.url del freenet-%RELEASE%-latest.jar.url
 goto end

-
+::Wrapper.conf is old, downloading new version and restarting update script
 :error5
 echo - Your wrapper.conf needs to be updated .... updating it ; please restart 
the script when done.
 if exist wrapper.conf.bak del wrapper.conf.bak
 if exist wrapper.conf ren wrapper.conf wrapper.conf.bak
-bin\wget.exe -o NUL --timeout=10 --waitretry=20 
http://downloads.freenetproject.org/alpha/update/wrapper.conf -O wrapper.conf
+bin\wget.exe -o NUL -c --timeout=5 --tries=5 --waitretry=10 
http://downloads.freenetproject.org/alpha/update/wrapper.conf -O wrapper.conf
 if exist wrapper.password type wrapper.password >> wrapper.conf
 start update.new.cmd
 goto veryend

-
+::Cleanup and restart if needed.
 :end
 echo -----
 echo - Cleaning up...


Reply via email to