| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 | #!/bin/bash#本地压缩文件名file_name="analysis.zip"#测试服器上的目录地址file_path="analysis.hczcxx.cn"#测试服务器上的演示地址demo_url="http://192.168.0.109:5188/"#测试服务器上的登录密码passwd="admin123@"# 打包前的准备node ./scripts/build.js# 执行打包命令vite build# 恢复配置文件node ./scripts/restore.js# 排除打包文件if [ $1 == "wgt" ]; then    node ./scripts/public.jsfi# 执行打包为zipnode ./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"    # 删除 static 目录    expect "*]#"    send "rm -rf static\r"    # 解压上传的文件压缩包    expect "*]#"    send "unzip -o ${file_name}\r"    # 退出    send "exit\r"    expect eofEOF    echo "编译打包后自动部署到测试服务器上完成"    echo "测试服务器地址:${demo_url}"}# 删除 plugins 等目录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"    # 删除 plugins 目录    expect "*]#"    send "rm -rf plugins\r"    # 退出    send "exit\r"    expect eofEOF    echo "plugins 等目录移除完成"}# 上传到测试服务器if [ $1 == "all" ]; then    delPublicfiuploadServer
 |