#!/usr/bin/env sh
set -eu

APPIMAGE="/opt/remoteroom-framestream/RemoteRoom-Framestream.AppImage"

if [ ! -x "$APPIMAGE" ]; then
  echo "RemoteRoom Framestream AppImage is not installed or executable: $APPIMAGE" >&2
  exit 1
fi

if [ "${APPIMAGE_EXTRACT_AND_RUN:-}" = "1" ]; then
  exec "$APPIMAGE" "$@"
fi

if command -v fusermount3 >/dev/null 2>&1 || command -v fusermount >/dev/null 2>&1; then
  exec "$APPIMAGE" "$@"
fi

export APPIMAGE_EXTRACT_AND_RUN=1
exec "$APPIMAGE" "$@"
