#!/bin/bash
cd /workspace/GW/mybitauto-operation
#替换环镜变量配置信息 src/main/resources/application.properties
sed -i '' 's/active=.*/active: prod/g' src/main/resources/application.properties
# git pull
mvn clean package
/usr/bin/expect <<-EOF
#参数设置
set timeout 1000
#sftp连接
spawn scp mybitauto-admin/target/mybitauto-admin.jar root@11.12.11.11:/data/yy.mybitauto.com/yy.mybitauto.com.jar
#第一次sftp时需输入yes
expect {
"(yes/no)?" {send "yes\r"; exp_continue}
"password:" {
send "Mybitauto@2018\r"
}
}
expect "*#"
spawn ssh root@47.11.11.11
expect "*password:"
send "Mybitauto@2018\r"
expect "*#"
send "cd /data/yy.mybitauto.com/\r"
expect "*#"
send "rm -rf log.log\r"
send "ps aux | grep yy.mybitauto.com | cut -c 9-15 | xargs kill -9\r"
send "nohup java -server -jar yy.mybitauto.com.jar --spring.profiles.active=prod>nohup.log 2>&1 &\r"
send "exit\r"
expect eof
EOF
cd /workspace/GW/mybitauto-operation
#替换环镜变量配置信息 src/main/resources/application.properties
sed -i '' 's/active=.*/active: prod/g' src/main/resources/application.properties
# git pull
mvn clean package
/usr/bin/expect <<-EOF
#参数设置
set timeout 1000
#sftp连接
spawn scp mybitauto-admin/target/mybitauto-admin.jar root@11.12.11.11:/data/yy.mybitauto.com/yy.mybitauto.com.jar
#第一次sftp时需输入yes
expect {
"(yes/no)?" {send "yes\r"; exp_continue}
"password:" {
send "Mybitauto@2018\r"
}
}
expect "*#"
spawn ssh root@47.11.11.11
expect "*password:"
send "Mybitauto@2018\r"
expect "*#"
send "cd /data/yy.mybitauto.com/\r"
expect "*#"
send "rm -rf log.log\r"
send "ps aux | grep yy.mybitauto.com | cut -c 9-15 | xargs kill -9\r"
send "nohup java -server -jar yy.mybitauto.com.jar --spring.profiles.active=prod>nohup.log 2>&1 &\r"
send "exit\r"
expect eof
EOF