# If kibana password is set, configure the kibana_system user
if[!-z"$KIBANA_PASSWORD"];then
echo"Setting kibana_system user password..."
until curl -s-X POST -u"elastic:${ELASTIC_PASSWORD}"-H"Content-Type: application/json" http://localhost:9200/_security/user/kibana_system/_password -d"{\"password\":\"${KIBANA_PASSWORD}\"}" | grep-q"^{}";do
echo"Waiting for Elasticsearch to be ready to set kibana_system password..."
sleep 5
done
echo"kibana_system password set."
attempts=$((attempts+1))
if[$attempts-ge$max_attempts];then
echo"Elasticsearch failed to start after 5 minutes. Check logs at /app/data/logs/"
exit 1
fi
done
echo"Elasticsearch is up and running!"
# Display the credentials
echo"-----------------------------"
@@ -127,12 +85,6 @@ echo ""
echo"Authentication credentials:"
echo" User: elastic"
echo" Password: $ELASTIC_PASSWORD"
if[!-z"$KIBANA_PASSWORD"];then
echo""
echo"Kibana system credentials:"
echo" User: kibana_system"
echo" Password: $KIBANA_PASSWORD"
fi
echo"-----------------------------"
# Create a credentials file for reference
@@ -141,13 +93,9 @@ Elasticsearch credentials:
URL: http://localhost:9200
User: elastic
Password: $ELASTIC_PASSWORD
Kibana system credentials:
User: kibana_system
Password: $KIBANA_PASSWORD
EOL
echo"Credentials saved to /app/data/credentials.txt"
# Keep script running
exec tail-f /dev/null
No newline at end of file
# Keep the script running to prevent the container from exiting