| #!/bin/bash |
|
|
| |
| |
| |
| |
| |
| if [ "$(id -u)" -ne 0 ]; then |
| echo "Running as non-root user ($(id -u)). Skipping permission setup." |
| exec "$@" |
| fi |
|
|
| |
| PUID=${PUID:-99} |
| PGID=${PGID:-100} |
|
|
| |
| |
| |
| |
| |
| if [ "$PUID" -eq 0 ]; then |
| echo "PUID set to 0. Running as internal root (Podman default behavior)." |
| exec "$@" |
| fi |
|
|
| echo "-------------------------------------------------------" |
| echo "Initializing Container with PUID: $PUID and PGID: $PGID" |
| echo "-------------------------------------------------------" |
|
|
| |
| if ! getent group "$PGID" >/dev/null; then |
| groupadd -g "$PGID" subgen |
| fi |
|
|
| |
| if ! getent passwd "$PUID" >/dev/null; then |
| useradd -u "$PUID" -g "$PGID" -m -s /bin/bash subgen |
| fi |
|
|
| |
| echo "Fixing permissions on /subgen..." |
| chown -R "$PUID":"$PGID" /subgen |
| echo "Fixing permissions on /cache..." |
| chown -R "$PUID":"$PGID" /cache |
| chown -R "$PUID":"$PGID" /tmp 2>/dev/null || true |
|
|
| |
| if [ -e "/dev/dri/renderD128" ]; then |
| echo "Adding group for /dev/dri/renderD128" |
| GID=`stat -c "%g" /dev/dri/renderD128` |
| groupadd -g $GID render2 |
| GROUP=`getent group $GID | cut -d: -f1` |
| usermod -aG $GROUP subgen |
| fi |
|
|
| echo "Dropping root privileges and starting application..." |
| exec gosu "$PUID" "$@" |
|
|