#!/bin/bash
set -e

#Allow local connection on default docker network
echo "host  asterisk    all 172.17.0.0/24  md5" >> /var/lib/postgresql/15/data/pg_hba.conf
echo "host  postgres    all 172.17.0.0/24  md5" >> /var/lib/postgresql/15/data/pg_hba.conf

xivo-dird-init-db
echo "Upgrading xivo-dird database ..."
cd /usr/src/xivo-dird && alembic -c alembic.ini upgrade head
