Commit 4e143c370fafe666b2cb2ac07c95c6a0223519b4

Authored by Omar Porras
1 parent 08009e9b07

Updated scripts to allow for the use of the --receipts and --gitconfig flags

Showing 1 changed file with 7 additions and 5 deletions 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 receipts = false
14 gitconfig = false
13 15
OptionParser.new do |o| 14 16 OptionParser.new do |o|
o.banner = "Remove most traces of Boxen from your machine." 15 17 o.banner = "Remove most traces of Boxen from your machine."
16 18
o.on("--all", "Remove everything possible.") { all = true } 17 19 o.on("--all", "Remove everything possible.") { all = true }
o.on("--force", "Actually do it.") { force = true } 18 20 o.on("--force", "Actually do it.") { force = true }
o.on("--help", "Show this help.") { abort o.to_s } 19 21 o.on("--help", "Show this help.") { abort o.to_s }
o.on("--opt", "Remove /opt/boxen.") { opt = true } 20 22 o.on("--opt", "Remove /opt/boxen.") { opt = true }
o.on("--services", "Remove and unload services.") { services = true } 21 23 o.on("--services", "Remove and unload services.") { services = true }
o.on("--receipts", "Remove package receipts used by Puppet.") { receipts = true } 22 24 o.on("--receipts", "Remove package receipts used by Puppet.") { receipts = true }
o.on("--gitconfig", "Remove Boxen-provided git credential helper config.") { gitconfig = true } 23 25 o.on("--gitconfig", "Remove Boxen-provided git credential helper config.") { gitconfig = true }
24 26
o.parse! 25 27 o.parse!
26 28
abort o.to_s unless all || opt || services 27 29 abort o.to_s unless all || opt || services || receipts || gitconfig
end 28 30 end
29 31
unless force 30 32 unless force
warn "** I won't actually do anything unless you pass --force." 31 33 warn "** I won't actually do anything unless you pass --force."
end 32 34 end
33 35
if all || services 34 36 if all || services
boxen_services = [] 35 37 boxen_services = []
boxen_services << Dir["/Library/Launch*/dev.*.plist"] 36 38 boxen_services << Dir["/Library/Launch*/dev.*.plist"]
37 39
boxen_services.flatten.each do |plist| 38 40 boxen_services.flatten.each do |plist|
warn "-> Removing #{plist}." 39 41 warn "-> Removing #{plist}."
40 42
if force 41 43 if force
system "launchctl", "unload", "-w", plist 42 44 system "launchctl", "unload", "-w", plist
system "rm", "-f", plist 43 45 system "rm", "-f", plist
end 44 46 end
end 45 47 end
46 48
system "rm", "-f", "/etc/resolver/dev" 47 49 system "rm", "-f", "/etc/resolver/dev"
end 48 50 end
49 51
if all || opt 50 52 if all || opt
warn "-> Removing /opt/boxen." 51 53 warn "-> Removing /opt/boxen."
system "rm", "-rf", "/opt/boxen" if force 52 54 system "rm", "-rf", "/opt/boxen" if force
end 53 55 end
54 56