---- 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.
&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,
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));
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'});
}
}
-# 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'}) {
}
}
-$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'});
$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();
$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"));
local $p = new Webmin::ConfirmPage(&zone_title($zinfo->{'name'}),
$text{$action.'_title'},
&text($action.'_rusure', "<tt>$zinfo->{'name'}</tt>"),
- "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'}",
$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'}",
$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);
[ 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);
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
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
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
# 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;
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)
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("<tt>zoneadm</tt> failed : <tt>$out</tt>");
}
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