-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
87 lines (74 loc) · 2.1 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
87 lines (74 loc) · 2.1 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env sh
set -eu
# If the user supplied args, respect them (advanced usage)
if [ "$#" -gt 0 ]; then
case "$1" in
-*)
# User passed flags directly
exec dragonfly "$@"
;;
dragonfly|*/dragonfly)
# User invoked dragonfly explicitly
exec "$@"
;;
*)
# User passed arbitrary command - reject to avoid confusion
echo "ERROR: Unrecognized command '$1'. Use dragonfly flags or leave empty for auto-config." >&2
exit 1
;;
esac
fi
# Defaults from env (see README for documentation)
LOGTOSTDERR="${LOGTOSTDERR:-true}"
DIR_ENV="${DIR:-}"
S3_BUCKET_URL="${S3_BUCKET_URL:-}"
DF_DIR="${DF_DIR:-/data}"
SNAPSHOT_CRON="${SNAPSHOT_CRON:-}"
DBFILENAME="${DBFILENAME:-dump-{timestamp}}"
S3_ENDPOINT="${S3_ENDPOINT:-}"
S3_USE_HTTPS="${S3_USE_HTTPS:-true}"
S3_SIGN_PAYLOAD="${S3_SIGN_PAYLOAD:-true}"
S3_EC2_METADATA="${S3_EC2_METADATA:-false}"
VMODULE="${VMODULE:-}"
# Build argument vector safely
set -- dragonfly
if [ "$LOGTOSTDERR" = "true" ]; then
set -- "$@" --logtostderr
fi
# Determine dir: prefer S3_BUCKET_URL, then DIR env, else fallback to DF_DIR
if [ -n "$S3_BUCKET_URL" ]; then
set -- "$@" --dir "$S3_BUCKET_URL"
else
if [ -n "$DIR_ENV" ]; then
set -- "$@" --dir "$DIR_ENV"
else
set -- "$@" --dir "$DF_DIR"
fi
fi
if [ -n "$SNAPSHOT_CRON" ]; then
set -- "$@" --snapshot_cron "$SNAPSHOT_CRON"
fi
if [ -n "$DBFILENAME" ]; then
set -- "$@" --dbfilename "$DBFILENAME"
fi
if [ -n "$S3_ENDPOINT" ]; then
set -- "$@" --s3_endpoint "$S3_ENDPOINT"
fi
set -- "$@" --s3_use_https="$S3_USE_HTTPS"
set -- "$@" --s3_sign_payload="$S3_SIGN_PAYLOAD"
set -- "$@" --s3_ec2_metadata="$S3_EC2_METADATA"
if [ -n "$VMODULE" ]; then
set -- "$@" --vmodule="$VMODULE"
fi
# Add password if REDIS_PASSWORD is set (for Coolify compatibility)
if [ -n "${REDIS_PASSWORD:-}" ]; then
set -- "$@" --requirepass "$REDIS_PASSWORD"
fi
# Allow extra flags via whitespace-separated EXTRA_FLAGS
if [ -n "${EXTRA_FLAGS:-}" ]; then
# Safely append each flag from EXTRA_FLAGS to the argument vector.
for flag in $EXTRA_FLAGS; do
set -- "$@" "$flag"
done
fi
exec "$@"