updater.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. set -e
  3. INSTALL_DIRECTORY=$1
  4. NEW_APP_DIRECTORY=$2
  5. APP_PID=$3
  6. APP_ARGUMENTS="${@:4}"
  7. error_handler() {
  8. local lineno="$1"
  9. script="""
  10. set alertTitle to \"Ryujinx - Updater error\"
  11. set alertMessage to \"An error occurred during Ryujinx update (updater.sh:$lineno)\n\nPlease download the update manually from our website if the problem persists.\"
  12. display dialog alertMessage with icon caution with title alertTitle buttons {\"Open Download Page\", \"Exit\"}
  13. set the button_pressed to the button returned of the result
  14. if the button_pressed is \"Open Download Page\" then
  15. open location \"https://ryujinx.org/download\"
  16. end if
  17. """
  18. osascript -e "$script"
  19. exit 1
  20. }
  21. trap 'error_handler ${LINENO}' ERR
  22. # Wait for Ryujinx to exit
  23. # NOTE: in case no fds are open, lsof could be returning with a process still living.
  24. # We wait 1s and assume the process stopped after that
  25. lsof -p $APP_PID +r 1 &>/dev/null
  26. sleep 1
  27. # Now replace and reopen.
  28. rm -rf "$INSTALL_DIRECTORY"
  29. mv "$NEW_APP_DIRECTORY" "$INSTALL_DIRECTORY"
  30. open -a "$INSTALL_DIRECTORY" --args "$APP_ARGUMENTS"