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

31 lines
1.1 KiB

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