-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
38 lines (33 loc) · 976 Bytes
/
docker-entrypoint.sh
File metadata and controls
38 lines (33 loc) · 976 Bytes
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
#!/bin/sh
set -eu
PUID="${PUID:-1000}"
PGID="${PGID:-1000}"
# Create or adjust group
group_recreated=false
if ! grep -q '^yoink:' /etc/group; then
addgroup -g "$PGID" -S yoink
else
existing_gid="$(awk -F: '$1 == "yoink" { print $3 }' /etc/group)"
if [ "$existing_gid" != "$PGID" ]; then
if id yoink >/dev/null 2>&1; then
deluser yoink
fi
delgroup yoink
addgroup -g "$PGID" -S yoink
group_recreated=true
fi
fi
# Create or adjust user
if ! id yoink >/dev/null 2>&1 || [ "$group_recreated" = true ]; then
adduser -u "$PUID" -S -D -H -h /app -s /bin/sh -G yoink yoink
else
existing_uid="$(id -u yoink)"
if [ "$existing_uid" != "$PUID" ]; then
deluser yoink
adduser -u "$PUID" -S -D -H -h /app -s /bin/sh -G yoink yoink
fi
fi
# Ensure ownership of writable directories
chown -R yoink:yoink /app /data /music
# Drop privileges and exec the main process
exec su-exec yoink "$@"