Last active
June 3, 2016 02:25
-
-
Save nmcspadden/72fd61a627942a3c6eea50c4abc41b34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def app_paths(bundle_identifier) | |
| # Search Spotlight for matching identifier, strip newlines | |
| Mixlib::ShellOut.new( | |
| "/usr/bin/mdfind \"kMDItemCFBundleIdentifier==#{bundle_identifier}\"" | |
| ).run_command.stdout.split('\n').map!(&:chomp) | |
| end | |
| def installed?(bundle_identifier) | |
| paths = app_paths(bundle_identifier) | |
| !paths.empty? | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # vim: syntax=ruby:expandtab:shiftwidth=2:softtabstop=2:tabstop=2 | |
| # | |
| # Cookbook Name:: cpe_security | |
| # Recipe:: remove_teamviewer | |
| # | |
| # Copyright 2015-Present, Facebook | |
| # | |
| # All rights reserved - Do Not Redistibute | |
| # | |
| tv_paths = CPE.app_paths('com.teamviewer.TeamViewer') | |
| # Get a list of paths via mdfind for this bundle identifier | |
| Chef::Log.info( | |
| "#{cookbook_name}/#{recipe_name}: Found Teamviewer at #{tv_paths}" | |
| ) if tv_paths | |
| tv_launchds = [ | |
| 'com.teamviewer.Helper', | |
| 'com.teamviewer.teamviewer_service' | |
| ] | |
| tv_launchas = [ | |
| 'com.teamviewer.teamviewer', | |
| 'com.teamviewer.teamviewer_desktop' | |
| ] | |
| tv_launchds.each do |tv_launchd| | |
| launchd tv_launchd do | |
| action :delete | |
| end | |
| end | |
| tv_launchas.each do |tv_launcha| | |
| launchd tv_launcha do | |
| type 'agent' | |
| action :delete | |
| end | |
| end | |
| security_agent = | |
| '/Library/Security/SecurityAgentPlugins/TeamViewerAuthPlugin.bundle' | |
| directory security_agent do | |
| recursive true | |
| action :delete | |
| end | |
| helper = | |
| '/Library/PrivilegedHelperTools/com.teamviewer.Helper' | |
| file helper do | |
| action :delete | |
| end | |
| font = | |
| '/Library/Fonts/TeamViewer11.otf' | |
| file font do | |
| action :delete | |
| end | |
| %w( | |
| com.teamviewer.teamviewer11 | |
| com.teamviewer.teamviewer11Agent | |
| com.teamviewer.teamviewer11AuthPlugin | |
| com.teamviewer.teamviewer11Font | |
| com.teamviewer.teamviewer11PriviledgedHelper | |
| com.teamviewer.teamviewer11Restarter | |
| ).each do |pkg_receipt| | |
| execute pkg_receipt do | |
| only_if { CPE.installed?('com.teamviewer.TeamViewer') } # true or false if mdfind has any results for this bundle identifier | |
| command "/usr/sbin/pkgutil --forget #{pkg_receipt}" | |
| ignore_failure true | |
| end | |
| end | |
| # Finally, delete the app itself | |
| tv_paths.each do |app_path| | |
| Chef::Log.info("#{cookbook_name}/#{recipe_name}: Removing app at #{app_path}") | |
| directory app_path do | |
| recursive true | |
| action :delete | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment