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
pull/1/head
reger 11 years ago
parent edc8e1c4de
commit a9b06f8719

@ -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);

@ -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

@ -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

Loading…
Cancel
Save