Author: nextgens
Date: 2006-04-09 10:12:27 +0000 (Sun, 09 Apr 2006)
New Revision: 8499

Modified:
   trunk/apps/installer/build.xml
   trunk/apps/installer/installclasspath/linux/update.sh
   trunk/apps/installer/installclasspath/windows/update.cmd
Log:
installer: Updated update script for both linux and windows

Modified: trunk/apps/installer/build.xml
===================================================================
--- trunk/apps/installer/build.xml      2006-04-08 18:37:31 UTC (rev 8498)
+++ trunk/apps/installer/build.xml      2006-04-09 10:12:27 UTC (rev 8499)
@@ -162,9 +162,6 @@
                </replace>
                <copy file="${basedir}/windows/wget.exe"  
tofile="${installDir}/bin/wget.exe"/>
                <copy file="${basedir}/windows/update.cmd"  
tofile="${installDir}/update.cmd"/>
-               <replace file="${installDir}/update.cmd">
-                       <replacefilter token="@serviceName@" 
value="${freenetWorkingMode}"/>
-               </replace>
                <copy file="${basedir}/windows/freenet.ico"  
tofile="${installDir}/freenet.ico"/>
                <echo message="Creating shortcuts"/>
                <exec executable="cscript" dir="${basedir}/windows" >

Modified: trunk/apps/installer/installclasspath/linux/update.sh
===================================================================
--- trunk/apps/installer/installclasspath/linux/update.sh       2006-04-08 
18:37:31 UTC (rev 8498)
+++ trunk/apps/installer/installclasspath/linux/update.sh       2006-04-09 
10:12:27 UTC (rev 8499)
@@ -1,31 +1,54 @@
 #!/bin/bash
-pushd @path@ 2>&1 >/dev/null
+WHEREAMI="$(pwd)"
+cd @path@
 echo "Updating freenet"

-wget -o /dev/null -N 
http://downloads.freenetproject.org/alpha/freenet-cvs-snapshot.jar.url
+if [[ "$(which wget)" == "" ]]
+then
+       WGET=0
+       DOWNLOADER="curl -q -f -L -o /dev/null -O "
+       DOWNLOADER2="curl -q -f -L -o /dev/null -O 
http://downloads.freenetproject.org/alpha/freenet-cvs-snapshot.jar";
+       DOWNLOADER3="curl -q -f -L -o /dev/null -O "
+else
+       WGET=1
+       # see https://bugs.freenetproject.org/view.php?id=223
+       # we can't afford a valid non-selfsigned SSL certificate :/
+       if [[ $(wget --version | head -n1 | cut -d" " -f3 | cut -d"." -f2) -ge 
10 ]]
+       then
+           NOCERT="--no-check-certificate "
+       fi
+       DOWNLOADER="wget -o /dev/null -N "
+       DOWNLOADER2="wget -o /dev/null -N -O freenet-cvs-snapshot.jar -i 
freenet-cvs-snapshot.jar.url"
+       DOWNLOADER3="wget -o /dev/null -N -O update2.sh $NOCERT "
+fi

-touch freenet-cvs-snapshot.jar.url.old
+rm -f freenet-cvs-snapshot.jar.url
+$DOWNLOADER 
http://downloads.freenetproject.org/alpha/freenet-cvs-snapshot.jar.url
+
+touch freenet-cvs-snapshot.jar.url.old freenet-cvs-snapshot.jar.url
 diff --brief freenet-cvs-snapshot.jar.url freenet-cvs-snapshot.jar.url.old
 if [[ $? -ne 0 ]]
 then
        echo "Downloading freenet"
-       wget -o /dev/null -i freenet-cvs-snapshot.jar.url -O 
freenet-cvs-snapshot.jar
-       mv freenet-cvs-snapshot.jar.url freenet-cvs-snapshot.jar.url.old
-       
-       echo "Restarting freenet"
-       exec sh run.sh restart
+       rm -f freenet-cvs-snapshot.jar freenet-cvs-snapshot.jar 
freenet-r*-snapshot.jar
+       $DOWNLOADER2
+       mv $(cat freenet-cvs-snapshot.jar.url|cut -d\/ -f 5) 
freenet-cvs-snapshot.jar
+       if [[ -s freenet-cvs-snapshot.jar ]]
+       then
+               mv freenet-cvs-snapshot.jar.url freenet-cvs-snapshot.jar.url.old
+               echo "Restarting freenet"
+               exec sh run.sh restart
+       else
+               echo "Error updating the node"
+               exit
+       fi
 else
        echo "Your freenet node is up to date"
 fi

-# see https://bugs.freenetproject.org/view.php?id=223
-# we can't afford a valid non-selfsigned SSL certificate :/
-if [[ $(wget --version | head -n1 | cut -d" " -f3 | cut -d"." -f2) -ge 10 ]]
-then
-    NOCERT="--no-check-certificate "
-fi

-wget $NOCERT -N -o /dev/null 
https://emu.freenetproject.org/svn/trunk/apps/installer/installclasspath/linux/update.sh
 -O update2.sh
+$DOWNLOADER3 
https://emu.freenetproject.org/svn/trunk/apps/installer/installclasspath/linux/update.sh
+touch update.sh update2.sh
 diff --brief update.sh update2.sh
 if [[ $? -ne 0 ]]
 then
