Attempting database install fix
This commit is contained in:
parent
35541522f7
commit
25a40d2131
|
@ -31,7 +31,22 @@ apt-get install -y gstreamer1.0-plugins-base \
|
||||||
postgresql-client
|
postgresql-client
|
||||||
|
|
||||||
# Creating database for testing
|
# Creating database for testing
|
||||||
psql -c 'CREATE DATABASE libretime;' -U postgres
|
setupAirtimePostgresUser() {
|
||||||
psql -c "CREATE USER libretime WITH PASSWORD 'libretime';" -U postgres
|
# here-doc to execute this block as postgres user
|
||||||
psql -c 'GRANT CONNECT ON DATABASE libretime TO libretime;' -U postgres
|
su postgres <<'EOF'
|
||||||
psql -c 'ALTER USER libretime CREATEDB;' -U postgres
|
set +e
|
||||||
|
count=$(psql -d postgres -tAc "SELECT count(*) FROM pg_roles WHERE rolname='airtime';")
|
||||||
|
if [[ $count -eq 0 ]]; then
|
||||||
|
psql -d postgres -tAc "CREATE USER airtime WITH ENCRYPTED PASSWORD 'airtime'; ALTER USER airtime CREATEDB; CREATE DATABASE libretime; GRANT CONNECT ON DATABASE libretime TO libretime;"
|
||||||
|
[[ $? -eq 0 ]] &&
|
||||||
|
echo "Created airtime user in PostgreSQL" ||
|
||||||
|
echo "$0:${FUNCNAME}(): ERROR: Can't create airtime user in PostgreSQL!"
|
||||||
|
else
|
||||||
|
echo "airtime user already exists in PostgreSQL"
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
# don't indent this!
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
setupAirtimePostgresUser
|
Loading…
Reference in New Issue