summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorreger <reger18@arcor.de>2014-02-24 05:16:31 +0100
committerreger <reger18@arcor.de>2014-02-24 05:16:31 +0100
commita9b06f87190fc9f94a7a2dbafc32c30766062f24 (patch)
tree6524e0831aebf413fcb693da66a7f7f88f6a9d72
parentedc8e1c4ded0cd7bc1f56c0642f80464500c9c13 (diff)
add a -config command line parameter e.g. -config "port=9090" "port.ssl=8043"
- useful for remote installation to set any config file property - multipe parameter can be set at once, on Windows enclose parameter in doublequotes - special handling "adminAccount=adminuser:adminpwd" sets adminusername and md5 encoded admin-pwd - adjusted windows startbatch to allow command line parameter handling - remove not needed classpath calculation from startYACY_debug.bat
-rw-r--r--source/net/yacy/yacy.java53
-rw-r--r--startYACY.bat7
-rw-r--r--startYACY_debug.bat15
3 files changed, 64 insertions, 11 deletions
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index e55af3fdf..69c48dfe9 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -63,9 +63,14 @@ import net.yacy.peers.operation.yacyVersion;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import com.google.common.io.Files;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import net.yacy.cora.document.id.DigestURL;
import net.yacy.cora.federate.yacy.CacheStrategy;
+import net.yacy.cora.order.Base64Order;
+import net.yacy.cora.order.Digest;
import net.yacy.crawler.retrieval.Response;
+import net.yacy.server.serverSwitch;
/**
@@ -635,7 +640,53 @@ public final class yacy {
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-version"))) {
// show yacy version
System.out.println(copyright);
- } else {
+ } else if ((args.length > 1) && (args[0].toLowerCase().equals("-config"))) {
+ // 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")
+ File f = new File (dataRoot,"DATA/SETTINGS/");
+ if (!f.exists()) {
+ mkdirsIfNeseccary(f);
+ } else {
+ if (new File(dataRoot, "DATA/yacy.running").exists()) {
+ System.out.println("please restart YaCy");
+ }
+ }
+ // use serverSwitch to read config properties (including init values from yacy.init
+ serverSwitch ss = new serverSwitch(dataRoot,applicationRoot,"defaults/yacy.init","DATA/SETTINGS/yacy.conf");
+
+ for (int icnt=1; icnt < args.length ; icnt++) {
+ String cfg = args[icnt];
+ int pos = cfg.indexOf('=');
+ if (pos > 0) {
+ String cmd = cfg.substring(0, pos);
+ String val = cfg.substring(pos + 1);
+
+ if (!val.isEmpty()) {
+ if (cmd.equalsIgnoreCase(SwitchboardConstants.ADMIN_ACCOUNT)) { // special command to set adminusername and md5-pwd
+ int cpos = val.indexOf(':'); //format adminAccount=adminname:adminpwd
+ if (cpos >= 0) {
+ String username = val.substring(0, cpos);
+ String pwdtxt = val.substring(cpos + 1);
+ if (!username.isEmpty()) {
+ ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, username);
+ System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME + " = " + username);
+ } else {
+ username = ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
+ }
+ ss.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "MD5:" + Digest.encodeMD5Hex(username + ":" + ss.getConfig(SwitchboardConstants.ADMIN_REALM, "YaCy") + ":" + pwdtxt));
+ System.out.println("Set property " + SwitchboardConstants.ADMIN_ACCOUNT_B64MD5 + " = " + ss.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""));
+ }
+ } 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 {
if (args.length == 1) applicationRoot= new File(args[0]);
preReadSavedConfigandInit(dataRoot);
startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false);
diff --git a/startYACY.bat b/startYACY.bat
index a70f48416..205b6b1f5 100644
--- a/startYACY.bat
+++ b/startYACY.bat
@@ -30,7 +30,12 @@ Echo.
Echo You can download Java at http://java.com/
Echo.
Echo ***************************************************************************
-start %priority% javaw %javacmd% -classpath %CLASSPATH% net.yacy.yacy
+Rem commandline parameter added for -config option, like -config "port=8090" "adminAccount=admin:password"
+Rem special parameter "adminAccount=admin:password" calculates and sets new admin-pwd
+Rem any parameter in yacy.conf can me modified this way (make sure to use correct upper/lower case)
+
+start %priority% javaw %javacmd% -classpath %CLASSPATH% net.yacy.yacy %1 %2 %3 %4 %5 %6 %7 %8 %9
+
Echo You can close the console safely now.
GoTo :END
diff --git a/startYACY_debug.bat b/startYACY_debug.bat
index 87c429957..3af009b59 100644
--- a/startYACY_debug.bat
+++ b/startYACY_debug.bat
@@ -3,11 +3,8 @@ title YaCy
if exist DATA\yacy.noconsole del DATA\yacy.noconsole
-If %1.==CPGEN. GoTo :CPGEN
-
Rem Generating the proper classpath unsing loops and labels
-Set CLASSPATH=htroot
-For %%X in (lib/*.jar) Do Call %0 CPGEN lib\%%X
+Set CLASSPATH=lib/yacycore.jar;htroot
REM Please change the "javastart" settings in the web-interface "Basic Configuration" -> "Advanced"
set jmx=
@@ -37,7 +34,11 @@ Echo ^>^> YaCy started as daemon process. Administration at http://localhost:%p
title YaCy - http://localhost:%port%
-start "YaCy" %priority% /B /WAIT java %javacmd% -classpath %CLASSPATH% net.yacy.yacy
+Rem commandline parameter added for -config option, like -config "port=8090" "adminAccount=admin:password"
+Rem special parameter "adminAccount=admin:password" calculates and sets new admin-pwd
+Rem any parameter in yacy.conf can me modified this way (make sure to use correct upper/lower case)
+
+start "YaCy" %priority% /B /WAIT java %javacmd% -classpath %CLASSPATH% net.yacy.yacy %1 %2 %3 %4 %5 %6 %7 %8 %9
if not exist DATA\yacy.restart GoTo :END
del DATA\yacy.restart
@@ -71,9 +72,5 @@ if defined priolvl (
GoTo :STARTJAVA
-Rem This target is used to concatenate the classpath parts
-:CPGEN
-Set CLASSPATH=%CLASSPATH%;%2
-
Rem Target needed to jump to the end of the file
:END