2 # Update, reboot or delete a zone
4 require './zones-lib.pl';
7 $zinfo = &get_zone($in{'zone'});
8 $zinfo || &error($text{'edit_egone'});
11 # Reboot after asking for confirmation
12 $p = &get_confirm_page(\%in, "reboot", $zinfo, $in{'list'});
13 if ($p->get_confirm()) {
15 $p = &get_execute_page("reboot", $zinfo, $in{'list'});
18 elsif ($p->get_cancel()) {
20 &redirect($p->get_footer(0));
28 $p = &get_execute_page("boot", $zinfo, $in{'list'});
32 # Shutdown after asking for confirmation
33 $p = &get_confirm_page(\%in, "halt", $zinfo, $in{'list'});
34 if ($p->get_confirm()) {
36 $p = &get_execute_page("halt", $zinfo, $in{'list'});
39 elsif ($p->get_cancel()) {
41 &redirect($p->get_footer(0));
47 elsif ($in{'install'}) {
49 $p = new Webmin::Page(&zone_title($zinfo->{'name'}), $text{'install_title'});
50 $d = new Webmin::DynamicText(\&execute_install);
52 $d->set_message($text{'install_doing'});
55 $p->add_footer("index.cgi", $text{'index_return'});
58 $p->add_footer("edit_zone.cgi?zone=$zinfo->{'name'}",
59 $text{'edit_return'});
63 elsif ($in{'delete'}) {
64 # Delete after confirming
65 $p = &get_confirm_page(\%in, "delete", $zinfo, $in{'list'});
66 if ($p->get_confirm()) {
68 $p = &get_execute_page("delete", $zinfo, $in{'list'});
71 elsif ($p->get_cancel()) {
73 &redirect($p->get_footer(0));
79 elsif ($in{'uninstall'}) {
80 # Un-install after confirming
81 $p = &get_confirm_page(\%in, "uninstall", $zinfo, $in{'list'});
82 if ($p->get_confirm()) {
84 $p = &get_execute_page("uninstall", $zinfo, $in{'list'}, "-F");
87 elsif ($p->get_cancel()) {
89 &redirect($p->get_footer(0));
95 elsif ($in{'wupgrade'} || $in{'winstall'}) {
97 $p = new Webmin::Page(&zone_title($in{'zone'}), $text{'webmin_title'});
98 $d = new Webmin::DynamicText(\&execute_webmin);
100 $d->set_message($text{'create_webmining'});
102 $p->add_footer("edit_zone.cgi?zone=$zinfo->{'name'}",
103 $text{'edit_return'});
106 elsif ($in{'webmin'}) {
107 # Redirect to Webmin in the zone
108 $url = &zone_running_webmin($zinfo);
109 &error($text{'save_ewebmin'}) if (!$url);
113 # Just update autoboot and pool
114 $gform = &get_zone_form(\%in, $zinfo);
115 $gform->validate_redirect("edit_zone.cgi");
116 &set_zone_variable($zinfo, "autoboot", $gform->get_value('autoboot'));
117 &set_zone_variable($zinfo, "pool", $gform->get_value('pool'));
118 &webmin_log("save", "zone", $in{'zone'});
122 # execute_install(&dynamic)
126 local $ok = &callback_zone_command($zinfo, "install",
127 \&Webmin::DynamicText::add_line, [ $d ]);
129 $p->add_message($text{'create_done'});
130 $sysidcfg = &zone_sysidcfg_file($in{'zone'});
132 # Copy sysidcfg into place, for later boot
133 # We Copy instead of Move just incase we
134 # uninstall the zone but want to reinstall it
136 &system_logged("cp $sysidcfg $zinfo->{'zonepath'}/root/etc/sysidcfg");
138 &config_zone_nfs($zinfo);
139 &webmin_log("install", "zone", $in{'zone'});
142 $p->add_error($text{'create_failed'});
149 $script = &get_zone_root($zinfo)."/tmp/install-webmin";
150 $err = &create_webmin_install_script($zinfo, $script);
152 $p->add_error(&text('created_wfailed', $err));
155 $ex = &run_in_zone_callback($zinfo, "/tmp/install-webmin",
156 \&Webmin::DynamicText::add_line, [ $d ]);
158 $p->add_message($text{'create_done'});
159 &post_webmin_install($zinfo);
162 $p->add_error($text{'create_failed'});