#!/bin/sh
if ! whoami &> /dev/null; then
  if [ -w /etc/passwd ]; then
  	sed  "/postgres:x:26/d" /etc/passwd >> /tmp/uid.tmp
  	cp /tmp/uid.tmp /etc/passwd
  	rm -f /tmp/uid.tmp
    echo "${USER_NAME:-postgres}:x:$(id -u):0:${USER_NAME:-postgres} user:${HOME}:/bin/bash" >> /etc/passwd
  fi
  
  if [ -w /etc/group ]; then
    echo "nfsnobody:x:65534:" >> /etc/group
    echo "postgres:x:$(id -u):postgres" >> /etc/group
  fi
fi
exec "$@"
 
#!/bin/bash

if ! whoami &> /dev/null
then
    if [[ -w /etc/passwd ]]
    then
        sed  "/postgres:x:26:/d" /etc/passwd >> /tmp/uid.tmp
        cp /tmp/uid.tmp /etc/passwd
        rm -f /tmp/uid.tmp
        echo "${USER_NAME:-postgres}:x:$(id -u):0:${USER_NAME:-postgres} user:${HOME}:/bin/bash" >> /etc/passwd
    fi

    if [[ -w /etc/group ]]
    then
        sed  "/postgres:x:26/d" /etc/group >> /tmp/gid.tmp
        cp /tmp/gid.tmp /etc/group
        rm -f /tmp/gid.tmp
        echo "nfsnobody:x:65534:" >> /etc/group
        echo "postgres:x:$(id -g):postgres" >> /etc/group
    fi
fi
exec "$@"

Fix GID bug in postgres containers
Fix GID bug in postgres containers
