#!/usr/bin/env bash

DIR=$(dirname $(dirname $BASH_SOURCE))

if [[ $1 = "update" ]] | [[ $1 = "install" ]]; then
    $DIR/scripts/update.sh $DIR
else
    FLASK_APP=$DIR flask db upgrade -d $DIR/migrations
    gunicorn cactool:app -b :$(python3 $DIR/scripts/get-port.py) --chdir $DIR -w 4
fi

