#!/bin/sh
set -eu
install_leap_os() {
    arch=$(dpkg --print-architecture 2>/dev/null) || arch=
    case "$arch" in
        amd64|arm64) ;;
        *) printf '%s\n' '当前系统不受支持（需要 amd64 或 arm64）' >&2; exit 1 ;;
    esac
    installer=$(curl --proto '=https' --proto-redir '=https' -fsSL --retry 2 \
        --connect-timeout 15 --max-time 60 \
        "https://get.leaprobotics.cn/beta/$arch/install.sh" </dev/null 2>/dev/null) &&
        [ -n "$installer" ] || { printf '%s\n' '下载 LeapOS 安装脚本失败，请稍后重试' >&2; exit 1; }
    exec bash -c "$installer" </dev/null
}
install_leap_os
