add opensearch addons
This commit is contained in:
14
opensearch-coord1/rootfs/etc/cont-init.d/10-copy-config
Normal file
14
opensearch-coord1/rootfs/etc/cont-init.d/10-copy-config
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/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
|
20
opensearch-coord1/rootfs/etc/cont-init.d/20-install-plugins
Normal file
20
opensearch-coord1/rootfs/etc/cont-init.d/20-install-plugins
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/command/with-contenv bash
|
||||
set -euo pipefail
|
||||
OPTIONS_FILE=/data/options.json
|
||||
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
|
@@ -0,0 +1,3 @@
|
||||
#!/command/execlineb -S0
|
||||
# Prevent restart loops; allow clean exit
|
||||
exit 0
|
@@ -0,0 +1,33 @@
|
||||
#!/command/with-contenv bash
|
||||
set -euo pipefail
|
||||
OPTIONS_FILE=/data/options.json || true
|
||||
NODE_NAME="os-coord-1"
|
||||
HEAP="2g"
|
||||
CLUSTER_NAME="hass-opensearch-cluster"
|
||||
HTTP_PORT=9203
|
||||
TRANSPORT_PORT=9303
|
||||
NODE_ROLES="coordinating_only"
|
||||
|
||||
# override from options.json if present
|
||||
if [ -f "$OPTIONS_FILE" ]; then
|
||||
NODE_NAME=$(jq -r '.node_name // "os-coord-1"' "$OPTIONS_FILE" 2>/dev/null || echo "os-coord-1")
|
||||
HEAP=$(jq -r '.opensearch_heap // "2g"' "$OPTIONS_FILE" 2>/dev/null || echo "2g")
|
||||
CLUSTER_NAME=$(jq -r '.cluster_name // "hass-opensearch-cluster"' "$OPTIONS_FILE" 2>/dev/null || echo "hass-opensearch-cluster")
|
||||
HTTP_PORT=$(jq -r '.http_port // 9203' "$OPTIONS_FILE" 2>/dev/null || echo 9203)
|
||||
TRANSPORT_PORT=$(jq -r '.transport_port // 9303' "$OPTIONS_FILE" 2>/dev/null || echo 9303)
|
||||
NODE_ROLES=$(jq -r '.node_roles // ["coordinating_only"] | join(",")' "$OPTIONS_FILE" 2>/dev/null || echo "coordinating_only")
|
||||
fi
|
||||
|
||||
export OPENSEARCH_JAVA_OPTS="-Xms$2g -Xmx$2g"
|
||||
|
||||
echo "[s6-run] Starting OpenSearch node: $os-coord-1 roles:$coordinating_only heap:$2g http:$9203 transport:$9303"
|
||||
|
||||
exec /usr/share/opensearch/bin/opensearch \
|
||||
-E cluster.name=$hass-opensearch-cluster \
|
||||
-E node.name=$os-coord-1 \
|
||||
-E node.roles=[$coordinating_only] \
|
||||
-E http.port=$9203 \
|
||||
-E transport.port=$9303 \
|
||||
-E network.host=0.0.0.0 \
|
||||
-E discovery.seed_hosts=os-master,os-data-1,os-data-2,os-coord-1,os-coord-2 \
|
||||
-E cluster.initial_master_nodes=os-master
|
Reference in New Issue
Block a user