new release file names with date and git hash

...without reference to 9000ish SVN
pull/533/head
Michael Peter Christen 2 years ago
parent ede9efe50c
commit 60c9986a0e

@ -4,7 +4,6 @@ javacTarget=1.8
# Release Configuration # Release Configuration
releaseVersion=1.925 releaseVersion=1.925
releaseNr=9749
releaseFileParentDir=yacy releaseFileParentDir=yacy
privateKeyFile=private.key privateKeyFile=private.key

@ -90,28 +90,27 @@
<property name="target-resolve-already-run" value="true" /> <property name="target-resolve-already-run" value="true" />
</target> </target>
<!-- find git version and write it to git.revision --> <!-- initializing all needed variables -->
<available file=".git" type="dir" property="git.present"/> <target name="init">
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--always"/>
<arg value="--abbrev=7"/>
<arg value="HEAD"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
</target>
<!-- initializing all needed variables -->
<target name="init" depends="git.revision">
<loadproperties srcFile="build.properties" /> <loadproperties srcFile="build.properties" />
<property name="stdReleaseFile" value="yacy_v${releaseVersion}_${releaseNr}.tar.gz"/>
<exec executable="git" outputproperty="repository.revision.date">
<arg value="log"/>
<arg value="-1"/>
<arg value="--pretty=format:%ad" />
<arg value="--date=format:%Y%m%d" />
</exec>
<exec executable="git" outputproperty="repository.revision.time">
<arg value="log"/>
<arg value="-1"/>
<arg value="--pretty=format:%ad" />
<arg value="--date=format:%H%m" />
</exec>
<exec executable="git" outputproperty="repository.revision.hash">
<arg value="log"/>
<arg value="-1"/>
<arg value="--pretty=format:%h" />
</exec>
<mkdir dir="${data}"/> <mkdir dir="${data}"/>
<mkdir dir="${release}"/> <mkdir dir="${release}"/>
@ -120,13 +119,23 @@
<echo message="YaCy Version number: ${releaseVersion}" /> <echo message="YaCy Version number: ${releaseVersion}" />
<filter token="REPL_VERSION" value="${releaseVersion}" /> <filter token="REPL_VERSION" value="${releaseVersion}" />
<!-- YaCy Release revision number -->
<echo message="YaCy Release number: ${releaseNr}" />
<filter token="REPL_REVISION_NR" value="${releaseNr}"/>
<!-- GIT Release revision number --> <!-- GIT Release revision number -->
<echo message="GIT Release Tag: ${repository.version}" /> <echo message="GIT Release Date: ${repository.revision.date}" />
<filter token="REPL_REPVER" value="${repository.version}"/> <echo message="GIT Release Time: ${repository.revision.time}" />
<echo message="GIT Release Hash: ${repository.revision.hash}" />
<filter token="REPL_REPVERDATE" value="${repository.revision.date}"/>
<filter token="REPL_REPVERTIME" value="${repository.revision.time}"/>
<filter token="REPL_REPVERHASH" value="${repository.revision.hash}"/>
<!-- set time stamp: DSTAMP should have the format yyyyMMdd, TSTAMP hhmm -->
<tstamp/>
<filter token="REPL_DSTAMP" value="${DSTAMP}"/>
<filter token="REPL_TSTAMP" value="${TSTAMP}"/>
<!-- release file names -->
<property name="stdReleaseStub" value="yacy_v${releaseVersion}_${repository.revision.date}${repository.revision.time}_${repository.revision.hash}"/>
<property name="stdReleaseFile" value="${stdReleaseStub}.tar.gz"/>
<filter token="REPL_RELEASESTUB" value="${stdReleaseStub}"/>
<!-- apply replacments --> <!-- apply replacments -->
<copy file="${defaults}/yacyBuild.properties.template" tofile="${defaults}/yacyBuild.properties" overwrite="true" filtering="true" /> <copy file="${defaults}/yacyBuild.properties.template" tofile="${defaults}/yacyBuild.properties" overwrite="true" filtering="true" />
@ -518,8 +527,8 @@
<arg value="-NOCD" /> <arg value="-NOCD" />
<arg value="${release_windows}/build.nsi" /> <arg value="${release_windows}/build.nsi" />
</exec> </exec>
<move file="${release_windows}/yacy_v${releaseVersion}_${releaseNr}.exe" <move file="${release_windows}/${stdReleaseStub}.exe"
tofile="${release}/yacy_v${releaseVersion}_${releaseNr}.exe" /> tofile="${release}/${stdReleaseStub}.exe" />
<delete dir="${release_main}"/> <delete dir="${release_main}"/>
<delete dir="${release_windows}" failonerror="false" /> <delete dir="${release_windows}" failonerror="false" />
@ -535,7 +544,7 @@
<chmod file="${release_mac}/YaCy.app/Contents/MacOS/startYACYMacOS.sh" perm="755"/> <chmod file="${release_mac}/YaCy.app/Contents/MacOS/startYACYMacOS.sh" perm="755"/>
<chmod file="${release_mac}/YaCy.app/Contents/MacOS/startYACY.sh" perm="755"/> <chmod file="${release_mac}/YaCy.app/Contents/MacOS/startYACY.sh" perm="755"/>
<exec executable="hdiutil"> <exec executable="hdiutil">
<arg line="create -srcfolder ${release_mac}/YaCy.app ${release}/yacy_v${releaseVersion}_${releaseNr}.dmg"/> <arg line="create -srcfolder ${release_mac}/YaCy.app ${release}/${stdReleaseStub}.dmg"/>
</exec> </exec>
<delete dir="${release_mac}" failonerror="false" verbose="false" /> <delete dir="${release_mac}" failonerror="false" verbose="false" />
</target> </target>

@ -1,3 +1,7 @@
SVNRevision = @REPL_REVISION_NR@
Version = @REPL_VERSION@ Version = @REPL_VERSION@
RepositoryVersion = @REPL_REPVER@ RepositoryVersionDate = @REPL_REPVERDATE@
RepositoryVersionTime = @REPL_REPVERTIME@
RepositoryVersionHash = @REPL_REPVERHASH@
ReleaseStub = @REPL_RELEASESTUB@
dstamp = @REPL_DSTAMP@
tstamp = @REPL_TSTAMP@

@ -1,6 +1,9 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<version> <version>
<number>#[versionstring]#</number> <file>#[versionstring]#</file>
<svnRevision>#[svnRev]#</svnRevision> <buildDate>#[buildDate]#</buildDate>
<buildDate>19700101</buildDate> <buildTime>#[buildTime]#</buildTime>
<buildDateTime>#[buildDateTime]#</buildDateTime>
<buildHash>#[buildDateTime]#</buildHash>
<buildVersion>#[buildVersion]#</buildVersion>
</version> </version>

