mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-07 01:32:47 +01:00
fix jq error when indices don't exist (seen on fresh installs when fleet hasn't ever been installed)
This commit is contained in:
@@ -23,18 +23,17 @@ if [[ "$RETURN_CODE" != "0" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ALIASES=".fleet-servers .fleet-policies-leader .fleet-policies .fleet-agents .fleet-artifacts .fleet-enrollment-api-keys .kibana_ingest"
|
ALIASES=(.fleet-servers .fleet-policies-leader .fleet-policies .fleet-agents .fleet-artifacts .fleet-enrollment-api-keys .kibana_ingest)
|
||||||
for ALIAS in ${ALIASES}
|
for ALIAS in "${ALIASES[@]}"; do
|
||||||
do
|
|
||||||
# Get all concrete indices from alias
|
# Get all concrete indices from alias
|
||||||
INDXS=$(curl -K /opt/so/conf/kibana/curl.config -s -k -L -H "Content-Type: application/json" "https://localhost:9200/_resolve/index/${ALIAS}" | jq -r '.aliases[].indices[]')
|
if INDXS_RAW=$(curl -sK /opt/so/conf/kibana/curl.config -s -k -L -H "Content-Type: application/json" "https://localhost:9200/_resolve/index/${ALIAS}" --fail 2>/dev/null); then
|
||||||
|
INDXS=$(echo "$INDXS_RAW" | jq -r '.aliases[].indices[]')
|
||||||
# Delete all resolved indices
|
# Delete all resolved indices
|
||||||
for INDX in ${INDXS}
|
for INDX in ${INDXS}; do
|
||||||
do
|
|
||||||
status "Deleting $INDX"
|
status "Deleting $INDX"
|
||||||
curl -K /opt/so/conf/kibana/curl.config -s -k -L -H "Content-Type: application/json" "https://localhost:9200/${INDX}" -XDELETE
|
curl -K /opt/so/conf/kibana/curl.config -s -k -L -H "Content-Type: application/json" "https://localhost:9200/${INDX}" -XDELETE
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Restarting Kibana...
|
# Restarting Kibana...
|
||||||
|
|||||||
Reference in New Issue
Block a user