123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #!/bin/bash
- file_name="admin.zip"
- file_path="measure.hczcxx.cn"
- demo_url="http://measure.hczcxx.cn/"
- passwd="%CX0&qPRk2BitWPH^tCa5jxZKPYuST"
- 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@47.110.251.215:/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@47.110.251.215
- 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@47.110.251.215
- 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
|