# 提示用户输入区块链用户地址
$userAddress = Read-Host "请输入区块链用户地址(Please input ethereum account address):"

# 验证Bitcoin地址的基本格式
function ValidateBitcoinAddress {
    param (
        [string]$address
    )
    $regex = "^0x[0-9a-fA-F]{40}$"
    if ($address -match $regex) {
        return $true
    } else {
        return $false
    }
}

# 检测用户输入的Bitcoin地址是否正确
if (-not (ValidateBitcoinAddress -address $userAddress)) {
    Write-Host "输入的Ethereum地址无效，请检查格式."
    Exit 1
}

Write-Host "输入的Ethereum地址有效."


# 提示用户输入用户密码
$userPwd = Read-Host "请输入用户密码:"
Write-Host "输入的密码为：$userPwd"

#wsl --update

#wsl --install

#wsl --set-default Ubuntu

#wsl --set-default-version 2

#wsl curl -fsSL get.docker.com -o get-docker.sh
#echo $userPwd | wsl sudo -S sh get-docker.sh --mirror Aliyun

# 在这里可以继续执行其他操作

$linuxDistribution="Ubuntu22.04"
$dockerSh=curl https://get.docker.com
wsl sh $dockerSh
$key=curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey
echo $userPwd | wsl -- sudo -S apt-key add - $key
$list=wsl curl -s -L https://nvidia.github.io/nvidia-docker/$linuxDistribution/nvidia-docker.list
echo $userPwd | wsl -- sudo -S tee /etc/apt/sources.list.d/nvidia-docker.list $list
echo $userPwd | wsl -- sudo -S apt-get update
echo $userPwd | wsl -- sudo -S apt-get install -y nvidia-docker2
echo $userPwd | wsl -- sudo -S  systemctl daemon-reload
echo $userPwd | wsl -- sudo -S  systemctl restart docker
Write-Host "安装nvida-docker依赖完成"



#wsl docker pull containrrr/watchtower
#wsl docker run -d --name watchtower -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --cleanup --debug --interval 60
#Write-Host "启动watchtower自更新程序完成"

#wsl docker pull caduceus/computing-node
#wsl docker run -d -p 9090:9090 -e REWARD_ADDRESS=$userAddress caduceus/computing-node
#Write-Host "启动computing-node程序完成"

