diff options
| -rw-r--r-- | htroot/ConfigUpdate_p.html | 5 | ||||
| -rw-r--r-- | htroot/ConfigUpdate_p.java | 4 | ||||
| -rw-r--r-- | htroot/Steering.java | 2 | ||||
| -rw-r--r-- | htroot/yacysearchitem.java | 1 | ||||
| -rw-r--r-- | source/de/anomic/server/serverSystem.java | 41 | ||||
| -rw-r--r-- | source/de/anomic/tools/tarTools.java | 98 | ||||
| -rw-r--r-- | source/de/anomic/yacy/yacyVersion.java | 104 | ||||
| -rw-r--r-- | startYACY.bat | 3 | ||||
| -rw-r--r-- | startYACY_noconsole.bat | 2 |
9 files changed, 210 insertions, 50 deletions
diff --git a/htroot/ConfigUpdate_p.html b/htroot/ConfigUpdate_p.html index 1e1496655..3c03e5332 100644 --- a/htroot/ConfigUpdate_p.html +++ b/htroot/ConfigUpdate_p.html @@ -10,9 +10,11 @@ #%env/templates/submenuConfig.template%# <h2>System Update</h2> + #(deploys)#::Release will be installed. Please wait.#(/deploys)# + #(candeploy)# This servlet can only be used on operation systems that are currently supported for deploy functions. - If you see this message this means that your operation sytem ist not supported. + If you see this message this means that your operation system is not supported. :: <fieldset> <legend>Manual System Update</legend> @@ -100,6 +102,7 @@ <dt>Last Deploy</dt><dd><p>#(lastdeploy)#never::#[time]##(/lastdeploy)#</p></dd> </dl> </fieldset> + :: #(/candeploy)# #%env/templates/footer.template%# diff --git a/htroot/ConfigUpdate_p.java b/htroot/ConfigUpdate_p.java index e5a31f363..bcbe3d565 100644 --- a/htroot/ConfigUpdate_p.java +++ b/htroot/ConfigUpdate_p.java @@ -52,6 +52,8 @@ public class ConfigUpdate_p { if (post.containsKey("update")) { prop.put("forwardToSteering", "1"); prop.put("forwardToSteering_release",post.get("releaseinstall", "")); + prop.put("deploys", "1"); + prop.put("candeploy", "2"); // display nothing else return prop; } @@ -117,7 +119,7 @@ public class ConfigUpdate_p { } // set if this should be visible - if (serverSystem.canExecUnix) { + if (serverSystem.canExecUnix || serverSystem.isWindows) { // we can deploy a new system with (i.e.) // cd DATA/RELEASE;tar xfz $1;cp -Rf yacy/* ../../;rm -Rf yacy prop.put("candeploy", "1"); diff --git a/htroot/Steering.java b/htroot/Steering.java index b9f8f0a49..d24ab0c1b 100644 --- a/htroot/Steering.java +++ b/htroot/Steering.java @@ -86,7 +86,7 @@ public class Steering { if (post.containsKey("update")) {
boolean devenvironment = yacyVersion.combined2prettyVersion(sb.getConfig("version","0.1")).startsWith("dev");
String releaseFileName = post.get("releaseinstall", "");
- File releaseFile = new File(sb.getRootPath(), "DATA/RELEASE/" + releaseFileName);
+ File releaseFile = new File(sb.getRootPath(), "DATA/RELEASE/".replace("/", File.separator) + releaseFileName);
if ((!devenvironment) && (releaseFile.length() > 0) && (releaseFile.exists())) {
yacyVersion.deployRelease(releaseFile);
}
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index 17acb16e7..def2ab8e1 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -224,7 +224,6 @@ public class yacysearchitem { ((yacyURL.probablyRootURL(result.hash())) ? ", probablyRootURL" : "") + (((wordURL = yacyURL.probablyWordURL(result.hash(), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : "")); plasmaSnippetCache.TextSnippet snippet = result.textSnippet(); - // TODO: check if tags are correctly stripped from snippet prop.put("content_snippet", (snippet == null) ? "(snippet not found)" : snippet.getLineMarked(theQuery.queryHashes)); serverProfiling.update("SEARCH", new plasmaProfiling.searchEvent(theQuery.id(true), plasmaSearchEvent.FINALIZATION + "-" + item, 0, 0)); diff --git a/source/de/anomic/server/serverSystem.java b/source/de/anomic/server/serverSystem.java index 02658a33d..60024b1e2 100644 --- a/source/de/anomic/server/serverSystem.java +++ b/source/de/anomic/server/serverSystem.java @@ -69,6 +69,7 @@ public final class serverSystem { public static boolean isMacArchitecture = false;
public static boolean isUnixFS = false;
public static boolean canExecUnix = false;
+ public static boolean isWindows = false;
// calculated system constants
public static int maxPathLength = 65535;
@@ -99,7 +100,8 @@ public final class serverSystem { isMacArchitecture = ((systemOS == systemMacOSC) || (systemOS == systemMacOSX));
isUnixFS = ((systemOS == systemMacOSX) || (systemOS == systemUnix));
- canExecUnix = ((isUnixFS) || (!((systemOS == systemMacOSC) || (systemOS == systemWindows))));
+ canExecUnix = ((isUnixFS) || (!((systemOS == systemMacOSC) || (systemOS == systemWindows))));
+ isWindows = (systemOS == systemWindows);
// set up the MRJ Methods through reflection
if (isMacArchitecture) try {
@@ -121,13 +123,13 @@ public final class serverSystem { macMRJFileUtils = null; macMRJOSType = null;
}
- // set up maximum path length accoring to system
- if (systemOS == systemWindows) maxPathLength = 255; else maxPathLength = 65535;
+ // set up maximum path length according to system
+ if (isWindows) maxPathLength = 255; else maxPathLength = 65535;
}
- public static boolean isWindows() {
+/* public static boolean isWindows() {
return systemOS == systemWindows;
- }
+ }*/
public static Object getMacOSTS(String s) {
if ((isMacArchitecture) && (macMRJFileUtils != null)) try {
@@ -330,19 +332,30 @@ public final class serverSystem { public static void deployScript(File scriptFile, String theScript) throws IOException {
serverFileUtils.copy(theScript.getBytes(), scriptFile);
- try {
- Runtime.getRuntime().exec("chmod 755 " + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();
- } catch (InterruptedException e) {
- serverLog.logSevere("DEPLOY", "deploy of script file failed. file = " + scriptFile.getAbsolutePath(), e);
- throw new IOException(e.getMessage());
+ if(!isWindows){ // set executable
+ try {
+ Runtime.getRuntime().exec("chmod 755 " + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();
+ } catch (InterruptedException e) {
+ serverLog.logSevere("DEPLOY", "deploy of script file failed. file = " + scriptFile.getAbsolutePath(), e);
+ throw new IOException(e.getMessage());
+ }
}
}
public static void execAsynchronous(File scriptFile) throws IOException {
- // runs a unix/linux script as separate thread
- File starterFile = new File(scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + ".starter.sh");
- //deployScript(starterFile, "touch restart.starter.startet1");
- deployScript(starterFile, "#!/bin/sh" + serverCore.LF_STRING + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + " &" + serverCore.LF_STRING);
+ // runs a script as separate thread
+ String starterFileExtension = null;
+ String script = null;
+ if(isWindows){
+ starterFileExtension = ".starter.bat";
+ // TODO: use /K to debug
+ script = "start /MIN CMD /C " + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ");
+ } else { // unix/linux
+ starterFileExtension = ".starter.sh";
+ script = "#!/bin/sh" + serverCore.LF_STRING + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + " &" + serverCore.LF_STRING;
+ }
+ File starterFile = new File(scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + starterFileExtension);
+ deployScript(starterFile, script);
try {
Runtime.getRuntime().exec(starterFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();
} catch (InterruptedException e) {
diff --git a/source/de/anomic/tools/tarTools.java b/source/de/anomic/tools/tarTools.java new file mode 100644 index 000000000..ff98fc1f3 --- /dev/null +++ b/source/de/anomic/tools/tarTools.java @@ -0,0 +1,98 @@ +// tarTools.java
+// (C) 2007 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany
+// contributed by David Wieditz; d.wieditz@gmx.de
+// first published 21.05.2008 on http://yacy.net
+//
+// This is a part of YaCy, a peer-to-peer based web search engine
+//
+// $LastChangedDate: $
+// $LastChangedRevision: $
+// $LastChangedBy: $
+//
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package de.anomic.tools;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+
+import com.ice.tar.TarEntry;
+import com.ice.tar.TarInputStream;
+
+import de.anomic.server.logging.serverLog;
+
+public class tarTools {
+
+ public static InputStream getInputStream(String tarFileName) throws Exception{
+ if(tarFileName.endsWith(".gz")){
+ return new GZIPInputStream(new FileInputStream(new File(tarFileName)));
+ } else {
+ return new FileInputStream(new File(tarFileName));
+ }
+ }
+
+ public static InputStream getInputStream(File tarFileName) throws Exception{
+ return getInputStream(tarFileName.toString());
+ }
+
+ /**
+ * untar for any archive, overwrites existing data
+ * @param in use getInputStream() for convenience
+ * @param untarDir destination path
+ * @throws Exception (IOException or FileNotFoundException)
+ */
+ public static void unTar(InputStream in, String untarDir) throws Exception{
+ serverLog.logInfo("UNTAR", "starting");
+ if(new File(untarDir).exists()){
+ TarInputStream tin = new TarInputStream(in);
+ TarEntry tarEntry = tin.getNextEntry();
+ while(tarEntry != null){
+ File destPath = new File(untarDir + File.separator + tarEntry.getName());
+ if (!tarEntry.isDirectory()) {
+ new File(destPath.getParent()).mkdirs(); // create missing subdirectories
+ FileOutputStream fout = new FileOutputStream(destPath);
+ tin.copyEntryContents(fout);
+ fout.close();
+ } else {
+ destPath.mkdir();
+ }
+ tarEntry = tin.getNextEntry();
+ }
+ tin.close();
+ } else { // untarDir doesn't exist
+ serverLog.logWarning("UNTAR", "destination " + untarDir + " doesn't exist.");
+ }
+ serverLog.logInfo("UNTAR", "finished");
+ }
+
+ public static void main(String args[]){
+ // @arg0 source
+ // @arg1 destination
+ if(args.length == 2){
+ try {
+ unTar(getInputStream(args[0]), args[1]);
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ } else {
+ System.out.println("usage: <source> <destination>");
+ }
+ }
+}
\ No newline at end of file diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.java index b2d48f77f..109a48577 100644 --- a/source/de/anomic/yacy/yacyVersion.java +++ b/source/de/anomic/yacy/yacyVersion.java @@ -50,6 +50,7 @@ import de.anomic.server.serverCore; import de.anomic.server.serverFileUtils;
import de.anomic.server.serverSystem;
import de.anomic.server.logging.serverLog;
+import de.anomic.tools.tarTools;
public final class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVersion> {
@@ -370,7 +371,7 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya public static void restart() {
plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
- if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
+ if (serverSystem.isWindows) {
// create yacy.restart file which is used in Windows startscript
final File yacyRestart = new File(sb.getRootPath(), "DATA/yacy.restart");
if (!yacyRestart.exists()) {
@@ -414,35 +415,78 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
String apphome = sb.getRootPath().toString();
serverLog.logInfo("UPDATE", "INITIATED");
- String script =
- "#!/bin/sh" + serverCore.LF_STRING +
- "cd " + sb.getRootPath() + "/DATA/RELEASE/" + serverCore.LF_STRING +
- ((releaseFile.getName().endsWith(".gz")) ?
- // test gz-file for integrity and tar xfz then
- ("if gunzip -t " + releaseFile.getAbsolutePath() + serverCore.LF_STRING +
- "then" + serverCore.LF_STRING +
- "gunzip -c " + releaseFile.getAbsolutePath() + " | tar xf -" + serverCore.LF_STRING) :
- // just tar xf the file, no integrity test possible?
- ("tar xf " + releaseFile.getAbsolutePath() + serverCore.LF_STRING)
- ) +
- "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +
- "sleep 1" + serverCore.LF_STRING +
- "done" + serverCore.LF_STRING +
- "cp -Rf yacy/* " + apphome + serverCore.LF_STRING +
- "rm -Rf yacy" + serverCore.LF_STRING +
- ((releaseFile.getName().endsWith(".gz")) ?
- // else-case of gunzip -t test: if failed, just restart
- ("else" + serverCore.LF_STRING +
- "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +
- "sleep 1" + serverCore.LF_STRING +
- "done" + serverCore.LF_STRING +
- "fi" + serverCore.LF_STRING) :
- // in case that we did not made the integrity test, there is no else case
- ""
- ) +
- "cd " + apphome + serverCore.LF_STRING +
- "nohup ./startYACY.sh > /dev/null" + serverCore.LF_STRING;
- File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/update.sh");
+ try{
+ tarTools.unTar(tarTools.getInputStream(releaseFile), sb.getRootPath() + "/DATA/RELEASE/".replace("/", File.separator));
+ } catch (Exception e){
+ serverLog.logSevere("UNTAR", "failed", e);
+ }
+ String script = null;
+ String scriptFileName = null;
+ if(serverSystem.isWindows){
+ script =
+ // TODO: does YaCy delete this file after 2nd update-shutdown? "Die Batchdatei kann nicht gefunden werden."
+ "@echo off" + serverCore.LF_STRING +
+ "title YaCy updater" + serverCore.LF_STRING +
+ "echo YACY UPDATER" + serverCore.LF_STRING +
+ "echo working..." + serverCore.LF_STRING +
+ "cd " + apphome + "/DATA/RELEASE/".replace("/", File.separator) + serverCore.LF_STRING +
+
+ ":WAIT" + serverCore.LF_STRING +
+ "ping -n 2 127.0.0.1 >nul" + serverCore.LF_STRING +
+ "IF exist ..\\yacy.running goto WAIT" + serverCore.LF_STRING +
+
+ "IF not exist yacy goto NODATA" + serverCore.LF_STRING +
+
+ "cd yacy" + serverCore.LF_STRING +
+ "xcopy *.* " + apphome + " /E /Y >nul" + serverCore.LF_STRING +
+ // /E - all subdirectories
+ // /Y - don't ask
+ "cd .." + serverCore.LF_STRING +
+ "rd yacy /S /Q" + serverCore.LF_STRING +
+ // /S delete tree
+ // /Q don't ask
+ "goto END" + serverCore.LF_STRING +
+
+ ":NODATA" + serverCore.LF_STRING +
+ "echo YACY UPDATER ERROR: NO UPDATE SOURCE FILES ON FILESYSTEM" + serverCore.LF_STRING +
+ "pause" + serverCore.LF_STRING +
+
+ ":END" + serverCore.LF_STRING +
+ "cd " + apphome + serverCore.LF_STRING +
+ "start /MIN CMD /C startYACY.bat" + serverCore.LF_STRING;
+ scriptFileName = "update.bat";
+ } else { // unix/linux
+ script =
+ "#!/bin/sh" + serverCore.LF_STRING +
+ "cd " + sb.getRootPath() + "/DATA/RELEASE/" + serverCore.LF_STRING +
+ /* ((releaseFile.getName().endsWith(".gz")) ?
+ // test gz-file for integrity and tar xfz then
+ ("if gunzip -t " + releaseFile.getAbsolutePath() + serverCore.LF_STRING +
+ "then" + serverCore.LF_STRING +
+ "gunzip -c " + releaseFile.getAbsolutePath() + " | tar xf -" + serverCore.LF_STRING) :
+ // just tar xf the file, no integrity test possible?
+ ("tar xf " + releaseFile.getAbsolutePath() + serverCore.LF_STRING)
+ ) +*/
+ "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +
+ "sleep 1" + serverCore.LF_STRING +
+ "done" + serverCore.LF_STRING +
+ "cp -Rf yacy/* " + apphome + serverCore.LF_STRING +
+ "rm -Rf yacy" + serverCore.LF_STRING +
+ /* ((releaseFile.getName().endsWith(".gz")) ?
+ // else-case of gunzip -t test: if failed, just restart
+ ("else" + serverCore.LF_STRING +
+ "while [ -f ../yacy.running ]; do" + serverCore.LF_STRING +
+ "sleep 1" + serverCore.LF_STRING +
+ "done" + serverCore.LF_STRING +
+ "fi" + serverCore.LF_STRING) :
+ // in case that we did not made the integrity test, there is no else case
+ ""
+ ) +*/
+ "cd " + apphome + serverCore.LF_STRING +
+ "nohup ./startYACY.sh > /dev/null" + serverCore.LF_STRING;
+ scriptFileName = "update.sh";
+ }
+ File scriptFile = new File(sb.getRootPath(), "DATA/RELEASE/".replace("/", File.separator) + scriptFileName);
serverSystem.deployScript(scriptFile, script);
serverLog.logInfo("UPDATE", "wrote update-script to " + scriptFile.getAbsolutePath());
serverSystem.execAsynchronous(scriptFile);
diff --git a/startYACY.bat b/startYACY.bat index df5c5c434..5cb36836b 100644 --- a/startYACY.bat +++ b/startYACY.bat @@ -11,7 +11,7 @@ For %%X in (libx/*.jar) Do Call %0 CPGEN libx\%%X REM Please change the "javastart" settings in the web-interface "Basic Configuration" -> "Advanced"
set jmx=
set jms=
-set javacmd=-Xmx64m -Xms10m
+set javacmd=-Xmx120m -Xms120m
set priolvl=0
set priority=/NORMAL
if exist DATA\SETTINGS\httpProxy.conf GoTo :RENAMEINDEX
@@ -36,6 +36,7 @@ start "YaCy" %priority% /B /WAIT java %javacmd% -classpath %CLASSPATH% yacy if not exist DATA\yacy.restart GoTo :END
del DATA\yacy.restart
+GoTo :GETSTARTOPTS
Rem PUBLIC is now freeworld (r4575)
:RENAMEINDEX
diff --git a/startYACY_noconsole.bat b/startYACY_noconsole.bat index ae78ca43b..af63bfcc1 100644 --- a/startYACY_noconsole.bat +++ b/startYACY_noconsole.bat @@ -11,7 +11,7 @@ For %%X in (libx/*.jar) Do Call %0 CPGEN libx\%%X REM Please change the "javastart" settings in the web-interface "Basic Configuration" -> "Advanced"
set jmx=
set jms=
-set javacmd=-Xmx94m -Xms94m
+set javacmd=-Xmx120m -Xms120m
set priolvl=0
set priority=/NORMAL
if exist DATA\SETTINGS\httpProxy.conf GoTo :RENAMEINDEX
|
