1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #!/bin/bash
- TRACIM_DB_USER='tracim_user'
- TRACIM_DB_USER_PASSWORD='tracim_user_password'
- TRACIM_DB_NAME='tracim'
-
-
-
-
- BUILD_DB_SQL="
- CREATE USER ${TRACIM_DB_USER} WITH PASSWORD '${TRACIM_DB_USER_PASSWORD}';
- CREATE DATABASE ${TRACIM_DB_NAME};
- GRANT ALL PRIVILEGES ON DATABASE ${TRACIM_DB_NAME} TO ${TRACIM_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: ${TRACIM_DB_NAME}"
- echo "- user: ${TRACIM_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 ${TRACIM_DB_USER} -W ${TRACIM_DB_NAME} < tracim-init-database.new.sql"
- echo
- echo "note that you'll be asked for the password"
|