@@ -33,8 +56,14 @@
        # we need to escape it, thanks to the_JinX for the hack
        WHAT="@pa"
        WHAT2="th@"
+       if [[ $WGET -eq 0 ]]
+       then
+               cp update.sh update2.sh
+       fi
        cat update2.sh |sed "s/$WHAT$WHAT2/$LOCATION/" > update.sh
        chmod +x update.sh
+       echo "New update script detected, re-running"
+       exec update.sh
 fi

-popd 2>&1 >/dev/null
+cd $WHEREAMI

Modified: trunk/apps/installer/installclasspath/windows/update.cmd
===================================================================
--- trunk/apps/installer/installclasspath/windows/update.cmd    2006-04-08 
18:37:31 UTC (rev 8498)
+++ trunk/apps/installer/installclasspath/windows/update.cmd    2006-04-09 
10:12:27 UTC (rev 8499)
@@ -1,8 +1,101 @@
- at echo "Stopping Freenet"
- at net stop freenet- at serviceName@
- at echo "Updating Freenet"
-bin\wget.exe -o NUL -N 
http://downloads.freenetproject.org/alpha/freenet-cvs-snapshot.jar.url
+ at echo off
+echo -----
+echo - Freenet windows update script by 1.0 Zero3Cool (zero3cool at 
zerosplayground.dk)
+echo - This script will automatically update your Freenet installation.
+echo - In case of a serious error, this script will pause.
+echo -----
+
+: Go to our location
+for %%i in (%0) do set LOCATION=%%~dpi
+cd %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
+echo - Freenet installation found at %LOCATION%
+echo -----
+
+: Clean up after old update
+if exist freenet-cvs-snapshot.jar.new.url del freenet-cvs-snapshot.jar.new.url
+
+: Is this session launched by an old updater? If so, don't try to update again 
this session
+for %%i in (%0) do set FILENAME=%%~nxi
+if %FILENAME%==update.new.cmd goto updaterok
+
+: Download latest updater and verify it
+echo - Checking for updater updates...
+bin\wget.exe -o NUL 
https://emu.freenetproject.org/svn/trunk/apps/installer/installclasspath/windows/update.cmd
 -O update.new.cmd
+if not exist update.new.cmd goto error1
+type update.new.cmd|find "FREENET WINDOWS UPDATE SCRIPT" > NUL
+if errorlevel 1 goto error1
+
+: Check if updater has been updated
+fc update.cmd update.new.cmd|find "***** " > nul
+if errorlevel 1 goto updaterok
+
+: It has! Update self and run again...
+echo - Updater updated, restarting update...
+start update.new.cmd
+goto veryend
+
+: Updater is up to date, check Freenet
+:updaterok
+echo - Updater is up to date.
+echo -----
+echo - Checking for Freenet updates...
+bin\wget.exe -o NUL 
http://downloads.freenetproject.org/alpha/freenet-cvs-snapshot.jar.url -O 
freenet-cvs-snapshot.jar.new.url
+if not exist freenet-cvs-snapshot.jar.new.url goto error3
+
+: Do we have something old to compare with? If not, update right away
+if not exist freenet-cvs-snapshot.jar.url goto updatefreenet
+
+: Compare with current copy
+fc freenet-cvs-snapshot.jar.url freenet-cvs-snapshot.jar.new.url|find "***** " 
> nul
+if errorlevel 1 goto noupdate
+
+:updatefreenet
+echo - New version found, shutting down and updating Freenet...
+sc query freenet-testnet|find "RUNNING" > NUL
+if not errorlevel 1 call stop.cmd > NUL
+if exist freenet-cvs-snapshot.jar.url del freenet-cvs-snapshot.jar.url
+ren freenet-cvs-snapshot.jar.new.url freenet-cvs-snapshot.jar.url
 bin\wget.exe -o NUL -i freenet-cvs-snapshot.jar.url -O freenet-cvs-snapshot.jar
-bin\wget.exe -o NUL 
https://emu.freenetproject.org/svn/trunk/apps/installer/installclasspath/windows/update.cmd
- at echo "Restarting Freenet"
- at net start freenet- at serviceName@
+echo - Freenet updated.
+goto end
+
+:noupdate
+echo - Freenet is up to date.
+goto end
+
+:error0
+echo - Error! Your OS is not supported by this update script.
+echo -----
+pause
+goto veryend
+
+:error1
+echo - Error! Downloaded update script is invalid. Try again later.
+goto end
+
+:error2
+echo - Error! Please run this script from a working Freenet installation.
+echo -----
+pause
+goto veryend
+
+:error3
+echo - Error! Could not download latest Freenet update information. Try again 
later.
+goto end
+
+:end
+echo -----
+echo - Cleaning up and restarting Freenet...
+echo -----
+if exist freenet-cvs-snapshot.jar.new.url del freenet-cvs-snapshot.jar.new.url
+sc query freenet-testnet|find "RUNNING" > NUL
+if errorlevel 1 call start.cmd > NUL
+if %FILENAME%==update.new.cmd copy /Y update.new.cmd update.cmd > NUL
+if exist update.new.cmd del update.new.cmd
+
+:veryend
+: FREENET WINDOWS UPDATE SCRIPT


Reply via email to