-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·44 lines (40 loc) · 1.3 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
#!/bin/sh
set -e
# first arg is `-f` or `--some-option`
# or first arg is `something.conf`
if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
set -- redis-server "$@"
fi
# allow the container to be started with `--user`
if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ]; then
chown -R redis .
exec gosu redis "$0" "$@"
fi
if [ "$1" = 'redis-server' ]; then
# Disable Redis protected mode [1] as it is unnecessary in context
# of Docker. Ports are not automatically exposed when running inside
# Docker, but rather explicitely by specifying -p / -P.
# [1] https://github.com/antirez/redis/commit/edd4d555df57dc84265fdfb4ef59a4678832f6da
doProtectedMode=1
configFile=
if [ -f "$2" ]; then
configFile="$2"
if grep -q '^protected-mode' "$configFile"; then
# if a config file is supplied and explicitly specifies "protected-mode", let it win
doProtectedMode=
fi
fi
if [ "$doProtectedMode" ]; then
shift # "redis-server"
if [ "$configFile" ]; then
shift
fi
set -- --protected-mode no "$@"
if [ "$configFile" ]; then
set -- "$configFile" "$@"
fi
set -- redis-server "$@" # redis-server [config file] --protected-mode no [other options]
# if this is supplied again, the "latest" wins, so "--protected-mode no --protected-mode yes" will result in an enabled status
fi
fi
exec "$@"