diff options
-rwxr-xr-x | draklive | 26 | ||||
-rw-r--r-- | lib/MDV/Draklive/Live.pm | 10 |
2 files changed, 24 insertions, 12 deletions
@@ -37,6 +37,7 @@ use IPC::Open3; use IO::Select; use IO::Handle; use MDV::Draklive::Utils; +use MDV::Draklive::Live; my $dir_distrib_sqfs = { mountpoint => '/distrib', @@ -1959,39 +1960,40 @@ my @all = qw(install boot loop master image replicator); die "you must be root to run this program\n" if $>; -my (%live, %opts); +my $live_object = 'MDV::Draklive::Live'->new; +my %opts; my $config_root = '/etc/draklive'; my $config_path = 'config/live.cfg'; my $settings_path = 'config/settings.cfg'; GetOptions( "help" => sub { Pod::Usage::pod2usage('-verbose' => 1) }, - "copy-wizard" => \$live{copy_wizard}, + "copy-wizard" => \$live_object->{copy_wizard}, "boot-only" => \$opts{boot_only}, "boot-image=s" => sub { $opts{boot} = $_[1]; $opts{boot_only} = 1 }, "all" => sub { $_->{to_run} = 1 foreach grep { member($_->{name}, @all) } @actions }, (map { $_->{name} => \$_->{to_run} } @actions), "device=s" => sub { $opts{device} = $_[1] }, - "all-regions" => sub { $live{all_regions} = 1 }, + "all-regions" => sub { $live_object->{all_regions} = 1 }, "config-root=s" => \$config_root, "config=s" => \$config_path, "settings=s" => \$settings_path, - "define=s" => \%{$live{settings}}, + "define=s" => \%{$live_object->{settings}}, ) or Pod::Usage::pod2usage(); require standalone; -if ($live{copy_wizard}) { - copy_wizard(\%live); +if ($live_object->{copy_wizard}) { + copy_wizard($live_object); } else { every { !$_->{to_run} } @actions and Pod::Usage::pod2usage(); - read_config(\%live, $config_root, $config_path, $settings_path); - check_config(\%live); - complete_config(\%live); - foreach my $region ($live{all_regions} ? sort(keys %{$live{regions}}) : $live{settings}{region}) { + read_config($live_object, $config_root, $config_path, $settings_path); + check_config($live_object); + complete_config($live_object); + foreach my $region ($live_object->{all_regions} ? sort(keys %{$live_object->{regions}}) : $live_object->{settings}{region}) { $region and print qq(=== proceeding with region "$region"\n); - $live{settings}{region} = $region; + $live_object->{settings}{region} = $region; foreach (grep { $_->{to_run} } @actions) { print qq(* entering step "$_->{name}"\n); - $_->{do}->(\%live, \%opts); + $_->{do}->($live_object, \%opts); print qq(* step "$_->{name}" done\n); } } diff --git a/lib/MDV/Draklive/Live.pm b/lib/MDV/Draklive/Live.pm new file mode 100644 index 0000000..1f3bd3d --- /dev/null +++ b/lib/MDV/Draklive/Live.pm @@ -0,0 +1,10 @@ +package MDV::Draklive::Live; + +use MDK::Common; + +sub new { + my ($class) = @_; + bless {}, $class; +} + +1; |