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

110 lines
2.9 KiB
Bash

#!/bin/bash
##########################################################################
# Shellscript : Uninstall Script
# Autor : Andreas Vogel,
##########################################################################
################################ Applications to Save ################################
# 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 ################
################################ Variablen ################################
ErrorIcon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
SuccessfulIcon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/TrashIcon.icns"
ErrorSaveMessage="
Bei der ausgewählten App, handelt es sich um eine geschützte App. Diese kann nicht gelöscht werden.
The selected app is a protected app. This cannot be deleted.
"
ErrorMessage="
Die App konnte nicht gelöscht werden!
The app could not be deleted!
"
SuccessfulMessage="
Die App wurde erfolgreich von dem System gelöscht.
The app was successfully deleted from the system.
"
sys=$(while read p; do echo "$p" | grep "/Applications" ; done </System/Library/Sandbox/rootless.conf)
list="
$app_protect
$sys"
################################ Funktionen ################################
ErrorSave()
{
HELPER=$(/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$ErrorIcon" -title "Warning" -description "$ErrorSaveMessage" -button1 "OK" -defaultButton 1)
}
Error()
{
HELPER=$(/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$ErrorIcon" -title "Warning" -description "$ErrorMessage" -button1 "OK" -defaultButton 1)
}
Successful()
{
HELPER=$(/Library/Application\ Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -icon "$SuccessfulIcon" -title "Warning" -description "$SuccessfulMessage" -button1 "OK" -defaultButton 1)
}
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
echo $app
################################ Ausführung ################################
# Loop for checking before deleting
for a in $list ; do
if [[ "$app" = *$a* ]]
then
echo $a
ErrorSave
exit 0
fi
done
pkill -f "$app"
echo $app
if sudo rm -rf "$app"
then
Successful
else
Error
fi
exit 0