added new command script to do a auto-Update from command line. this will make it easy to do mass-auto-updates in private yacy clusters

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6052 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 0fc1168554
commit 550312ac85

@ -553,12 +553,22 @@ public final class yacy {
*
* @param homePath Root-path where all the information is to be found.
*/
static void shutdown(final File homePath) {
public static void shutdown(final File homePath) {
// start up
System.out.println(copyright);
System.out.println(hline);
submitURL(homePath, "Steering.html?shutdown=", "Terminate YaCy");
}
final Properties config = configuration("REMOTE-SHUTDOWN", homePath);
public static void update(final File homePath) {
// start up
System.out.println(copyright);
System.out.println(hline);
submitURL(homePath, "ConfigUpdate_p.html?autoUpdate=", "Update YaCy to most recent version");
}
private static void submitURL(final File homePath, String path, String processdescription) {
final Properties config = configuration("COMMAND-STEERING", homePath);
// read port
final int port = serverCore.getPortNr(config.getProperty("port", "8080"));
@ -573,12 +583,11 @@ public final class yacy {
final httpClient con = new httpClient(10000, requestHeader);
httpResponse res = null;
try {
res = con.GET("http://localhost:"+ port +"/Steering.html?shutdown=");
res = con.GET("http://localhost:"+ port +"/" + path);
// read response
if (res.getStatusLine().startsWith("2")) {
Log.logConfig("REMOTE-SHUTDOWN", "YACY accepted shutdown command.");
Log.logConfig("REMOTE-SHUTDOWN", "Stand by for termination, which may last some seconds.");
Log.logConfig("COMMAND-STEERING", "YACY accepted steering command: " + processdescription);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(bos));
@ -586,11 +595,11 @@ public final class yacy {
res.closeStream();
}
} else {
Log.logSevere("REMOTE-SHUTDOWN", "error response from YACY socket: " + res.getStatusLine());
Log.logSevere("COMMAND-STEERING", "error response from YACY socket: " + res.getStatusLine());
System.exit(-1);
}
} catch (final IOException e) {
Log.logSevere("REMOTE-SHUTDOWN", "could not establish connection to YACY socket: " + e.getMessage());
Log.logSevere("COMMAND-STEERING", "could not establish connection to YACY socket: " + e.getMessage());
System.exit(-1);
} finally {
// release connection
@ -600,8 +609,7 @@ public final class yacy {
}
// finished
Log.logConfig("REMOTE-SHUTDOWN", "SUCCESSFULLY FINISHED remote-shutdown:");
Log.logConfig("REMOTE-SHUTDOWN", "YACY will terminate after working off all enqueued tasks.");
Log.logConfig("COMMAND-STEERING", "SUCCESSFULLY FINISHED COMMAND: " + processdescription);
}
/**
@ -995,6 +1003,10 @@ public final class yacy {
// normal shutdown of yacy
if (args.length == 2) applicationRoot= new File(args[1]);
shutdown(applicationRoot);
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-update"))) {
// aut-update yacy
if (args.length == 2) applicationRoot= new File(args[1]);
update(applicationRoot);
} else if ((args.length >= 1) && (args[0].toLowerCase().equals("-minimizeurldb"))) {
// migrate words from DATA/PLASMADB/WORDS path to assortment cache, if possible
// attention: this may run long and should not be interrupted!

@ -0,0 +1,22 @@
#!/bin/sh
cd `dirname $0`
if [ -x `which wget` ]
then
port=`cat DATA/SETTINGS/yacy.conf |grep "^port="|sed "s/.*=//"`
pw=`cat DATA/SETTINGS/yacy.conf |grep "^adminAccountBase64MD5="|sed "s/.*=//"`
wget -q -t 1 --timeout=5 --header "Authorization: realm=$pw" http://localhost:$port/ConfigUpdate_p.html?autoUpdate= -O /dev/null
elif [ -x `which java` ]
then
# generating the proper classpath
CLASSPATH=""
for N in lib/*.jar; do CLASSPATH="$CLASSPATH$N:"; done
for N in libx/*.jar; do CLASSPATH="$CLASSPATH$N:"; done
java -classpath classes:htroot:$CLASSPATH yacy -update
else
port=`cat DATA/SETTINGS/yacy.conf |grep "^port="|sed "s/.*=//"`
echo "Neither wget nor java could be found or are not executable."
fi
Loading…
Cancel
Save