Author: nextgens
Date: 2006-03-03 20:50:13 +0000 (Fri, 03 Mar 2006)
New Revision: 8149
Added:
trunk/apps/installer/installclasspath/config/freenet-default.ini
Modified:
trunk/apps/installer/antinstall-config.xml
trunk/apps/installer/build.xml
trunk/apps/installer/installclasspath/bin/run.cmd
trunk/apps/installer/installclasspath/bin/run.sh
trunk/apps/installer/src/Sha1Test.java
Log:
New version of the installer : imrpoved mirror handling, "l33t" mode is still
to be done
Modified: trunk/apps/installer/antinstall-config.xml
===================================================================
--- trunk/apps/installer/antinstall-config.xml 2006-03-03 20:49:45 UTC (rev
8148)
+++ trunk/apps/installer/antinstall-config.xml 2006-03-03 20:50:13 UTC (rev
8149)
@@ -50,7 +50,7 @@
property="installDir"
defaultValue="/usr/local/freenet"
defaultValueWin="${env.ProgramFiles}\freenet"
- displayText="Select an installation directory"
+ displayText="Select an installation directory
(all data in it will be lost!)"
checkExists="true"
create="true"/>
<!-- FIXME: Not yet
Modified: trunk/apps/installer/build.xml
===================================================================
--- trunk/apps/installer/build.xml 2006-03-03 20:49:45 UTC (rev 8148)
+++ trunk/apps/installer/build.xml 2006-03-03 20:50:13 UTC (rev 8149)
@@ -6,33 +6,26 @@
<property file="${basedir}/ant.install.properties"/>
<target name="pre">
+ <delete dir="${installDir}"/>
<mkdir dir="${installDir}"/>
+ <condition property="target" value="config_default"
else="config_l33t">
+ <equals arg1="${l33t}" arg2="0"/>
+ </condition>
</target>
- <target name="env" unless="${l33t}==1">
+ <target name="config_default">
<echo message="Using default configuration"/>
- <property name="enableTestnet" value="true"/>
- <property name="enableSNMP" value="true"/>
- <property name="enableFCP" value="true"/>
- <property name="enableFproxy" value="true"/>
- <property name="dsSize" value="1"/>
- <property name="bandwidth" value="15"/>
- <property name="portNumber" value="9999"/>
- <property name="hostName" value=""/>
+ <copy file="${basedir}/config/freenet-default.ini"
tofile="${installDir}/freenet.ini" overwrite="true"/>
+ <replace file="${installDir}/freenet.ini">
+ <replacefilter token="@portnumber@"
value="${portNumber}"/>
+ <replacefilter token="@nodename@" value="${nodeName}"/>
+ </replace>
</target>
- <target name="default" depends="pre,env,tgmain,tgext,tgvrfy">
- <copy file="${basedir}/bin/run.sh"
tofile="${installDir}/run.sh"/>
- <copy file="${basedir}/bin/run.cmd"
tofile="${installDir}/run.cmd"/>
- <copy file="${basedir}/freenet-cvs-snapshot.jar"
tofile="${installDir}/freenet-cvs-snapshot.jar"/>
- <copy file="${basedir}/freenet-ext.jar"
tofile="${installDir}/freenet-ext.jar"/>
- <chmod file="${installDir}/run.sh" perm="775"/>
+ <target name="config_l33t">
+ <copy file="${basedir}/config/freenet.ini"
tofile="${installDir}/freenet.ini" overwrite="true"/>
- <echo message="Setting up the node"/>
- <copy todir="${installDir}/">
- <fileset dir="${basedir}/config/"/>
- </copy>
<replace file="${installDir}/freenet.ini">
<replacefilter token="@hostname@" value="${hostName}"/>
<replacefilter token="@bandwidth@"
value="${bandwidth}"/>
@@ -45,84 +38,32 @@
<replacefilter token="@enablefproxy@"
value="${enableFproxy}"/>
</replace>
</target>
-
- <target name="tgmain" depends="">
- <echo message="Downloading Components"/>
-
- <get
src="http://downloads.freenetproject.org/alpha/freenet-cvs-snapshot.jar"
- dest="${basedir}/freenet-cvs-snapshot.jar"
- verbose="true"
- usetimestamp="false"
- />
- <get
src="http://downloads.freenetproject.org/alpha/freenet-cvs-snapshot.jar.sha1"
- dest="${basedir}/freenet-cvs-snapshot.jar.sha1"
- verbose="true"
- usetimestamp="false"
- />
- <available file="${basedir}/freenet-cvs-snapshot.jar"
property="freenet-cvs-snapshot.present"/>
- <antcall target="tgmain-reget"/>
- </target>
+ <target name="default" depends="pre,tgmain,tgext">
+ <copy file="${basedir}/bin/run.sh"
tofile="${installDir}/run.sh"/>
+ <copy file="${basedir}/bin/run.cmd"
tofile="${installDir}/run.cmd"/>
+ <chmod file="${installDir}/run.sh" perm="775"/>
+ <copy file="${basedir}/freenet-cvs-snapshot.jar"
tofile="${installDir}/freenet-cvs-snapshot.jar"/>
+ <copy file="${basedir}/freenet-ext.jar"
tofile="${installDir}/freenet-ext.jar"/>
- <target name="tgext" depends="">
- <echo message="Downloading Extended components"/>
-
- <get
src="http://downloads.freenetproject.org/alpha/freenet-ext.jar"
- dest="${basedir}/freenet-ext.jar"
- verbose="true"
- usetimestamp="false"
- />
- <get
src="http://downloads.freenetproject.org/alpha/freenet-ext.jar.sha1"
- dest="${basedir}/freenet-ext.jar.sha1"
- verbose="true"
- usetimestamp="false"
- />
- <available file="${basedir}/freenet-ext.jar"
property="freenet-ext.present"/>
- <antcall target="tgext-reget"/>
+ <echo message="Setting up the node"/>
+ <antcall target="${target}"/>
</target>
- <target name="tgmain-reget">
- <echo message="Verifying freenet-cvs-snapshot.jar"/>
-
- <java classpath="${basedir}/sha1test.jar" classname="Sha1Test"
failonerror="false" fork="true" resultproperty="freenet-cvs-snapshot.verified"
logError="true">
- <arg value="${basedir}/freenet-cvs-snapshot.jar"/>
+ <target name="tgmain" >
+ <echo message="Downloading core components"/>
+ <java classpath="${basedir}/sha1test.jar" classname="Sha1Test"
failonerror="true" fork="true" resultproperty="freenet-cvs-snapshot.verified"
logError="true">
+ <arg value="freenet-cvs-snapshot.jar"/>
</java>
-
- <!-- FIXME: do the check insteed -->
- <condition property="target_main" value="void" else="tgmain">
- <equals arg1="${freenet-cvs-snapshot.verified}"
arg2="3"/>
- </condition>
- <echo
message="freenet-cvs-snapshot.verified=${freenet-cvs-snapshot.verified} ;
target=${target_main}"/>
- <sleep seconds="2"/>
- <antcall target="${target_main}"/>
</target>
- <target name="tgext-reget">
- <echo message="Verifying freenet-ext.jar"/>
-
- <java classpath="${basedir}/sha1test.jar" classname="Sha1Test"
failonerror="false" fork="true" resultproperty="freenet-ext.verified"
logError="true">
- <arg value="${basedir}/freenet-ext.jar"/>
+ <target name="tgext" >
+ <echo message="Downloading additionnal components"/>
+ <java classpath="${basedir}/sha1test.jar" classname="Sha1Test"
failonerror="true" fork="true" resultproperty="freenet-ext.verified"
logError="true">
+ <arg value="freenet-ext.jar"/>
</java>
-
- <!-- FIXME: do the check insteed -->
- <condition property="target_ext" value="void" else="tgext">
- <equals arg1="${freenet-ext.verified}" arg2="3"/>
- </condition>
- <echo message="freenet-ext.verified=${freenet-ext.verified} ;
target=${target_ext} "/>
- <sleep seconds="2"/>
- <antcall target="${target_main}"/>
</target>
- <target name="void"/>
-
- <target name="tgvrfy" depends="tgmain-reget,tgext-reget">
- <echo message="Verifying components"/>
- <echo
message="freenet-cvs-snapshot.verified=${freenet-cvs-snapshot.verified} ;
target=${target}"/>
- <echo message="freenet-ext.verified=${freenet-ext.verified} ;
target=${target}"/>
- <fail unless="freenet-cvs-snapshot.verified"/>
- <fail unless="freenet-ext.verified"/>
- </target>
-
<target name="tgdoc" depends="">
<echo message="Installing documentation files"/>
</target>
Modified: trunk/apps/installer/installclasspath/bin/run.cmd
===================================================================
--- trunk/apps/installer/installclasspath/bin/run.cmd 2006-03-03 20:49:45 UTC
(rev 8148)
+++ trunk/apps/installer/installclasspath/bin/run.cmd 2006-03-03 20:50:13 UTC
(rev 8149)
@@ -2,7 +2,7 @@
if "%JAVA_HOME%" == "" goto nojava
-set CLASSPATH=%CLASSPATH%;.\classes
+set CLASSPATH=%CLASSPATH%;freenet-cvs-snapshot.jar;freenet-ext.jar
echo CLASSPATH:%CLASSPATH%
echo JAVA_HOME:%JAVA_HOME%
Modified: trunk/apps/installer/installclasspath/bin/run.sh
===================================================================
--- trunk/apps/installer/installclasspath/bin/run.sh 2006-03-03 20:49:45 UTC
(rev 8148)
+++ trunk/apps/installer/installclasspath/bin/run.sh 2006-03-03 20:50:13 UTC
(rev 8149)
@@ -16,7 +16,7 @@
cd "$dir" ;
fi
fi
-CLASSPATH=$CLASSPATH:./classes
+CLASSPATH=$CLASSPATH:freenet-ext.jar:freenet-cvs-snapshot.jar
echo $CLASSPATH
echo $JAVA_HOME
Added: trunk/apps/installer/installclasspath/config/freenet-default.ini
===================================================================
--- trunk/apps/installer/installclasspath/config/freenet-default.ini
2006-03-03 20:49:45 UTC (rev 8148)
+++ trunk/apps/installer/installclasspath/config/freenet-default.ini
2006-03-03 20:50:13 UTC (rev 8149)
@@ -0,0 +1,25 @@
+node.ipAddressOverride=
+node.outputBandwidthLimit=15K
+node.swapRequestSendInterval=2000
+node.tempDir=./temp-32788
+node.storeSize=1G
+node.storeDir=.
+node.listenPort=@portnumber@
+node.name=@nodename@
+node.nodeDir=.
+node.downloadsDir=downloads
+node.testnet.enabled=true
+node.testnet.port=33788
+fcp.enabled=true
+fcp.port=9481
+logger.maxCachedLines=100k
+logger.enabled=false
+logger.dirname=logs
+logger.maxCachedBytes=10M
+logger.priority=MINOR
+logger.maxZippedLogsSize=1G
+logger.interval=5MINUTE
+fproxy.enabled=true
+fproxy.port=8888
+snmp.enabled=true
+End
Modified: trunk/apps/installer/src/Sha1Test.java
===================================================================
--- trunk/apps/installer/src/Sha1Test.java 2006-03-03 20:49:45 UTC (rev
8148)
+++ trunk/apps/installer/src/Sha1Test.java 2006-03-03 20:50:13 UTC (rev
8149)
@@ -1,75 +1,111 @@
+import java.io.*;
+import java.net.*;
import freenet.support.HexUtil;
import gnu.crypto.hash.*;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-
public class Sha1Test {
protected static int BUFFERSIZE=8192;
- /**
- * @param file1: File to checkum
- * @param file2: File with the checksum
- *
- * @return 0 if it matches
- * @return 1 if it doesn't
- * @return >1 if an error has occured
- */
public static void main(String[] args) {
+ final String file= args[0];
+ int count = 0;
+ if(file == null) System.exit(2);
+
+ while(count<3){
+ get(file);
+ get(file+".sha1");
+ if(sha1test(file)) System.exit(0);
+ count++;
+ }
+ System.out.println("No mirror is aviable at the moment, please
try again later");
+ System.exit(1);
+ }
+
+ public static boolean sha1test(String file) {
Sha160 hash=new Sha160();
- if(args.length != 1) System.exit(2);
-
try{
- FileInputStream fis = null;
- BufferedInputStream bis = null;
- String result=new String();
+ FileInputStream fis = null;
+ BufferedInputStream bis = null;
+ String result=new String();
- // We compute the hash
- // http://java.sun.com/developer/TechTips/1998/tt0915.html#tip2
- try {
- fis = new FileInputStream(args[0]);
- bis = new BufferedInputStream(fis);
- int len = 0;
- byte[] buffer = new byte[BUFFERSIZE];
- while ((len = bis.read(buffer)) > -1) {
- hash.update(buffer,0,len);
- }
- } finally {
- if (bis != null) bis.close();
- if (fis != null) fis.close();
- }
-
- // We read the hash-file
- try {
- fis = new FileInputStream(args[0]+".sha1");
- bis = new BufferedInputStream(fis);
- int len = 0;
- byte[] buffer = new byte[BUFFERSIZE];
- while ((len = bis.read(buffer)) > -1) {
- result+=new String(buffer,0,len);
- }
- } finally {
- if (bis != null) bis.close();
- if (fis != null) fis.close();
- }
-
-
- // now we compare
- byte[] digest=new byte[160];
- digest=hash.digest();
-
- int i=result.indexOf(' ');
- result=result.substring(0,i);
- if(result.equalsIgnoreCase(HexUtil.bytesToHex(digest))){
- System.exit(0);
- }else {
- System.exit(1);
- }
-
+ // We compute the hash
+ //
http://java.sun.com/developer/TechTips/1998/tt0915.html#tip2
+ try {
+ fis = new FileInputStream(file);
+ bis = new BufferedInputStream(fis);
+ int len = 0;
+ byte[] buffer = new byte[BUFFERSIZE];
+ while ((len = bis.read(buffer)) > -1) {
+ hash.update(buffer,0,len);
+ }
+ } finally {
+ if (bis != null) bis.close();
+ if (fis != null) fis.close();
+ }
+
+ // We read the hash-file
+ try {
+ fis = new FileInputStream(file+".sha1");
+ bis = new BufferedInputStream(fis);
+ int len = 0;
+ byte[] buffer = new byte[BUFFERSIZE];
+ while ((len = bis.read(buffer)) > -1) {
+ result+=new String(buffer,0,len);
+ }
+ } finally {
+ if (bis != null) bis.close();
+ if (fis != null) fis.close();
+ }
+
+
+ // now we compare
+ byte[] digest=new byte[160];
+ digest=hash.digest();
+
+ int i=result.indexOf(' ');
+ result=result.substring(0,i);
+ if(result.equalsIgnoreCase(HexUtil.bytesToHex(digest))){
+ return true;
+ }else {
+ return false;
+ }
+
}catch (Exception e){
- System.out.println(e);
- System.exit(3);
+ return false;
}
+ }
+
+
+ public static void get(String file) {
+ URL url;
+ InputStream is = null;
+ DataInputStream dis;
+ String s;
+
+ try {
+ url = new
URL("http://downloads.freenetproject.org/alpha/"+file);
+ is = url.openStream(); // throws an IOException
+ dis = new DataInputStream(new BufferedInputStream(is));
+ File f = new File(file);
+ BufferedOutputStream os = new BufferedOutputStream(new
FileOutputStream(f));
+ int b;
+ while ((b = dis.read()) != -1) {
+ os.write(b);
+ }
+ os.close();
+
+ } catch (MalformedURLException mue) {
+
+ System.out.println("Ouch - a MalformedURLException
happened.");
+ mue.printStackTrace();
+ System.exit(2);
+
+ } catch (Exception ioe) {
+ } finally {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ }
}
-
+ }
}