sysconfig/expect-deploy.sh
2021-11-07 12:46:39 +08:00

16 lines
383 B
Bash
Executable File

#!/usr/bin/expect
# Usage: expect this.sh [0:hostname] [1:username] [2:filepath] [3:pwdadot]
set timeout 10
spawn ssh [lindex $argv 1]@[lindex $argv 0] -p 22
expect {
"yes/no"
{send "yes\n";exp_continue}
"password:"
{send "[lindex $argv 3]\n";exp_continue}
":~"
{send "cd [lindex $argv 2] && sudo git pull && sudo npx pm2 restart all && sudo npx pm2 log\n"}
}
interact