-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstartup.sh
38 lines (31 loc) · 895 Bytes
/
startup.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
#!/bin/bash
set -e
prog=/usr/bin/mackerel-agent
conf=/etc/mackerel-agent/mackerel-agent.conf
if [ "$apikey" != "" ]; then
$prog init -apikey="$apikey"
fi
if [ "$include" != "" ]; then
sed -i -e "s|# Configuration for Custom Metrics Plugins|include = \"${include}\"|" $conf
fi
if [ "$enable_docker_plugin" != "" ] && [ "$enable_docker_plugin" != "0" ] && ! grep '^\[plugin\.metrics\.docker\]' $conf; then
cat >> $conf << "EOF"
[plugin.metrics.docker]
command = "/usr/bin/mackerel-plugin-docker -name-format name"
EOF
fi
cleanup() {
sig="$1"
kill -"$sig" "$PID"
if [ "$auto_retirement" != "" ] && [ "$auto_retirement" != "0" ]; then
$prog retire -force $opts
fi
}
# Propagate signals to mackerel-agent.
for sig in INT TERM QUIT HUP; do
trap "cleanup $sig" $sig
done
echo /usr/bin/mackerel-agent -apikey="$apikey" $opts
$prog $opts &
PID=$!
wait $PID