Handle hostnames with upper-case letters
[webmin.git] / init / save_services.cgi
1 #!/usr/local/bin/perl
2 # Start or stop a bunch of win32 services
3
4 require './init-lib.pl';
5 &ReadParse();
6 @sel = split(/\0/, $in{'d'});
7 @sel || &error($text{'mass_enone2'});
8
9 $start = 1 if ($in{'start'} || $in{'addboot_start'});
10 $stop = 1 if ($in{'stop'} || $in{'delboot_stop'});
11 $enable = 1 if ($in{'addboot'} || $in{'addboot_start'});
12 $disable = 1 if ($in{'delboot'} || $in{'delboot_stop'});
13
14 &ui_print_unbuffered_header(undef, $start || $enable ? $text{'mass_start'}
15                                           : $text{'mass_stop'}, "");
16
17 if ($start || $stop) {
18         # Starting or stopping a bunch of services
19         $access{'bootup'} || &error($text{'ss_ecannot'});
20         foreach $s (@sel) {
21                 if ($start) {
22                         print &text('mass_starting', "<tt>$s</tt>"),"<p>\n";
23                         $err = &start_win32_service($s);
24                         }
25                 else {
26                         print &text('mass_stopping', "<tt>$s</tt>"),"<p>\n";
27                         $err = &stop_win32_service($s);
28                         }
29                 if ($err) {
30                         print "<pre>$err</pre>";
31                         print $text{'mass_failed'},"<p>\n";
32                         }
33                 else {
34                         print $text{'mass_ok'},"<p>\n";
35                         }
36                 }
37         }
38
39 if ($enable || $disable) {
40         # Enable or disable at boot
41         $access{'bootup'} == 1 || &error($text{'edit_ecannot'});
42         foreach $b (@sel) {
43                 if ($enable) {
44                         print &text('mass_enable', "<tt>$b</tt>"),"<p>\n";
45                         &enable_win32_service($b);
46                         }
47                 else {
48                         print &text('mass_disable', "<tt>$b</tt>"),"<p>\n";
49                         &disable_win32_service($b);
50                         }
51                 }
52         &webmin_log($enable ? 'massenable' : 'massdisable', 'action',
53                     join(" ", @sel));
54         }
55
56 &ui_print_footer("", $text{'index_return'});