#!/bin/bash

# This file was automatically generated. DO NOT EDIT.
# Any changes made to this file will be overwritten.

if [ -f .env ]; then
  set -a; . ./.env; set +a;
fi

if [ "${WORKFLOW_ACCESS_COUNT:-1}" == "1" ]; then
  stoobly-agent setting reset
  stoobly-agent snapshot apply
fi

echo "Configuring intercept..."
stoobly-agent intercept configure --mode record --policy all

if [ "$APP_PROXY_MODE" = "forward" ]; then
  echo "Configuring firewall..."
  stoobly-agent scaffold workflow firewall "$WORKFLOW_NAME"
fi

echo "Configuring UI..."
stoobly-agent setting ui set --url http://local.stoobly.com:4200 > /dev/null
stoobly-agent setting ui disable > /dev/null

entrypoint=$1

if [ -e "$entrypoint" ]; then
  ./"$entrypoint"
fi