#!/bin/sh

# echo '正在安装依赖'

# if cat /etc/os-release | grep "centos" > /dev/null
#     then
#     yum install tar wget socat -y > /dev/null
# else
#     apt update > /dev/null
#     apt-get install tar wget socat -y > /dev/null
# fi

nodeid=$1
domain=$2

if [ "${nodeid}" = '' ]; then
    echo -e "error:$ 节点ID为空!!"
    exit 1
fi

rm /opt/XrayR-release -rf
cd /opt
git clone https://github.com/XrayR-project/XrayR-release

wget --no-check-certificate -qO- https://sh.digac.icu/shell/docker_XrayR_vless_reality_config.yml > /opt/XrayR-release/config/config.yml
sed -i 's/API节点/xxx.xxxxxx.com/' /opt/XrayR-release/config/config.yml
sed -i 's/API秘钥/你里填写你的API密钥!!!!!!!!!/' /opt/XrayR-release/config/config.yml
sed -i 's/节点序号/'"${nodeid}"'/' /opt/XrayR-release/config/config.yml
sed -i 's/NodeType: V2ray/NodeType: Vless/' /opt/XrayR-release/config/config.yml #reality 要开启这个
sed -i 's/EnableVless: false/EnableVless: true/' /opt/XrayR-release/config/config.yml #reality 要开启这个
sed -i 's/EnableREALITY: false/EnableREALITY: true/' /opt/XrayR-release/config/config.yml #reality 要开启这个
sed -i 's/DisableLocalREALITYConfig: false/DisableLocalREALITYConfig: true/' /opt/XrayR-release/config/config.yml #reality 要开启这个
sed -i 's/Show: true/Show: false/' /opt/XrayR-release/config/config.yml #reality 要关闭这个

if [ "${domain}" != '' ]; then
#bash <(curl -Lso- 你的CloudFlare.sh脚本位置.修改域名IP为当前vps IP) $domain
# sed -i 's/CertMode: dns/CertMode: none/' /opt/XrayR-release/config/config.yml #关闭 ssl证书申请
# sed -i 's/CertMode: none/CertMode: dns/' /opt/XrayR-release/config/config.yml #开启 ssl证书申请
# sed -i 's/证书域名/'"${domain}"'/' /opt/XrayR-release/config/config.yml
# sed -i 's/证书邮箱/onepve@outlook.com/' /opt/XrayR-release/config/config.yml
# sed -i 's/证书秘钥/ef57d9e107e454e90538ca6a34bae1202cfd9/' /opt/XrayR-release/config/config.yml
fi
cat /opt/XrayR-release/config/config.yml
cd /opt/XrayR-release
docker-compose up -d
docker-compose logs -f -t --tail=10