3 # Start or stop multiple actions at once
5 require './init-lib.pl';
7 @sel = split(/\0/, $in{'idx'});
8 @sel || &error($text{'mass_enone2'});
10 $start = 1 if ($in{'start'} || $in{'addboot_start'});
11 $stop = 1 if ($in{'stop'} || $in{'delboot_stop'});
12 $restart = 1 if ($in{'restart'});
13 $enable = 1 if ($in{'addboot'} || $in{'addboot_start'});
14 $disable = 1 if ($in{'delboot'} || $in{'delboot_stop'});
16 &ui_print_unbuffered_header(undef, $start || $enable ? $text{'mass_start'} :
17 $restart ? $text{'mass_restart'} :
18 $text{'mass_stop'}, "");
20 # In case the action was Webmin
21 $SIG{'TERM'} = 'IGNORE';
23 if ($start || $stop || $restart) {
24 # Starting or stopping a bunch of actions
25 &foreign_require("proc", "proc-lib.pl");
26 $access{'bootup'} || &error($text{'ss_ecannot'});
28 # build list of normal and broken actions
29 ($initrl) = &get_inittab_runlevel();
30 @iacts = &list_actions();
32 @ac = split(/\s+/, $a);
34 local $order = "9" x $config{'order_digits'};
35 if ($ac[0] =~ /^\//) {
39 push(@actsf, "$config{'init_dir'}/$ac[0]");
40 local @lvls = &action_levels(
41 $start || $restart ? 'S' : 'K', $ac[0]);
42 foreach $lon (@lvls) {
43 local ($l, $o, $n) = split(/\s+/, $lon);
50 push(@orders, $order);
53 if ($start || $restart) {
54 @sel = sort { $orders[$a] <=> $orders[$b] } @sel;
57 @sel = sort { $orders[$b] <=> $orders[$a] } @sel;
60 local $cmd = "$actsf[$idx] ".($start ? "start" :
61 $restart ? "restart" :
63 print &text('ss_exec', "<tt>$cmd</tt>"),"<p>\n";
65 &foreign_call("proc", "safe_process_exec_logged", $cmd, 0, 0, STDOUT, undef, 1);
67 push(@selacts, $acts[$idx]);
69 &webmin_log($start ? 'massstart' :
70 $restart ? 'massrestart' : 'massstop', 'action',
74 if ($enable || $disable) {
75 # Enabling or disabling a bunch of actions
76 $access{'bootup'} == 1 || &error($text{'edit_ecannot'});
77 @iacts = &list_actions();
79 @ac = split(/\s+/, $a);
82 @toboot = map { $acts[$_] } @sel;
83 foreach $b (@toboot) {
85 &error(&text('mass_ebroken', $ac[0]));
90 foreach $b (@toboot) {
91 print &text('mass_enable', "<tt>$b</tt>"),"<p>\n";
97 foreach $b (@toboot) {
98 print &text('mass_disable', "<tt>$b</tt>"),"<p>\n";
102 &webmin_log($enable ? 'massenable' : 'massdisable', 'action',
106 &ui_print_footer("", $text{'index_return'});