deployment/scripts/databases.sh
adam 9b70bd9480
All checks were successful
gitea.arg.rip/deployment/pipeline/head This commit looks good
databases initializer script
I think I figured it out. your -s << 'ENDMARKER' is looking for a line that starts with ENDMARKER - no spaces. so you can't indent it nicely.
2024-12-06 21:23:57 -05:00

20 lines
565 B
Bash

#!/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