#!/usr/bin/expect -f

set timeout 600

spawn ssh -o StrictHostKeyChecking=no cfdaily@192.168.2.154

expect {
    "Password:" {
        send "Ccf7561523\r"
    }
    "password:" {
        send "Ccf7561523\r"
    }
    "Enter passphrase" {
        send "Ccf7561523\r"
    }
    timeout {
        puts "连接超时"
        exit 1
    }
}

expect "$ "

send "cd /volume1/stock/sanguo_vnpy\r"
expect "$ "

send "ls -la\r"
expect "$ "

send "chmod +x start_on_nas.sh\r"
expect "$ "

send "./start_on_nas.sh\r"

expect {
    "✅ sanguo_vnpy 启动成功" {
        puts "\n\n🎉 部署成功！"
    }
    "Docker" {
        puts "\n\n🚀 Docker 正在部署中，请稍候..."
    }
    timeout {
        puts "\n\n⏳ 命令执行中，部署可能需要5-10分钟..."
    }
}

interact
