lovart3/auto_deploy.exp
2025-12-17 20:15:18 +08:00

40 lines
900 B
Plaintext
Executable File

#!/usr/bin/expect
set timeout -1
set host "156.225.27.52"
set port "5204"
set user "root"
set password "Jsjj@8888"
set local_script "remote_deploy_dreamomni2.sh"
set remote_script "/root/remote_deploy_dreamomni2.sh"
puts "Starting deployment to $host..."
# Step 1: Upload the deployment script
puts "Uploading deployment script..."
spawn scp -P $port $local_script $user@$host:$remote_script
expect {
"Are you sure you want to continue connecting" {
send "yes\r"
exp_continue
}
"password:" {
send "$password\r"
}
}
expect eof
# Step 2: Execute the script remotely
puts "Executing deployment script on remote server..."
spawn ssh -p $port $user@$host "bash $remote_script"
expect {
"password:" {
send "$password\r"
}
}
# Keep the session open to show output until the remote command finishes
expect eof
puts "Deployment process finished."