-
Notifications
You must be signed in to change notification settings - Fork 39
/
run.sh
executable file
·42 lines (34 loc) · 1 KB
/
run.sh
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
#!/bin/sh
# Fail if LOGGLY_AUTH_TOKEN is not set
if [ -z "$LOGGLY_AUTH_TOKEN" ]; then
if [ ! -z "$TOKEN" ]; then
# grandfather old env var
export LOGGLY_AUTH_TOKEN=$TOKEN
else
echo "Missing \$LOGGLY_AUTH_TOKEN"
exit 1
fi
fi
# Fail if LOGGLY_TAG is not set
if [ -z "$LOGGLY_TAG" ]; then
if [ ! -z "$TAG" ]; then
# grandfather old env var
export LOGGLY_TAG=$TAG
else
echo "Missing \$LOGGLY_TAG"
exit 1
fi
fi
# Create spool directory
mkdir -p /var/spool/rsyslog
# If LOGGLY_DEBUG is true, write logs to stdout as well
if [ "$LOGGLY_DEBUG" = true ]; then
sed -i "/\*\.\* @@logs-01\.loggly\.com.*/a \*\.\* \:omstdout\:" /etc/rsyslog.conf
fi
# Expand multiple tags, in the format of tag1:tag2:tag3, into several tag arguments
LOGGLY_TAG=$(echo "$LOGGLY_TAG" | sed 's/:/\\\\" tag=\\\\"/g')
# Replace variables
sed -i "s/LOGGLY_AUTH_TOKEN/$LOGGLY_AUTH_TOKEN/" /etc/rsyslog.conf
sed -i "s/LOGGLY_TAG/$LOGGLY_TAG/" /etc/rsyslog.conf
# Run RSyslog daemon
exec /usr/sbin/rsyslogd -n