dup: Added --regenerate to print all command necessary to regenerate a container from scratch.
This commit is contained in:
parent
3879c20814
commit
45c5612efb
19
dup.rb
19
dup.rb
@ -155,6 +155,15 @@ def run_cmd(cmd, ignore_returnvalue=false, catch_interrupt=false, ignore_dry_run
|
|||||||
return returnvalue
|
return returnvalue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def collect_commands(&block)
|
||||||
|
$commands = []
|
||||||
|
def run_cmd(cmd, ignore_returnvalue=false, catch_interrupt=false, ignore_dry_run: false); $commands<<cmd; return 0; end
|
||||||
|
|
||||||
|
yield
|
||||||
|
|
||||||
|
return $commands
|
||||||
|
end
|
||||||
|
|
||||||
def esc(obj, escape=true)
|
def esc(obj, escape=true)
|
||||||
return obj unless escape
|
return obj unless escape
|
||||||
return obj.to_s.shellescape
|
return obj.to_s.shellescape
|
||||||
@ -218,8 +227,7 @@ end
|
|||||||
def action_regenerate(container)
|
def action_regenerate(container)
|
||||||
container.each do |c|
|
container.each do |c|
|
||||||
data = c.regenerate
|
data = c.regenerate
|
||||||
puts data.to_yaml
|
p collect_commands{ c.run }
|
||||||
puts
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -324,7 +332,7 @@ class Container
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return cmd
|
return cmd.compact.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
def build
|
def build
|
||||||
@ -403,7 +411,7 @@ class Container
|
|||||||
|
|
||||||
verbose "Creating container..."
|
verbose "Creating container..."
|
||||||
cmd = build_run_command
|
cmd = build_run_command
|
||||||
run_cmd(cmd.compact.join(" ") + " >/dev/null")
|
run_cmd(cmd + " >/dev/null")
|
||||||
|
|
||||||
self.connect_to_networks
|
self.connect_to_networks
|
||||||
|
|
||||||
@ -440,6 +448,7 @@ class Container
|
|||||||
data[name] = result
|
data[name] = result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@data = data
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -506,6 +515,7 @@ opts.each do |opt, arg|
|
|||||||
$net_host = true
|
$net_host = true
|
||||||
when '--regenerate'
|
when '--regenerate'
|
||||||
action = :regenerate
|
action = :regenerate
|
||||||
|
needs_container = false
|
||||||
when '--verbose'
|
when '--verbose'
|
||||||
$verbose = true
|
$verbose = true
|
||||||
when '--all'
|
when '--all'
|
||||||
@ -533,6 +543,7 @@ elsif action == :update
|
|||||||
action_update(base_dir)
|
action_update(base_dir)
|
||||||
elsif action == :regenerate
|
elsif action == :regenerate
|
||||||
action_regenerate(container)
|
action_regenerate(container)
|
||||||
|
container.each {|c| puts c.build_run_command}
|
||||||
elsif action == :_completion
|
elsif action == :_completion
|
||||||
action_completion($base_dir, completion_str)
|
action_completion($base_dir, completion_str)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user