diff --git a/salt/kibana/bin/so-kibana-config-load b/salt/kibana/bin/so-kibana-config-load index dc6919ecb..3ff85b368 100644 --- a/salt/kibana/bin/so-kibana-config-load +++ b/salt/kibana/bin/so-kibana-config-load @@ -2,24 +2,29 @@ # {%- set MANAGER = salt['pillar.get']('global:url_base', '') %} . /usr/sbin/so-common -if $1; then +if [ ! -z "$1" ]; then ndjson_template_file=$1 else ndjson_template_file='/opt/so/conf/kibana/saved_objects.ndjson.template' fi -ndjson_file=$(echo $ndjson_template | sed -e "s/\.template$//") -# Copy template file -#cp /opt/so/conf/kibana/saved_objects.ndjson.template /opt/so/conf/kibana/saved_objects.ndjson -cp $ndjson_template $ndjson_file -# SOCtopus and Manager -if grep -lq 'PLACEHOLDER' $ndjson_file; then - sed -i "s/PLACEHOLDER/{{ MANAGER }}/g" $ndjson_file +if [ -f "$ndjson_template_file" ]; then + ndjson_file=$(echo $ndjson_template_file | sed -e "s/\.template$//") + # Copy template file + #cp /opt/so/conf/kibana/saved_objects.ndjson.template /opt/so/conf/kibana/saved_objects.ndjson + cp "$ndjson_template_file" "$ndjson_file" + + # SOCtopus and Manager + if grep -lq 'PLACEHOLDER' "$ndjson_file"; then + sed -i "s/PLACEHOLDER/{{ MANAGER }}/g" "$ndjson_file" + fi + + wait_for_web_response "http://localhost:5601/app/kibana" "Elastic" 300 "{{ ELASTICCURL }}" + + SESSIONCOOKIE=$({{ ELASTICCURL }} -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}') + + # Load saved objects + {{ ELASTICCURL }} -b "sid=$SESSIONCOOKIE" -L -X POST "localhost:5601/api/saved_objects/_import?overwrite=true" -H "kbn-xsrf: true" --form file=@"$ndjson_file" >> /opt/so/log/kibana/misc.log +else + echo "File $ndjson_template_file does not exist." fi - -wait_for_web_response "http://localhost:5601/app/kibana" "Elastic" 300 "{{ ELASTICCURL }}" - -SESSIONCOOKIE=$({{ ELASTICCURL }} -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}') - -# Load saved objects -{{ ELASTICCURL }} -b "sid=$SESSIONCOOKIE" -L -X POST "localhost:5601/api/saved_objects/_import?overwrite=true" -H "kbn-xsrf: true" --form file=@$ndjson_file >> /opt/so/log/kibana/misc.log