#!/usr/bin/env bash set -eau dbname="nomnomdev" port="12345" dbdir="$(mktemp -d)" cfgfile="${dbdir}/config.json" trap 'rm -rf ${dbdir}' EXIT initdb "$dbdir" postgres -D "${dbdir}" -c unix_socket_directories="${dbdir}" -c listen_addresses= -c port="${port}" & pgpid=$! # Trick to help the "./psql" script to find the DB dir & co cat < "/tmp/nom-nom-dev-args" export host="$dbdir" export port="$port" export dbname="$dbname" export cfgfile="$cfgfile" EOF trap 'rm -rf ${dbdir} && rm /tmp/nom-nom-dev-args && kill ${pgpid}' EXIT # Yeah, this is very meh. We need to wait for the server to be ready #to receive requests to create the DB. sleep 2 createdb -h "${dbdir}" -p "${port}" "${dbname}" cat < "${cfgfile}" { "url": "http://localhost:8001", "db_host": "${dbdir}", "db_port": ${port}, "db_name": "${dbname}" } EOF cargo build rust-gdb --args ./target/debug/nom-nom-gc-server --bind "[::1]:8001" --config "${cfgfile}"