automation script for postgresql

Could you please help how can I run automation script for postgresql after installing postgresql on Ubuntu? I need to automatize DB preparation before using it (create table, insert data, alter permissions).

I need to do it with the current rights of the user.
E.g., I have the only user admin_ubuntu. He has all rights to run psql.
All scripts are written but how can I run the script? usually, I need to edit configs ( I believe, /etc/postgresql/9.1/main/pg_hba.conf). But I do not want to do it.

  • Sentry Docker Port 80
  • Build and use docker image from docker-compose
  • Should Fig be on inside of Vagrant VM or outside for OSX?
  • How to make volumes permanent with Docker Compose v2
  • Docker for Windows error: “Hardware assisted virtualization and data execution protection must be enabled in the BIOS”
  • Dokku showing errors in console
  • So, what I need is just to run sql which will make a lot of things. How can I do it to run it? The problem is that I need to do a lot of things to allow to run sql when the OS is immaculate (empty).

    It will be made every time when the Ubuntu will have been installed.

  • Copy file to a Docker container before starting it
  • Send a file via SFTP to a Docker Container
  • Docker volume conflict
  • how to load dump on docker mysql container based on centos6?
  • Should files from a base Docker image be present in a derived image?
  • YUM lock while running multiple Docker containers on a single host
  • One Solution collect form web for “automation script for postgresql”

    you should be able to run shell provisioning – following is example of what you can do:

    # creating user
    sudo -u postgres psql -c "CREATE USER admin WITH PASSWORD 'password';"
    # creating new db if needed .. might need 2 (dev/test)
    createdb -U vagrant mydevdb
    # if you have more complex things you'll need to put that in a create_db.sql file and run the script as
    sudo -u postgres psql < create_db.sql

    The create_db.sql file can contain any CREATE TABLE statement

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.