1#!/bin/bash
2set -e
3
4# Get current UID/GID from environment or use defaults
5USER_ID=${PUID:-$(stat -c '%u' "$SMALLWEB_DIR")}
6GROUP_ID=${PGID:-$(stat -c '%g' "$SMALLWEB_DIR")}
7
8if [ "$USER_ID" = "0" ]; then
9 exec /usr/local/bin/smallweb "$@"
10fi
11
12if [ "$(id -u smallweb)" != "$USER_ID" ]; then
13 echo "Updating user 'smallweb' with new UID -> $USER_ID"
14 usermod -u "$USER_ID" smallweb
15fi
16
17if [ "$(id -g smallweb)" != "$GROUP_ID" ]; then
18 echo "Updating group 'smallweb' with new GID -> $GROUP_ID"
19 groupmod -g "$GROUP_ID" smallweb
20fi
21
22# Execute the command as the smallweb user
23exec gosu smallweb:smallweb /usr/local/bin/smallweb "$@"