1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/bin/bash
- POD_DB_USER='pod_user'
- POD_DB_USER_PASSWORD='pod_user_password'
- POD_DB_NAME='pod'
-
-
-
-
- BUILD_DB_SQL="
- CREATE USER ${POD_DB_USER} WITH PASSWORD '${POD_DB_USER_PASSWORD}';
- CREATE DATABASE ${POD_DB_NAME};
- GRANT ALL PRIVILEGES ON DATABASE ${POD_DB_NAME} to ${POD_DB_USER};
- "
-
- if [ `whoami` != 'postgres' ]; then
- echo "This script is intended to be executed as postgres user."
- exit 1
- fi
-
- echo "About to create a new database and user:"
- echo "- database: ${POD_DB_NAME}"
- echo "- user: ${POD_DB_USER}"
- echo "- password: xxxxxx"
- echo
- echo "Sleeping 10 seconds."
- echo "- stop process by CTRL+C if in doubt."
- echo "..."
- sleep 10
-
- echo ${BUILD_DB_SQL} | psql
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- echo
- echo "You can now init schema and data by running the following command:"
- echo
- echo "psql -h 127.0.0.1 -U ${POD_DB_USER} -W ${POD_DB_NAME} < pod-init-database.sql"
- echo
- echo "note that you'll be asked for the password"
|