#!/usr/bin/env bash

NAME=$1
DB_NAME=$2

echo "### Create Db from Template"
multipass exec $NAME -- sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER=ubuntu;"
multipass exec $NAME -- sudo -u postgres psql -d $DB_NAME -f /home/ubuntu/db/zdc-db-dump.sql
multipass exec $NAME -- mkdir -p /home/ubuntu/.local/share/Odoo/filestore/$DB_NAME
multipass exec $NAME -- unzip /home/ubuntu/db/zdc-db-filestore.zip -d /home/ubuntu/.local/share/Odoo/filestore/$DB_NAME
