This commit is contained in:
ai-dev
2025-09-21 23:38:26 +02:00
parent 4c55afbc92
commit e8098221d8
10 changed files with 119 additions and 134 deletions

View File

@@ -1,14 +0,0 @@
#!/command/with-contenv bash
set -euo pipefail
SRC_DIR=/rootfs-config
DST_DIR=/usr/share/opensearch/config
if [ -d "$SRC_DIR" ]; then
echo "[cont-init] Copying config snippets from $SRC_DIR to $DST_DIR"
for f in "$SRC_DIR"/*; do
base=$(basename "$f")
if [ ! -f "$DST_DIR/$base" ]; then
cp "$f" "$DST_DIR/"
echo "[cont-init] Copied $base"
fi
done
fi

View File

@@ -1,27 +0,0 @@
#!/command/with-contenv bash
set -euo pipefail
OPTIONS_FILE=/data/options.json
# Read options from Supervisor
admin_password=$(bashio::config 'admin_password')
# Export as environment variables for OpenSearch
export OPENSEARCH_INITIAL_ADMIN_PASSWORD="${admin_password}"
if [ ! -f "$OPTIONS_FILE" ]; then
echo "[cont-init] No options.json, skipping plugin install"
exit 0
fi
if ! jq -e '.plugins // [] | length > 0' "$OPTIONS_FILE" >/dev/null 2>&1; then
echo "[cont-init] No plugins configured, skipping"
exit 0
fi
echo "[cont-init] Installing plugins from options.json"
jq -r '.plugins[]' "$OPTIONS_FILE" | while read -r plugin; do
echo "[cont-init] Installing plugin: $plugin"
if /usr/share/opensearch/bin/opensearch-plugin install --batch "$plugin"; then
echo "[cont-init] Installed $plugin"
else
echo "[cont-init] Failed to install $plugin (continuing)"
fi
done

View File

@@ -0,0 +1,17 @@
cluster.name: ${CLUSTER_NAME}
node.name: ${NODE_NAME}
node.roles: [${NODE_ROLE}]
path.data: /usr/share/opensearch/data
path.logs: /usr/share/opensearch/logs
network.host: 0.0.0.0
http.port: ${HTTP_PORT}
transport.port: ${TRANSPORT_PORT}
discovery.seed_hosts: [${DISCOVERY_SEEDS}]
cluster.initial_master_nodes: [${INITIAL_MASTERS}]
plugins.security.disabled: ${SECURITY_ENABLED}
action.auto_create_index: true

View File

@@ -1,3 +0,0 @@
#!/command/execlineb -S0
# Prevent restart loops; allow clean exit
exit 0

View File

@@ -1,33 +0,0 @@
#!/command/with-contenv bash
set -euo pipefail
OPTIONS_FILE=/data/options.json || true
NODE_NAME="os-master"
HEAP="1.5g"
CLUSTER_NAME="hass-opensearch-cluster"
HTTP_PORT=9200
TRANSPORT_PORT=9300
NODE_ROLES="master"
# override from options.json if present
if [ -f "$OPTIONS_FILE" ]; then
NODE_NAME=$(jq -r '.node_name // "os-master"' "$OPTIONS_FILE" 2>/dev/null || echo "os-master")
HEAP=$(jq -r '.opensearch_heap // "1.5g"' "$OPTIONS_FILE" 2>/dev/null || echo "1.5g")
CLUSTER_NAME=$(jq -r '.cluster_name // "hass-opensearch-cluster"' "$OPTIONS_FILE" 2>/dev/null || echo "hass-opensearch-cluster")
HTTP_PORT=$(jq -r '.http_port // 9200' "$OPTIONS_FILE" 2>/dev/null || echo 9200)
TRANSPORT_PORT=$(jq -r '.transport_port // 9300' "$OPTIONS_FILE" 2>/dev/null || echo 9300)
NODE_ROLES=$(jq -r '.node_roles // ["master"] | join(",")' "$OPTIONS_FILE" 2>/dev/null || echo "master")
fi
# Read options from Supervisor
admin_password=$(bashio::config 'admin_password')
opensearch_heap=$(bashio::config 'opensearch_heap')
# Export as environment variables for OpenSearch
export OPENSEARCH_INITIAL_ADMIN_PASSWORD="${admin_password}"
export OPENSEARCH_JAVA_OPTS="-Xms${opensearch_heap} -Xmx${opensearch_heap}"
echo "[s6-run] Starting OpenSearch node: $NODE_NAME roles:$NODE_ROLES heap:$HEAP http:$HTTP_PORT transport:$TRANSPORT_PORT"
exec /usr/share/opensearch/bin/opensearch \
-E cluster.name=$CLUSTER_NAME \
-E node.name=$NODE_NAME