123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #!/bin/bash
- file_name="measure.zip"
- file_path="measure.hcxxy.com"
- demo_url="http://192.168.0.109:5180/"
- passwd="admin123@"
- node ./scripts/build.js
- vite build
- node ./scripts/restore.js
- if [ $1 == "wgt" ]; then
- node ./scripts/public.js
- fi
- node ./scripts/zip.js
-
- function uploadServer() {
- expect -c "
- spawn scp ./zip/${file_name} root@192.168.0.109:/www/wwwroot/${file_path}
- expect {
- \"yes/no\" {send \"yes\r\";exp_continue;}
- \"*password\" {set timeout 500;send \"${passwd}\r\";}
- }
- expect eof"
- /usr/bin/expect << EOF
- set time 30
- spawn ssh root@192.168.0.109
- expect {
- "*yes/no" { send "yes\r"; exp_continue }
- "*password:" { send "${passwd}\r" }
- }
-
- expect "*]#"
- send "cd /www/wwwroot/${file_path}\r"
-
- expect "*]#"
- send "rm -rf static\r"
-
- expect "*]#"
- send "unzip -o ${file_name}\r"
-
- send "exit\r"
- expect eof
- EOF
- echo "编译打包后自动部署到测试服务器上完成"
- echo "测试服务器地址:${demo_url}"
- }
- function delPublic() {
- echo "准备移除 plugins 等目录"
- /usr/bin/expect << EOF
- set time 30
- spawn ssh root@192.168.0.109
- expect {
- "*yes/no" { send "yes\r"; exp_continue }
- "*password:" { send "${passwd}\r" }
- }
-
- expect "*]#"
- send "cd /www/wwwroot/${file_path}\r"
-
- expect "*]#"
- send "rm -rf plugins\r"
-
- send "exit\r"
- expect eof
- EOF
- echo "plugins 等目录移除完成"
- }
- if [ $1 == "all" ]; then
- delPublic
- fi
- uploadServer
|