#!/bin/bash

wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh  &>/dev/null
bash install.sh -y &>/tmp/install.log

# 获取 BT-Panel 默认信息
bt_info=$(bt default)

# 提取外网面板地址
external_url=$(echo "$bt_info" | grep -o "https://[^' ]*" | head -n 1)

# 使用 curl 检查外网面板地址的返回码
external_status_code=$(curl -o /dev/null -s -w "%{http_code}" "$external_url")

if [ "$external_status_code" -eq 200 ] || [ "$external_status_code" -eq 404 ]; then
    echo $bt_info |base64
    exit 0
else
    echo "BTPanel install failed."
    exit 1
fi
