2023-02-25 12:30:48 +01:00
#!/bin/bash
set -e
INSTALL_DIRECTORY = $1
NEW_APP_DIRECTORY = $2
APP_PID = $3
2023-06-28 19:09:48 +02:00
APP_ARGUMENTS = ( " ${ @ : 4 } " )
2023-02-25 12:30:48 +01:00
error_handler( ) {
local lineno = " $1 "
script = "" "
set alertTitle to \" Ryujinx - Updater error\"
set alertMessage to \" An error occurred during Ryujinx update ( updater.sh:$lineno ) \n \n Please download the update manually from our website if the problem persists.\"
display dialog alertMessage with icon caution with title alertTitle buttons { \" Open Download Page\" , \" Exit\" }
set the button_pressed to the button returned of the result
if the button_pressed is \" Open Download Page\" then
2024-12-06 15:18:24 +01:00
open location \" https://ryujinx.app/download\"
2023-02-25 12:30:48 +01:00
end if
"" "
osascript -e " $script "
exit 1
}
2023-05-19 21:20:01 +02:00
trap 'error_handler ${LINENO}' ERR
2023-05-28 22:54:30 +02:00
# Wait for Ryujinx to exit.
# If the main process is still acitve, we wait for 1 second and check it again.
# After the fifth time checking, this script exits with status 1.
attempt = 0
while true; do
2023-06-28 19:09:48 +02:00
if lsof -p " $APP_PID " +r 1 & >/dev/null || ps -p " $APP_PID " & >/dev/null; then
2023-05-28 22:54:30 +02:00
if [ " $attempt " -eq 4 ] ; then
exit 1
fi
sleep 1
else
break
fi
( ( attempt++ ) )
done
sleep 1
2023-02-25 12:30:48 +01:00
# Now replace and reopen.
rm -rf " $INSTALL_DIRECTORY "
mv " $NEW_APP_DIRECTORY " " $INSTALL_DIRECTORY "
2023-05-17 19:02:15 +02:00
if [ " $# " -le 3 ] ; then
open -a " $INSTALL_DIRECTORY "
else
2023-06-28 19:09:48 +02:00
open -a " $INSTALL_DIRECTORY " --args " ${ APP_ARGUMENTS [@] } "
2024-12-06 15:18:24 +01:00
fi