fix: configure postgres password auth in bootstrap
This commit is contained in:
@@ -143,6 +143,22 @@ SELECT 'CREATE DATABASE ${DB_NAME} OWNER ${DB_USER}'
|
|||||||
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '${DB_NAME}')\\gexec
|
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '${DB_NAME}')\\gexec
|
||||||
ALTER DATABASE ${DB_NAME} OWNER TO ${DB_USER};
|
ALTER DATABASE ${DB_NAME} OWNER TO ${DB_USER};
|
||||||
SQL
|
SQL
|
||||||
|
local hba_file
|
||||||
|
hba_file="$(runuser -u postgres -- psql -Atc 'SHOW hba_file;')"
|
||||||
|
if [[ -n "$hba_file" ]] && ! grep -q "CMPP platform local access" "$hba_file"; then
|
||||||
|
log "Configuring PostgreSQL local password authentication"
|
||||||
|
cp "$hba_file" "${hba_file}.bak.$(date +%Y%m%d%H%M%S)"
|
||||||
|
{
|
||||||
|
echo "# CMPP platform local access"
|
||||||
|
echo "host ${DB_NAME} ${DB_USER} 127.0.0.1/32 scram-sha-256"
|
||||||
|
echo "host ${DB_NAME} ${DB_USER} ::1/128 scram-sha-256"
|
||||||
|
cat "$hba_file"
|
||||||
|
} >"${hba_file}.tmp"
|
||||||
|
mv "${hba_file}.tmp" "$hba_file"
|
||||||
|
chown postgres:postgres "$hba_file"
|
||||||
|
chmod 600 "$hba_file"
|
||||||
|
fi
|
||||||
|
systemctl reload postgresql || systemctl reload postgresql.service
|
||||||
}
|
}
|
||||||
|
|
||||||
write_env() {
|
write_env() {
|
||||||
|
|||||||
Reference in New Issue
Block a user