#!/bin/sh
# Generated by scripts/after-pack.cjs — see there for why this exists.
#
# Runs getCut with Chromium's sandbox, and falls back to --no-sandbox only
# when the sandbox is what stopped it starting. On Ubuntu 23.10+ that is the
# default state unless /opt/getCut/chrome-sandbox is setuid root or an
# AppArmor profile grants the binary 'userns'.

HERE=$(dirname "$(readlink -f "$0")")
REAL="$HERE/getcut-bin"

if [ ! -x "$REAL" ]; then
  echo "getCut: cannot find \$REAL" >&2
  exit 127
fi

START=$(date +%s)
"$REAL" "$@"
STATUS=$?

if [ "$STATUS" -eq 133 ] && [ "$(( $(date +%s) - START ))" -lt 10 ]; then
  exec "$REAL" --no-sandbox "$@"
fi

exit "$STATUS"
