forked from SergeyZh/docker-awslogs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-services.sh
53 lines (33 loc) · 811 Bytes
/
run-services.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
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
shutdown_awslogs()
{
echo "Stopping container..."
kill $(pgrep -f /var/awslogs/bin/aws)
exit 0
}
trap shutdown_awslogs INT TERM HUP
REGION=${AWS_REGION:-"eu-west-1"}
cp -f /awslogs.conf.dummy /var/awslogs/etc/awslogs.conf
cp -f /aws.conf.dummy /var/awslogs/etc/aws.conf
if [ "${AWS_ACCESS_KEY_ID}" = "" ] || [ "${AWS_SECRET_ACCESS_KEY}" = "" ]; then
cat >> /var/awslogs/etc/aws.conf <<EOF
region = ${REGION}
EOF
else
cat >> /var/awslogs/etc/aws.conf <<EOF
region = ${REGION}
aws_access_key_id = ${AWS_ACCESS_KEY_ID}
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}
EOF
fi
mkdir ~/.aws
cat >> ~/.aws/config <<EOF
[default]
region=${REGION}
EOF
/configure-awslogs.sh
echo "AWS log config is:"
cat /var/awslogs/etc/awslogs.conf
/usr/sbin/cron
/run-awslogs-agent.sh &
wait