This repository has been archived by the owner on Sep 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
47 lines (38 loc) · 1.58 KB
/
run.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
#!/bin/bash
if [ "${REDIS_PASS}" == "**Random**" ]; then
unset REDIS_PASS
fi
# Set initial configuration
if [ ! -f /.redis_configured ]; then
touch /etc/redis/redis_default.conf
if [ "${REDIS_PASS}" != "**None**" ]; then
PASS=${REDIS_PASS:-$(pwgen -s 32 1)}
_word=$( [ ${REDIS_PASS} ] && echo "preset" || echo "random" )
echo "=> Securing redis with a ${_word} password"
echo "requirepass $PASS" >> /etc/redis/redis_default.conf
echo "=> Done!"
echo "========================================================================"
echo "You can now connect to this Redis server using:"
echo ""
echo " redis-cli -a $PASS -h <host> -p <port>"
echo ""
echo "Please remember to change the above password as soon as possible!"
echo "========================================================================"
fi
unset REDIS_PASS
# Backwards compatibility
if [ ! -z "${REDIS_MODE}" ]; then
echo "!! WARNING: \$REDIS_MODE is deprecated. Please use \$REDIS_MAXMEMORY_POLICY instead"
if [ "${REDIS_MODE}" == "LRU" ]; then
export REDIS_MAXMEMORY_POLICY=allkeys-lru
unset REDIS_MODE
fi
fi
for i in $(printenv | grep REDIS_); do
echo $i | sed "s/REDIS_//" | sed "s/_/-/" | sed "s/=/ /" | sed "s/^[^ ]*/\L&\E/" >> /etc/redis/redis_default.conf
done
echo "=> Using redis.conf:"
cat /etc/redis/redis_default.conf | grep -v "requirepass"
touch /.redis_configured
fi
exec /usr/bin/redis-server /etc/redis/redis_default.conf