Dispatcharr/docker/init/01-user-setup.sh

21 lines
558 B
Bash

#!/bin/bash
# Set up user details
export PUID=${PUID:-1000}
export PGID=${PGID:-1000}
# Create group if it doesn't exist
if ! getent group "$PGID" >/dev/null 2>&1; then
groupadd -g "$PGID" dispatch
fi
# Create user if it doesn't exist
if ! getent passwd $PUID > /dev/null 2>&1; then
useradd -u $PUID -g $PGID -m $POSTGRES_USER
else
existing_user=$(getent passwd $PUID | cut -d: -f1)
if [ "$existing_user" != "$POSTGRES_USER" ]; then
usermod -l $POSTGRES_USER -g $PGID "$existing_user"
fi
fi
usermod -aG www-data $POSTGRES_USER