forked from bochengyang/redis-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·54 lines (49 loc) · 2.33 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
#!/bin/sh
set -e
if [ "$1" = 'redis-server' ]; then
if [ "$REDISPASSWORD" ]; then
if [ "$STANDALONE" = 1 ]; then
echo "requirepass $REDISPASSWORD" >> /conf/master.conf
elif [ "$ACT_MASTER" = 1 ]; then
echo "requirepass $REDISPASSWORD" >> /conf/master.conf
echo "masterauth $REDISPASSWORD" >> /conf/master.conf
echo "sentinel auth-pass redis-cluster $REDISPASSWORD" >> /conf/master_sentinel.conf
elif [ "$ACT_SLAVE" = 1 ]; then
echo "requirepass $REDISPASSWORD" >> /conf/slave.conf
echo "masterauth $REDISPASSWORD" >> /conf/slave.conf
echo "sentinel auth-pass redis-cluster $REDISPASSWORD" >> /conf/slave_sentinel.conf
elif [ "$ACT_SENTINEL" = 1 ]; then
echo "sentinel auth-pass redis-cluster $REDISPASSWORD" >> /conf/sentinel_only.conf
fi
fi
if [ "$STANDALONE" = 1 ]; then
redis-server /conf/master.conf &
elif [ "$ACT_MASTER" = 1 ]; then
# string replacement for configuration
cat /conf/master_sentinel.conf | sed "s/REDIS_MASTER_HOSTNAME/$REDIS_MASTER_HOSTNAME/" | sed "s/SENTINEL_QUORUM/$SENTINEL_QUORUM/" > /conf/master_sentinel.conf.tmp
cat /conf/master_sentinel.conf.tmp > /conf/master_sentinel.conf
rm /conf/master_sentinel.conf.tmp
redis-server /conf/master.conf &
redis-sentinel /conf/master_sentinel.conf
elif [ "$ACT_SLAVE" = 1 ]; then
# string replacement for configuration
cat /conf/slave.conf | sed "s/REDIS_MASTER_HOSTNAME/$REDIS_MASTER_HOSTNAME/" > /conf/slave.conf.tmp
cat /conf/slave.conf.tmp > /conf/slave.conf
rm /conf/slave.conf.tmp
cat /conf/slave_sentinel.conf | sed "s/REDIS_MASTER_HOSTNAME/$REDIS_MASTER_HOSTNAME/" | sed "s/SENTINEL_QUORUM/$SENTINEL_QUORUM/" > /conf/slave_sentinel.conf.tmp
cat /conf/slave_sentinel.conf.tmp > /conf/slave_sentinel.conf
rm /conf/slave_sentinel.conf.tmp
redis-server /conf/slave.conf &
redis-sentinel /conf/slave_sentinel.conf
elif [ "$ACT_SENTINEL" = 1 ]; then
# string replacement for configuration
cat /conf/sentinel_only.conf | sed "s/REDIS_MASTER_HOSTNAME/$REDIS_MASTER_HOSTNAME/" | sed "s/SENTINEL_QUORUM/$SENTINEL_QUORUM/" > /conf/sentinel_only.conf.tmp
cat /conf/sentinel_only.conf.tmp > /conf/sentinel_only.conf
rm /conf/sentinel_only.conf.tmp
redis-sentinel /conf/sentinel_only.conf
else
echo "You have not specified STANDALONE, ACT_MASTER, ACT_SLAVE or ACT_SENTINEL in your environment variable"
fi
else
exec "$@"
fi