#!/usr/bin/env sh

set -e

[ "$(id -u )" -ne 0 ] && exec sudo "$0"

systemctl start postgresql

if ! runuser -u postgres -- psql -lqt | cut -d \| -f 1 | grep -qw faraday; then
  echo
  echo ">>> Init database"
  faraday-manage initdb
  echo
fi

# Only works with localhost, not 127.0.0.1
kali-service-start faraday 5985 http://localhost:5985

