Author: toad
Date: 2008-04-05 18:26:50 +0000 (Sat, 05 Apr 2008)
New Revision: 19040

Modified:
   trunk/apps/installer/installclasspath/linux/update.sh
Log:
Auto-upgrade sha1test.jar for old installs. Check the md5sum, so reasonably 
secure, and won't be done anyway unless the sha1sum.jar's md5sum isn't what it 
should be.

Modified: trunk/apps/installer/installclasspath/linux/update.sh
===================================================================
--- trunk/apps/installer/installclasspath/linux/update.sh       2008-04-05 
15:32:27 UTC (rev 19039)
+++ trunk/apps/installer/installclasspath/linux/update.sh       2008-04-05 
18:26:50 UTC (rev 19040)
@@ -18,6 +18,20 @@
        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
@@ -56,6 +70,31 @@
                echo Could not download Sha1Test. The servers may be offline?
                exit
        fi
+else
+       # Check the md5sum, if we can. Upgrade old installs, which have a 
sha1test that doesn't support the second argument so cannot do 
download-to-a-temp-dir.
+       if test -x "`which md5sum`"
+       then
+               echo Checking sha1test.jar ...
+               if test "`md5sum sha1test.jar | cut -d ' ' -f 1`" != 
"6a6d76ea75439c2fb7199c2e4c66e49d"
+               then
+                       echo sha1test.jar may be out of date or corrupt, 
attempting to download a new version
+                       cd download-temp
+                       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 "`md5sum sha1test.jar | cut -d ' ' -f 1`" = 
"6a6d76ea75439c2fb7199c2e4c66e49d"
+                       then
+                               echo Downloaded sha1test.jar successfully.
+                               mv sha1test.jar ../sha1test.jar
+                       else
+                               echo Downloaded sha1test.jar but its md5sum is 
bogus.
+                               echo Using old jar.
+                       fi
+               fi
+       fi
 fi

 if java $JOPTS -cp sha1test.jar Sha1Test update/update.sh
@@ -77,20 +116,6 @@
        exit
 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
-
 if java $JOPTS -cp sha1test.jar Sha1Test freenet-$RELEASE-latest.jar 
download-temp
 then
        echo Downloaded freenet-$RELEASE-latest.jar
@@ -98,6 +123,7 @@
        echo Could not download new freenet-$RELEASE-latest.jar.
        exit
 fi
+#ls -l download-temp/freenet-$RELEASE-latest.jar

 if java $JOPTS -cp sha1test.jar Sha1Test freenet-ext.jar download-temp
 then
@@ -106,6 +132,7 @@
        echo Could not download new freenet-ext.jar.
        exit
 fi
+#ls -l download-temp/freenet-ext.jar

 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


Reply via email to