-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·45 lines (36 loc) · 1.34 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·45 lines (36 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
set -e
PORT=80
if [ "${USE_TLS}" != 'false' ]; then
PORT=443
sed -i -e "s/#USE_TLS#//g" /etc/rsyslog.conf
fi
CONFIG=""
for cfg in ${LOGENTRIES_CONFIG}; do
name=$(echo $cfg | cut -f1 -d ':')
token=$(echo $cfg | cut -f2 -d ':')
filter=$(echo $cfg | cut -f3 -d ':')
value=$(echo $cfg | cut -f4 -d ':')
if [ -z "${name}" -o -z "${token}" -o -z "${filter}" -o -z "${value}" ]; then
echo "[ERROR]: must supply LOGENTRIES_CONFIG in the format of 'name:token:(hostname|fromip):value'"
exit 1
fi
if [ "${filter}" = 'hostname' -o "${filter}" = 'fromip' ]; then
CONFIG="${CONFIG}\n\$template Logentries-${name},\"${token} %HOSTNAME% %syslogtag%%msg%\\\n\"\n"
if [ "${filter}" = 'hostname' ]; then
CONFIG="${CONFIG}if \$hostname == '${value}' then @@data.logentries.com:${PORT};Logentries-${name}\n& ~"
elif [ "${filter}" = 'fromip' ]; then
CONFIG="${CONFIG}if \$fromhost-ip startswith '${value}' then @@data.logentries.com:${PORT};Logentries-${name}\n& ~"
fi
else
echo "[ERROR]: LOGENTRIES_CONFIG filter must be one of hostname|fromip"
exit 1
fi
done
# If rsyslog doesnt clean up properly then it leaves a hanging pid file, clean it up
if [ -f "/var/run/rsyslogd.pid" ]; then
rm /var/run/rsyslogd.pid
fi
echo -e "${CONFIG}" > /etc/rsyslog.d/logentries.conf
echo "[INFO]: starting rsyslog"
exec "$@"