From 30b814213b9b60a7458a9ff9afa7cfdb1947f14a Mon Sep 17 00:00:00 2001 From: hackacad Date: Tue, 27 Jul 2021 15:29:15 +0200 Subject: [PATCH] FreeBSD Java support Signed-off-by: hackacad --- distribution/src/bin/opensearch-env | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/distribution/src/bin/opensearch-env b/distribution/src/bin/opensearch-env index debf0596d2cd7..99bded2ad0e52 100644 --- a/distribution/src/bin/opensearch-env +++ b/distribution/src/bin/opensearch-env @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e -o pipefail @@ -6,6 +6,15 @@ CDPATH="" SCRIPT="$0" +UNAME=$(uname -s) +if [ $UNAME = "FreeBSD" ]; then + OS="freebsd" +elif [ $UNAME = "Darwin" ]; then + OS="darwin" +else + OS="other" +fi + # SCRIPT might be an arbitrarily deep series of symbolic links; loop until we # have the concrete path while [ -h "$SCRIPT" ] ; do @@ -40,9 +49,12 @@ if [ ! -z "$JAVA_HOME" ]; then JAVA="$JAVA_HOME/bin/java" JAVA_TYPE="JAVA_HOME" else - if [ "$(uname -s)" = "Darwin" ]; then - # macOS has a different structure + if [ $OS = "darwin" ]; then + # macOS bundled Java JAVA="$OPENSEARCH_HOME/jdk.app/Contents/Home/bin/java" + elif [ $OS = "freebsd" ]; then + # using FreeBSD default java from ports if JAVA_HOME is not set + JAVA="/usr/local/bin/java" else JAVA="$OPENSEARCH_HOME/jdk/bin/java" fi