-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathentrypoint.sh
More file actions
30 lines (23 loc) · 857 Bytes
/
entrypoint.sh
File metadata and controls
30 lines (23 loc) · 857 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
#!/bin/sh
set -e
# Default values if not provided
UID=${UID:-1000}
GID=${GID:-1000}
# Create group if it doesn't exist
if ! getent group omnomgroup >/dev/null; then
addgroup --gid $GID omnomgroup
fi
# Create user if it doesn't exist
if ! id omnomuser >/dev/null 2>&1; then
adduser --disabled-password --gecos "" --shell /bin/sh \
--uid $UID --gid $GID omnomuser
fi
LOCAL_UID=$(id -u omnomuser)
LOCAL_GID=$(getent group omnomgroup | cut -d ":" -f 3)
if [ ! "$UID" = "$LOCAL_UID" ] || [ ! "$GID" = "$LOCAL_GID" ]; then
echo "Warning: User with differing UID $LOCAL_UID/GID $LOCAL_GID already exists, most likely this container was started before with a different UID/GID. Re-create it to change UID/GID."
fi
# Change ownership of the application directory
chown -R $UID:$GID /omnom
# Run as the specified user
exec gosu $UID:$GID "$@"