Other Setting password in BSD installer for postgresql user via bash

There is a need for the BSD installer to add a password change script to PostgreSQL. The script looks like this:
Code:
#!/bin/sh
read -p "New password: " POSTWD
chroot $BSDINSTALL_CHROOT /usr/local/etc/rc.d/postgresql oneinitdb
chroot $BSDINSTALL_CHROOT /usr/local/etc/rc.d/postgresql onestart
chroot $BSDINSTALL_CHROOT psql -U postgres -c "alter user postgres with password '$POSTWD'"
The database is initialized and started, but the password is not set. The command is correct for normal execution. Maybe for the installer it needs to be issued differently or what could be the problem?
 
Read pg_hba.conf for Trust auth for local connections.

/usr/local/pgsql/data/pg_hba.conf

Code:
# TYPE  DATABASE        USER            CIDR-ADDRESS            METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust

Then restart the postgresql and login without password. After that you can set your password and change back the pg_hba.conf to require password as this:


Code:
# TYPE  DATABASE        USER            CIDR-ADDRESS            METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     password
# IPv4 local connections:
host    all             all             127.0.0.1/32            password
# IPv6 local connections:
host    all             all             ::1/128                 password

host    all             all             10.0.1.0/24         password
 
Back
Top