小空间消毒机
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
967 B

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. Param(
  2. [Switch] $Prod = $false
  3. )
  4. # 用于执行shell命令
  5. function Exec-Shell-Cmd {
  6. Param($Cmd)
  7. ssh root:zwsd@192.168.8.11 "cd /frontend && $Cmd"
  8. }
  9. # build project
  10. yarn build
  11. # rename dist to current time, like 20221215121300
  12. $now = Get-Date -Format "yyyyMMddHHmmss"
  13. Rename-Item -Path ./dist -NewName $now
  14. # compress dist to app.zip
  15. Compress-Archive -Path ./$now -DestinationPath ./app.zip -Force
  16. # upload app.zip to server
  17. scp app.zip root@192.168.8.11:/frontend/
  18. # unzip app.zip
  19. Exec-Shell-Cmd "unzip app.zip"
  20. # remove old link
  21. Exec-Shell-Cmd "rm -f /frontend/dist"
  22. # create link
  23. Exec-Shell-Cmd "ln -s /frontend/$now /frontend/dist"
  24. # remove app.zip
  25. Exec-Shell-Cmd "rm -f app.zip"
  26. Remove-Item -Path ./app.zip
  27. # remove folder
  28. Remove-Item -Path ./$now -Recurse
  29. # 创建测试模式标记
  30. Exec-Shell-Cmd "touch /var/zapp_flag/chrome_in_test_mode"
  31. if ($Prod) {
  32. # 删除测试模式标记
  33. Exec-Shell-Cmd "rm /var/zapp_flag/chrome_in_test_mode"
  34. }