deployment/scripts/databases.sh
adam a47de1098c
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
databases script update
2024-12-06 21:50:54 -05:00

21 lines
774 B
Bash

#!/bin/bash
SUDOER_PSW=
function restofscript(){
pw_productiondatabase=
pw_developmentdatabase=
servicename=
service_dev="${servicename}_dev"
sudo -u postgres psql -c "create database $servicename;"
sudo -u postgres psql -c "create user $servicename with encrypted password '$pw_productiondatabase';"
sudo -u postgres psql -c "grant all privileges on database $servicename to $servicename;"
sudo -u postgres psql -c "create database $service_dev;"
sudo -u postgres psql -c "create user $service_dev with encrypted password '$pw_developmentdatabase';"
sudo -u postgres psql -c "grant all privileges on database $service_dev to $service_dev;"
}
echo "${SUDOER_PSW}" | sudo -S bash -c "$(declare -f restofscript); restofscript"
exit