@@ -177,7 +177,7 @@ function generate_postgresql_recovery_config() {
177
177
function generate_passwd_file() {
178
178
export USER_ID=$( id -u)
179
179
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"
181
181
echo " postgres:x:${USER_ID} :${GROUP_ID} :PostgreSQL Server:${HOME} :/bin/bash" >> " $HOME /passwd"
182
182
export LD_PRELOAD=libnss_wrapper.so
183
183
export NSS_WRAPPER_PASSWD=${HOME} /passwd
@@ -189,7 +189,10 @@ initdb_wrapper ()
189
189
# Initialize the database cluster with utf8 support enabled by default.
190
190
# This might affect performance, see:
191
191
# 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
193
196
}
194
197
195
198
function initialize_database() {
222
225
function create_users() {
223
226
if [[ " ,$postinitdb_actions ," = * ,simple_db,* ]]; then
224
227
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 "
226
238
fi
227
239
228
240
if [ -v POSTGRESQL_MASTER_USER ]; then
0 commit comments