Author: toad
Date: 2006-06-15 21:54:51 +0000 (Thu, 15 Jun 2006)
New Revision: 9216
Modified:
trunk/apps/installer/installclasspath/linux/update.sh
Log:
update.sh: Check the SHA1 checksums on freenet-*.jar.
Modified: trunk/apps/installer/installclasspath/linux/update.sh
===================================================================
--- trunk/apps/installer/installclasspath/linux/update.sh 2006-06-15
20:55:06 UTC (rev 9215)
+++ trunk/apps/installer/installclasspath/linux/update.sh 2006-06-15
21:54:51 UTC (rev 9216)
@@ -3,6 +3,8 @@
cd @path@
echo "Updating freenet"
+# Attempt to use the auto-fetcher code, which will check the sha1sums.
+
if [[ "$1" != "debug" ]]
then
THEMASK="-o /dev/null"
@@ -27,37 +29,65 @@
DOWNLOADER3="wget $THEMASK -N -O update2.sh $NOCERT "
fi
-rm -f freenet-cvs-snapshot.jar.url
-$DOWNLOADER
http://downloads.freenetproject.org/alpha/freenet-cvs-snapshot.jar.url
+if [[ ! -s sha1test.jar ]]
+then
+ echo Downloading sha1test.jar utility jar which will download the
actual update.
+ $DOWNLOADER https://emu.freenetproject.org/sha1test.jar
+ if [[ ! -s sha1test.jar ]]
+ then
+ echo Could not download Sha1Test. The servers may be offline?
+ exit
+ fi
+fi
-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 ]]
+cp freenet-cvs-snapshot.jar freenet-cvs-snapshot.jar.old
+cp freenet-ext.jar freenet-ext.jar.old
+
+if java -cp sha1test.jar Sha1Test freenet-cvs-snapshot.jar
then
- echo "Downloading freenet"
- rm -f freenet-r*-snapshot.jar
- $DOWNLOADER2
- if [[ -s $(cat freenet-cvs-snapshot.jar.url | cut -d\/ -f 5) ]]
+ echo Downloaded freenet-cvs-snapshot.jar
+else
+ echo Could not download new freenet-cvs-snapshot.jar.
+ exit
+fi
+
+if java -cp sha1test.jar Sha1Test freenet-ext.jar
+then
+ echo Downloaded freenet-ext.jar
+else
+ echo Could not download new freenet-ext.jar.
+ exit
+fi
+
+if [[ ! -x "$(which cmp)" ]]
+then
+ if [[ ! -x "$(which md5sum)" ]]
then
- rm -f freenet-cvs-snapshot.jar
- mv $(cat freenet-cvs-snapshot.jar.url | cut -d\/ -f 5)
freenet-cvs-snapshot.jar
+ echo No cmp or md5sum utility detected
+ echo Restarting the node as we cannot tell whether we need to.
+ ./run.sh restart
else
- echo "Error downloading the new node: Please try again in 5
minutes, mirrors may not be fully updated if an update has just been published."
+ echo hmmm
+ if [[ "$(md5sum freenet-cvs-snapshot.jar)" != "$(md5sum
freenet-cvs-snapshot.jar.old)" ]]
+ then
+ echo Restarting node because freenet-cvs-snapshot.jar
updated.
+ ./run.sh restart
+ elif [[ "$(md5sum freenet-ext.jar)" != "$(md5sum
freenet-ext.jar.old)" ]]
+ then
+ echo Restarting node because freenet-ext.jar updated.
+ ./run.sh restart
+ fi
fi
- if [[ -s freenet-cvs-snapshot.jar ]]
+else
+ if cmp freenet-cvs-snapshot.jar freenet-cvs-snapshot.jar.old && cmp
freenet-ext.jar freenet-ext.jar.old
then
- mv freenet-cvs-snapshot.jar.url freenet-cvs-snapshot.jar.url.old
- echo "Restarting freenet"
- exec sh run.sh restart
+ echo Your node is up to date
else
- echo "Error updating the node"
- exit
+ echo Restarting node because freenet-cvs-snapshot.jar or
freenet-ext.jar updated.
+ ./run.sh restart
fi
-else
- echo "Your freenet node is up to date"
fi
-
$DOWNLOADER3
https://emu.freenetproject.org/svn/trunk/apps/installer/installclasspath/linux/update.sh
touch update.sh update2.sh
diff --brief update.sh update2.sh