server-scripts/lxc-destroy

33 lines
644 B
Ruby
Executable File

#!/usr/bin/env ruby
require "optparse"
def sh(*args)
puts("$ #{args.join(" ")}")
system(*args)
end
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: lxc-destroy [options]"
opts.on("-nNAME", "--name=NAME", "container name") do |n|
options[:name] = n
end
end.parse!
unless options[:name]
$stderr.puts "no option for --name supplied"
exit(1)
end
print "enter the name of the container to delete: "
unless options[:name] == STDIN.gets.chomp
puts "does not match"
exit(1)
end
PREFIX="/run/current-system/sw/bin"
#sh "#{PREFIX}/lxc-stop", "-n", options[:name]
sh "#{PREFIX}/lxc-destroy", "-n", options[:name]