Files
dropshell-templates/logclient/start.sh
Your Name d32042e42d
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 45s
Update 3 files
2025-09-20 11:34:01 +12:00

36 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
# Check that config file exists
if [ ! -f "${CONFIG_PATH}/filebeat.yml" ]; then
_die "filebeat.yml not found in ${CONFIG_PATH}/filebeat.yml"
fi
# Create Docker command
DOCKER_RUN_CMD="docker run -d \
--name $CONTAINER_NAME \
--restart unless-stopped \
--user root \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /var/log:/var/log:ro \
-v ${CONFIG_PATH}:/usr/share/filebeat/config:ro \
-v ${DATA_VOLUME}:/usr/share/filebeat/data \
-e LOGSERVER_HOST=${LOGSERVER_HOST} \
-e LOGSERVER_PORT=${LOGSERVER_PORT} \
-e API_KEY=${API_KEY} \
-e HOSTNAME=$(hostname) \
$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG \
filebeat -e -strict.perms=false \
-c /usr/share/filebeat/config/filebeat.yml"
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
_die "Failed to start container ${CONTAINER_NAME}"
fi
# Check if the container is running
if ! _is_container_running "$CONTAINER_NAME"; then
_die "Container ${CONTAINER_NAME} is not running"
fi
echo "Container ${CONTAINER_NAME} started"