forked from docker-library/rabbitmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·63 lines (57 loc) · 1.21 KB
/
docker-entrypoint.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
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
if [ "$RABBITMQ_ERLANG_COOKIE" ]; then
cookieFile='/var/lib/rabbitmq/.erlang.cookie'
if [ -e "$cookieFile" ]; then
if [ "$(cat "$cookieFile" 2>/dev/null)" != "$RABBITMQ_ERLANG_COOKIE" ]; then
echo >&2
echo >&2 "warning: $cookieFile contents do not match RABBITMQ_ERLANG_COOKIE"
echo >&2
fi
else
echo "$RABBITMQ_ERLANG_COOKIE" > "$cookieFile"
chmod 600 "$cookieFile"
chown rabbitmq "$cookieFile"
fi
fi
if [ "$1" = 'rabbitmq-server' ]; then
configs=(
# https://www.rabbitmq.com/configure.html
default_vhost
default_user
default_pass
)
haveConfig=
for conf in "${configs[@]}"; do
var="RABBITMQ_${conf^^}"
val="${!var}"
if [ "$val" ]; then
haveConfig=1
break
fi
done
if [ "$haveConfig" ]; then
cat > /etc/rabbitmq/rabbitmq.config <<-'EOH'
[
{rabbit,
[
EOH
for conf in "${configs[@]}"; do
var="RABBITMQ_${conf^^}"
val="${!var}"
[ "$val" ] || continue
cat >> /etc/rabbitmq/rabbitmq.config <<-EOC
{$conf, <<"$val">>},
EOC
done
cat >> /etc/rabbitmq/rabbitmq.config <<-'EOF'
{loopback_users, []}
]
}
].
EOF
fi
chown -R rabbitmq /var/lib/rabbitmq
set -- gosu rabbitmq tini -- "$@"
fi
exec "$@"