#!/bin/bash
set -euo pipefail

APP_BIN="/var/lib/mymo-client/current/mymo-client"

case "${1:-}" in
  --check-updates)
    if [ ! -x "$APP_BIN" ]; then
      /usr/lib/mymo-client/bootstrap.sh --check-only
      exit 0
    fi
    exec "$APP_BIN" --check-updates
    ;;
  --bootstrap)
    exec /usr/lib/mymo-client/bootstrap.sh --bootstrap
    ;;
  *)
    if [ ! -x "$APP_BIN" ]; then
      echo "No active MyMo version installed. Run bootstrap first." >&2
      exit 1
    fi
    exec "$APP_BIN" "$@"
    ;;
esac