@ -78,26 +78,26 @@ public class ConfigUpdate_p {
final String release = post.get("releasedownload", ""); final String release = post.get("releasedownload", "");
if (!release.isEmpty()) { if (!release.isEmpty()) {
try { try {
yacyRelease versionToDownload = new yacyRelease(new DigestURL(release)); yacyRelease versionToDownload = new yacyRelease(new DigestURL(release));
// replace this version with version which contains public key // replace this version with version which contains public key
final yacyRelease.DevAndMainVersions allReleases = yacyRelease.allReleases(false, false); final yacyRelease.DevAndMainVersions allReleases = yacyRelease.allReleases(false, false);
final Set<yacyRelease> mostReleases = versionToDownload.isMainRelease() ? allReleases.main : allReleases.dev; final Set<yacyRelease> mostReleases = versionToDownload.isMainRelease() ? allReleases.main : allReleases.dev;
for (final yacyRelease rel : mostReleases) { for (final yacyRelease rel : mostReleases) {
if (rel.equals(versionToDownload)) { if (rel.equals(versionToDownload)) {
versionToDownload = rel; versionToDownload = rel;
break; break;
} }
} }
final File downloadedRelease = versionToDownload.downloadRelease(); final File downloadedRelease = versionToDownload.downloadRelease();
if(downloadedRelease == null) { if(downloadedRelease == null) {
prop.put("candeploy_downloadError", "1"); prop.put("candeploy_downloadError", "1");
prop.putHTML("candeploy_downloadError_releasedownload", release); prop.putHTML("candeploy_downloadError_releasedownload", release);
} }
} catch (final IOException e) { } catch (final IOException e) {
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
prop.put("candeploy_downloadError", "1"); prop.put("candeploy_downloadError", "1");
prop.putHTML("candeploy_downloadError_releasedownload", release); prop.putHTML("candeploy_downloadError_releasedownload", release);
} }
} }
} }
@ -112,8 +112,8 @@ public class ConfigUpdate_p {
try { try {
// only delete files from RELEASE directory // only delete files from RELEASE directory
if (FileUtils.isInDirectory(new File(sb.releasePath, release), sb.releasePath)) { if (FileUtils.isInDirectory(new File(sb.releasePath, release), sb.releasePath)) {
FileUtils.deletedelete(new File(sb.releasePath, release)); FileUtils.deletedelete(new File(sb.releasePath, release));
FileUtils.deletedelete(new File(sb.releasePath, release + ".sig")); FileUtils.deletedelete(new File(sb.releasePath, release + ".sig"));
} else { } else {
sb.getLog().severe("AUTO-UPDATE: could not delete " + release + ": file not in release directory."); sb.getLog().severe("AUTO-UPDATE: could not delete " + release + ": file not in release directory.");
} }
@ -141,9 +141,9 @@ public class ConfigUpdate_p {
prop.put("candeploy_autoUpdate", "4"); prop.put("candeploy_autoUpdate", "4");
} else { } else {
if(yacyRelease.deployRelease(downloaded)) { if(yacyRelease.deployRelease(downloaded)) {
sb.terminate(10, "manual release update to " + downloaded.getName()); sb.terminate(10, "manual release update to " + downloaded.getName());
sb.getLog().info("AUTO-UPDATE: deploy and restart initiated"); sb.getLog().info("AUTO-UPDATE: deploy and restart initiated");
prop.put("candeploy_autoUpdate", "1"); prop.put("candeploy_autoUpdate", "1");
} else { } else {
sb.getLog().info("AUTO-UPDATE: omitting update because an error occurred while trying to deploy the release.."); sb.getLog().info("AUTO-UPDATE: omitting update because an error occurred while trying to deploy the release..");
prop.put("candeploy_autoUpdate", "5"); prop.put("candeploy_autoUpdate", "5");
@ -163,7 +163,7 @@ public class ConfigUpdate_p {
} }
// version information // version information
final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision(); final String versionstring = yacyBuildProperties.getReleaseStub();
prop.putHTML("candeploy_versionpp", versionstring); prop.putHTML("candeploy_versionpp", versionstring);
final boolean devenvironment = new File(sb.getAppPath(), ".git").exists(); final boolean devenvironment = new File(sb.getAppPath(), ".git").exists();
float thisVersion = Float.parseFloat(yacyBuildProperties.getVersion()); float thisVersion = Float.parseFloat(yacyBuildProperties.getVersion());
@ -180,14 +180,14 @@ public class ConfigUpdate_p {
prop.put("candeploy_deployenabled", (downloadedFilesNum == 0) ? "0" : ((devenvironment) ? "1" : "2")); // prevent that a developer-version is over-deployed prop.put("candeploy_deployenabled", (downloadedFilesNum == 0) ? "0" : ((devenvironment) ? "1" : "2")); // prevent that a developer-version is over-deployed
final NavigableSet<yacyRelease> downloadedReleases = new TreeSet<yacyRelease>(); final NavigableSet<yacyRelease> downloadedReleases = new TreeSet<>();
for (final File downloaded : downloadedFiles) { for (final File downloaded : downloadedFiles) {
try { try {
final yacyRelease release = new yacyRelease(downloaded); final yacyRelease release = new yacyRelease(downloaded);
downloadedReleases.add(release); downloadedReleases.add(release);
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
// not a valid release // not a valid release
// can be also a restart- or deploy-file // can be also a restart- or deploy-file
final File invalid = downloaded; final File invalid = downloaded;
if (!(invalid.getName().endsWith(".bat") || invalid.getName().endsWith(".sh") || invalid.getName().endsWith(".sig"))) { // Windows & Linux don't like deleted scripts while execution! if (!(invalid.getName().endsWith(".bat") || invalid.getName().endsWith(".sh") || invalid.getName().endsWith(".sig"))) { // Windows & Linux don't like deleted scripts while execution!
invalid.deleteOnExit(); invalid.deleteOnExit();
@ -216,7 +216,7 @@ public class ConfigUpdate_p {
final yacyRelease.DevAndMainVersions releasess = yacyRelease.allReleases(false, false); final yacyRelease.DevAndMainVersions releasess = yacyRelease.allReleases(false, false);
relcount = 0; relcount = 0;
final ArrayList<yacyRelease> rlist = new ArrayList<yacyRelease>(); final ArrayList<yacyRelease> rlist = new ArrayList<>();
final Set<yacyRelease> remoteDevReleases = releasess.dev; final Set<yacyRelease> remoteDevReleases = releasess.dev;
remoteDevReleases.removeAll(downloadedReleases); remoteDevReleases.removeAll(downloadedReleases);
for (final yacyRelease release : remoteDevReleases) { for (final yacyRelease release : remoteDevReleases) {

@ -58,9 +58,9 @@ public class Status
private static final String PEERSTATUS = "peerStatus"; private static final String PEERSTATUS = "peerStatus";
public static serverObjects respond( public static serverObjects respond(
final RequestHeader header, final RequestHeader header,
final serverObjects post, final serverObjects post,
final serverSwitch env) { final serverSwitch env) {
// return variable that accumulates replacements // return variable that accumulates replacements
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard) env; final Switchboard sb = (Switchboard) env;
@ -77,7 +77,7 @@ public class Status
if ( post != null && !post.isEmpty() ) { if ( post != null && !post.isEmpty() ) {
if ( sb.adminAuthenticated(header) < 2 ) { if ( sb.adminAuthenticated(header) < 2 ) {
prop.authenticationRequired(); prop.authenticationRequired();
return prop; return prop;
} }
boolean redirect = false; boolean redirect = false;
@ -133,7 +133,7 @@ public class Status
// password protection // password protection
if ( (sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty()) if ( (sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty())
&& (!sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false)) ) { && (!sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false)) ) {
prop.put("protection", "0"); // not protected prop.put("protection", "0"); // not protected
prop.put("urgentSetPassword", "1"); prop.put("urgentSetPassword", "1");
} else { } else {
@ -143,8 +143,8 @@ public class Status
if ( sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false) ) { if ( sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false) ) {
prop.put("unrestrictedLocalAccess", 1); prop.put("unrestrictedLocalAccess", 1);
if(sb.getConfig(SwitchboardConstants.SERVER_SERVLETS_CALLED, "").indexOf("ConfigAccounts_p.html", 0) < 0) { if(sb.getConfig(SwitchboardConstants.SERVER_SERVLETS_CALLED, "").indexOf("ConfigAccounts_p.html", 0) < 0) {
/* Encourage checking accounts config page to be sure that unrestricted local access is desired */ /* Encourage checking accounts config page to be sure that unrestricted local access is desired */
prop.put("warningUnrestrictedLocalAccess", true); prop.put("warningUnrestrictedLocalAccess", true);
} }
} }
@ -157,7 +157,7 @@ public class Status
} }
if ( !sb.observer.getMemoryAvailable() ) { if ( !sb.observer.getMemoryAvailable() ) {
final String minFree = final String minFree =
Formatter.bytesToString(sb.observer.getMinFreeMemory() * 1024L * 1024L); Formatter.bytesToString(sb.observer.getMinFreeMemory() * 1024L * 1024L);
prop.put("warningMemoryLow", "1"); prop.put("warningMemoryLow", "1");
prop.put("warningMemoryLow_minSpace", minFree); prop.put("warningMemoryLow_minSpace", minFree);
} }
@ -166,7 +166,7 @@ public class Status
// version information // version information
//final String versionstring = yacyVersion.combined2prettyVersion(sb.getConfig("version","0.1")); //final String versionstring = yacyVersion.combined2prettyVersion(sb.getConfig("version","0.1"));
final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision(); final String versionstring = yacyBuildProperties.getReleaseStub();
prop.put("versionpp", versionstring); prop.put("versionpp", versionstring);
prop.put("java.version", System.getProperty("java.version")); prop.put("java.version", System.getProperty("java.version"));
@ -239,18 +239,18 @@ public class Status
} }
} }
final String peerStatus = final String peerStatus =
((sb.peers.mySeed() == null) ? Seed.PEERTYPE_VIRGIN : sb.peers.mySeed().get( ((sb.peers.mySeed() == null) ? Seed.PEERTYPE_VIRGIN : sb.peers.mySeed().get(
Seed.PEERTYPE, Seed.PEERTYPE,
Seed.PEERTYPE_VIRGIN)); Seed.PEERTYPE_VIRGIN));
if ( Seed.PEERTYPE_VIRGIN.equals(peerStatus) if ( Seed.PEERTYPE_VIRGIN.equals(peerStatus)
&& "freeworld".equals(sb.getConfig(SwitchboardConstants.NETWORK_NAME, "")) && "freeworld".equals(sb.getConfig(SwitchboardConstants.NETWORK_NAME, ""))
&& !SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) { && !SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) {
prop.put(PEERSTATUS, "0"); prop.put(PEERSTATUS, "0");
prop.put("urgentStatusVirgin", "1"); prop.put("urgentStatusVirgin", "1");
} else if ( Seed.PEERTYPE_JUNIOR.equals(peerStatus) } else if ( Seed.PEERTYPE_JUNIOR.equals(peerStatus)
&& "freeworld".equals(sb.getConfig(SwitchboardConstants.NETWORK_NAME, "")) && "freeworld".equals(sb.getConfig(SwitchboardConstants.NETWORK_NAME, ""))
&& !SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) { && !SwitchboardConstants.CLUSTER_MODE_PRIVATE_PEER.equals(sb.getConfig(SwitchboardConstants.CLUSTER_MODE, ""))) {
prop.put(PEERSTATUS, "1"); prop.put(PEERSTATUS, "1");
prop.put("warningStatusJunior", "1"); prop.put("warningStatusJunior", "1");
} else if ( Seed.PEERTYPE_SENIOR.equals(peerStatus) ) { } else if ( Seed.PEERTYPE_SENIOR.equals(peerStatus) ) {
@ -266,9 +266,9 @@ public class Status
final String seedUploadMethod = sb.getConfig("seedUploadMethod", ""); final String seedUploadMethod = sb.getConfig("seedUploadMethod", "");
if ( !"none".equalsIgnoreCase(seedUploadMethod) if ( !"none".equalsIgnoreCase(seedUploadMethod)
|| ("".equals(seedUploadMethod) && (sb.getConfig("seedFTPPassword", "").length() > 0 || sb || ("".equals(seedUploadMethod) && (sb.getConfig("seedFTPPassword", "").length() > 0 || sb
.getConfig("seedFilePath", "") .getConfig("seedFilePath", "")
.length() > 0)) ) { .length() > 0)) ) {
if ( "".equals(seedUploadMethod) ) { if ( "".equals(seedUploadMethod) ) {
if ( sb.getConfig("seedFTPPassword", "").length() > 0 ) { if ( sb.getConfig("seedFTPPassword", "").length() > 0 ) {
sb.setConfig("seedUploadMethod", "Ftp"); sb.setConfig("seedUploadMethod", "Ftp");
@ -289,8 +289,8 @@ public class Status
prop.putHTML("seedServer_seedFile", sb.getConfig("seedFilePath", "")); prop.putHTML("seedServer_seedFile", sb.getConfig("seedFilePath", ""));
} }
prop.put( prop.put(
"seedServer_lastUpload", "seedServer_lastUpload",
PeerActions.formatInterval(System.currentTimeMillis() - sb.peers.lastSeedUpload_timeStamp)); PeerActions.formatInterval(System.currentTimeMillis() - sb.peers.lastSeedUpload_timeStamp));
} else { } else {
prop.put(SEEDSERVER, "0"); // disabled prop.put(SEEDSERVER, "0"); // disabled
} }
@ -347,18 +347,18 @@ public class Status
prop.put("loaderQueuePercent", (loaderPercent > 100) ? 100 : loaderPercent); prop.put("loaderQueuePercent", (loaderPercent > 100) ? 100 : loaderPercent);
prop.putNum("localCrawlQueueSize", sb prop.putNum("localCrawlQueueSize", sb
.getThread(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) .getThread(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)
.getJobCount()); .getJobCount());
prop.put("localCrawlPaused", sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) prop.put("localCrawlPaused", sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)
? "1" ? "1"
: "0"); : "0");
prop.putNum( prop.putNum(
"remoteTriggeredCrawlQueueSize", "remoteTriggeredCrawlQueueSize",
sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) != null ? sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount() : 0); sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) != null ? sb.getThread(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount() : 0);
prop.put( prop.put(
"remoteTriggeredCrawlPaused", "remoteTriggeredCrawlPaused",
sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? "1" : "0"); sb.crawlJobIsPaused(SwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? "1" : "0");
prop.putNum("stackCrawlQueueSize", sb.crawlStacker.size()); prop.putNum("stackCrawlQueueSize", sb.crawlStacker.size());

@ -12,9 +12,12 @@ public class version {
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) { public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
// return variable that accumulates replacements // return variable that accumulates replacements
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
prop.put("versionstring", yacyBuildProperties.getReleaseStub());
prop.put("versionstring", yacyBuildProperties.getLongVersion()); prop.put("buildDate", yacyBuildProperties.getRepositoryVersionDate());
prop.put("svnRev", yacyBuildProperties.getSVNRevision()); prop.put("buildTime", yacyBuildProperties.getRepositoryVersionTime());
prop.put("buildDateTime", yacyBuildProperties.getRepositoryVersionDate() + yacyBuildProperties.getRepositoryVersionTime());
prop.put("buildHash", yacyBuildProperties.getRepositoryVersionHash());
prop.put("buildVersion", yacyBuildProperties.getVersion());
// return rewrite properties // return rewrite properties
return prop; return prop;

@ -57,8 +57,8 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
private static final Pattern multiDumpFilterPattern = Pattern.compile(multiDumpFilter); private static final Pattern multiDumpFilterPattern = Pattern.compile(multiDumpFilter);
public static class StackTrace { public static class StackTrace {
private String text; private final String text;
private Thread.State state; private final Thread.State state;
public StackTrace(final String text, final Thread.State state) { public StackTrace(final String text, final Thread.State state) {
this.state = state; this.state = state;
this.text = text; this.text = text;
@ -81,7 +81,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
} }
public static class Lock { public static class Lock {
private String id; private final String id;
public Lock(final String name) { public Lock(final String name) {
this.id = name; this.id = name;
} }
@ -122,7 +122,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
/** /**
* Try to get the thread dump from a yacy.log file which is available when YaCy is started with * Try to get the thread dump from a yacy.log file which is available when YaCy is started with
* startYACY.sh -l * startYACY.sh -l
* @param logFile the log file to read * @param logFile the log file to read
* @throws IOException when a read/write error occurred * @throws IOException when a read/write error occurred
*/ */
@ -145,10 +145,10 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
if (sizeAfter <= sizeBefore) return; if (sizeAfter <= sizeBefore) return;
try(final RandomAccessFile raf = new RandomAccessFile(logFile, "r");) { try(final RandomAccessFile raf = new RandomAccessFile(logFile, "r");) {
raf.seek(sizeBefore); raf.seek(sizeBefore);
final byte[] b = new byte[(int) (sizeAfter - sizeBefore)]; final byte[] b = new byte[(int) (sizeAfter - sizeBefore)];
raf.readFully(b); raf.readFully(b);
// import the thread dump; // import the thread dump;
importText(new ByteArrayInputStream(b)); importText(new ByteArrayInputStream(b));
} }
@ -179,7 +179,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
String line; String line;
String thread = null; String thread = null;
int p; int p;
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<>();
Thread.State state = null; Thread.State state = null;
Thread.State state0; Thread.State state0;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
@ -189,7 +189,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
if (thread != null) { if (thread != null) {
put(new ThreadDump.StackTrace(thread, state), list); put(new ThreadDump.StackTrace(thread, state), list);
} }
list = new ArrayList<String>(); list = new ArrayList<>();
thread = null; thread = null;
state = null; state = null;
continue; continue;
@ -262,7 +262,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
final String threaddump = sb.toString(); final String threaddump = sb.toString();
@SuppressWarnings("unlikely-arg-type") @SuppressWarnings("unlikely-arg-type")
List<String> threads = get(threaddump); List<String> threads = get(threaddump);
if (threads == null) threads = new ArrayList<String>(); if (threads == null) threads = new ArrayList<>();
Thread.State state = null; Thread.State state = null;
for (final String t: threads) { for (final String t: threads) {
final int p = t.indexOf(statestatement); final int p = t.indexOf(statestatement);
@ -303,8 +303,8 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
for (int i = size() + 10; i > 0; i--) { for (int i = size() + 10; i > 0; i--) {
for (final Map.Entry<StackTrace, Integer> entry: locks.entrySet()) { for (final Map.Entry<StackTrace, Integer> entry: locks.entrySet()) {
if (entry.getValue().intValue() == i) { if (entry.getValue().intValue() == i) {
bufferappend(buffer, plain, "holds lock for " + i + " threads:"); bufferappend(buffer, plain, "holds lock for " + i + " threads:");
final List<String> list = get(entry.getKey()); final List<String> list = get(entry.getKey());
if (list == null) continue; if (list == null) continue;
bufferappend(buffer, plain, "Thread= " + entry.getKey()); bufferappend(buffer, plain, "Thread= " + entry.getKey());
for (final String s: list) bufferappend(buffer, plain, " " + (plain ? s : s.replaceAll("<", "&lt;").replaceAll(">", "&gt;"))); for (final String s: list) bufferappend(buffer, plain, " " + (plain ? s : s.replaceAll("<", "&lt;").replaceAll(">", "&gt;")));
@ -323,7 +323,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
final boolean plain) { final boolean plain) {
// collect single dumps // collect single dumps
final Map<String, Integer> dumps = new HashMap<String, Integer>(); final Map<String, Integer> dumps = new HashMap<>();
ThreadDump x; ThreadDump x;
for (final Map<Thread, StackTraceElement[]> trace: stackTraces) { for (final Map<Thread, StackTraceElement[]> trace: stackTraces) {
x = new ThreadDump(rootPath, trace, plain, Thread.State.RUNNABLE); x = new ThreadDump(rootPath, trace, plain, Thread.State.RUNNABLE);
@ -384,7 +384,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
public List<Map.Entry<StackTrace, List<String>>> freerun() { public List<Map.Entry<StackTrace, List<String>>> freerun() {
final List<Map.Entry<StackTrace, List<String>>> runner = new ArrayList<Map.Entry<StackTrace, List<String>>>(); final List<Map.Entry<StackTrace, List<String>>> runner = new ArrayList<>();
runf: for (final Map.Entry<StackTrace, List<String>> entry: entrySet()) { runf: for (final Map.Entry<StackTrace, List<String>> entry: entrySet()) {
// check if the thread is locked or holds a lock // check if the thread is locked or holds a lock
if (entry.getKey().state != Thread.State.RUNNABLE) continue runf; if (entry.getKey().state != Thread.State.RUNNABLE) continue runf;
@ -402,7 +402,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
*/ */
public Map<Lock, StackTrace> locks() { public Map<Lock, StackTrace> locks() {
int p; int p;
final Map<Lock, StackTrace> locks = new HashMap<Lock, StackTrace>(); final Map<Lock, StackTrace> locks = new HashMap<>();
for (final Map.Entry<StackTrace, List<String>> entry: entrySet()) { for (final Map.Entry<StackTrace, List<String>> entry: entrySet()) {
for (final String s: entry.getValue()) { for (final String s: entry.getValue()) {
if ((p = s.indexOf("locked <",0)) > 0) { if ((p = s.indexOf("locked <",0)) > 0) {
@ -433,7 +433,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
public Map<StackTrace, Integer> countLocks() { public Map<StackTrace, Integer> countLocks() {
final Map<Lock, StackTrace> locks = locks(); final Map<Lock, StackTrace> locks = locks();
final Map<StackTrace, Integer> count = new HashMap<StackTrace, Integer>(); final Map<StackTrace, Integer> count = new HashMap<>();
for (final Map.Entry<Lock, StackTrace> entry: locks.entrySet()) { for (final Map.Entry<Lock, StackTrace> entry: locks.entrySet()) {
// look where the lock has an effect // look where the lock has an effect
int c = 0; int c = 0;
@ -461,8 +461,8 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
if (sleep > 0) try {Thread.sleep(sleep);} catch (final InterruptedException e) {} if (sleep > 0) try {Thread.sleep(sleep);} catch (final InterruptedException e) {}
// Thread dump // Thread dump
final Date dt = new Date(); final Date dt = new Date();
final String versionstring = yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision(); final String versionstring = yacyBuildProperties.getReleaseStub();
Runtime runtime = Runtime.getRuntime(); final Runtime runtime = Runtime.getRuntime();
ThreadDump.bufferappend(buffer, plain, "************* Start Thread Dump " + dt + " *******************"); ThreadDump.bufferappend(buffer, plain, "************* Start Thread Dump " + dt + " *******************");
ThreadDump.bufferappend(buffer, plain, "&nbsp;"); ThreadDump.bufferappend(buffer, plain, "&nbsp;");
@ -473,9 +473,9 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
ThreadDump.bufferappend(buffer, plain, "&nbsp;"); ThreadDump.bufferappend(buffer, plain, "&nbsp;");
ThreadDump.bufferappend(buffer, plain, "&nbsp;"); ThreadDump.bufferappend(buffer, plain, "&nbsp;");
File appPath = sb.getAppPath(); final File appPath = sb.getAppPath();
if (multiple) { if (multiple) {
final ArrayList<Map<Thread,StackTraceElement[]>> traces = new ArrayList<Map<Thread,StackTraceElement[]>>(); final ArrayList<Map<Thread,StackTraceElement[]>> traces = new ArrayList<>();
for (int i = 0; i < multipleCount; i++) { for (int i = 0; i < multipleCount; i++) {
try { try {
traces.add(ThreadDump.getAllStackTraces()); traces.add(ThreadDump.getAllStackTraces());
@ -486,7 +486,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
ThreadDump.appendStackTraceStats(appPath, buffer, traces, plain); ThreadDump.appendStackTraceStats(appPath, buffer, traces, plain);
} else { } else {
// write a thread dump to standard error output // write a thread dump to standard error output
File logFile = new File("yacy.log"); final File logFile = new File("yacy.log");
if (ThreadDump.canProduceLockedBy(logFile)) { if (ThreadDump.canProduceLockedBy(logFile)) {
try { try {
new ThreadDump(logFile).appendBlockTraces(buffer, plain); new ThreadDump(logFile).appendBlockTraces(buffer, plain);
@ -511,10 +511,10 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
ThreadDump.bufferappend(buffer, plain, "************* End Thread Dump " + dt + " *******************"); ThreadDump.bufferappend(buffer, plain, "************* End Thread Dump " + dt + " *******************");
ThreadDump.bufferappend(buffer, plain, ""); ThreadDump.bufferappend(buffer, plain, "");
ThreadMXBean threadbean = ManagementFactory.getThreadMXBean(); final ThreadMXBean threadbean = ManagementFactory.getThreadMXBean();
ThreadDump.bufferappend(buffer, plain, "Thread list from ThreadMXBean, " + threadbean.getThreadCount() + " threads:"); ThreadDump.bufferappend(buffer, plain, "Thread list from ThreadMXBean, " + threadbean.getThreadCount() + " threads:");
ThreadInfo[] threadinfo = threadbean.dumpAllThreads(true, true); final ThreadInfo[] threadinfo = threadbean.dumpAllThreads(true, true);
for (ThreadInfo ti: threadinfo) { for (final ThreadInfo ti: threadinfo) {
ThreadDump.bufferappend(buffer, plain, ti.getThreadName()); ThreadDump.bufferappend(buffer, plain, ti.getThreadName());
} }

@ -2,39 +2,51 @@ package net.yacy.peers.operation;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Locale;
import java.util.Properties; import java.util.Properties;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public final class yacyBuildProperties { public final class yacyBuildProperties {
private static Properties props = new Properties(); private static Properties props = new Properties();
static { static {
try { try {
props.load(new FileInputStream("defaults/yacyBuild.properties")); props.load(new FileInputStream("defaults/yacyBuild.properties"));
} catch (IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
props = null; props = null;
} }
} }
public static String getSVNRevision() { public static String getVersion() {
if (props == null) return "0"; return props.getProperty("Version", "0.1");
final String revision = props.getProperty("SVNRevision");
return revision.contains("@") || revision.contains("$") ? "0" : revision;
} }
public static String getVersion() { public static String getRepositoryVersionDate() {
if (props == null) return "0.1"; return props.getProperty("RepositoryVersionDate", "20220101");
final String version = props.getProperty("Version"); }
return version.contains("@") ? "0.1" : version;
public static String getRepositoryVersionTime() {
return props.getProperty("RepositoryVersionTime", "0000");
}
public static String getRepositoryVersionHash() {
return props.getProperty("RepositoryVersionHash", "0");
}
public static String getReleaseStub() {
return props.getProperty("ReleaseStub", "yacy_v0.1_202201010000_000000000");
} }
public static final Pattern versionMatcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z"); public static String getDstamp() {
return props.getProperty("dstamp", "20220101");
public static String getLongVersion() {
return String.format(Locale.US, "%.3f%05d", Float.valueOf(getVersion()), Integer.valueOf(getSVNRevision()));
} }
public static String getTstamp() {
return props.getProperty("tstamp", "0000");
}
public static final Pattern versionMatcher = Pattern.compile("\\A(\\d+\\.\\d{1,3})(\\d{0,5})\\z");
} }

@ -79,10 +79,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
if (thisVersion == null) { if (thisVersion == null) {
final Switchboard sb = Switchboard.getSwitchboard(); final Switchboard sb = Switchboard.getSwitchboard();
if (sb == null) return null; if (sb == null) return null;
thisVersion = new yacyVersion( thisVersion = new yacyVersion(yacyBuildProperties.getReleaseStub() + ".tar.gz", null);
"yacy" +
"_v" + yacyBuildProperties.getVersion() + "_" +
yacyBuildProperties.getSVNRevision() + ".tar.gz", null);
} }
return thisVersion; return thisVersion;
} }
@ -134,17 +131,17 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
* "dev/00000" - If the input does not matcht the regular expression above * "dev/00000" - If the input does not matcht the regular expression above
*/ */
public static String[] combined2prettyVersion(final String ver) { public static String[] combined2prettyVersion(final String ver) {
return combined2prettyVersion(ver, ""); return combined2prettyVersion(ver, "");
} }
public static String[] combined2prettyVersion(final String ver, final String computerName) { public static String[] combined2prettyVersion(final String ver, final String computerName) {
final Matcher matcher = yacyBuildProperties.versionMatcher.matcher(ver); final Matcher matcher = yacyBuildProperties.versionMatcher.matcher(ver);
if (!matcher.find()) { if (!matcher.find()) {
ConcurrentLog.warn("STARTUP", "Peer '"+computerName+"': wrong format of version-string: '" + ver + "'. Using default string 'dev/00000' instead"); ConcurrentLog.warn("STARTUP", "Peer '"+computerName+"': wrong format of version-string: '" + ver + "'. Using default string 'dev/00000' instead");
return new String[]{"dev", "0000"}; return new String[]{"dev", "0000"};
} }
final String mainversion = (Double.parseDouble(matcher.group(1)) < 0.11 ? "dev" : matcher.group(1)); final String mainversion = (Double.parseDouble(matcher.group(1)) < 0.11 ? "dev" : matcher.group(1));
String revision = matcher.group(2); String revision = matcher.group(2);
for(int i=revision.length();i<4;++i) revision += "0"; for(int i=revision.length();i<4;++i) revision += "0";
return new String[]{mainversion, revision}; return new String[]{mainversion, revision};
@ -166,7 +163,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
*/ */
public static double versvn2combinedVersion(final double version, final int svn) { public static double versvn2combinedVersion(final double version, final int svn) {
return (Math.rint((version*100000000.0) + (svn))/100000000); return (Math.rint((version*100000000.0) + (svn))/100000000);
} }
/** /**
* Timestamp of this version * Timestamp of this version

@ -4497,7 +4497,7 @@ public final class Switchboard extends serverSwitch {
mySeed.put(Seed.ICOUNT, Long.toString(this.index.RWICount())); // the minimum number of words that the peer has indexed (as it says) mySeed.put(Seed.ICOUNT, Long.toString(this.index.RWICount())); // the minimum number of words that the peer has indexed (as it says)
mySeed.put(Seed.SCOUNT, Integer.toString(this.peers.sizeConnected())); // the number of seeds that the peer has stored mySeed.put(Seed.SCOUNT, Integer.toString(this.peers.sizeConnected())); // the number of seeds that the peer has stored
mySeed.put(Seed.CCOUNT, Float.toString(((int) ((this.peers.sizeConnected() + this.peers.sizeDisconnected() + this.peers.sizePotential()) * 60.0f / (uptime + 1.01f)) * 100.0f) / 100.0f)); // the number of clients that the peer connects (as connects/hour) mySeed.put(Seed.CCOUNT, Float.toString(((int) ((this.peers.sizeConnected() + this.peers.sizeDisconnected() + this.peers.sizePotential()) * 60.0f / (uptime + 1.01f)) * 100.0f) / 100.0f)); // the number of clients that the peer connects (as connects/hour)
mySeed.put(Seed.VERSION, yacyBuildProperties.getLongVersion()); mySeed.put(Seed.VERSION, yacyBuildProperties.getReleaseStub());
mySeed.setFlagDirectConnect(true); mySeed.setFlagDirectConnect(true);
mySeed.setLastSeenUTC(); mySeed.setLastSeenUTC();
mySeed.put(Seed.UTC, GenericFormatter.UTCDiffString()); mySeed.put(Seed.UTC, GenericFormatter.UTCDiffString());

@ -84,40 +84,40 @@ import net.yacy.utils.translation.TranslatorXliff;
/** /**
* This is the main class of YaCy. Several threads are started from here: * This is the main class of YaCy. Several threads are started from here:
* <ul> * <ul>
* <li>one single instance of the plasmaSwitchboard is generated, which itself * <li>one single instance of the plasmaSwitchboard is generated, which itself
* starts a thread with a plasmaHTMLCache object. This object simply counts * starts a thread with a plasmaHTMLCache object. This object simply counts
* files sizes in the cache and terminates them. It also generates a * files sizes in the cache and terminates them. It also generates a
* plasmaCrawlerLoader object, which may itself start some more httpc-calling * plasmaCrawlerLoader object, which may itself start some more httpc-calling
* threads to load web pages. They terminate automatically when a page has * threads to load web pages. They terminate automatically when a page has
* loaded. * loaded.
* <li>one serverCore - thread is started, which implements a multi-threaded * <li>one serverCore - thread is started, which implements a multi-threaded
* server. The process may start itself many more processes that handle * server. The process may start itself many more processes that handle
* connections.lo * connections.lo
* <li>finally, all idle-dependent processes are written in a queue in * <li>finally, all idle-dependent processes are written in a queue in
* plasmaSwitchboard which are worked off inside an idle-sensitive loop of the * plasmaSwitchboard which are worked off inside an idle-sensitive loop of the
* main process. (here) * main process. (here)
* </ul> * </ul>
* *
* On termination, the following must be done: * On termination, the following must be done:
* <ul> * <ul>
* <li>stop feeding of the crawling process because it otherwise fills the * <li>stop feeding of the crawling process because it otherwise fills the
* indexing queue. * indexing queue.
* <li>say goodbye to connected peers and disable new connections. Don't wait for * <li>say goodbye to connected peers and disable new connections. Don't wait for
* success. * success.
* <li>first terminate the serverCore thread. This prevents that new cache * <li>first terminate the serverCore thread. This prevents that new cache
* objects are queued. * objects are queued.
* <li>wait that the plasmaHTMLCache terminates (it should be normal that this * <li>wait that the plasmaHTMLCache terminates (it should be normal that this
* process already has terminated). * process already has terminated).
* <li>then wait for termination of all loader process of the * <li>then wait for termination of all loader process of the
* plasmaCrawlerLoader. * plasmaCrawlerLoader.
* <li>work off the indexing and cache storage queue. These values are inside a * <li>work off the indexing and cache storage queue. These values are inside a
* RAM cache and would be lost otherwise. * RAM cache and would be lost otherwise.
* <li>write all settings. * <li>write all settings.
* <li>terminate. * <li>terminate.
* </ul> * </ul>
*/ */
public final class yacy { public final class yacy {
@ -139,12 +139,12 @@ public final class yacy {
private static Switchboard sb = null; private static Switchboard sb = null;
/** /**
* Starts up the whole application. Sets up all datastructures and starts * Starts up the whole application. Sets up all datastructures and starts
* the main threads. * the main threads.
* *
* @param homePath Root-path where all information is to be found. * @param homePath Root-path where all information is to be found.
* @param startupFree free memory at startup time, to be used later for statistics * @param startupFree free memory at startup time, to be used later for statistics
*/ */
private static void startup(final File dataHome, final File appHome, final long startupMemFree, final long startupMemTotal, final boolean gui) { private static void startup(final File dataHome, final File appHome, final long startupMemFree, final long startupMemTotal, final boolean gui) {
String tmpdir=null; String tmpdir=null;
try { try {
@ -185,7 +185,7 @@ public final class yacy {
System.out.println("could not find logging properties in homePath=" + dataHome); System.out.println("could not find logging properties in homePath=" + dataHome);
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
} }
ConcurrentLog.config("STARTUP", "YaCy version: " + yacyBuildProperties.getVersion() + "/" + yacyBuildProperties.getSVNRevision()); ConcurrentLog.config("STARTUP", "YaCy version: " + yacyBuildProperties.getReleaseStub());
ConcurrentLog.config("STARTUP", "Java version: " + System.getProperty("java.version", "no-java-version")); ConcurrentLog.config("STARTUP", "Java version: " + System.getProperty("java.version", "no-java-version"));
ConcurrentLog.config("STARTUP", "Operation system: " + System.getProperty("os.name","unknown")); ConcurrentLog.config("STARTUP", "Operation system: " + System.getProperty("os.name","unknown"));
ConcurrentLog.config("STARTUP", "Application root-path: " + appHome); ConcurrentLog.config("STARTUP", "Application root-path: " + appHome);
@ -235,7 +235,7 @@ public final class yacy {
if (oldRev > 1) { if (oldRev > 1) {
oldVer = Double.parseDouble(tmpversion) + oldRev / 100000000.0; oldVer = Double.parseDouble(tmpversion) + oldRev / 100000000.0;
} else { } else {
oldVer = Double.parseDouble(yacyBuildProperties.getLongVersion()); // failsafe (assume current version = no migration) oldVer = Double.parseDouble(yacyBuildProperties.getVersion()); // failsafe (assume current version = no migration)
} }
} else { } else {
oldVer = Double.parseDouble(tmpversion); oldVer = Double.parseDouble(tmpversion);
@ -243,8 +243,8 @@ public final class yacy {
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
oldVer = 0.0d; oldVer = 0.0d;
} }
final double newRev = Double.parseDouble(yacyBuildProperties.getLongVersion()); final double newRev = Double.parseDouble(yacyBuildProperties.getVersion());
sb.setConfig(Seed.VERSION, yacyBuildProperties.getLongVersion()); sb.setConfig(Seed.VERSION, yacyBuildProperties.getVersion());
sb.setConfig("applicationRoot", appHome.toString()); sb.setConfig("applicationRoot", appHome.toString());
sb.setConfig("dataRoot", dataHome.toString()); sb.setConfig("dataRoot", dataHome.toString());
@ -262,16 +262,16 @@ public final class yacy {
final File htdocsReadme = new File(htDocsPath, "readme.txt"); final File htdocsReadme = new File(htDocsPath, "readme.txt");
if (!(htdocsReadme.exists())) try {FileUtils.copy(( if (!(htdocsReadme.exists())) try {FileUtils.copy((
"This is your root directory for individual Web Content\r\n" + "This is your root directory for individual Web Content\r\n" +
"\r\n" + "\r\n" +
"Please place your html files into the www subdirectory.\r\n" + "Please place your html files into the www subdirectory.\r\n" +
"The URL of that path is either\r\n" + "The URL of that path is either\r\n" +
"http://www.<your-peer-name>.yacy or\r\n" + "http://www.<your-peer-name>.yacy or\r\n" +
"http://<your-ip>:<your-port>/www\r\n" + "http://<your-ip>:<your-port>/www\r\n" +
"\r\n" + "\r\n" +
"Other subdirectories may be created; they map to corresponding sub-domains.\r\n" + "Other subdirectories may be created; they map to corresponding sub-domains.\r\n" +
"This directory shares it's content with the applications htroot path, so you\r\n" + "This directory shares it's content with the applications htroot path, so you\r\n" +
"may access your yacy search page with\r\n" + "may access your yacy search page with\r\n" +
"http://<your-peer-name>.yacy/\r\n" + "http://<your-peer-name>.yacy/\r\n" +
"\r\n").getBytes(), htdocsReadme);} catch (final IOException e) { "\r\n").getBytes(), htdocsReadme);} catch (final IOException e) {
System.out.println("Error creating htdocs readme: " + e.getMessage()); System.out.println("Error creating htdocs readme: " + e.getMessage());
} }
@ -314,7 +314,7 @@ public final class yacy {
Browser.openBrowser(("http://localhost:"+port) + "/" + browserPopUpPage); Browser.openBrowser(("http://localhost:"+port) + "/" + browserPopUpPage);
} }
}.start(); }.start();
// Browser.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage); // Browser.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage);
} catch (final Throwable e) { } catch (final Throwable e) {
// cannot open browser. This may be normal in headless environments // cannot open browser. This may be normal in headless environments
//Log.logException(e); //Log.logException(e);
@ -377,11 +377,11 @@ public final class yacy {
// save information about available memory after all initializations // save information about available memory after all initializations
//try { //try {
sb.setConfig("memoryFreeAfterInitBGC", MemoryControl.free()); sb.setConfig("memoryFreeAfterInitBGC", MemoryControl.free());
sb.setConfig("memoryTotalAfterInitBGC", MemoryControl.total()); sb.setConfig("memoryTotalAfterInitBGC", MemoryControl.total());
System.gc(); System.gc();
sb.setConfig("memoryFreeAfterInitAGC", MemoryControl.free()); sb.setConfig("memoryFreeAfterInitAGC", MemoryControl.free());
sb.setConfig("memoryTotalAfterInitAGC", MemoryControl.total()); sb.setConfig("memoryTotalAfterInitAGC", MemoryControl.total());
//} catch (final ConcurrentModificationException e) {} //} catch (final ConcurrentModificationException e) {}
// wait for server shutdown // wait for server shutdown
@ -446,15 +446,15 @@ public final class yacy {
} }
/** /**
* Loads the configuration from the data-folder. * Loads the configuration from the data-folder.
* FIXME: Why is this called over and over again from every method, instead * FIXME: Why is this called over and over again from every method, instead
* of setting the configurationdata once for this class in main? * of setting the configurationdata once for this class in main?
* *
* @param mes Where are we called from, so that the errormessages can be * @param mes Where are we called from, so that the errormessages can be
* more descriptive. * more descriptive.
* @param homePath Root-path where all the information is to be found. * @param homePath Root-path where all the information is to be found.
* @return Properties read from the configurationfile. * @return Properties read from the configurationfile.
*/ */
private static Properties configuration(final String mes, final File homePath) { private static Properties configuration(final String mes, final File homePath) {
ConcurrentLog.config(mes, "Application Root Path: " + homePath.toString()); ConcurrentLog.config(mes, "Application Root Path: " + homePath.toString());
@ -490,11 +490,11 @@ public final class yacy {
} }
/** /**
* Call the shutdown-page of YaCy to tell it to shut down. This method is * Call the shutdown-page of YaCy to tell it to shut down. This method is
* called if you start yacy with the argument -shutdown. * called if you start yacy with the argument -shutdown.
* *
* @param homePath Root-path where all the information is to be found. * @param homePath Root-path where all the information is to be found.
*/ */
public static void shutdown(final File homePath) { public static void shutdown(final File homePath) {
// start up // start up
System.out.println(copyright); System.out.println(copyright);
@ -773,51 +773,51 @@ public final class yacy {
// show yacy version // show yacy version
System.out.println(copyright); System.out.println(copyright);
} else if ((args.length > 1) && (args[0].toLowerCase(Locale.ROOT).equals("-config"))) { } else if ((args.length > 1) && (args[0].toLowerCase(Locale.ROOT).equals("-config"))) {
// set config parameter. Special handling of adminAccount=user:pwd (generates md5 encoded password) // set config parameter. Special handling of adminAccount=user:pwd (generates md5 encoded password)
// on Windows parameter should be enclosed in doublequotes to accept = sign (e.g. -config "port=8090" "port.ssl=8043") // on Windows parameter should be enclosed in doublequotes to accept = sign (e.g. -config "port=8090" "port.ssl=8043")
final File f = new File (dataRoot,"DATA/SETTINGS/"); final File f = new File (dataRoot,"DATA/SETTINGS/");
if (!f.exists()) { if (!f.exists()) {
mkdirsIfNeseccary(f); mkdirsIfNeseccary(f);
} else { } else {
if (new File(dataRoot, "DATA/yacy.running").exists()) { if (new File(dataRoot, "DATA/yacy.running").exists()) {
System.out.println("please restart YaCy"); System.out.println("please restart YaCy");
}
} }
// use serverSwitch to read config properties (including init values from yacy.init }
final serverSwitch ss = new serverSwitch(dataRoot,applicationRoot,"defaults/yacy.init","DATA/SETTINGS/yacy.conf"); // use serverSwitch to read config properties (including init values from yacy.init
final serverSwitch ss = new serverSwitch(dataRoot,applicationRoot,"defaults/yacy.init","DATA/SETTINGS/yacy.conf");
for (int icnt=1; icnt < args.length ; icnt++) {
final String cfg = args[icnt]; for (int icnt=1; icnt < args.length ; icnt++) {
final int pos = cfg.indexOf('='); final String cfg = args[icnt];
if (pos > 0) { final int pos = cfg.indexOf('=');
final String cmd = cfg.substring(0, pos); if (pos > 0) {
final String val = cfg.substring(pos + 1); final String cmd = cfg.substring(0, pos);
final String val = cfg.substring(pos + 1);
if (!val.isEmpty()) {
if (cmd.equalsIgnoreCase(SwitchboardConstants.ADMIN_ACCOUNT)) { // special command to set adminusername and md5-pwd if (!val.isEmpty()) {
final int cpos = val.indexOf(':'); //format adminAccount=adminname:adminpwd if (cmd.equalsIgnoreCase(SwitchboardConstants.ADMIN_ACCOUNT)) { // special command to set adminusername and md5-pwd
if (cpos >= 0) { final int cpos = val.indexOf(':'); //format adminAccount=adminname:adminpwd
String username = val.substring(0, cpos); if (cpos >= 0) {
final String pwdtxt = val.substring(cpos + 1); String username = val.substring(0, cpos);
if (!username.isEmpty()) { final String pwdtxt = val.substring(cpos + 1);
ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, username); if (!username.isEmpty()) {
System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME + " = " + username); ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, username);
} else { System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME + " = " + username);
username = ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"); } else {
} username = ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, sb.encodeDigestAuth(username, pwdtxt));
System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_B64MD5 + " = " + ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));
} }
} else { ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, sb.encodeDigestAuth(username, pwdtxt));
ss.setConfig(cmd, val); System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_B64MD5 + " = " + ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));
System.out.println("Set property " + cmd + " = " + val);
} }
} else {
ss.setConfig(cmd, val);
System.out.println("Set property " + cmd + " = " + val);
} }
} else {
System.out.println("skip parameter " + cfg + " (equal sign missing, put parameter in doublequotes)");
} }
System.out.println(); } else {
System.out.println("skip parameter " + cfg + " (equal sign missing, put parameter in doublequotes)");
} }
System.out.println();
}
} else { } else {
if (args.length == 1) { if (args.length == 1) {
applicationRoot= new File(args[0]); applicationRoot= new File(args[0]);
@ -832,9 +832,9 @@ public final class yacy {
} }
/** /**
* This class is a helper class whose instance is started, when the java virtual * This class is a helper class whose instance is started, when the java virtual
* machine shuts down. Signals the plasmaSwitchboard to shut down. * machine shuts down. Signals the plasmaSwitchboard to shut down.
*/ */
class shutdownHookThread extends Thread { class shutdownHookThread extends Thread {
private final Switchboard sb; private final Switchboard sb;
private final Semaphore shutdownSemaphore; private final Semaphore shutdownSemaphore;

Loading…
Cancel
Save