Update 4 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 40s

This commit is contained in:
Your Name
2025-09-20 10:26:23 +12:00
parent fb02cbd0e8
commit fa4ef61a0a
4 changed files with 81 additions and 13 deletions

View File

@@ -39,6 +39,23 @@ echo "Generating Filebeat configuration..."
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
bash "$SCRIPT_DIR/scripts/generate-config.sh" || _die "Failed to generate configuration"
# Create Docker volumes
CONFIG_VOLUME="${CONFIG_VOLUME:-${CONTAINER_NAME}_config}"
DATA_VOLUME="${DATA_VOLUME:-${CONTAINER_NAME}_data}"
CERTS_VOLUME="${CERTS_VOLUME:-${CONTAINER_NAME}_certs}"
echo "Creating Docker volumes..."
docker volume create "$CONFIG_VOLUME" >/dev/null 2>&1 || true
docker volume create "$DATA_VOLUME" >/dev/null 2>&1 || true
docker volume create "$CERTS_VOLUME" >/dev/null 2>&1 || true
# Copy config to volume
if [ -f "${CONFIG_PATH}/filebeat.yml" ]; then
echo "Copying configuration to Docker volume..."
docker run --rm -v "${CONFIG_VOLUME}:/config" -v "${CONFIG_PATH}:/source:ro" alpine \
cp /source/filebeat.yml /config/filebeat.yml
fi
# Start the new container
bash ./start.sh || _die "Failed to start Filebeat"

View File

@@ -3,7 +3,14 @@
# Generate Filebeat configuration from template
# This script creates a filebeat.yml configuration file with proper authentication
CONFIG_DIR="${CONFIG_VOLUME:-${CONFIG_PATH:-./config}}"
# Determine config directory - use CONFIG_PATH from dropshell or fallback
if [ -n "$CONFIG_PATH" ]; then
CONFIG_DIR="$CONFIG_PATH"
elif [ -d "./config" ]; then
CONFIG_DIR="./config"
else
CONFIG_DIR="."
fi
# Ensure config directory exists
mkdir -p "$CONFIG_DIR"

View File

@@ -2,6 +2,11 @@
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
# Define volume names if not set
CONFIG_VOLUME="${CONFIG_VOLUME:-${CONTAINER_NAME}_config}"
DATA_VOLUME="${DATA_VOLUME:-${CONTAINER_NAME}_data}"
CERTS_VOLUME="${CERTS_VOLUME:-${CONTAINER_NAME}_certs}"
# Create Docker command
cmd="docker run -d \
--name $CONTAINER_NAME \

View File

@@ -56,29 +56,68 @@ fi
echo "Starting ELK stack..."
docker compose up -d --build || _die "Failed to start ELK stack"
# Wait for services to be ready
# Wait for services to be ready with polling
echo "Waiting for services to start..."
sleep 10
MAX_WAIT=120 # Maximum 2 minutes
WAITED=0
while [ $WAITED -lt $MAX_WAIT ]; do
# Check if all services are running
if bash ./status.sh 2>/dev/null | grep -q "Running"; then
echo "All services are up!"
break
fi
# Check status
bash ./status.sh || _die "Services failed to start properly"
# Show progress
echo -n "."
sleep 2
WAITED=$((WAITED + 2))
done
echo ""
if [ $WAITED -ge $MAX_WAIT ]; then
echo "Warning: Services took longer than expected to start"
echo "Checking current status..."
bash ./status.sh || true
fi
# Create custom user
echo "Setting up custom user..."
docker exec ${CONTAINER_NAME}_elasticsearch bash -c "
until curl -s -u elastic:${ELASTIC_PASSWORD} http://localhost:9200/_cluster/health | grep -q '\"status\":\"yellow\"\|\"status\":\"green\"'; do
sleep 2
done
echo "Setting up custom user '${KIBANA_USERNAME:-admin}'..."
echo -n "Waiting for Elasticsearch API..."
curl -X POST -u elastic:${ELASTIC_PASSWORD} \
# First wait for Elasticsearch to be ready
WAITED=0
while [ $WAITED -lt 60 ]; do
if docker exec ${CONTAINER_NAME}_elasticsearch curl -s -u elastic:${ELASTIC_PASSWORD} http://localhost:9200/_cluster/health 2>/dev/null | grep -q '"status":"yellow"\|"status":"green"'; then
echo " Ready!"
break
fi
echo -n "."
sleep 2
WAITED=$((WAITED + 2))
done
if [ $WAITED -lt 60 ]; then
# Now create the user
docker exec ${CONTAINER_NAME}_elasticsearch bash -c "
result=\$(curl -s -X POST -u elastic:${ELASTIC_PASSWORD} \
-H 'Content-Type: application/json' \
http://localhost:9200/_security/user/${KIBANA_USERNAME:-admin} \
-d '{
\"password\" : \"${KIBANA_USER_PASSWORD:-changeme}\",
\"roles\" : [ \"superuser\" ],
\"full_name\" : \"Admin User\"
}' 2>/dev/null || true
"
}' 2>/dev/null)
if echo \"\$result\" | grep -q '\"created\":true'; then
echo \"User created successfully\"
else
echo \"User already exists (this is fine)\"
fi
"
else
echo "Warning: Elasticsearch API not ready after 60 seconds"
fi
echo "Installation of ${CONTAINER_NAME} complete"
echo ""