#!/bin/sh
# SCDO T460p first-generation node upgrade 1.0.1. No shell pipe to root.
set -eu
command -v python3 >/dev/null || { echo 'Existing Python 3.10+ required' >&2; exit 2; }
command -v curl >/dev/null || { echo 'Existing curl required' >&2; exit 2; }
command -v sha256sum >/dev/null || { echo 'Existing sha256sum required' >&2; exit 2; }
d=$(mktemp -d)
trap 'rm -rf -- "$d"' EXIT HUP INT TERM
curl -q --fail --silent --show-error --proto '=https' --proto-redir '=https' --tlsv1.2 --connect-timeout 15 --max-time 90 --max-filesize 100000 https://scdo.com.au/downloads/t460p-1.0.1/install.py -o "$d/install.py"
printf '%s  %s\n' '188e63d5bd45cff40642a27258277e11274ba3621f82d604775d9d33a6717b30' "$d/install.py" | sha256sum -c -
python3 -I -B "$d/install.py" "$@"
