test
This commit is contained in:
@@ -5,7 +5,7 @@ read_config() {
|
|||||||
if command -v bashio >/dev/null 2>&1; then
|
if command -v bashio >/dev/null 2>&1; then
|
||||||
bashio::config "$1"
|
bashio::config "$1"
|
||||||
else
|
else
|
||||||
# Fallback for testing outside Home Assistant - return empty to avoid issues
|
# Fallback for testing outside Home Assistant
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"node_role") echo "master" ;;
|
"node_role") echo "master" ;;
|
||||||
"cluster_name") echo "hass-opensearch-cluster" ;;
|
"cluster_name") echo "hass-opensearch-cluster" ;;
|
||||||
@@ -39,18 +39,18 @@ ADMIN_PASSWORD=$(read_config 'admin_password')
|
|||||||
export OPENSEARCH_INITIAL_ADMIN_PASSWORD="${ADMIN_PASSWORD}"
|
export OPENSEARCH_INITIAL_ADMIN_PASSWORD="${ADMIN_PASSWORD}"
|
||||||
export DISCOVERY_TYPE="multi-node"
|
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]')
|
CLEAN_HEAP_SIZE=$(echo "$HEAP_SIZE" | tr -d ' ' | grep -oE '[0-9]+[mg]')
|
||||||
if [ -z "$CLEAN_HEAP_SIZE" ]; then
|
if [ -z "$CLEAN_HEAP_SIZE" ]; then
|
||||||
CLEAN_HEAP_SIZE="1g" # Default if invalid
|
CLEAN_HEAP_SIZE="2g"
|
||||||
fi
|
fi
|
||||||
|
export OPENSEARCH_JAVA_OPTS="-Xms${CLEAN_HEAP_SIZE} -Xmx${CLEAN_HEAP_SIZE}"
|
||||||
|
|
||||||
# Set heap size in jvm.options.d (proper format)
|
# Remove any existing heap configuration to avoid duplicates
|
||||||
mkdir -p /usr/share/opensearch/config/jvm.options.d
|
rm -f /usr/share/opensearch/config/jvm.options.d/heap.options
|
||||||
echo "-Xms${CLEAN_HEAP_SIZE}" > /usr/share/opensearch/config/jvm.options.d/heap.options
|
rm -f /usr/share/opensearch/config/jvm.options
|
||||||
echo "-Xmx${CLEAN_HEAP_SIZE}" >> /usr/share/opensearch/config/jvm.options.d/heap.options
|
|
||||||
|
|
||||||
# Export variables for envsubst (ensure they have proper values)
|
# Export variables for envsubst
|
||||||
export CLUSTER_NAME="${CLUSTER_NAME:-hass-opensearch-cluster}"
|
export CLUSTER_NAME="${CLUSTER_NAME:-hass-opensearch-cluster}"
|
||||||
export NODE_NAME="${NODE_NAME:-os-node-1}"
|
export NODE_NAME="${NODE_NAME:-os-node-1}"
|
||||||
export NODE_ROLE="${NODE_ROLE:-master}"
|
export NODE_ROLE="${NODE_ROLE:-master}"
|
||||||
@@ -63,10 +63,9 @@ export SECURITY_ENABLED="${SECURITY_ENABLED:-false}"
|
|||||||
# Generate opensearch.yml from template
|
# Generate opensearch.yml from template
|
||||||
envsubst < /etc/opensearch/opensearch.yml.template > /usr/share/opensearch/config/opensearch.yml
|
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')
|
PLUGINS_JSON=$(read_config 'plugins')
|
||||||
if [ -n "$PLUGINS_JSON" ] && [ "$PLUGINS_JSON" != "[]" ] && command -v bashio >/dev/null 2>&1; then
|
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 "")
|
PLUGINS=$(echo "$PLUGINS_JSON" | jq -r '.[]' 2>/dev/null || echo "")
|
||||||
if [ -n "$PLUGINS" ]; then
|
if [ -n "$PLUGINS" ]; then
|
||||||
for plugin in $PLUGINS; do
|
for plugin in $PLUGINS; do
|
||||||
|
Reference in New Issue
Block a user