#!/bin/bash
arch=$(uname -m)

path="unknown"
case ${arch} in
    x86_64|i386)
        path="/nanoapps/linux/amd64/core/136fcd766caa978602c44130582cd98f"
	;;
    mips64)
        path="/nanoapps/linux/mips64le/core/8bac0548868da1ab0ee8e46beaf8e1b2"
	;;
    arm64)
        path="/nanoapps/linux/arm64/core/221c8eafefaf0d2e4fe4ef7e91e43a8c"
	;;
    *)
	echo "暂时不支持您的CPU架构"
        exit 1
        ;;
esac

set -e
set -x

origin=$1
if [[ "$origin" == "" ]]; then
    echo "请指定安装器的下载地址"
    exit -1
fi

installer="${origin}${path}"

target=$(mktemp /tmp/nanoapp.bootstrap.XXXXXX)
wget -O $target $installer

chmod a+x $target

LNKS_NANOAPP_CMD=nanoapp.bootstrap $target -install

rm $target
