-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit: Add Freerouting CLI tool
- Loading branch information
Showing
17 changed files
with
17,403 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
||
# Binary files should be left untouched | ||
*.jar binary | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
* | ||
* This is a general purpose Gradle build. | ||
* Learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.12/samples | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Stage 1: Build the application | ||
FROM eclipse-temurin:21-jdk-jammy AS build | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the current directory contents into the container at /app | ||
COPY . /app | ||
|
||
# Gradle build the application | ||
RUN ./gradlew build | ||
|
||
# Stage 2: Create the final image | ||
FROM eclipse-temurin:21-jre-jammy | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy the built application from the build stage | ||
COPY --from=build /app/build/libs/freerouting-executable.jar /app/freerouting-executable.jar | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 37864 | ||
|
||
# Define a writable volume | ||
VOLUME /mnt/freerouting | ||
|
||
|
||
# Run the application | ||
CMD ["java", "-jar", "/app/freerouting-executable.jar", "--api_server-enabled=true", "--gui-enabled=false", "--feature_flags-save_jobs=1", "--user_data_path=/mnt/freerouting", "[email protected]"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[Editors] | ||
Order= |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# Copyright © 2015-2021 the original authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# Freerouting CLI for interacting with the Freerouting API | ||
# Adjustments for custom configuration paths and CLI commands | ||
############################################################################## | ||
|
||
# Attempt to set APP_HOME | ||
|
||
# Resolve links: $0 may be a link | ||
app_path=$0 | ||
|
||
# Need this for daisy-chained symlinks. | ||
while | ||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path | ||
[ -h "$app_path" ] | ||
do | ||
ls=$( ls -ld "$app_path" ) | ||
link=${ls#*' -> '} | ||
case $link in | ||
/*) app_path=$link ;; | ||
*) app_path=$APP_HOME$link ;; | ||
esac | ||
done | ||
|
||
APP_BASE_NAME=${0##*/} | ||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit | ||
|
||
# Define constants for Freerouting | ||
FREEROUTING_API_URL="https://api.freerouting.app" | ||
FREEROUTING_CLI_PATH="$APP_HOME/cli" | ||
|
||
# Set Java command | ||
JAVACMD=java | ||
if [ ! -x "$JAVACMD" ] ; then | ||
die "ERROR: Java is not found in your PATH. Please install Java or set JAVA_HOME." | ||
fi | ||
|
||
# Configuration function for Freerouting CLI | ||
configure_freerouting() { | ||
echo "Configuring Freerouting CLI..." | ||
|
||
if [ -n "$1" ]; then | ||
profile_id="$1" | ||
echo "Setting profile ID: $profile_id" | ||
freerouting config set-profile "$profile_id" | ||
else | ||
echo "Creating a new profile..." | ||
freerouting config create-profile | ||
fi | ||
|
||
if [ -n "$2" ]; then | ||
api_url="$2" | ||
echo "Setting custom API URL: $api_url" | ||
freerouting config set-api-url "$api_url" | ||
else | ||
echo "Using default API URL: $FREEROUTING_API_URL" | ||
fi | ||
} | ||
|
||
# Start Freerouting local server | ||
start_local_server() { | ||
echo "Starting Freerouting local server..." | ||
freerouting server start | ||
} | ||
|
||
# Check API system status | ||
check_system_status() { | ||
echo "Checking Freerouting API system status..." | ||
freerouting system status | ||
} | ||
|
||
# Main functionality to handle CLI commands | ||
case $1 in | ||
"config") | ||
configure_freerouting "$2" "$3" | ||
;; | ||
"server") | ||
start_local_server | ||
;; | ||
"status") | ||
check_system_status | ||
;; | ||
*) | ||
echo "Usage: $0 {config|server|status}" | ||
exit 1 | ||
;; | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This file was generated by the Gradle 'init' task. | ||
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties | ||
|
||
org.gradle.configuration-cache=true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This file was generated by the Gradle 'init' task. | ||
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.