82 lines
2.2 KiB
Plaintext
Executable File
82 lines
2.2 KiB
Plaintext
Executable File
#!/usr/bin/expect -f
|
|
|
|
set timeout 1800
|
|
set password "DMUEjmnh6mDs/qlzhpjDzQ"
|
|
set server "2.58.65.188"
|
|
|
|
log_user 1
|
|
|
|
spawn ssh -o StrictHostKeyChecking=no service@$server
|
|
|
|
expect {
|
|
"password:" {
|
|
send "$password\r"
|
|
exp_continue
|
|
}
|
|
"$ " {
|
|
# Переход в root
|
|
send "sudo su -\r"
|
|
expect {
|
|
"password:" {
|
|
send "$password\r"
|
|
expect "# "
|
|
}
|
|
"# " {
|
|
# Уже root
|
|
}
|
|
}
|
|
|
|
# Проверка и запуск скрипта
|
|
send "ls -la /tmp/auto_deploy.sh\r"
|
|
expect "# "
|
|
|
|
send "chmod +x /tmp/auto_deploy.sh\r"
|
|
expect "# "
|
|
|
|
send "echo 'Starting MY Network Bootstrap deployment...'\r"
|
|
expect "# "
|
|
|
|
# Запуск скрипта развертывания
|
|
send "/tmp/auto_deploy.sh\r"
|
|
|
|
# Ожидаем завершения установки (до 30 минут)
|
|
expect {
|
|
"Bootstrap узел готов к работе!" {
|
|
send "echo 'Deployment completed successfully!'\r"
|
|
expect "# "
|
|
|
|
# Проверка результата
|
|
send "systemctl status my-network-bootstrap --no-pager\r"
|
|
expect "# "
|
|
|
|
send "curl -s https://my-public-node-3.projscale.dev/api/my/health || echo 'API check failed'\r"
|
|
expect "# "
|
|
|
|
send "ufw status numbered\r"
|
|
expect "# "
|
|
|
|
send "echo 'MY Network Bootstrap Node deployed successfully!'\r"
|
|
expect "# "
|
|
|
|
interact
|
|
}
|
|
"error" {
|
|
send "echo 'Deployment error occurred'\r"
|
|
interact
|
|
}
|
|
timeout {
|
|
send "echo 'Deployment timeout - checking status...'\r"
|
|
send "systemctl status my-network-bootstrap nginx docker\r"
|
|
interact
|
|
}
|
|
}
|
|
}
|
|
timeout {
|
|
puts "Connection timeout"
|
|
exit 1
|
|
}
|
|
eof {
|
|
puts "Connection closed"
|
|
exit 1
|
|
}
|
|
} |