-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update db init script to set proper permissions for RO user
- Loading branch information
Showing
2 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Create the telemetry database and the telemetry role | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL | ||
CREATE DATABASE telemetry; | ||
CREATE ROLE telemetry WITH LOGIN PASSWORD 'changeme'; | ||
GRANT CONNECT ON DATABASE telemetry TO telemetry; | ||
GRANT USAGE ON SCHEMA public TO telemetry; | ||
GRANT SELECT ON ALL TABLES IN SCHEMA public TO telemetry; | ||
CREATE ROLE ${POSTGRES_RO_USER:-telemetry} WITH LOGIN PASSWORD '${POSTGRES_RO_PASSWORD:-changeme}'; | ||
GRANT CONNECT ON DATABASE telemetry TO ${POSTGRES_RO_USER:-telemetry}; | ||
EOSQL | ||
|
||
# Connect to the telemetry database to set up permissions and triggers | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "telemetry" <<-EOSQL | ||
GRANT USAGE ON SCHEMA public TO ${POSTGRES_RO_USER:-telemetry}; | ||
-- Grant SELECT privileges on existing tables | ||
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ${POSTGRES_RO_USER:-telemetry}; | ||
-- Set default privileges for future tables created by the postgres user | ||
ALTER DEFAULT PRIVILEGES FOR USER ${POSTGRES_USER} IN SCHEMA public GRANT SELECT ON TABLES TO ${POSTGRES_RO_USER:-telemetry}; | ||
EOSQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
podman network create rekuper | ||
podman run --name rekuper_db --network rekuper --rm -e POSTGRES_PASSWORD=changeme -v ./init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh:z -p 25432:5432 postgres:17 | ||
podman run \ | ||
--rm \ | ||
--name rekuper_db \ | ||
--network rekuper \ | ||
-e POSTGRES_USER=postgres \ | ||
-e POSTGRES_PASSWORD=changeme \ | ||
-e POSTGRES_RO_USER=telemetry \ | ||
-e POSTGRES_RO_PASSWORD=fero \ | ||
-v ./init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh:z \ | ||
-p 25432:5432 \ | ||
postgres:17 postgres -c log_statement=all |