小空间消毒机
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.

38 lines
1.1 KiB

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