Commit 3a6e8ee440d566dae80722d3fabbca097d32670a

Authored by Will Farrington

Merge pull request #85 from boztek/nuke-delete-receipts

Fix script/nuke to properly delete receipts

Showing 1 changed file Inline Diff

#!/usr/bin/ruby 1 1 #!/usr/bin/ruby
2 2
require "optparse" 3 3 require "optparse"
4 4
unless ENV["USER"] == "root" 5 5 unless ENV["USER"] == "root"
exec "sudo", $0, *ARGV 6 6 exec "sudo", $0, *ARGV
end 7 7 end
8 8
all = false 9 9 all = false
force = false 10 10 force = false
opt = false 11 11 opt = false
services = false 12 12 services = false
13 13
OptionParser.new do |o| 14 14 OptionParser.new do |o|
o.banner = "Remove most traces of Boxen from your machine." 15 15 o.banner = "Remove most traces of Boxen from your machine."
16 16
o.on("--all", "Remove everything possible.") { all = true } 17 17 o.on("--all", "Remove everything possible.") { all = true }
o.on("--force", "Actually do it.") { force = true } 18 18 o.on("--force", "Actually do it.") { force = true }
o.on("--help", "Show this help.") { abort o.to_s } 19 19 o.on("--help", "Show this help.") { abort o.to_s }
o.on("--opt", "Remove /opt/boxen.") { opt = true } 20 20 o.on("--opt", "Remove /opt/boxen.") { opt = true }
o.on("--services", "Remove and unload services.") { services = true } 21 21 o.on("--services", "Remove and unload services.") { services = true }
o.on("--receipts", "Remove package receipts used by Puppet.") { receipts = true } 22 22 o.on("--receipts", "Remove package receipts used by Puppet.") { receipts = true }
o.on("--gitconfig", "Remove Boxen-provided git credential helper config.") { gitconfig = true } 23 23 o.on("--gitconfig", "Remove Boxen-provided git credential helper config.") { gitconfig = true }
24 24
o.parse! 25 25 o.parse!
26 26
abort o.to_s unless all || opt || services 27 27 abort o.to_s unless all || opt || services
end 28 28 end
29 29
unless force 30 30 unless force
warn "** I won't actually do anything unless you pass --force." 31 31 warn "** I won't actually do anything unless you pass --force."
end 32 32 end
33 33
if all || services 34 34 if all || services
boxen_services = [] 35 35 boxen_services = []
boxen_services << Dir["/Library/Launch*/dev.*.plist"] 36 36 boxen_services << Dir["/Library/Launch*/dev.*.plist"]
37 37
boxen_services.flatten.each do |plist| 38 38 boxen_services.flatten.each do |plist|
warn "-> Removing #{plist}." 39 39 warn "-> Removing #{plist}."
40 40
if force 41 41 if force
system "launchctl", "unload", "-w", plist 42 42 system "launchctl", "unload", "-w", plist
system "rm", "-f", plist 43 43 system "rm", "-f", plist
end 44 44 end
end 45 45 end
46 46
system "rm", "-f", "/etc/resolver/dev" 47 47 system "rm", "-f", "/etc/resolver/dev"
end 48 48 end
49 49
if all || opt 50 50 if all || opt