Skip to content

Commit

Permalink
Initial commit: Add Freerouting CLI tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Girma35 committed Jan 23, 2025
1 parent 06f7b6f commit b84d573
Show file tree
Hide file tree
Showing 17 changed files with 17,403 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .gitattributes
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

7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,9 @@ dist
.vscode
.aider*

test-output.dsn
test-output.dsn
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
6 changes: 6 additions & 0 deletions build.gradle
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
*/
30 changes: 30 additions & 0 deletions freerouting-docker/Dockerfile.dev
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]"]
2 changes: 2 additions & 0 deletions freerouting-docker/Dockerfile.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Editors]
Order=
Empty file added freerouting-docker/ls
Empty file.
104 changes: 104 additions & 0 deletions gradle-wrapper.sh
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

5 changes: 5 additions & 0 deletions gradle.properties
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

2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
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 added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
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
Loading

0 comments on commit b84d573

Please sign in to comment.