#!/bin/sh
set -eu
if ! command -v python3 >/dev/null 2>&1; then
  echo "Disk Doctor requires Python 3.9+ (Linux preview)." >&2; exit 1
fi
python3 -c 'import sys; sys.exit(0 if sys.version_info >= (3,9) and sys.platform.startswith("linux") else 1)' || {
  echo "This preview requires Linux with Python 3.9+." >&2; exit 1;
}
download_dir=$(mktemp -d)
trap 'rm -f "$download_dir/disk_doctor.py"; rmdir "$download_dir"' EXIT HUP INT TERM
curl -fsSL --proto '=https' --tlsv1.2 'https://lupable.com/plugins/disk-doctor/0.3.1/disk_doctor.py' -o "$download_dir/disk_doctor.py"
python3 -c 'import hashlib,sys; b=open(sys.argv[1],"rb").read(); sys.exit(0 if hashlib.sha256(b).hexdigest()==sys.argv[2] else "Download checksum mismatch; not installed")' "$download_dir/disk_doctor.py" 1294b8bb4ecb9cc9f295d4f71dc285c84380a3331f79b34362ec74655ecc3341
python3 "$download_dir/disk_doctor.py" install "$@"
python3 "$download_dir/disk_doctor.py" report
