@@ -177,7 +177,7 @@ function generate_postgresql_recovery_config() {
177177function generate_passwd_file() {
178178 export USER_ID=$( id -u)
179179 export GROUP_ID=$( id -g)
180- grep -v -e ^postgres -e ^$USER_ID /etc/passwd > " $HOME /passwd"
180+ grep -v -e ^postgres -e ^$USER_ID -e ^ $( id -un ) /etc/passwd > " $HOME /passwd"
181181 echo " postgres:x:${USER_ID} :${GROUP_ID} :PostgreSQL Server:${HOME} :/bin/bash" >> " $HOME /passwd"
182182 export LD_PRELOAD=libnss_wrapper.so
183183 export NSS_WRAPPER_PASSWD=${HOME} /passwd
@@ -189,7 +189,10 @@ initdb_wrapper ()
189189 # Initialize the database cluster with utf8 support enabled by default.
190190 # This might affect performance, see:
191191 # http://www.postgresql.org/docs/14/static/locale.html
192- LANG=${LANG:- en_US.utf8} " $@ "
192+ ENCODING=${POSTGRESQL_ENCODING:- UTF8}
193+ LOCALE=${POSTGRESQL_LOCALE:- en_US}
194+ if [ ${LOCALE} == " C" ] ; then LANG=C; fi
195+ LANG=${LANG:- $LOCALE .$ENCODING } " $@ " -E $ENCODING
193196}
194197
195198function initialize_database() {
222225function create_users() {
223226 if [[ " ,$postinitdb_actions ," = * ,simple_db,* ]]; then
224227 createuser " $POSTGRESQL_USER "
225- createdb --owner=" $POSTGRESQL_USER " " $POSTGRESQL_DATABASE "
228+
229+ EXTRA_ARGS=" "
230+ if [ -v POSTGRESQL_ENCODING ]; then
231+ EXTRA_ARGS=" $EXTRA_ARGS -E $POSTGRESQL_ENCODING "
232+ fi
233+ if [ -v POSTGRESQL_LOCALE ]; then
234+ EXTRA_ARGS=" $EXTRA_ARGS -l $POSTGRESQL_LOCALE "
235+ fi
236+
237+ createdb $EXTRA_ARGS --owner=" $POSTGRESQL_USER " " $POSTGRESQL_DATABASE "
226238 fi
227239
228240 if [ -v POSTGRESQL_MASTER_USER ]; then
0 commit comments