#!/bin/sh
# Read-only, offline preflight for this exact manual-install package.
set -eu
package=${1:-/tmp/gvvpn_0.1.0-8_x86_64.ipk}
expected=098bfca828533e9ce8b9a8aa2ebbf8db6ec7c0870e67a3ca66e2f1210fa9a12f
[ -r /etc/openwrt_release ] || { echo 'Unsupported system: OpenWrt required.' >&2; exit 1; }
. /etc/openwrt_release
[ "${DISTRIB_ID:-}" = OpenWrt ] && [ "${DISTRIB_RELEASE:-}" = 24.10.7 ] || {
 echo 'This release is verified only on OpenWrt 24.10.7.' >&2; exit 1;
}
command -v opkg >/dev/null 2>&1 || { echo 'opkg is required; APK systems are not supported by this IPK.' >&2; exit 1; }
opkg print-architecture | awk '$2=="x86_64" {ok=1} END {exit !ok}' || {
 echo 'This package requires x86_64.' >&2; exit 1;
}
[ -f "$package" ] || { echo 'Upload the exact IPK to the router first.' >&2; exit 1; }
actual=$(sha256sum "$package"); actual=${actual%% *}
[ "$actual" = "$expected" ] || { echo 'Package checksum mismatch; installation refused.' >&2; exit 1; }
printf '%s\n' 'Compatible release and architecture; exact package checksum verified.'
printf '%s\n' 'Dependencies must come from feeds matching this firmware and kernel.'
printf '%s\n' 'No installation or router setting has been changed.'
