2025-08-11 10:20:07 +02:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
|
|
require 'optparse'
|
|
|
|
|
require 'ostruct'
|
|
|
|
|
require 'virtual-machine'
|
|
|
|
|
|
|
|
|
|
# vm setup debian --arch "<host:arch64>" --name "<image_name: debian>"
|
|
|
|
|
|
|
|
|
|
options = OpenStruct.new
|
|
|
|
|
subcommand = ARGV.shift&.to_sym
|
|
|
|
|
options.parameter = ARGV[0] && ARGV[0] !~ /^-/ ? ARGV.shift : nil
|
|
|
|
|
|
|
|
|
|
OptionParser.new do |opt|
|
|
|
|
|
opt.on('--arch ARCH', 'Architecture arm64 or x86_64') do |arch|
|
|
|
|
|
options.arch = arch
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
opt.on('--name NAME', 'Virtaul Machine name') do |arch|
|
|
|
|
|
options.arch = arch
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end.parse!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case subcommand
|
|
|
|
|
when :create
|
|
|
|
|
puts "Creating image...."
|
|
|
|
|
|
|
|
|
|
when :setup
|
|
|
|
|
options[:distro] = subcommand
|
|
|
|
|
VirtualMachine.setup(options)
|
|
|
|
|
else
|
|
|
|
|
puts "Error not found #{options.type}"
|
|
|
|
|
end
|