Skip to content
Snippets Groups Projects
Commit 9ef0a5ec authored by Mario Wenzel's avatar Mario Wenzel
Browse files

user creation script

parent 7ff1ec04
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER docker;
CREATE DATABASE docker;
GRANT ALL PRIVILEGES ON DATABASE docker TO docker;
users=`cat /docker-entrypoint-initdb.d/users`
for user in $users ;
do
echo Creating user $user
user_pw=`echo -n $user | md5sum | cut -c -5`
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER $user;
CREATE DATABASE $user;
REVOKE connect ON DATABASE $user FROM PUBLIC;
GRANT ALL PRIVILEGES ON DATABASE $user TO $user;
ALTER USER $user WITH PASSWORD '$user_pw';
EOSQL
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment