From 9c6c414a35dce1a210cde7887c82aacc846a33c8 Mon Sep 17 00:00:00 2001 From: Gonzalo Exequiel Pedone Date: Thu, 4 Nov 2021 16:56:06 -0300 Subject: [PATCH] Improved uninstall script. --- ports/deploy/mac/uninstall.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ports/deploy/mac/uninstall.sh b/ports/deploy/mac/uninstall.sh index 07deb08..52967d2 100644 --- a/ports/deploy/mac/uninstall.sh +++ b/ports/deploy/mac/uninstall.sh @@ -1,4 +1,27 @@ appName=AkVirtualCamera + +if [[ "$*" == *--no-gui* ]]; then + if [ "$EUID" -ne 0 ]; then + echo "The uninstall script must be run as root" 1>&2 + + exit -1 + fi +else + answer=$(osascript -e "button returned of (display dialog \"Uninstall ${appName}?\" with icon caution buttons {\"Yes\", \"No\"} default button 2)") + + if [ "$answer" == No ]; then + echo "Uninstall not executed" 1>&2 + + exit -1 + fi + + if [ "$EUID" -ne 0 ]; then + osascript -e "do shell script \"$0 --no-gui\" with administrator privileges" + + exit $? + fi +fi + path=$(realpath "$0") targetDir=$(dirname "$path") @@ -23,3 +46,12 @@ rm -f "${daemonPlist}" # Remove installed files rm -rf "${targetDir}" + +# Ending message +endMessage="${appName} successfully uninstalled" + +if [[ "$*" == *--no-gui* ]]; then + echo "${endMessage}" +else + osascript -e "display dialog \"${endMessage}\" buttons {\"Ok\"} default button 1" +fi