diff --git a/htroot/Status.html b/htroot/Status.html index a4ac1d985..74afeceff 100644 --- a/htroot/Status.html +++ b/htroot/Status.html @@ -68,6 +68,7 @@ #(/hintVersionAvailable)# + + #(hintStatusSenior)#::
good
You are running a server in senior mode and you support the global internet index, @@ -146,6 +148,36 @@ +
+
+ System Update +
+
Available Releases
+
  +   
+
+
Downloaded Releases
+
  +
+
+
+
+
Public System Properties
diff --git a/htroot/Status.java b/htroot/Status.java index 030a69dc3..9a537a15b 100644 --- a/htroot/Status.java +++ b/htroot/Status.java @@ -46,13 +46,17 @@ // javac -classpath .:../Classes Status.java // if the shell's current path is HTROOT +import java.io.IOException; import java.text.DecimalFormat; import java.util.Date; +import java.util.Iterator; +import java.util.TreeSet; import de.anomic.http.httpHeader; import de.anomic.http.httpd; import de.anomic.http.httpdByteCountInputStream; import de.anomic.http.httpdByteCountOutputStream; +import de.anomic.net.URL; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverCore; import de.anomic.server.serverDate; @@ -61,6 +65,7 @@ import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacySeed; +import de.anomic.yacy.yacyVersion; public class Status { @@ -72,16 +77,16 @@ public class Status { final serverObjects prop = new serverObjects(); final plasmaSwitchboard sb = (plasmaSwitchboard) env; - if ((post != null) && (post.containsKey("login"))) { + if (post != null) { if (sb.adminAuthenticated(header) < 2) { prop.put("AUTHENTICATE","admin log-in"); - } else { - prop.put("LOCATION",""); + return prop; } - return prop; - } else if (post != null) { - boolean redirect = false; - if (post.containsKey("pauseCrawlJob")) { + boolean redirect = false; + if (post.containsKey("login")) { + prop.put("LOCATION",""); + return prop; + } else if (post.containsKey("pauseCrawlJob")) { String jobType = (String) post.get("jobType"); if (jobType.equals("localCrawl")) sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL); @@ -111,7 +116,18 @@ public class Status { sb.setConfig("browserPopUpTrigger", "true"); } redirect = true; - } + } else if (post.containsKey("downloadRelease")) { + // download a release + String release = post.get("releasedownload", ""); + if (release.length() > 0) { + try { + yacyVersion.downloadRelease(new yacyVersion(new URL(release))); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } if (redirect) { prop.put("LOCATION",""); @@ -140,24 +156,64 @@ public class Status { } // if running on Windows or with updater/wrapper enable restart button - if ((sb.updaterCallback != null) || (System.getProperty("os.name").toLowerCase().startsWith("win"))) { + if (System.getProperty("os.name").toLowerCase().startsWith("win")) { prop.put("restartEnabled", 1); } // version information prop.put("versionpp", yacy.combined2prettyVersion(sb.getConfig("version","0.1"))); - - + double thisVersion = Double.parseDouble(sb.getConfig("version","0.1")); // cut off the SVN Rev in the Version try {thisVersion = Math.round(thisVersion*1000.0)/1000.0;} catch (NumberFormatException e) {} + + // list downloaded releases + yacyVersion release, dflt; + String[] downloaded = sb.releasePath.list(); + TreeSet downloadedreleases = new TreeSet(); + for (int j = 0; j < downloaded.length; j++) { + release = (yacyVersion) new yacyVersion(downloaded[j]); + downloadedreleases.add(release); + } + dflt = (downloadedreleases.size() == 0) ? null : (yacyVersion) downloadedreleases.last(); + Iterator i = downloadedreleases.iterator(); + int relcount = 0; + while (i.hasNext()) { + release = (yacyVersion) i.next(); + prop.put("downloadedreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); + prop.put("downloadedreleases_" + relcount + "_file", release.name); + prop.put("downloadedreleases_" + relcount + "_selected", (release == dflt) ? 1 : 0); + relcount++; + } + prop.put("downloadedreleases", relcount); - if ((adminaccess) && (sb.updaterCallback != null) && (sb.updaterCallback.updateYaCyIsPossible())){ - prop.put("hintVersionAvailable", 1); - prop.put("hintVersionAvailable_latestVersion", sb.updaterCallback.getYaCyUpdateReleaseVersion()); - if ((post != null) && (post.containsKey("aquirerelease"))) { - sb.updaterCallback.grantYaCyUpdate(); - } + // list remotely available releases + TreeSet[] releasess = yacyVersion.allReleases(); // {0=promain, 1=prodev, 2=stdmain, 3=stddev} + relcount = 0; + // main + TreeSet releases = releasess[(yacy.pro) ? 0 : 2]; + releases.removeAll(downloadedreleases); + i = releases.iterator(); + while (i.hasNext()) { + release = (yacyVersion) i.next(); + prop.put("availreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); + prop.put("availreleases_" + relcount + "_url", release.url.toString()); + prop.put("availreleases_" + relcount + "_selected", 0); + relcount++; } + // dev + dflt = (releasess[(yacy.pro) ? 1 : 3].size() == 0) ? null : (yacyVersion) releasess[(yacy.pro) ? 1 : 3].last(); + releases = releasess[(yacy.pro) ? 1 : 3]; + releases.removeAll(downloadedreleases); + i = releases.iterator(); + while (i.hasNext()) { + release = (yacyVersion) i.next(); + prop.put("availreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); + prop.put("availreleases_" + relcount + "_url", release.url.toString()); + prop.put("availreleases_" + relcount + "_selected", (release == dflt) ? 1 : 0); + relcount++; + } + prop.put("availreleases", relcount); + /* if ((adminaccess) && (yacyVersion.latestRelease >= (thisVersion+0.01))) { // only new Versions(not new SVN) @@ -171,11 +227,12 @@ public class Status { prop.put("hintVersionAvailable", 1); } } + prop.put("hintVersionAvailable", 1); // for testing + prop.putASIS("hintVersionDownload_versionResMain", (yacyVersion.latestMainRelease == null) ? "-" : yacyVersion.latestMainRelease.toAnchor()); prop.putASIS("hintVersionDownload_versionResDev", (yacyVersion.latestDevRelease == null) ? "-" : yacyVersion.latestDevRelease.toAnchor()); prop.put("hintVersionAvailable_latestVersion", Double.toString(yacyVersion.latestRelease)); - */ - + */ // place some more hints if ((adminaccess) && (sb.getThread(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL).getJobCount() == 0) && (sb.getThread(plasmaSwitchboard.INDEXER).getJobCount() == 0)) { prop.put("hintCrawlStart", 1); diff --git a/htroot/Steering.java b/htroot/Steering.java index 4d6b724de..a577f19dd 100644 --- a/htroot/Steering.java +++ b/htroot/Steering.java @@ -73,14 +73,13 @@ public class Steering { } if (post.containsKey("shutdown")) { - if (sb.updaterCallback != null) { sb.setConfig("Updater.restartSignal", 0); } sb.terminate(3000); prop.put("info", 3); return prop; } if (post.containsKey("restart")) { - if ((sb.updaterCallback == null) && (System.getProperty("os.name").toLowerCase().startsWith("win"))) { + if (System.getProperty("os.name").toLowerCase().startsWith("win")) { // create yacy.restart file which is used in Windows startscript final File yacyRestart = new File(sb.getRootPath(), "DATA/yacy.restart"); if (!yacyRestart.exists()) { @@ -92,12 +91,6 @@ public class Steering { } } } - - if (sb.updaterCallback != null) { - sb.setConfig("Updater.shutdownSignal", 1); - } else { - serverLog.logWarning("SHUTDOWN", "No wrapper/updater running! Performing a normal shutdown..."); - } sb.terminate(5000); prop.put("info", 4); diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.java index a1558d3ea..3371ca407 100644 --- a/htroot/yacy/transfer.java +++ b/htroot/yacy/transfer.java @@ -79,12 +79,10 @@ public final class transfer { prop.putASIS("process_path", ""); prop.putASIS("process_maxsize", "0"); - if (sb.isRobinsonMode()) { + if (sb.isRobinsonMode() || !sb.rankingOn) { // in a robinson environment, do not answer. We do not do any transfer in a robinson cluster. return prop; } - - if (!sb.rankingOn) { return prop; } yacySeed otherseed = yacyCore.seedDB.get(otherpeer); if ((otherseed == null) || (filename.indexOf("..") >= 0)) { diff --git a/lib/YaCyUpdater_r4.jar b/lib/YaCyUpdater_r4.jar deleted file mode 100644 index 4fd1219fd..000000000 Binary files a/lib/YaCyUpdater_r4.jar and /dev/null differ diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java index f77f23641..4da88f6b3 100644 --- a/source/de/anomic/http/httpdFileHandler.java +++ b/source/de/anomic/http/httpdFileHandler.java @@ -717,7 +717,6 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http targetDate, null, tp.getOutgoingHeader(), null, "chunked", nocache); // send the content in chunked parts, see RFC 2616 section 3.6.1 - //byte[] result = o.toByteArray(); // this interrupts streaming (bad idea!) httpChunkedOutputStream chos = new httpChunkedOutputStream(out); httpSSI.writeSSI(targetFile, o, chos); //chos.write(result); diff --git a/source/de/anomic/net/URL.java b/source/de/anomic/net/URL.java index 0cdac47c9..d71309b5d 100644 --- a/source/de/anomic/net/URL.java +++ b/source/de/anomic/net/URL.java @@ -75,7 +75,7 @@ public class URL { } path = resolveBackpath(path); - identPort(url); + identPort(url, (protocol.equals("http") ? 80 : ((protocol.equals("https")) ? 443 : ((protocol.equals("ftp")) ? 21 : -1)))); identRef(); identQuest(); escape(); @@ -370,11 +370,11 @@ public class URL { return sbuf.toString(); } - private void identPort(String inputURL) throws MalformedURLException { + private void identPort(String inputURL, int dflt) throws MalformedURLException { // identify ref in file int r = this.host.indexOf(':'); if (r < 0) { - this.port = -1; + this.port = dflt; } else { try { String portStr = this.host.substring(r + 1); diff --git a/source/de/anomic/plasma/plasmaRankingDistribution.java b/source/de/anomic/plasma/plasmaRankingDistribution.java index 085a675e8..808958f6e 100644 --- a/source/de/anomic/plasma/plasmaRankingDistribution.java +++ b/source/de/anomic/plasma/plasmaRankingDistribution.java @@ -88,14 +88,6 @@ public final class plasmaRankingDistribution { while (st.hasMoreTokens()) {this.address[c++] = st.nextToken();} } - public plasmaRankingDistribution(serverLog log, File sourcePath, int method, int percentage, String address[]) { - this.log = log; - this.sourcePath = sourcePath; - this.method = method; - this.percentage = percentage; - this.address = address; - } - public void setMethod(int method, int percentage, String address[]) { this.method = method; this.percentage = percentage; diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 40a789ac7..7a1953c82 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -161,9 +161,9 @@ import de.anomic.server.serverObjects; import de.anomic.server.serverSemaphore; import de.anomic.server.serverSwitch; import de.anomic.server.serverThread; -import de.anomic.server.serverUpdaterCallback; import de.anomic.server.logging.serverLog; import de.anomic.tools.crypt; +import de.anomic.yacy.yacyVersion; import de.anomic.yacy.yacyClient; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacyNewsPool; @@ -210,6 +210,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser public File htDocsPath; public File rankingPath; public File workPath; + public File releasePath; public HashMap rankingPermissions; public plasmaCrawlNURL noticeURL; public plasmaCrawlZURL errorURL, delegatedURL; @@ -278,11 +279,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser private serverSemaphore shutdownSync = new serverSemaphore(0); private boolean terminate = false; - /** - * Reference to the Updater callback class - */ - public serverUpdaterCallback updaterCallback = null; - //private Object crawlingPausedSync = new Object(); //private boolean crawlingIsPaused = false; @@ -735,6 +731,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser */ public static final String HTCACHE_PATH = "proxyCache"; public static final String HTCACHE_PATH_DEFAULT = "DATA/HTCACHE"; + public static final String RELEASE_PATH = "releases"; + public static final String RELEASE_PATH_DEFAULT = "DATA/RELEASE"; /** *

