#!/bin/bash
read -p "请选择您的架构, 然后按回车
(0) linux-amd64
(1) linux-arm64
(2) linux-armv7
" INDEX

spruce_type=(
    "linux-amd64"
    "linux-arm64"
    "linux-armv7"
    )

if [ ${INDEX} -ge ${#spruce_type[@]} ] || [ ${INDEX} -lt 0 ]; then
    echo "请输入有效的源编号"
    exit 1
fi

#别人的api
# MOREF=`curl $1 -s -L -I -o /dev/null -w '%{url_effective}'  https://glare.now.sh/Dreamacro/clash/${spruce_type[${INDEX}]}`

DOWNLOAD_URL=$(curl -s https://api.github.com/repos/Dreamacro/clash/releases/latest \
        | grep browser_download_url \
        | grep ${spruce_type[${INDEX}]}\
        | cut -d '"' -f 4)


proxy="https://gh.api.99988866.xyz/"

wget -O clash.gz  $proxy$DOWNLOAD_URL
gzip -d clash.gz
#curl -L $proxy$DOWNLOAD_URL -o  clash 

rm /usr/local/bin/clash
chmod +x clash
mv clash /usr/local/bin
pm2 start clash



