-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
32 lines (25 loc) · 992 Bytes
/
Copy pathentrypoint.sh
File metadata and controls
32 lines (25 loc) · 992 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
#!/bin/bash
# Get PUID and PGID from environment variables, with defaults
PUID=${PUID:-1000}
PGID=${PGID:-1000}
# Get current user info
CURRENT_UID=$(id -u appuser)
CURRENT_GID=$(id -g appuser)
# Adjust IDs if needed
if [ "$PUID" != "$CURRENT_UID" ] || [ "$PGID" != "$CURRENT_GID" ]; then
echo "Updating user appuser to UID:$PUID GID:$PGID"
[ "$PGID" != "$CURRENT_GID" ] && groupmod -g "$PGID" appuser
[ "$PUID" != "$CURRENT_UID" ] && usermod -u "$PUID" appuser
fi
# Always ensure directories exist and are owned correctly (important for SQLite write access)
for d in /app/data /app/backups /app/logs; do
mkdir -p "$d"
chown -R appuser:appuser "$d" 2>/dev/null || true
chmod 775 "$d" 2>/dev/null || true
done
# Ensure app code ownership (helps when mounting volumes)
chown -R appuser:appuser /app 2>/dev/null || true
echo "Directory permissions:"
ls -ld /app/data /app/backups /app/logs 2>/dev/null || true
echo "Switching to appuser..."
exec gosu appuser "$@"