Files
Alte_Skripte/de.ing.uninstall_Application_2.0.sh
2026-02-16 15:05:15 +01:00

75 lines
1.6 KiB
Bash

#!/bin/bash
##########################################################################
# Shellscript : Uninstall Script
# Autor : Andreas Vogel,
##########################################################################
# Script asks for the file to be deleted.
#
# Only for test - comment out in production!
# set -x
###### please only edit here
###### list files to protect here
app_protect="
NoMAD
McAfee
ING Germany Self Service
Preproxy
Identity Agent
jamf"
##### End ################
# Variabeln
sys=$(while read p; do echo "$p" | grep "/Applications" ; done </System/Library/Sandbox/rootless.conf)
list="
$app_protect
$sys"
askapp () {
/usr/bin/osascript <<EOF - 2>/dev/null
set strPath to POSIX file "/Applications/"
set f to (choose file with prompt "$1" default location strPath)
set posixF to POSIX path of f
tell application "Finder" to set filesDir to container of f as alias as text
set posixDir to POSIX path of filesDir
posixF
EOF
}
asknewdir () {
osascript <<EOF - 2>/dev/null
tell application "SystemUIServer"
activate
text returned of (display dialog "$1" default answer "")
end tell
EOF
}
app=$(askapp 'Please select the program to be deleted') || exit
# Loop for checking before deleting
for a in $list ; do
if [[ "$app" = *$a* ]]; then
osascript -e 'display dialog "This program can not be deleted!" buttons {"OK"} default button 1'
exit 0
fi
done
# Program is stopped and deleted
pkill -f "$app"
sudo rm -rf "$app"
osascript -e 'display dialog "The app has been deleted" buttons {"OK"} default button "OK"'
exit 0