Skip to content

Commit 7e5e879

Browse files
committed
πŸ› fix: redis μ‹œμž‘ 및 μž¬μ‹œμž‘ μ‹œ --aclfile /data/users.acl μ˜΅μ…˜ μΆ”κ°€
1 parent 2acee86 commit 7e5e879

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

β€Ždocker-compose/redis-init.shβ€Ž

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
11
#!/bin/sh
22
set -e
33

4-
# Redis μ„œλ²„λ₯Ό λ°±κ·ΈλΌμš΄λ“œμ—μ„œ μ‹œμž‘
5-
redis-server --daemonize yes
6-
7-
# Redisκ°€ μ™„μ „νžˆ μ‹œμž‘λ  λ•ŒκΉŒμ§€ λŒ€κΈ°
8-
sleep 5
9-
10-
# ν™˜κ²½λ³€μˆ˜λ₯Ό μ‚¬μš©ν•˜μ—¬ ACL μ‚¬μš©μž 생성
11-
# μ»¨ν…Œμ΄λ„ˆ λ‚΄λΆ€μ—μ„œ μ‹€ν–‰λ˜λ―€λ‘œ env_file둜 μ£Όμž…λœ ν™˜κ²½λ³€μˆ˜ μ‚¬μš© κ°€λŠ₯
12-
if [ -n "$REDIS_USER" ] && [ -n "$REDIS_PASSWORD" ]; then
13-
# heredoc을 μ‚¬μš©ν•˜μ—¬ λΉ„λ°€λ²ˆν˜Έ λ…ΈμΆœ λ°©μ§€
14-
if redis-cli <<EOF
15-
ACL SETUSER $REDIS_USER on >$REDIS_PASSWORD allkeys allcommands
16-
ACL SAVE
17-
EOF
18-
then
19-
echo "Redis ACL user created and saved: $REDIS_USER"
20-
else
21-
echo "Error: Failed to create Redis ACL user"
22-
exit 1
23-
fi
24-
else
25-
echo "Warning: REDIS_USER or REDIS_PASSWORD not set"
26-
echo "Error: Redis credentials are required"
4+
echo "Starting Redis initialization..."
5+
6+
# ν™˜κ²½λ³€μˆ˜ 확인
7+
if [ -z "$REDIS_USER" ] || [ -z "$REDIS_PASSWORD" ]; then
8+
echo "Error: REDIS_USER or REDIS_PASSWORD not set"
279
exit 1
2810
fi
2911

30-
# ACL 섀정이 μ™„λ£Œλ˜μ—ˆμœΌλ―€λ‘œ Redisλ₯Ό μ•ˆμ „ν•˜κ²Œ μ’…λ£Œ
12+
echo "REDIS_USER: $REDIS_USER"
13+
14+
# Redisλ₯Ό μ„€μ • 파일과 ν•¨κ»˜ λ°±κ·ΈλΌμš΄λ“œ μ‹œμž‘
15+
redis-server --daemonize yes --dir /data --aclfile /data/users.acl
16+
17+
# μ‹œμž‘ λŒ€κΈ°
18+
sleep 8
19+
20+
# ACL μ‚¬μš©μž 생성
21+
echo "Creating ACL user..."
22+
redis-cli ACL SETUSER "$REDIS_USER" on ">$REDIS_PASSWORD" allkeys allcommands
23+
24+
# ACL 섀정을 νŒŒμΌμ— μ €μž₯ (이제 κ°€λŠ₯!)
25+
redis-cli ACL SAVE
26+
echo "ACL saved to /data/users.acl"
27+
28+
# 확인
29+
redis-cli ACL LIST
30+
31+
# Redis μ’…λ£Œ
3132
redis-cli shutdown
32-
# Redisκ°€ μ™„μ „νžˆ μ’…λ£Œλ  λ•ŒκΉŒμ§€ λŒ€κΈ°
3333
sleep 2
3434

35-
# ν¬κ·ΈλΌμš΄λ“œλ‘œ Redis μž¬μ‹œμž‘ (μ»¨ν…Œμ΄λ„ˆκ°€ μ’…λ£Œλ˜μ§€ μ•Šλ„λ‘)
36-
exec redis-server
35+
# μž¬μ‹œμž‘ μ‹œμ—λ„ ACL 파일 μ‚¬μš©
36+
echo "Starting Redis with ACL configuration..."
37+
exec redis-server --dir /data --aclfile /data/users.acl

0 commit comments

Comments
Β (0)