Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove launchjob files during uninstall, even if they are not loaded #14730

Merged
merged 2 commits into from Oct 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions lib/hbc/artifact/uninstall_base.rb
Expand Up @@ -212,17 +212,15 @@ def dispatch_uninstall_directives(stanza, expand_tilde=true)
plist_status = @command.run('/bin/launchctl', :args => ['list', service], :sudo => with_sudo, :print_stderr => false).stdout
if %r{^\{}.match(plist_status)
result = @command.run!('/bin/launchctl', :args => ['remove', service], :sudo => with_sudo)
if result.success?
paths = ["/Library/LaunchAgents/#{service}.plist",
"/Library/LaunchDaemons/#{service}.plist"]
paths.each { |elt| elt.prepend('~') } unless with_sudo
paths = paths.map { |elt| Pathname(elt) }.select(&:exist?)
paths.each do |path|
@command.run!('/bin/rm', :args => ['-f', '--', path], :sudo => with_sudo)
end
end
sleep 1
end
paths = ["/Library/LaunchAgents/#{service}.plist",
"/Library/LaunchDaemons/#{service}.plist"]
paths.each { |elt| elt.prepend(ENV['HOME']) } unless with_sudo
paths = paths.map { |elt| Pathname(elt) }.select(&:exist?)
paths.each do |path|
@command.run!('/bin/rm', :args => ['-f', '--', path], :sudo => with_sudo)
end
# undocumented and untested: pass a path to uninstall :launchctl
if Pathname(service).exist?
@command.run!('/bin/launchctl', :args => ['unload', '-w', '--', service], :sudo => with_sudo)
Expand Down