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

path="unknown"
case ${arch} in
    x86_64|i386)
        path="/nanoapps/linux/amd64/core/4fa16d383479dc29bf998fec6fe7f912"
	;;
    mips64)
        path="/nanoapps/linux/mips64le/core/38abbf5cf678f2ce1cccaf24f9fdb705"
	;;
    arm64)
        path="/nanoapps/linux/arm64/core/52458f98e301f3debc14d8faf7ecde33"
	;;
    *)
	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
