#!/bin/bash # It is preferable to place lphybeast inside the BEAST2 bin folder if [ -z "$BEAST" ]; then ## resolve links - $0 may be a link to application PRG="$0" # need this for relative symlinks while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG="`dirname "$PRG"`/$link" fi done # make it fully qualified saveddir=`pwd` BEAST0=`dirname "$PRG"`/.. BEAST=`cd "$BEAST0" && pwd` cd "$saveddir" fi if [ -n "$BEAST" ]; then # if not empty BEAST_LIB="$BEAST/lib" else echo "Error: cannot locate the BEAST 2 folder ! $BEAST" exit 1 fi if [ -d "$BEAST"/jre ]; then # use Zulu JRE in the BEAST directory if it exists JAVA="$BEAST"/jre/bin/java elif [ -n "$JAVA_HOME" ]; then # else use $JAVA_HOME JAVA="$JAVA_HOME"/bin/java else # else JAVA=java fi # print Java version echo $("$JAVA" -version) # use BEAGLE_LIB if it is not empty if [ -n "$BEAGLE_LIB" ]; then if [ -n "$BEAST_EXTRA_LIBS" ]; then BEAST_EXTRA_LIBS="$BEAST_EXTRA_LIBS:$BEAGLE_LIB" else BEAST_EXTRA_LIBS="$BEAGLE_LIB" fi fi # Explicitly add /usr/local/lib to library search path to ensure # beast continues to find beagle when installed here. (This is # necessary due to known problems with certain JREs.) if [ -z "$LD_LIBRARY_PATH" ]; then export LD_LIBRARY_PATH=/usr/local/lib else export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/local/lib fi ### $LPHY_LIB must be provided if [ -z "$LPHY_LIB" ]; then # if $LPHY_LIB does not exist, detect the OS if [[ "$OSTYPE" == "linux-gnu"* ]]; then echo "Guessing LPHY_LIB on Linux ..." # set working dir to ~ OS_PREFIX="$HOME" elif [[ "$OSTYPE" == "darwin"* ]]; then echo "Guessing LPHY_LIB on macOS ..." OS_PREFIX="/Applications" # elif [[ "$OSTYPE" == "cygwin" ]]; then # echo "Running on Cygwin (Windows)" # elif [[ "$OSTYPE" == "msys" ]]; then # echo "Running on MSYS (Windows)" # elif [[ "$OSTYPE" == "win32" ]]; then # echo "Running on Windows" else echo "Cannot guess the LPhy library path LPHY_LIB in unknown OS: $OSTYPE !" echo "Please set it as your environment variable." echo "Get help from https://linguaphylo.github.io/setup" exit 1 fi # if multiple LPhy installed, sort the search result to get the latest version, usually last line LPHY_DIR=$(find "$OS_PREFIX" -maxdepth 1 -type d -name 'lphy*studio-1*' | sort | tail -1) # Guess LPHY_LIB LPHY_LIB="$LPHY_DIR/lib" fi # set to specific path in script #LPHY_LIB="/Applications/BEAST 2.7.5/lphystudio-1.4.3/lib" if [ ! -d "$LPHY_LIB" ]; then echo "Error: Invalid LPhy library path : $LPHY_LIB !" echo "Please set an existing LPhy library path to LPHY_LIB as your environment variable." echo "Get help from https://linguaphylo.github.io/setup" exit 1 fi echo "BEAST_LIB = $BEAST_LIB" echo "BEAST_EXTRA_LIBS = $BEAST_EXTRA_LIBS" echo "LPHY_LIB = $LPHY_LIB" echo "" # test if there is any lphy*.jar JAR_FILES=$(ls "$LPHY_LIB"/lphy*.jar) if [ -z "$JAR_FILES" ]; then echo "Error: No core jar files found in $LPHY_LIB !" echo "Please install LPhy properly. Get help from https://linguaphylo.github.io/setup" exit 1 fi # must set -Dpicocli.disable.closures=true using picocli:4.7.0 # otherwise it will throw otherwise java.lang.NoClassDefFoundError: groovy.lang.Closure ARG="-Xms256m -Xmx60g -Dpicocli.disable.closures=true -Dlauncher.wait.for.exit=true -Duser.language=en" if [ -n "$BEAST_EXTRA_LIBS" ]; then "$JAVA" $ARG -Djava.library.path="$BEAST_EXTRA_LIBS" -cp "$BEAST_LIB/launcher.jar:$LPHY_LIB/*" beast.pkgmgmt.launcher.AppLauncherLauncher lphybeast $* else "$JAVA" $ARG -cp "$BEAST_LIB/launcher.jar:$LPHY_LIB/*" beast.pkgmgmt.launcher.AppLauncherLauncher lphybeast $* fi