forked from mtusi2026/mtusi2026lab7
17 lines
738 B
Bash
17 lines
738 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
password_hash=$(tr -d '\r\n' </run/secrets/redis_password | sha256sum | cut -d ' ' -f 1)
|
|
mkdir -p /run/redis
|
|
umask 077
|
|
printf 'user session on #%s ~session:* +get +set +del +ping +hello +select +client|setinfo\n' "$password_hash" >/run/redis/users.acl
|
|
if [ -r /run/secrets/test_redis_password ]; then
|
|
test_hash=$(sha256sum </run/secrets/test_redis_password | cut -d ' ' -f 1)
|
|
printf 'user default reset on #%s ~* &* +@all\n' "$test_hash" >>/run/redis/users.acl
|
|
else
|
|
printf 'user default off\n' >>/run/redis/users.acl
|
|
fi
|
|
chown redis:redis /run/redis/users.acl
|
|
chmod 600 /run/redis/users.acl
|
|
exec /usr/local/bin/docker-entrypoint.sh redis-server /usr/local/etc/redis/redis.conf --aclfile /run/redis/users.acl
|