#!/bin/bash SUDOER_PSW= pw_productiondatabase= pw_developmentdatabase= servicename= service_dev="${servicename}_dev" echo "${SUDOER_PSW}" | sudo -Su postgres psql && bash -s << 'ENDPSQL' create database $servicename; create user $servicename with encrypted password '$pw_productiondatabase'; grant all privileges on database $servicename to $servicename; create database $service_dev; create user $service_dev with encrypted password '$pw_developmentdatabase'; grant all privileges on database $service_dev to $service_dev; ENDPSQL exit