Improved uninstall script.

This commit is contained in:
Gonzalo Exequiel Pedone 2021-11-04 16:56:06 -03:00
parent 35c648554a
commit 9c6c414a35
No known key found for this signature in database
GPG key ID: B8B09E63E9B85BAF

View file

@ -1,4 +1,27 @@
appName=AkVirtualCamera 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") path=$(realpath "$0")
targetDir=$(dirname "$path") targetDir=$(dirname "$path")
@ -23,3 +46,12 @@ rm -f "${daemonPlist}"
# Remove installed files # Remove installed files
rm -rf "${targetDir}" 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