From f3f478448bab001849d3d621c159a2a0de8758cc Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 2 Sep 2016 11:22:39 +0200 Subject: [PATCH 1/5] Explicitely set YaCy data folder when starting in MacOS bundle --- addon/YaCy.app/Contents/Info.plist | 2 +- addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh | 8 ++++++++ build.xml | 3 ++- startYACY.sh | 17 +++++++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100755 addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh diff --git a/addon/YaCy.app/Contents/Info.plist b/addon/YaCy.app/Contents/Info.plist index 69804aa9f..5f772f193 100644 --- a/addon/YaCy.app/Contents/Info.plist +++ b/addon/YaCy.app/Contents/Info.plist @@ -19,7 +19,7 @@ CFBundleAllowMixedLocalizations true CFBundleExecutable -startYACY.sh +startYACYMacOS.sh CFBundleDevelopmentRegion English CFBundlePackageType diff --git a/addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh b/addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh new file mode 100755 index 000000000..456ddea4e --- /dev/null +++ b/addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +# Launcher for YaCy in a MacOS bundle : +# rely on the generic startYACY.sh, but specifies the user home relative path for YaCy data +# This data directory is set in conforming to OS X File System Programming Guide +# see : https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html + +"`dirname $0`"/startYACY.sh -startup "'Library/Application Support/net.yacy.YaCy'" diff --git a/build.xml b/build.xml index 879296ef4..14acd7b66 100644 --- a/build.xml +++ b/build.xml @@ -764,7 +764,8 @@ - + + diff --git a/startYACY.sh b/startYACY.sh index 8763b9086..567cc5e89 100755 --- a/startYACY.sh +++ b/startYACY.sh @@ -40,6 +40,7 @@ Options -l, --logging save the output of YaCy to yacy.log -d, --debug show the output of YaCy on the console -p, --print-out only print the command, which would be executed to start YaCy + -start, -startup [data-path] start YaCy using the specified data folder path, relative to the current user home -g, --gui start a gui for YaCy USAGE } @@ -101,6 +102,10 @@ for option in $options;do -t|--tail-log) TAILLOG=1 ;; + -start|-startup) + STARTUP=1 + isparameter=1 + ;; -g|--gui) GUI=1 isparameter=1 @@ -111,7 +116,11 @@ for option in $options;do isparameter=1; continue else - parameter="$parameter $option" + if [ $parameter ];then + parameter="$parameter $option" + else + parameter="$option" + fi fi fi #parameter or option? done @@ -189,7 +198,11 @@ for N in lib/*.jar; do CLASSPATH="$CLASSPATH$N:"; done CLASSPATH=".:$CLASSPATH" cmdline="$JAVA $JAVA_ARGS -classpath $CLASSPATH net.yacy.yacy"; -if [ $GUI -eq 1 ] #gui + +if [ $STARTUP -eq 1 ] #startup +then + cmdline="$cmdline -startup $parameter" +elif [ $GUI -eq 1 ] #gui then cmdline="$cmdline -gui $parameter" fi From 1dc4306058a3354f61435d403561829590fc4e9d Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 2 Sep 2016 11:23:02 +0200 Subject: [PATCH 2/5] Fixed indentation for better readability. --- source/net/yacy/yacy.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java index db7bbce51..44803ec6e 100644 --- a/source/net/yacy/yacy.java +++ b/source/net/yacy/yacy.java @@ -713,13 +713,17 @@ public final class yacy { //System.out.print("args=["); for (int i = 0; i < args.length; i++) System.out.print(args[i] + ", "); System.out.println("]"); if ((args.length >= 1) && (args[0].toLowerCase().equals("-startup") || args[0].equals("-start"))) { // normal start-up of yacy - if (args.length > 1) dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); - preReadSavedConfigandInit(dataRoot); + if (args.length > 1) { + dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); + } + preReadSavedConfigandInit(dataRoot); startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false); } else if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) { // start-up of yacy with gui - if (args.length > 1) dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); - preReadSavedConfigandInit(dataRoot); + if (args.length > 1) { + dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); + } + preReadSavedConfigandInit(dataRoot); startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, true); } else if ((args.length >= 1) && ((args[0].toLowerCase().equals("-shutdown")) || (args[0].equals("-stop")))) { // normal shutdown of yacy @@ -732,7 +736,7 @@ public final class yacy { } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-version"))) { // show yacy version System.out.println(copyright); - } else if ((args.length > 1) && (args[0].toLowerCase().equals("-config"))) { + } 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/"); @@ -778,9 +782,11 @@ public final class yacy { } System.out.println(); } - } else { - if (args.length == 1) applicationRoot= new File(args[0]); - preReadSavedConfigandInit(dataRoot); + } else { + if (args.length == 1) { + applicationRoot= new File(args[0]); + } + preReadSavedConfigandInit(dataRoot); startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false); } } finally { From 24b87412921c6e247d28e7fbe19b388d4124e71e Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 2 Sep 2016 11:55:46 +0200 Subject: [PATCH 3/5] Fix for startup option - Var initialization - Declaration in getopt --- startYACY.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/startYACY.sh b/startYACY.sh index 567cc5e89..5e52a9292 100755 --- a/startYACY.sh +++ b/startYACY.sh @@ -40,7 +40,7 @@ Options -l, --logging save the output of YaCy to yacy.log -d, --debug show the output of YaCy on the console -p, --print-out only print the command, which would be executed to start YaCy - -start, -startup [data-path] start YaCy using the specified data folder path, relative to the current user home + --start, --startup [data-path] start YaCy using the specified data folder path, relative to the current user home -g, --gui start a gui for YaCy USAGE } @@ -57,7 +57,7 @@ then options="`getopt hdlptg: $*`" else - options="`getopt -n YaCy -o h,d,l,p,t,g -l help,debug,logging,print-out,tail-log,gui -- $@`" + options="`getopt -n YaCy -o h,d,l,p,t,g -l help,debug,logging,print-out,tail-log,gui,start,startup -- $@`" fi if [ $? -ne 0 ];then @@ -72,6 +72,7 @@ LOGGING=0 DEBUG=0 PRINTONLY=0 TAILLOG=0 +STARTUP=0 GUI=0 for option in $options;do if [ $isparameter -ne 1 ];then #option @@ -202,8 +203,7 @@ cmdline="$JAVA $JAVA_ARGS -classpath $CLASSPATH net.yacy.yacy"; if [ $STARTUP -eq 1 ] #startup then cmdline="$cmdline -startup $parameter" -elif [ $GUI -eq 1 ] #gui -then +elif [ $GUI -eq 1 ];then #gui cmdline="$cmdline -gui $parameter" fi if [ $DEBUG -eq 1 ] #debug From 421a6e3a95ee7db257a79c35c5bb3bf6067d676b Mon Sep 17 00:00:00 2001 From: luccioman Date: Sat, 3 Sep 2016 14:46:58 +0200 Subject: [PATCH 4/5] Fixed options processing for Mac OS - getopt is BSD style and does not support long options - fixed typing error inparameter value extracting for all platforms --- addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh | 2 +- startYACY.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh b/addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh index 456ddea4e..692ec913f 100755 --- a/addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh +++ b/addon/YaCy.app/Contents/MacOS/startYACYMacOS.sh @@ -5,4 +5,4 @@ # This data directory is set in conforming to OS X File System Programming Guide # see : https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html -"`dirname $0`"/startYACY.sh -startup "'Library/Application Support/net.yacy.YaCy'" +"`dirname $0`"/startYACY.sh -s "'Library/Application Support/net.yacy.YaCy'" diff --git a/startYACY.sh b/startYACY.sh index 5e52a9292..f935ae2e3 100755 --- a/startYACY.sh +++ b/startYACY.sh @@ -40,7 +40,7 @@ Options -l, --logging save the output of YaCy to yacy.log -d, --debug show the output of YaCy on the console -p, --print-out only print the command, which would be executed to start YaCy - --start, --startup [data-path] start YaCy using the specified data folder path, relative to the current user home + -s, --startup [data-path] start YaCy using the specified data folder path, relative to the current user home -g, --gui start a gui for YaCy USAGE } @@ -48,16 +48,16 @@ USAGE #startup YaCy cd "`dirname $0`" -if [ $OS = "OpenBSD" ] +if [ $OS = "OpenBSD" ] || [ $OS = "Darwin" ] then if [ $(echo $@ | grep -o "\-\-" | wc -l) -ne 0 ] then echo "WARNING: Unfortunately this script does not support long options in $OS." fi - options="`getopt hdlptg: $*`" + options="`getopt hdlptsg: $*`" else - options="`getopt -n YaCy -o h,d,l,p,t,g -l help,debug,logging,print-out,tail-log,gui,start,startup -- $@`" + options="`getopt -n YaCy -o h,d,l,p,t,s,g -l help,debug,logging,print-out,tail-log,startup,gui -- $@`" fi if [ $? -ne 0 ];then @@ -103,7 +103,7 @@ for option in $options;do -t|--tail-log) TAILLOG=1 ;; - -start|-startup) + -s|-startup) STARTUP=1 isparameter=1 ;; @@ -113,7 +113,7 @@ for option in $options;do ;; esac #case option else #parameter - if [ x$option = "--" ];then #option / parameter separator + if [ $option = "--" ];then #option / parameter separator isparameter=1; continue else From 8255e91c994a6bc85817dd4943f7e78df34b640d Mon Sep 17 00:00:00 2001 From: luccioman Date: Sat, 3 Sep 2016 15:21:02 +0200 Subject: [PATCH 5/5] Fixed serverClassLoader.findClass method htroot is a supposed to be a subfolder of appPath and not of dataPath, as assumed in other places where htroot is loaded. This issue was not visible when dataPath and appPath are equals. --- source/net/yacy/server/serverClassLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/net/yacy/server/serverClassLoader.java b/source/net/yacy/server/serverClassLoader.java index 9412dc4be..cd627a22c 100644 --- a/source/net/yacy/server/serverClassLoader.java +++ b/source/net/yacy/server/serverClassLoader.java @@ -64,7 +64,7 @@ public final class serverClassLoader extends ClassLoader { @Override protected Class findClass(String classname) throws ClassNotFoundException { // construct path to htroot for a servletname - File cpath = new File (Switchboard.getSwitchboard().getDataPath(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT),classname+".class"); + File cpath = new File (Switchboard.getSwitchboard().getAppPath(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT),classname+".class"); return loadClass(cpath); }