[! use strict; use PVE::I18N; use PVE::ConfigServer; use PVE::HTMLTable; use PVE::HTMLDropDown; use PVE::HTMLUtils; !] [- use strict; my $out = ''; my @header = ( '1', '20px', ' ', '1', '10px', ' ', '1', '100px', __('Service'), '1', '100px', __('State'), '1', '100px', __('Autostart'), '1', '400px', __('Description') ); my $table = PVE::HTMLTable->new ([]); $table->add_headline (\@header); my $ddown = PVE::HTMLDropDown->new (); $ddown->add_item("item","?action=startservice", __("Start") ); $ddown->add_item("item","?action=stopservice", __("Stop") ); $ddown->add_item("item","?action=restartservice", __("Restart") ); $ddown->add_item("apache","?action=restartservice", __("Restart") ); my $conn = PVE::ConfigClient::connect (); if ($udat{action}) { eval { check_write_mode ($udat{AM}); if ($udat{action} eq 'restartservice') { if ($fdat{service} eq 'apache') { eval { $conn->service_cmd ($fdat{service}, 'restart'); }; } else { $conn->service_cmd ($fdat{service}, 'restart'); } } elsif ($udat{action} eq 'startservice') { $conn->service_cmd ($fdat{service}, 'start'); } elsif ($udat{action} eq 'stopservice') { $conn->service_cmd ($fdat{service}, 'stop'); } }; if ($@) { $udat{popup_error} = $@; $udat{redirect} = $fdat{__uri}; return; } } my $states = $conn->service_state_all ()->result; $out .= "
"; foreach my $s (sort {$states->{$a}->{short} cmp $states->{$b}->{short}} keys %$states) { my $stat = $states->{$s}->{status}; my $ddname = 'item'; if (($s eq 'apache') || ($s eq 'bind')) { $ddname = 'apache'; } $table->add_row ('', $ddown->out_symbol ($ddname, "", "&service=$s"), '', $states->{$s}->{short}, $stat, "", $states->{$s}->{long}); } $out .= $ddown->out_dropdown_menu("item"); $out .= $ddown->out_dropdown_menu("apache"); $out .= $table->out_table(); $out .= "
"; if ($udat{AM} eq 'w') { $out .= "

"; $out .= " " . __("Restart Server") . "
"; $out .= " " . __("Shutdown Server") . ""; $out .= "

"; } print OUT $out; -]