Allow to run server.sh from source directory

Running server.sh after cloning and building did not work without
also customizing paths and/or moving files around.

By referring to already existing default locations the out-of-the-box
experience should be a bit smoother.

In order to not affect existing installations and to retain support for
running released versions from http://brouter.de/brouter/revisions.html,
the old default paths are still checked.
This commit is contained in:
Henrik Fehlauer 2019-05-30 23:52:59 +02:00
parent 5ed67a6507
commit 3118dd4e76
2 changed files with 25 additions and 3 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
misc/segments4
misc/customprofiles
target/
*.BAK
.classpath

View file

@ -6,6 +6,26 @@ cd "$(dirname "$0")"
# maxRunningTime is the request timeout in seconds, set to 0 to disable timeout
JAVA_OPTS="-Xmx128M -Xms128M -Xmn8M -DmaxRunningTime=300"
CLASSPATH=../brouter.jar
java $JAVA_OPTS -cp $CLASSPATH btools.server.RouteServer ../segments4 ../profiles2 ../customprofiles 17777 1 $BINDADDRESS
# If paths are unset, first search in locations matching the directory structure
# as found in the official BRouter zip archive
CLASSPATH=${CLASSPATH:-"../brouter.jar"}
SEGMENTSPATH=${SEGMENTSPATH:-"../segments4"}
PROFILESPATH=${PROFILESPATH:-"../profiles2"}
CUSTOMPROFILESPATH=${CUSTOMPROFILESPATH:-"../customprofiles"}
# Otherwise try to locate files inside the source checkout
if [ ! -e "$CLASSPATH" ]; then
CLASSPATH="$(ls ../../../brouter-server/target/brouter-server-*jar-with-dependencies.jar | sort --reverse --version-sort | head --lines 1)"
fi
if [ ! -e "$SEGMENTSPATH" ]; then
SEGMENTSPATH="../../segments4"
fi
if [ ! -e "$PROFILESPATH" ]; then
PROFILESPATH="../../profiles2"
fi
if [ ! -e "$CUSTOMPROFILESPATH" ]; then
CUSTOMPROFILESPATH="../../customprofiles"
fi
java $JAVA_OPTS -cp $CLASSPATH btools.server.RouteServer "$SEGMENTSPATH" "$PROFILESPATH" "$CUSTOMPROFILESPATH" 17777 1 $BINDADDRESS