Skip to content

Commit 4aa6cd7

Browse files
committed
Add LOG_DIR + LOG_FILE arguments
1 parent f892016 commit 4aa6cd7

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

Dockerfile

+13-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ ENV WORKDIR="/home/user"
55
ARG CLIENT_ID=""
66
ARG CLIENT_SECRET=""
77
ARG API_BASE_URL=""
8+
# The LOG_DIR has to be the directory until the LOG_FILE
9+
# By default the LOG_FILE writes to stdout
10+
# Example:
11+
# LOG_DIR="/var/log/crowdstrike/falconhoseclient/"
12+
# LOG_FILE="output"
13+
ARG LOG_DIR=""
14+
ARG LOG_FILE="/dev/stdout"
15+
16+
# Pass them to the environment
17+
ENV LOG_DIR=$LOG_DIR
18+
ENV LOG_FILE=$LOG_FILE
819

920
USER root
1021

@@ -20,15 +31,14 @@ RUN apt-get update && apt-get install -y gettext-base curl
2031
COPY deb/crowdstrike-cs-falconhoseclient_2.18.0_amd64.deb "${WORKDIR}/crowdstrike.deb"
2132
RUN dpkg -i "${WORKDIR}/crowdstrike.deb"
2233

23-
RUN mkdir -p /var/log/pods/falconhoseclient
34+
RUN if [ ! -z "${LOG_DIR}" ]; then mkdir -p "${LOG_DIR}"; fi
2435

2536
# Prepare a simple user instead of root
2637
RUN groupadd -g 1000 user && useradd -r -u 1000 -g user user
2738
RUN chown -R user:user /var/log/crowdstrike/falconhoseclient
2839
RUN chmod -R 755 /var/log/crowdstrike/falconhoseclient
2940
RUN chown -R user:user /opt/crowdstrike/etc
30-
RUN chown -R user:user /var/log/pods/falconhoseclient
31-
RUN chmod -R 755 /var/log/pods/falconhoseclient
41+
RUN if [ ! -z "${LOG_DIR}" ]; then chown -R user:user "${LOG_DIR}"; chmod -R 755 "${LOG_DIR}"; fi
3242

3343
WORKDIR "${WORKDIR}"
3444

cfg/cs.falconhoseclient.cfg.template

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ output_format = json
3232
# Will be true regardless if Syslog is not enabled
3333
# If path does not exist or user has no permission, log file will be used
3434
output_to_file = true
35-
#output_path = /dev/stdout
36-
output_path = /var/log/pods/falconhoseclient/events.log
35+
output_path = $LOG_DIR$LOG_FILE
3736

3837
# Offset file full filepath and filename
3938
offset_path = /var/log/crowdstrike/falconhoseclient/stream_offsets

entrypoint.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ if [ -z "$CLIENT_ID" ] || [ -z "$CLIENT_SECRET" ] || [ -z "$API_BASE_URL" ]; the
2727
exit 1
2828
fi
2929

30+
if [ -z "$LOG_DIR" ] && [ -z "$LOG_FILE" ]; then
31+
LOG_DIR=""
32+
LOG_FILE="/dev/stdout"
33+
fi
34+
3035
# Substitute things properly
31-
export $(echo "CLIENT_ID=$CLIENT_ID CLIENT_SECRET=$CLIENT_SECRET API_BASE_URL=$API_BASE_URL") && envsubst < "${WORKDIR}/${CONFIG}.template" > "${CONFIGDIR}/${CONFIG}"
36+
export $(echo "CLIENT_ID=$CLIENT_ID CLIENT_SECRET=$CLIENT_SECRET API_BASE_URL=$API_BASE_URL LOG_DIR=$LOG_DIR LOG_FILE=$LOG_FILE") && envsubst < "${WORKDIR}/${CONFIG}.template" > "${CONFIGDIR}/${CONFIG}"
3237

3338
# Run the client
3439
cs.falconhoseclient -nodaemon -config="${CONFIGDIR}/${CONFIG}" 2>&1

0 commit comments

Comments
 (0)