2023-04-29 01:32:09 +08:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure|upgrade|1|2)
|
|
|
|
|
|
|
|
fc-cache -f
|
|
|
|
|
2023-05-11 04:07:44 +08:00
|
|
|
sudo -u postgres psql -c "alter user postgres password 'bbb_graphql'"
|
2023-07-21 09:25:30 +08:00
|
|
|
sudo -u postgres psql -c "drop database if exists bbb_graphql"
|
2023-09-14 20:31:49 +08:00
|
|
|
sudo -u postgres psql -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
|
2023-08-08 21:41:16 +08:00
|
|
|
sudo -u postgres psql -c "alter database bbb_graphql set timezone to 'UTC'"
|
2023-08-23 20:26:32 +08:00
|
|
|
sudo -u postgres psql -U postgres -d bbb_graphql -a -f /usr/share/bbb-graphql-server/bbb_schema.sql --set ON_ERROR_STOP=on
|
2023-07-20 08:31:02 +08:00
|
|
|
|
|
|
|
DATABASE_NAME="hasura_app"
|
|
|
|
DB_EXISTS=$(sudo -u postgres psql -U postgres -tAc "SELECT 1 FROM pg_database WHERE datname='$DATABASE_NAME'")
|
|
|
|
if [ "$DB_EXISTS" = '1' ]
|
|
|
|
then
|
|
|
|
echo "Database $DATABASE_NAME already exists"
|
|
|
|
else
|
|
|
|
sudo -u postgres psql -c "create database hasura_app"
|
|
|
|
echo "Database $DATABASE_NAME created"
|
|
|
|
fi
|
|
|
|
|
2023-04-29 01:32:09 +08:00
|
|
|
echo "Postgresql configured"
|
|
|
|
|
2023-08-15 03:37:22 +08:00
|
|
|
if [ ! -f /.dockerenv ]; then
|
|
|
|
systemctl enable bbb-graphql-server.service
|
|
|
|
systemctl daemon-reload
|
|
|
|
startService bbb-graphql-server || echo "bbb-graphql-server service could not be registered or started"
|
2023-09-15 23:51:47 +08:00
|
|
|
|
|
|
|
#Check if Hasura is ready before applying metadata
|
|
|
|
HASURA_PORT=8080
|
|
|
|
while ! netstat -tuln | grep ":$HASURA_PORT " > /dev/null; do
|
|
|
|
echo "Waiting for Hasura's port ($HASURA_PORT) to be ready..."
|
|
|
|
sleep 1
|
|
|
|
done
|
2023-08-15 04:01:52 +08:00
|
|
|
|
|
|
|
# Apply BBB metadata in Hasura
|
|
|
|
cd /usr/share/bbb-graphql-server
|
2023-08-29 22:01:23 +08:00
|
|
|
/usr/local/bin/hasura metadata apply
|
2023-08-15 04:01:52 +08:00
|
|
|
cd ..
|
|
|
|
rm -rf /usr/share/bbb-graphql-server/metadata
|
2023-08-15 03:37:22 +08:00
|
|
|
fi
|
2023-07-18 04:26:07 +08:00
|
|
|
|
2023-04-29 01:32:09 +08:00
|
|
|
;;
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|