Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -e
- _DB_HOST='127.0.0.1'
- _DB_PORT='5432'
- _DB_USER='postgres'
- _DB_PASSWD='password'
- _PSQL_CLI='psql'
- _DB_LIST=$(cat prod_db_list.txt)
- _PSQL_COMMON="${_PSQL_CLI} -h ${_DB_HOST} -p ${_DB_PORT} -U ${_DB_USER}"
- export PGPASSWORD="${_DB_PASSWD}"
- for _db_name in ${_DB_LIST[@]};
- do
- _TABLE_NAMES=$(${_PSQL_COMMON} -d ${_db_name} -t -c "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';")
- for _table_name in ${_TABLE_NAMES[@]};
- do
- echo ${_PSQL_COMMON} -d ${_db_name} -c "grant all on public.${_table_name} to pguser;"
- done
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement