diff --git a/zones/CHANGELOG b/zones/CHANGELOG index 7d7e3b17d..36ffab74b 100644 --- a/zones/CHANGELOG +++ b/zones/CHANGELOG @@ -1,2 +1,4 @@ ---- Changes since 1.200 ---- First version of this module, for creating and managing Zones on a Solaris 10 system. +---- Changes since 1.480 ---- +Added support for zone brands, thanks to a patch from Todd Kennedy. diff --git a/zones/create_form.cgi b/zones/create_form.cgi index 81982ea34..49e4953a6 100755 --- a/zones/create_form.cgi +++ b/zones/create_form.cgi @@ -25,6 +25,9 @@ print &ui_table_row($text{'create_path'}, &text('create_auto', $config{'base_dir'}), $text{'create_sel'})."\n". &file_chooser_button("path", 1)); + +print &ui_table_row($text{'create_brand'}, + &ui_select("brand",undef, [ &list_brands() ], 0, 0, $value ? 1 : 0)); print &ui_table_row($text{'create_address'}, &ui_opt_textbox("address", undef, 20, @@ -38,6 +41,9 @@ print &ui_table_row($text{'create_install'}, print &ui_table_row($text{'create_webmin'}, &ui_yesno_radio("webmin", 0)); + +print &ui_table_row($text{'pkg_inherit'}, + &ui_yesno_radio("inherit", 0)); print &ui_table_row($text{'create_pkgs'}, &ui_textarea("pkgs", undef, 5, 50)); @@ -111,5 +117,5 @@ print &ui_table_row($text{'create_router'}, print &ui_table_end(); print &ui_form_end([ [ "ok", $text{'create_ok'} ] ]); -&ui_print_footer("", $text{'index_return'}); +&ui_print_footer("index.cgi", $text{'index_return'}); diff --git a/zones/create_zone.cgi b/zones/create_zone.cgi index 49921bd6c..d6dfa6627 100755 --- a/zones/create_zone.cgi +++ b/zones/create_zone.cgi @@ -112,19 +112,32 @@ if (!$in{'address_def'}) { } } -# Add extra package directories -if (@pkgs) { - $d3 = new Webmin::DynamicHTML(\&execute_pkgs, undef, $text{'create_addingpkgs'}); - $p->add_form($d3); - sub execute_pkgs - { - foreach $p (@pkgs) { - $pkg = { 'keytype' => 'inherit-pkg-dir', - 'dir' => $p }; - &create_zone_object($zinfo, $pkg); +# Add or remove extra package directories +# add for sparse root zone and remove for whole root zone +if ($in{'inherit'} eq '0' ) { + $d3 = new Webmin::DynamicHTML(\&remove_pkgs, undef, $text{'create_removingpkgs'}); + $p->add_form($d3); + sub remove_pkgs + { + $pkg = { 'keytype' => 'inherit-pkg-dir' }; + &delete_zone_object($zinfo,$pkg); + $p->add_message_after($d3, $text{'create_done'}); + } +} + else { + if (@pkgs) { + $d3 = new Webmin::DynamicHTML(\&execute_pkgs, undef, $text{'create_addingpkgs'}); + $p->add_form($d3); + sub execute_pkgs + { + foreach $p (@pkgs) { + $pkg = { 'keytype' => 'inherit-pkg-dir', + 'dir' => $p }; + &create_zone_object($zinfo, $pkg); + } + $p->add_message_after($d3, $text{'create_done'}); + } } - $p->add_message_after($d3, $text{'create_done'}); - } } if ($in{'install'}) { @@ -187,7 +200,19 @@ if ($in{'install'} && $in{'webmin'}) { } } -$p->add_footer("", $text{'index_return'}); +#set the brand +if ($in{'brand'}) { + $d6 = new Webmin::DynamicHTML(\&create_brand,undef, $text{'create_brandmsg'}); + $p->add_form($d6); + + sub create_brand + { + &set_zone_variable($zinfo,"brand",$form->get_value("brand")); + $p->add_message_after($d6, $text{'create_done'}); + } +} + +$p->add_footer("index.cgi", $text{'index_return'}); $p->print(); &webmin_log("create", "zone", $in{'name'}); diff --git a/zones/edit_zone.cgi b/zones/edit_zone.cgi index 3551eb00c..de488bf2c 100755 --- a/zones/edit_zone.cgi +++ b/zones/edit_zone.cgi @@ -140,7 +140,7 @@ $gtable->set_emptymsg($text{'edit_attrnone'}); $gtable->add_link("edit_attr.cgi?zone=$in{'zone'}&new=1", $text{'edit_attradd'}); -$p->add_footer("", $text{'index_return'}); +$p->add_footer("index.cgi", $text{'index_return'}); $p->print(); diff --git a/zones/forms-lib.pl b/zones/forms-lib.pl index cc4fd2ea7..70d35eb4f 100644 --- a/zones/forms-lib.pl +++ b/zones/forms-lib.pl @@ -21,6 +21,7 @@ local $auto = new Webmin::Select("autoboot", $zinfo->{'autoboot'}, $section->add_input($text{'edit_autoboot'}, $auto); local $pool = &pool_object("pool", $zinfo->{'pool'}); $section->add_input($text{'edit_pool'}, $pool); +$section->add_row($text{'edit_brand'}, "$zinfo->{'brand'}"); local @actions = &zone_status_actions($zinfo, 1); $form->add_button(new Webmin::Submit($text{'save'}, "save")); @@ -48,9 +49,9 @@ local ($in, $action, $zinfo, $list) = @_; local $p = new Webmin::ConfirmPage(&zone_title($zinfo->{'name'}), $text{$action.'_title'}, &text($action.'_rusure', "$zinfo->{'name'}"), - "save_zone.cgi", $in, $text{'edit_'.$action}); + "save_zone.cgi", $in, $text{'edit_'.$action}, $text{'ui_cancel'}); if ($list) { - $p->add_footer("", $text{'index_return'}); + $p->add_footer("index.cgi", $text{'index_return'}); } else { $p->add_footer("edit_zone.cgi?zone=$zinfo->{'name'}", @@ -70,7 +71,7 @@ $p->add_form($d); $d->set_message($text{$action.'_doing'}); $d->set_wait(1); if ($list || $action eq "delete") { - $p->add_footer("", $text{'index_return'}); + $p->add_footer("index.cgi", $text{'index_return'}); } else { $p->add_footer("edit_zone.cgi?zone=$zinfo->{'name'}", @@ -466,6 +467,9 @@ local $path = new Webmin::OptTextbox("path", undef, 30, $path->set_validation_func(\&validate_zone_path); $section->add_input($text{'create_path'}, $path); +local $brand = new Webmin::Select("brand",undef, [ &list_brands() ], 0, 0, $value ? 1 : 0); +$section->add_input($text{'create_brand'}, $brand); + local $address = new Webmin::OptTextbox("address", undef, 20, $text{'create_noaddress'}); $address->set_validation_func(\&validate_address); @@ -482,6 +486,11 @@ local $webmin = new Webmin::Radios("webmin", 0, [ [ 1, $text{'yes'} ], [ 0, $text{'no'} ] ]); $section->add_input($text{'create_webmin'}, $webmin); +local $inherit = new Webmin::Radios("inherit", 1, [ [ 1, $text{'pkg_inherit_yes'} ], + [ 0, $text{'pkg_inherit_no'} ] ]); +$section->add_input($text{'pkg_inherit'}, $inherit); + + local $pkgs = new Webmin::Multiline("pkgs", undef, 5, 50); $section->add_input($text{'create_pkgs'}, $pkgs); diff --git a/zones/lang/en b/zones/lang/en index 114ebface..c246f5728 100644 --- a/zones/lang/en +++ b/zones/lang/en @@ -57,6 +57,9 @@ edit_attrvalue=Attribute value edit_attrnone=No generic attributes have been defined yet. edit_attradd=Add a new generic attribute. edit_webmin=Open Webmin +edit_brand=Brand + +ui_cancel=Cancel save_err=Failed to save zone save_epool=Missing or invalid pool @@ -112,6 +115,10 @@ pkg_egone=Directory no longer exists! pkg_err=Failed to save package directory pkg_edir=Invalid or non-existant directory pkg_eclash=The package directory already exists in this zone +pkg_inherit=Inherit packages from global zone +pkg_inherit_yes=Yes (sparse root zone) +pkg_inherit_no=No (whole root zone) + fs_title1=Create Filesystem fs_title2=Edit Filesystem @@ -248,6 +255,9 @@ create_eservers=No DNS or NIS name servers entered create_eresolvname=The zone's hostname could not be resolved, which will cause automatic configuration to fail. You should add it to the DNS before creating this zone create_router=Default router create_erouter=Missing or invalid default router IP address +create_removingpkgs=removing inherited package directories ... +create_brand=Brand +create_brandmsg=Branding zone log_create_zone=Created zone $1 log_delete_zone=Deleted zone $1 diff --git a/zones/zones-lib.pl b/zones/zones-lib.pl index ac1ce1fa7..14593f9dd 100644 --- a/zones/zones-lib.pl +++ b/zones/zones-lib.pl @@ -56,7 +56,7 @@ $zinfo->{'id'} = $status->{'id'}; # Add zone-level variables local ($p, $r); -foreach $p ("zonepath", "autoboot", "pool") { +foreach $p ("zonepath", "autoboot", "pool", "brand") { local @lines = &get_zonecfg_output($zone, "info $p"); if ($lines[0] =~ /^$p:\s*(.*)/) { $zinfo->{$p} = $1; @@ -170,7 +170,12 @@ push(@{$zinfo->{$thing->{'keytype'}}}, $thing); sub delete_zone_object { local ($zinfo, $thing) = @_; -&get_zonecfg_output($zinfo->{'name'}, "remove $thing->{'keytype'} $thing->{'keyfield'}=$thing->{'key'}", 1); +if ( !$thing->{'keyfield'}) { + &get_zonecfg_output($zinfo->{'name'}, "remove -F $thing->{'keytype'}", 1); + } + else { + &get_zonecfg_output($zinfo->{'name'}, "remove $thing->{'keytype'} $thing->{'keyfield'}=$thing->{'key'}", 1); + } } # create_zone(name, path) @@ -313,7 +318,7 @@ return &text('zone_in', "$_[0]"); sub run_zone_command { local ($zinfo, $cmd, $re) = @_; -local $out = &backquote_logged("ctrun zoneadm -z $zinfo->{'name'} $cmd 2>&1"); +local $out = &backquote_logged("ctrun -l child zoneadm -z $zinfo->{'name'} $cmd 2>&1"); if ($? && !$re) { &error("zoneadm failed : $out"); } @@ -417,6 +422,22 @@ close(FS); return @rv; } +#list_brands() +#returns a list of valid brands +sub list_brands +{ + local @rv; + opendir(BRND, "/usr/lib/brand"); + foreach (readdir(BRND)) { + if ($_ !~ /^\./){ + push(@rv, $_); + } + } + close(BRND); +return @rv; +} + + # run_in_zone(&zinfo, command) # Runs some command within a zone, and returns the output sub run_in_zone