From 5ed67a6507d54f6cd3e6705ade5df590d641f58a Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Thu, 30 May 2019 23:52:59 +0200 Subject: [PATCH 1/4] Merge server.sh and local.sh By setting BINDADDRESS and delegating to server.sh we can avoid duplicating most of the code. This also makes 0d5e1c1 available for local.sh, i.e. being able to launch local.sh from arbitrary directories too. --- misc/scripts/standalone/local.sh | 9 +-------- misc/scripts/standalone/server.sh | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/misc/scripts/standalone/local.sh b/misc/scripts/standalone/local.sh index 972b038..8211acf 100755 --- a/misc/scripts/standalone/local.sh +++ b/misc/scripts/standalone/local.sh @@ -1,10 +1,3 @@ #!/bin/sh -# BRouter standalone server -# java -cp brouter.jar btools.brouter.RouteServer [bindaddress] - -# 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 localhost +BINDADDRESS="localhost" "$(dirname "$0")/server.sh" diff --git a/misc/scripts/standalone/server.sh b/misc/scripts/standalone/server.sh index f37b0d8..9ea86a8 100755 --- a/misc/scripts/standalone/server.sh +++ b/misc/scripts/standalone/server.sh @@ -2,10 +2,10 @@ cd "$(dirname "$0")" # BRouter standalone server -# java -cp brouter.jar btools.brouter.RouteServer +# java -cp brouter.jar btools.brouter.RouteServer [bindaddress] # 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 +java $JAVA_OPTS -cp $CLASSPATH btools.server.RouteServer ../segments4 ../profiles2 ../customprofiles 17777 1 $BINDADDRESS From 3118dd4e76e465fb99a649c8ded3bc0bea4205c8 Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Thu, 30 May 2019 23:52:59 +0200 Subject: [PATCH 2/4] 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. --- .gitignore | 4 +++- misc/scripts/standalone/server.sh | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 941c9a5..180efb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ +misc/segments4 +misc/customprofiles target/ *.BAK .classpath .project *.class .idea/ -*.iml \ No newline at end of file +*.iml diff --git a/misc/scripts/standalone/server.sh b/misc/scripts/standalone/server.sh index 9ea86a8..9a439ed 100755 --- a/misc/scripts/standalone/server.sh +++ b/misc/scripts/standalone/server.sh @@ -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 From f5ee3ef6f09babe6dc6bf3ef7b2bacc70dd52557 Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Thu, 30 May 2019 23:52:59 +0200 Subject: [PATCH 3/4] Expand README to make it easier to build and run BRouter --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 769f001..4b33bad 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,23 @@ For more infos see http://brouter.de/brouter Get it on Google Play + +## Build and Install + Compile with (Java 6!): > mvn clean install -Dandroid.sdk.path= +To skip building for Android, add ``-pl '!brouter-routing-app'``. + +Next, download one or more [data file(s)](http://brouter.de/brouter/segments4/) (rd5) into the ``misc/segments4`` directory. + +## Run + +On Linux: +> ./misc/scripts/standalone/server.sh + + Related Projects ================ From 4c6e17c650c07ec69af45de8f6257d851562357a Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Thu, 30 May 2019 23:52:59 +0200 Subject: [PATCH 4/4] Allow to run server.cmd from source directory This also enables launching server.cmd from arbitrary directories to match the behaviour of server.sh. --- README.md | 6 ++++++ misc/scripts/standalone/server.cmd | 31 ++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b33bad..290c09f 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ Next, download one or more [data file(s)](http://brouter.de/brouter/segments4/) On Linux: > ./misc/scripts/standalone/server.sh +On Windows (using Bash): +> ./misc/scripts/standalone/server.sh + +On Windows (using CMD): +> misc\scripts\standalone\server.cmd + Related Projects ================ diff --git a/misc/scripts/standalone/server.cmd b/misc/scripts/standalone/server.cmd index d26c2c3..dc35e9c 100644 --- a/misc/scripts/standalone/server.cmd +++ b/misc/scripts/standalone/server.cmd @@ -3,8 +3,35 @@ REM BRouter standalone server REM java -cp brouter.jar btools.brouter.RouteServer +pushd %~dp0 + REM maxRunningTime is the request timeout in seconds, set to 0 to disable timeout set JAVA_OPTS=-Xmx128M -Xms128M -Xmn8M -DmaxRunningTime=300 -set CLASSPATH=../brouter.jar -java %JAVA_OPTS% -cp %CLASSPATH% btools.server.RouteServer ..\segments4 ..\profiles2 ..\customprofiles 17777 1 +REM First search in locations matching the directory structure as found in the official BRouter zip archive +set CLASSPATH=../brouter.jar +set SEGMENTSPATH=..\segments4 +set PROFILESPATH=..\profiles2 +set CUSTOMPROFILESPATH=..\customprofiles + +REM Otherwise try to locate files inside the source checkout +if not exist "%CLASSPATH%" ( + for /f "tokens=*" %%w in ( + 'where /R ..\..\..\brouter-server\target brouter-server*-jar-with-dependencies.jar' + ) do ( + set CLASSPATH=%%w + ) +) +if not exist "%SEGMENTSPATH%" ( + set SEGMENTSPATH=..\..\segments4 +) +if not exist "%PROFILESPATH%" ( + set PROFILESPATH=..\..\profiles2 +) +if not exist "%CUSTOMPROFILESPATH%" ( + set CUSTOMPROFILESPATH=..\..\customprofiles +) + +java %JAVA_OPTS% -cp %CLASSPATH% btools.server.RouteServer "%SEGMENTSPATH%" "%PROFILESPATH%" "%CUSTOMPROFILESPATH%" 17777 1 + +popd