Handle hostnames with upper-case letters
[webmin.git] / init / mass_rcs.cgi
1 #!/usr/local/bin/perl
2 # Start or stop a bunch of RC scripts
3
4 require './init-lib.pl';
5 &ReadParse();
6 @sel = split(/\0/, $in{'d'});
7 @sel || &error($text{'mass_enone'});
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                         ($ok, $out) = &start_rc_script($s);
24                         }
25                 else {
26                         print &text('mass_stopping', "<tt>$s</tt>"),"<p>\n";
27                         ($ok, $out) = &stop_rc_script($s);
28                         }
29                 print "<pre>$out</pre>";
30                 if (!$ok) {
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         &lock_rc_files();
43         foreach $b (@sel) {
44                 if ($enable) {
45                         print &text('mass_enable', "<tt>$b</tt>"),"<p>\n";
46                         &enable_rc_script($b);
47                         }
48                 else {
49                         print &text('mass_disable', "<tt>$b</tt>"),"<p>\n";
50                         &disable_rc_script($b);
51                         }
52                 }
53         &unlock_rc_files();
54         &webmin_log($enable ? 'massenable' : 'massdisable', 'action',
55                     join(" ", @sel));
56         }
57
58 &ui_print_footer("", $text{'index_return'});