Skip to content

Commit

Permalink
Merge pull request #72 from luccioman/dist_macOS
Browse files Browse the repository at this point in the history
YaCy Mac OS bundle : store data in the right place
  • Loading branch information
luccioman committed Sep 5, 2016
2 parents 51c077f + 74f9927 commit d14a9ee
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 17 deletions.
2 changes: 1 addition & 1 deletion addon/YaCy.app/Contents/Info.plist
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleAllowMixedLocalizations</key>
<string>true</string>
<key>CFBundleExecutable</key>
<string>startYACY.sh</string>
<string>startYACYMacOS.sh</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundlePackageType</key>
Expand Down
8 changes: 8 additions & 0 deletions 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 -s "'Library/Application Support/net.yacy.YaCy'"
3 changes: 2 additions & 1 deletion build.xml
Expand Up @@ -764,7 +764,8 @@
</copy>
<copy file="${addon}/YaCy.app/Contents/Info.plist" tofile="${release_mac}/YaCy.app/Contents/Info.plist" filtering="true" overwrite="true" />
<move file="${release_main}" tofile="${release_mac}/YaCy.app/Contents/MacOS" verbose="false" />
<!-- startYACY.sh will be the main entry point : we set permissions to make it an executable file -->
<!-- startYACY.sh and startYACYMacOS.sh will be the main entry points : we set permissions to make it executable files -->
<chmod file="${release_mac}/YaCy.app/Contents/MacOS/startYACYMacOS.sh" perm="755"/>
<chmod file="${release_mac}/YaCy.app/Contents/MacOS/startYACY.sh" perm="755"/>
<exec executable="hdiutil">
<arg line="create -srcfolder ${release_mac}/YaCy.app ${release}/yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.dmg"/>
Expand Down
2 changes: 1 addition & 1 deletion source/net/yacy/server/serverClassLoader.java
Expand Up @@ -64,7 +64,7 @@ public serverClassLoader(final ClassLoader parent) {
@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);
}

Expand Down
22 changes: 14 additions & 8 deletions source/net/yacy/yacy.java
Expand Up @@ -713,13 +713,17 @@ public static void main(String args[]) {
//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
Expand All @@ -732,7 +736,7 @@ public static void main(String args[]) {
} 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/");
Expand Down Expand Up @@ -778,9 +782,11 @@ public static void main(String args[]) {
}
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 {
Expand Down
25 changes: 19 additions & 6 deletions startYACY.sh
Expand Up @@ -40,23 +40,24 @@ 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
-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
}

#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 -- $@`"
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
Expand All @@ -71,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
Expand Down Expand Up @@ -101,17 +103,25 @@ for option in $options;do
-t|--tail-log)
TAILLOG=1
;;
-s|-startup)
STARTUP=1
isparameter=1
;;
-g|--gui)
GUI=1
isparameter=1
;;
esac #case option
else #parameter
if [ x$option = "--" ];then #option / parameter separator
if [ $option = "--" ];then #option / parameter separator
isparameter=1;
continue
else
parameter="$parameter $option"
if [ $parameter ];then
parameter="$parameter $option"
else
parameter="$option"
fi
fi
fi #parameter or option?
done
Expand Down Expand Up @@ -189,8 +199,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 ];then #gui
cmdline="$cmdline -gui $parameter"
fi
if [ $DEBUG -eq 1 ] #debug
Expand Down

0 comments on commit d14a9ee

Please sign in to comment.