Files
dropshell-templates/logserver/scripts/setup-user.sh
Your Name fb02cbd0e8
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 38s
docs: Add 1 and update 4 files
2025-09-20 10:11:14 +12:00

33 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Script to create a custom user for Kibana login
# This runs after Elasticsearch is up and creates the user defined in service.env
# Wait for Elasticsearch to be ready
echo "Waiting for Elasticsearch to be ready..."
until curl -s -u elastic:${ELASTIC_PASSWORD} http://localhost:9200/_cluster/health | grep -q '"status":"yellow"\|"status":"green"'; do
sleep 5
done
echo "Creating user '${KIBANA_USERNAME}'..."
# Create the custom user with superuser role
curl -X POST -u elastic:${ELASTIC_PASSWORD} \
-H "Content-Type: application/json" \
http://localhost:9200/_security/user/${KIBANA_USERNAME} \
-d '{
"password" : "'${KIBANA_USER_PASSWORD}'",
"roles" : [ "superuser" ],
"full_name" : "Admin User",
"email" : "admin@example.com"
}'
if [ $? -eq 0 ]; then
echo ""
echo "User '${KIBANA_USERNAME}' created successfully!"
echo "You can now log in to Kibana with:"
echo " Username: ${KIBANA_USERNAME}"
echo " Password: ${KIBANA_USER_PASSWORD}"
else
echo "Note: User might already exist or there was an error"
fi