1
1
mirror of https://github.com/bitgapp/eqMac.git synced 2024-11-27 02:02:15 +03:00

updated postinstall script

This commit is contained in:
Nodeful 2021-06-24 14:34:45 +03:00
parent efa87d630a
commit 9cf4695528

View File

@ -4,89 +4,96 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CURRENT_DRIVER_VERSION=$(defaults read /Library/Audio/Plug-Ins/HAL/eqMac.driver/Contents/Info CFBundleVersion) CURRENT_DRIVER_VERSION=$(defaults read /Library/Audio/Plug-Ins/HAL/eqMac.driver/Contents/Info CFBundleVersion)
NEEDED_DRIVER_VERSION=$(defaults read $DIR/eqMac.driver/Contents/Info CFBundleVersion) LATEST_DRIVER_VERSION=$(defaults read $DIR/eqMac.driver/Contents/Info CFBundleVersion)
echo $CURRENT_DRIVER_VERSION echo $CURRENT_DRIVER_VERSION
echo $NEEDED_DRIVER_VERSION echo $LATEST_DRIVER_VERSION
if [ "$CURRENT_DRIVER_VERSION" != "$NEEDED_DRIVER_VERSION" ]; then restart_mac () {
osascript <<EOT
ignoring application responses
tell application "System Events" to restart
end ignoring
EOT
pkill -9 "Installer"
exit 0
}
if [ "$CURRENT_DRIVER_VERSION" != "$LATEST_DRIVER_VERSION" ]; then
# Copy driver into Plug-Ins folder # Copy driver into Plug-Ins folder
cp -f -r "$DIR/eqMac.driver" /Library/Audio/Plug-Ins/HAL/ &>/dev/null cp -f -r "$DIR/eqMac.driver" /Library/Audio/Plug-Ins/HAL/ &>/dev/null
if osascript <<EOT DECISION=$(
tell application id "com.apple.systemuiserver" osascript <<EOT
display dialog \ tell application id "com.apple.systemuiserver"
"It is recommended you restart your Mac for the eqMac to function properly. Alternatively, we can try restarting the macOS Audio service to kickstart the Driver." \ display dialog \
buttons {"Restart Audio", "Restart Mac"} \ "It is recommended you restart your Mac for the eqMac to function properly. \n\nAlternatively, we can try restarting the macOS Audio service to kickstart the Driver (Make sure to Quit any app that uses Audio in any way). \n\nAs last resort, if you're in the middle of critical work, you can skip the recommended steps for now but eqMac might not work until you perform a Restart." \
default button "Restart Mac" \ buttons {"Skip for now", "Restart Audio", "Restart Mac"} \
cancel button "Restart Audio" \ default button "Restart Mac" \
with icon POSIX file "/Applications/eqMac.app/Contents/Resources/AppIcon.icns" with icon POSIX file "/Applications/eqMac.app/Contents/Resources/AppIcon.icns"
end tell end tell
EOT EOT
then )
echo "RESTART"
case $DECISION in
osascript <<EOT "button returned:Skip for now")
ignoring application responses echo "Skip"
tell application "System Events" to restart ;;
end ignoring
"button returned:Restart Audio")
echo "SKIP RESTART"
# Restart CoreAudio
coreaudiod_plist="/System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist"
(launchctl kickstart -k system/com.apple.audio.coreaudiod &>/dev/null || \
launchctl kill SIGTERM system/com.apple.audio.coreaudiod &>/dev/null || \
launchctl kill TERM system/com.apple.audio.coreaudiod &>/dev/null || \
launchctl kill 15 system/com.apple.audio.coreaudiod &>/dev/null || \
launchctl kill -15 system/com.apple.audio.coreaudiod &>/dev/null || \
(launchctl unload "$coreaudiod_plist" &>/dev/null && \
launchctl load "$coreaudiod_plist" &>/dev/null) || \
killall coreaudiod &>/dev/null)
# Wait until CoreAudio restarts
sleep 5
# Wait until coreaudiod has restarted and device is ready to use.
retries=5
while [[ $retries -gt 0 ]]; do
if ! system_profiler SPAudioDataType | grep "eqMac:" >/dev/null 2>&1; then
retries=$((retries - 1))
if [[ $retries -gt 0 ]]; then
echo "Device not ready yet, waiting..."
sleep 3
else
if osascript <<EOT
tell application id "com.apple.systemuiserver"
display dialog \
"Something went wrong during the Audio Service restart process. We highly recommend you restart your Mac, and then launch eqMac." \
buttons {"Skip restart", "Restart Mac"} \
default button "Restart Mac" \
cancel button "Skip restart" \
with icon POSIX file "/Applications/eqMac.app/Contents/Resources/AppIcon.icns"
end tell
EOT EOT
pkill -9 "Installer" then
exit 0 restart_mac()
fi
fi
else else
echo "SKIP RESTART" retries=0
# Restart CoreAudio
coreaudiod_plist="/System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist"
(launchctl kickstart -k system/com.apple.audio.coreaudiod &>/dev/null || \
launchctl kill SIGTERM system/com.apple.audio.coreaudiod &>/dev/null || \
launchctl kill TERM system/com.apple.audio.coreaudiod &>/dev/null || \
launchctl kill 15 system/com.apple.audio.coreaudiod &>/dev/null || \
launchctl kill -15 system/com.apple.audio.coreaudiod &>/dev/null || \
(launchctl unload "$coreaudiod_plist" &>/dev/null && \
launchctl load "$coreaudiod_plist" &>/dev/null) || \
killall coreaudiod &>/dev/null)
# Wait until CoreAudio restarts
sleep 5
# Wait until coreaudiod has restarted and device is ready to use.
retries=5
while [[ $retries -gt 0 ]]; do
if ! system_profiler SPAudioDataType | grep "eqMac:" >/dev/null 2>&1; then
retries=$((retries - 1))
if [[ $retries -gt 0 ]]; then
echo "Device not ready yet, waiting..."
sleep 3
else
if osascript <<EOT
tell application id "com.apple.systemuiserver"
display dialog \
"Something went wrong during the Audio Service restart process. We highly recommend you restart your Mac, and then launch eqMac." \
buttons {"Skip restart", "Restart Mac"} \
default button "Restart Mac" \
cancel button "Skip restart" \
with icon POSIX file "/Applications/eqMac.app/Contents/Resources/AppIcon.icns"
end tell
EOT
then
osascript <<EOT
ignoring application responses
tell application "System Events" to restart
end ignoring
EOT
pkill -9 "Installer"
exit 0
fi
fi
else
retries=0
fi
done
echo "Device became active"
killall SystemUIServer # Restart the menu bar
killall ControlStrip || true # Restart the MBP TouchBar, if you have one
fi fi
done
echo "Device became active"
killall SystemUIServer # Restart the menu bar
killall ControlStrip || true # Restart the MBP TouchBar, if you have one
;;
"button returned:Restart Mac")
echo "RESTART"
restart_mac()
;;
esac
fi fi
open /Applications/eqMac.app open /Applications/eqMac.app