Author: nextgens Date: 2008-05-28 14:02:46 +0000 (Wed, 28 May 2008) New Revision: 20113
Added: trunk/apps/new_installer/scripts/ trunk/apps/new_installer/scripts/update.cmd trunk/apps/new_installer/scripts/update.sh Log: new_installer: move scripts from the old location to the new one Copied: trunk/apps/new_installer/scripts/update.cmd (from rev 20112, trunk/apps/installer/installclasspath/windows/update.cmd) =================================================================== --- trunk/apps/new_installer/scripts/update.cmd (rev 0) +++ trunk/apps/new_installer/scripts/update.cmd 2008-05-28 14:02:46 UTC (rev 20113) @@ -0,0 +1,282 @@ + at echo off +::This script is designed for the Windows command line shell, so please don't put it into anything else! :) +::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 parameter 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.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 - node to reduce traffic on our servers, thanks!!! +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 +set PATH=%SYSTEMROOT%\System32\;%PATH% +set RELEASE=stable +if "%1"=="testing" set RELEASE=testing + +::Go to our location +for %%I in (%0) do set LOCATION=%%~dpI +cd /D %LOCATION% + +::Check if its valid, or at least looks like it +if not exist freenet.ini goto error2 +if not exist bin\wget.exe goto error2 + +if not exist wrapper.conf.bak copy wrapper.conf wrapper.conf.bak > NUL + +::Get the filename and skip straight to the Freenet update if this is a new updater +for %%I in (%0) do set FILENAME=%%~nxI +if %FILENAME%==update.new.cmd goto updaterok + +::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 -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 +if errorlevel 1 goto error1 + +find "freenet.jar" wrapper.conf > NUL +if errorlevel 1 goto error5 + +find "freenet.jar.new" wrapper.conf > NUL +if not errorlevel 1 goto error5 + +:: fix #1527 +find "freenet-ext.jar.new" wrapper.conf > NUL +if not errorlevel 1 goto skipit +copy freenet-ext.jar.new freenet-ext.jar > NUL +del /F freenet-ext.jar.new +:skipit + +::Check if updater has been updated +fc update.cmd update.new.cmd > NUL +if not errorlevel 1 goto updaterok + +::It has! Run new version and end self +echo - Update script updated, restarting update script... +echo ----- +start update.new.cmd +goto veryend + + +::Updater is up to date, check Freenet +:updaterok +echo - Update script is current. +echo ----- + +::Handle older installations where start and stop are not in the bin\ directory +if not exist bin\stop.cmd copy stop.cmd bin\stop.cmd > NUL +if not exist bin\start.cmd copy start.cmd bin\start.cmd > NUL +if not exist bin\stop.cmd goto error2 +if not exist bin\start.cmd goto error2 + +echo - Freenet installation found at %LOCATION% +echo ----- + +:: Register .fref file extention +if exist fref.reg goto regupdated +echo - Registering .fref file extention + +echo Windows Registry Editor Version 5.00 >> fref.reg +echo [HKEY_CLASSES_ROOT\.fref] >> fref.reg +echo @="fref_auto_file" >> fref.reg +echo [HKEY_CLASSES_ROOT\fref_auto_file] >> fref.reg +echo @="Freenet node reference" >> fref.reg +echo "EditFlags"=dword:00000000 >> fref.reg +echo "BrowserFlags"=dword:00000008 >> fref.reg +echo [HKEY_CLASSES_ROOT\fref_auto_file\DefaultIcon] >> fref.reg +echo @="shell32.dll,56" >> fref.reg +echo [HKEY_CLASSES_ROOT\fref_auto_file\shell] >> fref.reg +echo @="Open" >> fref.reg +regedit /s fref.reg > NUL +FTYPE fref_auto_file=start javaw -cp "%LOCATION%\freenet.jar" freenet.tools.AddRef "%%1" > NUL +:regupdated + +echo ----- +echo - Checking for Freenet JAR updates... + +::Check for sha1test and download if needed. +if not exist lib mkdir lib +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 + +:: Disable password expiration on freenet's account +if exist bin\netuser.exe goto pwupdated + at java -cp lib\sha1test.jar Sha1Test installer/netuser.exe > NUL + at move netuser.exe bin\ > NUL +if not errorlevel 0 goto error3 + at bin\netuser.exe freenet /pwnexp:y >NUL +:pwupdated + +if exist freenet-%RELEASE%-latest.jar.new.url del 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 + +::Do we have something old to compare with? If not, update right away +if not exist freenet-%RELEASE%-latest.jar.url goto update1 + +::Compare with current copy +fc freenet-%RELEASE%-latest.jar.url freenet-%RELEASE%-latest.jar.new.url > NUL +if not errorlevel 1 goto noupdate + + +::New version found, check if the node is currently running +:update1 +echo - New version found! +echo ----- + +net start | find "Freenet 0.7 darknet" > NUL +if errorlevel 1 goto update2 > NUL +set RESTART=1 +::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 0.7 darknet" > 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 - "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 0.7 darknet" > NUL +if errorlevel 1 goto update2 > NUL +call bin\stop.cmd > NUL +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 +::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 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 + at del /F bin\netuser.exe +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 +if exist freenet-%RELEASE%-latest.jar.bak ren freenet-%RELEASE%-latest.jar.bak freenet-%RELEASE%-latest.jar +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 -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... +if exist freenet-%RELEASE%-latest.jar.new.url del freenet-%RELEASE%-latest.jar.new.url +if exist freenet-%RELEASE%-latest.jar.bak del freenet-%RELEASE%-latest.jar.bak + +if %RESTART%==0 goto cleanup2 +echo - Restarting Freenet... +call bin\start.cmd > NUL + + +:cleanup2 +if %FILENAME%==update.new.cmd goto newend +if exist update.new.cmd del update.new.cmd +echo ----- +goto veryend + + +::If this session was launched by an old updater, replace it now (and force exit, or we will leave a command prompt open) +:newend +copy /Y update.new.cmd update.cmd > NUL +echo ----- +exit + + +:veryend +::FREENET WINDOWS UPDATE SCRIPT Copied: trunk/apps/new_installer/scripts/update.sh (from rev 20112, trunk/apps/installer/installclasspath/linux/update.sh) =================================================================== --- trunk/apps/new_installer/scripts/update.sh (rev 0) +++ trunk/apps/new_installer/scripts/update.sh 2008-05-28 14:02:46 UTC (rev 20113) @@ -0,0 +1,172 @@ +#!/bin/sh +WHEREAMI="`pwd`" +JOPTS="-Djava.net.preferIPv4Stack=true" +echo "Updating freenet" + +# Attempt to use the auto-fetcher code, which will check the sha1sums. + +if test "$#" -gt 0 +then + if test "$1" = "testing" + then + RELEASE="testing" + echo "WARNING! you're downloading an UNSTABLE snapshot version of freenet." + else + RELEASE="stable" + fi +else + RELEASE="stable" +fi + +# We need to download the jars to temporary locations, check whether they are different, +# and if necessary shutdown the node before replacing, because java may do wierd things +# otherwise. + +mkdir -p download-temp + +if test -d download-temp +then + echo Created temporary download directory. +else + echo Could not create temporary download directory. + exit +fi + +# see https://bugs.freenetproject.org/view.php?id=223 +# we can't afford a valid non-selfsigned SSL certificate :/ +if test `wget --version | head -n1 | cut -d" " -f3 | cut -d"." -f2` -ge 10 +then + NOCERT="--no-check-certificate " +fi + +if test ! -x "`which wget`" +then + WGET=0 + DOWNLOADER="curl --insecure -q -f -L -O " +else + WGET=1 + DOWNLOADER="wget -o /dev/null -N " +fi + +if test ! -s sha1test.jar +then + for x in 1 2 3 4 5 + do + echo Downloading sha1test.jar utility jar which will download the actual update. + if test $WGET -eq 1 + then + $DOWNLOADER $NOCERT http://get.freenetproject.org/sha1test.jar + else + $DOWNLOADER http://get.freenetproject.org/sha1test.jar + fi + + if test -s sha1test.jar + then + break + fi + done + if test ! -s sha1test.jar + then + echo Could not download Sha1Test. The servers may be offline? + exit + fi +fi + +if java $JOPTS -cp sha1test.jar Sha1Test update/update.sh +then + echo "Downloaded update.sh" + chmod +x update.sh + + touch update.sh update2.sh + if cmp update.sh update2.sh >/dev/null 2>&1 + then + echo "Your update.sh is up to date" + else + cp update.sh update2.sh + exec ./update.sh $RELEASE + exit + fi +else + echo "Could not download new update.sh." + exit +fi + +if java $JOPTS -cp sha1test.jar Sha1Test freenet-$RELEASE-latest.jar download-temp +then + echo Downloaded freenet-$RELEASE-latest.jar +else + echo Could not download new freenet-$RELEASE-latest.jar. + exit +fi + +if java $JOPTS -cp sha1test.jar Sha1Test freenet-ext.jar download-temp +then + echo Downloaded freenet-ext.jar +else + echo Could not download new freenet-ext.jar. + exit +fi + +cat wrapper.conf | sed 's/freenet-cvs-snapshot/freenet/g' | sed 's/freenet-stable-latest/freenet/g' | sed 's/freenet.jar.new/freenet.jar/g' | sed 's/freenet-ext.jar.new/freenet-ext.jar/g' > wrapper2.conf +mv wrapper2.conf wrapper.conf + +if test ! -x "`which cmp`" +then + if test ! -x "`which md5sum`" + then + echo No cmp or md5sum utility detected + echo Restarting the node as we cannot tell whether we need to. + ./run.sh stop + mv download-temp/freenet-$RELEASE-latest.jar freenet-$RELEASE-latest.jar + rm freenet.jar + ln -s freenet-$RELEASE-latest.jar freenet.jar + mv download-temp/freenet-ext.jar freenet-ext.jar + ./run.sh start + else + if test "`md5sum freenet.jar | cut -d ' ' -f1`" != "`md5sum download-temp/freenet-$RELEASE-latest.jar | cut -d ' ' -f1`" + then + echo Restarting node because freenet-$RELEASE-latest.jar updated. + ./run.sh stop + mv download-temp/freenet-$RELEASE-latest.jar freenet-$RELEASE-latest.jar + rm freenet.jar + ln -s freenet-$RELEASE-latest.jar freenet.jar + mv download-temp/freenet-ext.jar freenet-ext.jar + ./run.sh start + elif test "`md5sum freenet-ext.jar | cut -d ' ' -f 1`" != "`md5sum download-temp/freenet-ext.jar | cut -d ' ' -f1`" + then + echo Restarting node because freenet-ext.jar updated. + ./run.sh stop + mv download-temp/freenet-ext.jar freenet-ext.jar + ./run.sh restart + else + echo Your node is up to date. + fi + fi +else + if cmp freenet.jar download-temp/freenet-$RELEASE-latest.jar + then + # freenet.jar is up to date + if cmp download-temp/freenet-ext.jar freenet-ext.jar + then + echo Your node is up to date + else + echo Restarting node because freenet-ext.jar updated. + ./run.sh stop + mv download-temp/freenet-ext.jar freenet-ext.jar + ./run.sh start + fi + else + echo Restarting node because freenet-$RELEASE-latest.jar updated + ./run.sh stop + mv download-temp/freenet-$RELEASE-latest.jar freenet-$RELEASE-latest.jar + rm freenet.jar + ln -s freenet-$RELEASE-latest.jar freenet.jar + mv download-temp/freenet-ext.jar freenet-ext.jar + ./run.sh start + fi +fi + +rm -f download-temp/freenet-$RELEASE-latest.jar* download-temp/freenet-ext.jar* +rmdir download-temp + +cd $WHEREAMI
