-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
58 lines (48 loc) · 1.07 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
58 lines (48 loc) · 1.07 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
#!/bin/sh
set -eu
APP_UID=1000
APP_GID=1000
CONFIG_DIR="${CONFIG_DIR:-/config}"
case "$CONFIG_DIR" in
/*)
;;
*)
echo "CONFIG_DIR must be an absolute path: $CONFIG_DIR" >&2
exit 1
;;
esac
case "$CONFIG_DIR" in
"/"|\
"/app"|"/app/"*|\
"/bin"|"/bin/"*|\
"/dev"|"/dev/"*|\
"/etc"|"/etc/"*|\
"/lib"|"/lib/"*|\
"/proc"|"/proc/"*|\
"/root"|"/root/"*|\
"/run"|"/run/"*|\
"/sbin"|"/sbin/"*|\
"/sys"|"/sys/"*|\
"/usr"|"/usr/"*)
echo "Refusing unsafe CONFIG_DIR: $CONFIG_DIR" >&2
exit 1
;;
esac
if [ "$(id -u)" -eq 0 ]; then
mkdir -p "$CONFIG_DIR"
echo "Ensuring ownership of $CONFIG_DIR"
chown -R "${APP_UID}:${APP_GID}" "$CONFIG_DIR"
exec /sbin/su-exec \
"${APP_UID}:${APP_GID}" \
/app/dyndns \
"$@"
fi
if [ ! -d "$CONFIG_DIR" ]; then
echo "CONFIG_DIR does not exist: $CONFIG_DIR" >&2
exit 1
fi
if [ ! -w "$CONFIG_DIR" ]; then
echo "CONFIG_DIR is not writable by UID $(id -u): $CONFIG_DIR" >&2
exit 1
fi
exec /app/dyndns "$@"