public static final String HTDOCS_PATH = "htDocsPath"

*

Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all @@ -934,6 +932,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser } } + // set auto-updater locations + yacyVersion.latestDevReleaseLocation = getConfig("network.unit.update.location.dev", ""); + yacyVersion.latestMainReleaseLocation = getConfig("network.unit.update.location.main", ""); + // load values from configs this.plasmaPath = new File(rootPath, getConfig(DBPATH, DBPATH_DEFAULT)); this.log.logConfig("Plasma DB Path: " + this.plasmaPath.toString()); @@ -1079,6 +1081,18 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser boolean cacheMigration = getConfigBool(PROXY_CACHE_MIGRATION, true); this.cacheManager = new plasmaHTCache(htCachePath, maxCacheSize, ramHTTP_time, cacheLayout, cacheMigration); + // create the release download directory + String release = getConfig(RELEASE_PATH, RELEASE_PATH_DEFAULT); + release = release.replace('\\', '/'); + if (release.endsWith("/")) { release = release.substring(0, release.length() - 1); } + if (new File(release).isAbsolute()) { + releasePath = new File(release); // don't use rootPath + } else { + releasePath = new File(rootPath, release); + } + releasePath.mkdirs(); + this.log.logInfo("RELEASE Path = " + releasePath.getAbsolutePath()); + // starting message board initMessages(ramMessage_time); @@ -1225,7 +1239,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser CRDist1Percent = 30 CRDist1Target = kaskelix.de:8080,yacy.dyndns.org:8000,suma-lab.de:8080 **/ - rankingOn = getConfig(RANKING_DIST_ON, "true").equals("true"); + rankingOn = getConfig(RANKING_DIST_ON, "true").equals("true") && getConfig("network.unit.name", "").equals("freeworld"); rankingOwnDistribution = new plasmaRankingDistribution(log, new File(rankingPath, getConfig(RANKING_DIST_0_PATH, plasmaRankingDistribution.CR_OWN)), (int) getConfigLong(RANKING_DIST_0_METHOD, plasmaRankingDistribution.METHOD_ANYSENIOR), (int) getConfigLong(RANKING_DIST_0_METHOD, 0), getConfig(RANKING_DIST_0_TARGET, "")); rankingOtherDistribution = new plasmaRankingDistribution(log, new File(rankingPath, getConfig(RANKING_DIST_1_PATH, plasmaRankingDistribution.CR_OTHER)), (int) getConfigLong(RANKING_DIST_1_METHOD, plasmaRankingDistribution.METHOD_MIXEDSENIOR), (int) getConfigLong(RANKING_DIST_1_METHOD, 30), getConfig(RANKING_DIST_1_TARGET, "kaskelix.de:8080,yacy.dyndns.org:8000,suma-lab.de:8080")); @@ -1757,14 +1771,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser errorURL.close(); wordIndex.close(); yc.close(); - // signal shutdown to the updater - if (updaterCallback != null) { - if (sb.getConfigLong("Updater.shutdownSignal", -1) == 0) - updaterCallback.signalYaCyShutdown(); - else if - (sb.getConfigLong("Updater.shutdownSignal", -1) == 1) - updaterCallback.signalYaCyRestart(); - } log.logConfig("SWITCHBOARD SHUTDOWN TERMINATED"); } @@ -1916,9 +1922,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser int count = rankingOwnDistribution.size() / 100; if (count == 0) count = 1; if (count > 5) count = 5; - rankingOwnDistribution.transferRanking(count); - rankingOtherDistribution.transferRanking(1); - + if (rankingOn) { + rankingOwnDistribution.transferRanking(count); + rankingOtherDistribution.transferRanking(1); + } + // clean up delegated stack checkInterruption(); if ((delegatedURL.stackSize() > 1000)) { diff --git a/source/de/anomic/server/serverUpdaterCallback.java b/source/de/anomic/server/serverUpdaterCallback.java deleted file mode 100644 index 3cbcd97e1..000000000 --- a/source/de/anomic/server/serverUpdaterCallback.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.anomic.server; - -public interface serverUpdaterCallback { - public boolean updateYaCyIsPossible(); - public void grantYaCyUpdate(); - public String getYaCyUpdateReleaseVersion(); - //public File getYaCyUpdateReleaseFile(); - public String getYaCyUpdateSource(); - /** Signal a user initiated YaCy shutdown (not restart!) to the updater so it can terminate itself */ - public void signalYaCyShutdown(); - public void signalYaCyRestart(); -} \ No newline at end of file diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.java index 137a65bf3..64f0b1124 100644 --- a/source/de/anomic/yacy/yacyVersion.java +++ b/source/de/anomic/yacy/yacyVersion.java @@ -27,6 +27,7 @@ package de.anomic.yacy; +import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.util.Comparator; @@ -35,7 +36,10 @@ import java.util.Map; import java.util.TreeSet; import de.anomic.htmlFilter.htmlFilterContentScraper; +import de.anomic.http.httpc; import de.anomic.net.URL; +import de.anomic.plasma.plasmaSwitchboard; +import de.anomic.server.serverFileUtils; public final class yacyVersion implements Comparator, Comparable { @@ -50,16 +54,20 @@ public final class yacyVersion implements Comparator, Comparable { public static double latestRelease = 0.1; // this value is overwritten when a peer with later version appears // information about latest release, retrieved from download pages - public static yacyVersion latestDevRelease = null; - public static yacyVersion latestMainRelease = null; - + // this static information should be overwritten by network-specific locations + // for details see yacy.network.unit + private static TreeSet[] allDevReleases = null; + private static TreeSet[] allMainReleases = null; + public static String latestDevReleaseLocation = ""; // will be initialized with value in yacy.network.unit + public static String latestMainReleaseLocation = ""; // will be initialized with value in yacy.network.unit // class variables public float releaseNr; public String dateStamp; public int svn; - public boolean mainRelease; + public boolean proRelease, mainRelease; public URL url; + public String name; public yacyVersion(URL url) { this(url.getFileName()); @@ -73,16 +81,17 @@ public final class yacyVersion implements Comparator, Comparable { // yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz // i.e. yacy_v0.51_20070321_3501.tar.gz this.url = null; + this.name = release; if ((release == null) || (!release.endsWith(".tar.gz"))) { throw new RuntimeException("release file name '" + release + "' is not valid, no tar.gz"); } // cut off tail release = release.substring(0, release.length() - 7); - if (release.startsWith("yacy_dev_v")) { - mainRelease = false; + if (release.startsWith("yacy_pro_v")) { + proRelease = true; release = release.substring(10); } else if (release.startsWith("yacy_v")) { - mainRelease = true; + proRelease = false; release = release.substring(6); } else { throw new RuntimeException("release file name '" + release + "' is not valid, wrong prefix"); @@ -98,6 +107,8 @@ public final class yacyVersion implements Comparator, Comparable { } catch (NumberFormatException e) { throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[0] + "' should be a float number"); } + this.mainRelease = ((int) (this.releaseNr * (float) 1000)) % 10 == 0; + //System.out.println("Release version " + this.releaseNr + " is " + ((this.mainRelease) ? "main" : "std")); this.dateStamp = comp[1]; if (this.dateStamp.length() != 8) { throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[1] + "' should be a 8-digit date string"); @@ -110,16 +121,6 @@ public final class yacyVersion implements Comparator, Comparable { // finished! we parsed a relase string } - /* - public yacyVersion(URL url, float releaseNr, String dateStamp, int svn, boolean mainRelease) { - this.url = url; - this.releaseNr = releaseNr; - this.dateStamp = dateStamp; - this.svn = svn; - this.mainRelease = mainRelease; - } - */ - public int compareTo(Object obj) { yacyVersion v = (yacyVersion) obj; return compare(this, v); @@ -144,35 +145,67 @@ public final class yacyVersion implements Comparator, Comparable { public String toAnchor() { // generates an anchor string that can be used to embed in an html for direct download - return "YaCy " + ((this.mainRelease) ? "main release" : "developer release") + " v" + this.releaseNr + ", SVN " + this.svn + ""; + return "YaCy " + ((this.proRelease) ? "pro release" : "standard release") + " v" + this.releaseNr + ", SVN " + this.svn + ""; + } + /* + public static yacyVersion latestStandardRelease() { + // get the latest release info from a internet resource + yacyVersion devrel = (yacyVersion) allDevReleases().last(); + yacyVersion mainrel = (yacyVersion) allDevReleases().last(); } - public static void aquireLatestReleaseInfo() { - if ((latestDevRelease == null) && (latestMainRelease == null)) { - if (latestDevRelease == null) latestDevRelease = aquireLatestDevRelease(); - if (latestMainRelease == null) latestMainRelease = aquireLatestMainRelease(); + public static yacyVersion latestProRelease() { + // get the latest release info from a internet resource + return (yacyVersion) allMainReleases().last(); + } + */ + public static TreeSet[] allReleases() { + // join the release infos + // {promainreleases, prodevreleases, stdmainreleases, stddevreleases} + TreeSet[] a = allMainReleases(); + TreeSet[] b = allDevReleases(); + TreeSet[] r = new TreeSet[4]; + TreeSet s; + for (int i = 0; i < 4; i++) { + s = new TreeSet(); + if (b[i] != null) s.addAll((TreeSet) b[i]); + if (a[i] != null) s.addAll((TreeSet) a[i]); + r[i] = s; } + return r; } - public static yacyVersion aquireLatestDevRelease() { - // get the latest release info from a internet resource - try { - return latestReleaseFrom(new URL("http://latest.yacy-forum.net")); + private static TreeSet[] allDevReleases() { + // get release info from a internet resource + // {promainreleases, prodevreleases, stdmainreleases, stddevreleases} + if ((allDevReleases == null) || + ((allDevReleases[0].size() == 0) && + (allDevReleases[1].size() == 0) && + (allDevReleases[2].size() == 0) && + (allDevReleases[3].size() == 0) )) try { + allDevReleases = allReleaseFrom(new URL(latestDevReleaseLocation)); } catch (MalformedURLException e) { return null; } + return allDevReleases; } - public static yacyVersion aquireLatestMainRelease() { - // get the latest release info from a internet resource - try { - return latestReleaseFrom(new URL("http://yacy.net/yacy/Download.html")); + private static TreeSet[] allMainReleases() { + // get release info from a internet resource + // {promainreleases, prodevreleases, stdmainreleases, stddevreleases} + if ((allMainReleases == null) || + ((allMainReleases[0].size() == 0) && + (allMainReleases[1].size() == 0) && + (allMainReleases[2].size() == 0) && + (allMainReleases[3].size() == 0) )) try { + allMainReleases = allReleaseFrom(new URL(latestMainReleaseLocation)); } catch (MalformedURLException e) { return null; } + return allMainReleases; } - public static yacyVersion latestReleaseFrom(URL url) { + private static TreeSet[] allReleaseFrom(URL url) { // retrieves the latest info about releases // this is done by contacting a release location, // parsing the content and filtering+parsing links @@ -187,7 +220,10 @@ public final class yacyVersion implements Comparator, Comparable { // analyse links in scraper resource, and find link to latest release in it Map anchors = scraper.getAnchors(); // a url (String) / name (String) relation Iterator i = anchors.keySet().iterator(); - TreeSet releases = new TreeSet(); // will contain a release (Float) / url (String) relation + TreeSet stddevreleases = new TreeSet(); + TreeSet prodevreleases = new TreeSet(); + TreeSet stdmainreleases = new TreeSet(); + TreeSet promainreleases = new TreeSet(); yacyVersion release; while (i.hasNext()) { try { @@ -198,7 +234,10 @@ public final class yacyVersion implements Comparator, Comparable { try { release = new yacyVersion(url); //System.out.println("r " + release.toAnchor()); - releases.add(release); + if ( release.proRelease && release.mainRelease) promainreleases.add(release); + if ( release.proRelease && !release.mainRelease) prodevreleases.add(release); + if (!release.proRelease && release.mainRelease) stdmainreleases.add(release); + if (!release.proRelease && !release.mainRelease) stddevreleases.add(release); } catch (RuntimeException e) { // the release string was not well-formed. // that might have been another link @@ -206,8 +245,22 @@ public final class yacyVersion implements Comparator, Comparable { continue; } } - if (releases.size() == 0) return null; - //i = releases.iterator(); while (i.hasNext()) {System.out.println("v " + ((yacyVersion) i.next()).toAnchor());} - return (yacyVersion) releases.last(); + return new TreeSet[] {promainreleases, prodevreleases, stdmainreleases, stddevreleases} ; + } + + public static void downloadRelease(yacyVersion release) throws IOException { + File storagePath = plasmaSwitchboard.getSwitchboard().releasePath; + // load file + byte[] file = httpc.wget( + release.url, + release.url.getHost(), + 10000, + null, + null, + plasmaSwitchboard.getSwitchboard().remoteProxyConfig + ); + if (file == null) throw new IOException("wget of url " + release.url + " failed"); + // save file + serverFileUtils.write(file, new File(storagePath, release.url.getFileName())); } } diff --git a/source/yacy.java b/source/yacy.java index 69bfd8b4e..b7bc7121b 100644 --- a/source/yacy.java +++ b/source/yacy.java @@ -90,7 +90,6 @@ import de.anomic.server.serverFileUtils; import de.anomic.server.serverMemory; import de.anomic.server.serverSemaphore; import de.anomic.server.serverSystem; -import de.anomic.server.serverUpdaterCallback; import de.anomic.server.logging.serverLog; import de.anomic.tools.enumerateFiles; import de.anomic.yacy.yacyClient; @@ -137,7 +136,8 @@ public final class yacy { // static objects private static String vString = "@REPL_VERSION@"; private static double version = 0.1; - + public static boolean pro; + private static final String vDATE = "@REPL_DATE@"; private static final String copyright = "[ YaCy v" + vString + ", build " + vDATE + " by Michael Christen / www.yacy.net ]"; private static final String hline = "-------------------------------------------------------------------------------"; @@ -258,27 +258,8 @@ public final class yacy { } f.createNewFile(); f.deleteOnExit(); - - /* - // Testing if the yacy archive file were unzipped correctly. - // This test is needed because of classfile-names longer than 100 chars - // which could cause problems with incompatible unzip software. - // See: - // - http://www.yacy-forum.de/viewtopic.php?t=1763 - // - http://www.yacy-forum.de/viewtopic.php?t=715 - // - http://www.yacy-forum.de/viewtopic.php?t=1674 - File unzipTest = new File(homePath,"doc/This_is_a_test_if_the_archive_file_containing_YaCy_was_unpacked_correctly_If_not_please_use_gnu_tar_instead.txt"); - if (!unzipTest.exists()) { - String errorMsg = "The archive file containing YaCy was not unpacked correctly. " + - "Please use 'GNU-Tar' or upgrade to a newer version of your unzip software.\n" + - "For detailed information on this bug see: " + - "http://www.yacy-forum.de/viewtopic.php?t=715"; - System.err.println(errorMsg); - serverLog.logSevere("STARTUP", errorMsg); - System.exit(1); - } - */ - boolean pro = new File(homePath, "libx").exists(); + + pro = new File(homePath, "libx").exists(); sb = new plasmaSwitchboard(homePath, "yacy.init", "DATA/SETTINGS/httpProxy.conf", pro); sbSync.V(); // signal that the sb reference was set @@ -548,26 +529,6 @@ public final class yacy { } } - /** - * Function to set the updater callback class - * @param updaterCallback - * @throws InterruptedException - */ - public static void setUpdaterCallback(serverUpdaterCallback updaterCallback) throws InterruptedException { - sbSync.P(); - sb.updaterCallback = updaterCallback; - sbSync.V(); - } - - /** - * Function allowing the updater to block until the startup has finished - * @throws InterruptedException - */ - public static void waitForFinishedStartup() throws InterruptedException { - startupFinishedSync.P(); - startupFinishedSync.V(); - } - /** * Call the shutdown-page of YaCy to tell it to shut down. This method is * called if you start yacy with the argument -shutdown. diff --git a/yacy.init b/yacy.init index 7bc7284fd..c9f7bd3d2 100644 --- a/yacy.init +++ b/yacy.init @@ -157,6 +157,9 @@ proxyCache = DATA/HTCACHE proxyCacheSize = 100 proxyCacheSize__pro = 600 +# storage place for new releases +releases = DATA/RELEASE + # use the mostly direct mapping of URLs to Filenames # makes it easy watching the content of the cache using file browsers # problems arise when a file already exists where a new entry expects a directory diff --git a/yacy.network.unit b/yacy.network.unit index 93ce5ae39..13720a503 100644 --- a/yacy.network.unit +++ b/yacy.network.unit @@ -62,6 +62,11 @@ network.unit.bootstrap.seedlist4 = http://www.yacy.net/yacy/seed.txt network.unit.bootstrap.seedlist5 = http://www.marcelhenseler.de/yacy/seed.txt network.unit.bootstrap.seedlist6 = http://www.dc-art.de/yacy/seed.txt +# each network may use different yacy distributions. +# the auto-updater can access network-specific update locations +network.unit.update.location.dev = http://latest.yacy-forum.net +network.unit.update.location.main = http://yacy.net/yacy/Download.html + # properties for in-protocol response authentification: #network.unit.protocol.control = uncontrolled #network.unit.protocol.request.authentification.method = salted-magic