2004-11-25 jrandom
* Revised the installer to include start menu and desktop shortcuts for windows platforms, including pretty icons (thanks DrWoo!) * Allow clients specified in clients.config to have an explicit startup delay. * Update the default install to launch a browser pointing at the console whenever I2P starts up, rather than only the first time it starts up (configurable on /configservice.jsp, or in clients.config) * Bugfix to the clock skew checking code to monitor the delta between offsets, not the offset itself (duh) * Router console html update * New (and uuuuugly) code to verify that the wrapper.config contains the necessary classpath entries on update. If it has to update the wrapper.config, it will stop the JVM and service completely, since the java service wrapper doesn't reread the wrapper.config on JVM restart - requiring the user to manually restart the service after an update. * Increase the TCP connection timeout to 30s (which is obscenely long) ------------------------------------------------
This commit is contained in:
@ -66,9 +66,9 @@ public class Clock implements Timestamper.UpdateListener {
|
||||
|
||||
// only allow substantial modifications before the first 10 minutes
|
||||
if (_alreadyChanged && (System.currentTimeMillis() - _startedOn > 10 * 60 * 1000)) {
|
||||
if ( (offsetMs > MAX_LIVE_OFFSET) || (offsetMs < 0 - MAX_LIVE_OFFSET) ) {
|
||||
if ( (delta > MAX_LIVE_OFFSET) || (delta < 0 - MAX_LIVE_OFFSET) ) {
|
||||
getLog().log(Log.CRIT, "The clock has already been updated, but you want to change it by "
|
||||
+ offsetMs + "? Did something break?");
|
||||
+ delta + " to " + offsetMs + "? Did something break?");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
11
core/java/src/net/i2p/util/Copy.java
Normal file
11
core/java/src/net/i2p/util/Copy.java
Normal file
@ -0,0 +1,11 @@
|
||||
package net.i2p.util;
|
||||
|
||||
/**
|
||||
* Usage: Copy from to
|
||||
*
|
||||
*/
|
||||
public class Copy {
|
||||
public static void main(String args[]) {
|
||||
FileUtil.copy(args[0], args[1], true);
|
||||
}
|
||||
}
|
11
core/java/src/net/i2p/util/Delete.java
Normal file
11
core/java/src/net/i2p/util/Delete.java
Normal file
@ -0,0 +1,11 @@
|
||||
package net.i2p.util;
|
||||
|
||||
/**
|
||||
* Usage: Delete name
|
||||
*
|
||||
*/
|
||||
public class Delete {
|
||||
public static void main(String args[]) {
|
||||
FileUtil.rmdir(args[0], false);
|
||||
}
|
||||
}
|
25
core/java/src/net/i2p/util/Exec.java
Normal file
25
core/java/src/net/i2p/util/Exec.java
Normal file
@ -0,0 +1,25 @@
|
||||
package net.i2p.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Usage: Exec dir command [args ...]
|
||||
*
|
||||
*/
|
||||
public class Exec {
|
||||
public static void main(String args[]) {
|
||||
try {
|
||||
String cmd[] = new String[args.length - 1];
|
||||
System.arraycopy(args, 1, cmd, 0, cmd.length);
|
||||
Process proc = Runtime.getRuntime().exec(cmd, (String[])null, new File(args[0]));
|
||||
|
||||
// ugly hack, because it seems we'll block otherwise!
|
||||
// http://cephas.net/blog/2004/03/23/external_applications_javas_runtimeexec.html
|
||||
try { proc.exitValue(); } catch (Throwable t) { }
|
||||
Runtime.getRuntime().halt(0);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -127,10 +127,13 @@ public class FileUtil {
|
||||
|
||||
/**
|
||||
* Read in the last few lines of a (newline delimited) textfile, or null if
|
||||
* the file doesn't exist.
|
||||
* the file doesn't exist.
|
||||
*
|
||||
* @param startAtBeginning if true, read the first maxNumLines, otherwise read
|
||||
* the last maxNumLines
|
||||
*
|
||||
*/
|
||||
public static String readTextFile(String filename, int maxNumLines) {
|
||||
public static String readTextFile(String filename, int maxNumLines, boolean startAtBeginning) {
|
||||
File f = new File(filename);
|
||||
if (!f.exists()) return null;
|
||||
FileInputStream fis = null;
|
||||
@ -141,8 +144,12 @@ public class FileUtil {
|
||||
String line = null;
|
||||
while ( (line = in.readLine()) != null) {
|
||||
lines.add(line);
|
||||
while (lines.size() > maxNumLines)
|
||||
lines.remove(0);
|
||||
if (lines.size() >= maxNumLines) {
|
||||
if (startAtBeginning)
|
||||
break;
|
||||
else
|
||||
lines.remove(0);
|
||||
}
|
||||
}
|
||||
StringBuffer buf = new StringBuffer(lines.size() * 80);
|
||||
for (int i = 0; i < lines.size(); i++)
|
||||
@ -155,9 +162,53 @@ public class FileUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
testRmdir();
|
||||
/** return true if it was copied successfully */
|
||||
public static boolean copy(String source, String dest, boolean overwriteExisting) {
|
||||
File src = new File(source);
|
||||
File dst = new File(dest);
|
||||
|
||||
if (dst.exists() && dst.isDirectory())
|
||||
dst = new File(dst, src.getName());
|
||||
|
||||
if (!src.exists()) return false;
|
||||
if (dst.exists() && !overwriteExisting) return false;
|
||||
|
||||
byte buf[] = new byte[4096];
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(src);
|
||||
FileOutputStream out = new FileOutputStream(dst);
|
||||
|
||||
int read = 0;
|
||||
while ( (read = in.read(buf)) != -1)
|
||||
out.write(buf, 0, read);
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
return true;
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Usage: FileUtil (delete path | copy source dest)
|
||||
*
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
if ( (args == null) || (args.length < 2) ) {
|
||||
testRmdir();
|
||||
} else if ("delete".equals(args[0])) {
|
||||
boolean deleted = FileUtil.rmdir(args[1], false);
|
||||
if (!deleted)
|
||||
System.err.println("Error deleting [" + args[1] + "]");
|
||||
} else if ("copy".equals(args[0])) {
|
||||
boolean copied = FileUtil.copy(args[1], args[2], false);
|
||||
if (!copied)
|
||||
System.err.println("Error copying [" + args[1] + "] to [" + args[2] + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static void testRmdir() {
|
||||
File t = new File("rmdirTest/test/subdir/blah");
|
||||
boolean created = t.mkdirs();
|
||||
|
@ -349,7 +349,9 @@ public class ShellCommand {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
command.append("\"").append(args[i]).append("\" ");
|
||||
}
|
||||
cmd.execute(command.toString());
|
||||
try {
|
||||
cmd.executeSilent(command.toString());
|
||||
} catch (IOException ioe) { ioe.printStackTrace(); }
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user