From 86ef7be0072b8bd35c6ffc35f76c44b35524f479 Mon Sep 17 00:00:00 2001 From: ai-dev Date: Mon, 22 Sep 2025 00:11:50 +0200 Subject: [PATCH] test --- .../rootfs/usr/bin/configure-opensearch | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/opensearch-master/rootfs/usr/bin/configure-opensearch b/opensearch-master/rootfs/usr/bin/configure-opensearch index 00ed47e..dde2964 100644 --- a/opensearch-master/rootfs/usr/bin/configure-opensearch +++ b/opensearch-master/rootfs/usr/bin/configure-opensearch @@ -5,7 +5,7 @@ read_config() { if command -v bashio >/dev/null 2>&1; then bashio::config "$1" else - # Fallback for testing outside Home Assistant - return empty to avoid issues + # Fallback for testing outside Home Assistant case "$1" in "node_role") echo "master" ;; "cluster_name") echo "hass-opensearch-cluster" ;; @@ -39,18 +39,18 @@ ADMIN_PASSWORD=$(read_config 'admin_password') export OPENSEARCH_INITIAL_ADMIN_PASSWORD="${ADMIN_PASSWORD}" export DISCOVERY_TYPE="multi-node" -# Set heap size with proper format (remove any extra spaces or invalid characters) +# Set heap size using environment variable (better approach) CLEAN_HEAP_SIZE=$(echo "$HEAP_SIZE" | tr -d ' ' | grep -oE '[0-9]+[mg]') if [ -z "$CLEAN_HEAP_SIZE" ]; then - CLEAN_HEAP_SIZE="1g" # Default if invalid + CLEAN_HEAP_SIZE="2g" fi +export OPENSEARCH_JAVA_OPTS="-Xms${CLEAN_HEAP_SIZE} -Xmx${CLEAN_HEAP_SIZE}" -# Set heap size in jvm.options.d (proper format) -mkdir -p /usr/share/opensearch/config/jvm.options.d -echo "-Xms${CLEAN_HEAP_SIZE}" > /usr/share/opensearch/config/jvm.options.d/heap.options -echo "-Xmx${CLEAN_HEAP_SIZE}" >> /usr/share/opensearch/config/jvm.options.d/heap.options +# Remove any existing heap configuration to avoid duplicates +rm -f /usr/share/opensearch/config/jvm.options.d/heap.options +rm -f /usr/share/opensearch/config/jvm.options -# Export variables for envsubst (ensure they have proper values) +# Export variables for envsubst export CLUSTER_NAME="${CLUSTER_NAME:-hass-opensearch-cluster}" export NODE_NAME="${NODE_NAME:-os-node-1}" export NODE_ROLE="${NODE_ROLE:-master}" @@ -63,10 +63,9 @@ export SECURITY_ENABLED="${SECURITY_ENABLED:-false}" # Generate opensearch.yml from template envsubst < /etc/opensearch/opensearch.yml.template > /usr/share/opensearch/config/opensearch.yml -# Install plugins if specified (only if not in test mode) +# Install plugins if specified PLUGINS_JSON=$(read_config 'plugins') if [ -n "$PLUGINS_JSON" ] && [ "$PLUGINS_JSON" != "[]" ] && command -v bashio >/dev/null 2>&1; then - # Extract plugins from JSON array properly PLUGINS=$(echo "$PLUGINS_JSON" | jq -r '.[]' 2>/dev/null || echo "") if [ -n "$PLUGINS" ]; then for plugin in $PLUGINS; do