autopkg / dataJAR-recipes

Elegant and powerful Apple services for business and education.
https://www.datajar.co.uk
Apache License 2.0
113 stars 80 forks source link

OpenVPN Connect not uninstalling correctly #337

Closed opus-nbonenberger closed 3 months ago

opus-nbonenberger commented 3 months ago

Hi @paul-cossey!

I noticed that OpenVPN Connect does not uninstall correctly with Munki.

Here is the managedsoftwareupdate log of Munki:

May 14 2024 09:10:41 +0200     Determining which filesystem items to remove
May 14 2024 09:10:42 +0200     Removing 391 filesystem items
May 14 2024 09:10:42 +0200     Removing: /Library/LaunchDaemons/org.openvpn.helper.plist
May 14 2024 09:10:42 +0200     Removing: /Library/LaunchDaemons/org.openvpn.client.plist
May 14 2024 09:10:42 +0200     Removing: /Library/LaunchDaemons/
May 14 2024 09:10:42 +0200 ERROR: Did not remove /Library/LaunchDaemons/ because it is not empty.
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OpenVPNConnect.framework/Versions/Current/usr/sbin/ovpnagent
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OpenVPNConnect.framework/Versions/Current/usr/sbin/dmg_profile_extract
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OpenVPNConnect.framework/Versions/Current/usr/sbin
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OpenVPNConnect.framework/Versions/Current/usr
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OpenVPNConnect.framework/Versions/Current
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OpenVPNConnect.framework/Versions
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OVPNHelper.framework/Versions/Current/usr/sbin/ovpnhelper
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OVPNHelper.framework/Versions/Current/usr/sbin
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OVPNHelper.framework/Versions/Current/usr
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OVPNHelper.framework/Versions/Current
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OVPNHelper.framework/Versions
May 14 2024 09:10:42 +0200     Removing: /Library/Frameworks/OVPNHelper.framework/
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/_CodeSignature/CodeResources
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/_CodeSignature
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/Resources/remove.sh
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/Resources/icon.icns
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/Resources
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/MacOS/uninstaller
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/MacOS
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/Info.plist
May 14 2024 09:10:42 +0200     Removing: /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents
May 14 2024 09:10:42 +0200     ---------------------------------------------------
May 14 2024 09:10:42 +0200     There were problems removing some filesystem items.
May 14 2024 09:10:42 +0200     ---------------------------------------------------
May 14 2024 09:10:42 +0200     
Did not remove /Library/LaunchDaemons/ because it is not empty.
May 14 2024 09:10:42 +0200     Removing receipt info
May 14 2024 09:10:42 +0200     Removing package data from internal database...
May 14 2024 09:10:42 +0200     Forgot package 'org.openvpn.client.pkg' on '/'.
May 14 2024 09:10:42 +0200     Removing package data from internal database...
May 14 2024 09:10:42 +0200     Forgot package 'org.openvpn.client_uninstall.pkg' on '/'.
May 14 2024 09:10:42 +0200     Removing package data from internal database...
May 14 2024 09:10:42 +0200     Forgot package 'org.openvpn.client_framework.pkg' on '/'.
May 14 2024 09:10:42 +0200     Removing package data from internal database...
May 14 2024 09:10:42 +0200     Forgot package 'org.openvpn.client_launch.pkg' on '/'.
May 14 2024 09:10:42 +0200     Removing package data from internal database...
May 14 2024 09:10:42 +0200     Forgot package 'org.openvpn.helper_framework.pkg' on '/'.
May 14 2024 09:10:42 +0200     Removing package data from internal database...
May 14 2024 09:10:42 +0200     Forgot package 'org.openvpn.helper_launch.pkg' on '/'.
May 14 2024 09:10:42 +0200     Removing unused paths from internal package database...
May 14 2024 09:10:43 +0200     Package removal complete.
May 14 2024 09:10:43 +0200 Uninstall of OpenVPN was successful.

removing the Package only removes some files but the OpenVPN Connect folder inside /Applications/ (and its contents) remain, along with the Symlink to the app. There is an uninstaller app located at /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app. This also gets destroyed (0 bytes size) after uninstalling the package.

Inside this uninstaller app, there is an uninstaller shell script /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/Resources/remove.sh which removes the complete installation. Can you adjust the recipe? I guess the removepackages method is still needed to get rid of the package but you shoud add a pre-uninstall script that executes /Applications/OpenVPN Connect/Uninstall OpenVPN Connect.app/Contents/Resources/remove.sh before removing the package.

paul-cossey commented 3 months ago

Thanks for this, @opus-nbonenberger

Updated to use an uninstall script, can you give this commit a try https://github.com/autopkg/dataJAR-recipes/commit/79716763cc0c54800bd900befef7f558e18756c8 please?

opus-nbonenberger commented 3 months ago

Yes, this approach works. The app is uninstalled and Munki recognizes it as "not installed". Thanks @paul-cossey