Start/stop buttons per service, ability to comment out multi-line start blocks
authorJamie Cameron <jcameron@webmin.com>
Tue, 19 Apr 2011 05:09:49 +0000 (22:09 -0700)
committerJamie Cameron <jcameron@webmin.com>
Tue, 19 Apr 2011 05:09:49 +0000 (22:09 -0700)
init/edit_upstart.cgi
init/init-lib.pl
init/lang/en
init/mass_upstarts.cgi
init/save_upstart.cgi

index 825903b..13f1bad 100755 (executable)
@@ -73,8 +73,8 @@ if ($in{'new'}) {
        }
 else {
        print &ui_form_end([ [ undef, $text{'save'} ],
-                            [ 'start', $text{'index_start'} ],
-                            [ 'stop', $text{'index_stop'} ],
+                            [ 'start', $text{'edit_startnow'} ],
+                            [ 'stop', $text{'edit_stopnow'} ],
                             [ 'delete', $text{'delete'} ] ]);
        }
 
index e1d808b..481bd5d 100755 (executable)
@@ -602,9 +602,19 @@ if ($init_mode eq "upstart" && (!-r "$config{'init_dir'}/$_[0]" ||
                # Config file exists, make sure it is enabled
                &system_logged("insserv ".quotemeta($_[0])." >/dev/null 2>&1");
                my $lref = &read_file_lines($cfile);
+               my $foundstart;
                foreach my $l (@$lref) {
-                       if ($l =~ /^#+\s*start/) {
+                       if ($l =~ /^#+start/) {
+                               # Start of start block
                                $l =~ s/^#+//;
+                               $foundstart = 1;
+                               }
+                       elsif ($l =~ /^#+\s+\S/ && $foundstart) {
+                               # Continuation line for start
+                               $l =~ s/^#+//;
+                               }
+                       elsif ($l =~ /^\S/ && $foundstart) {
+                               # Some other directive after start
                                last;
                                }
                        }
@@ -917,9 +927,19 @@ if ($init_mode eq "upstart") {
        my $cfile = "/etc/init/$_[0].conf";
        if (-r $cfile) {
                my $lref = &read_file_lines($cfile);
+               my $foundstart;
                foreach my $l (@$lref) {
-                       if ($l =~ /^\s*start/) {
+                       if ($l =~ /^start\s/) {
+                               # Start of start block
                                $l = "#".$l;
+                               $foundstart = 1;
+                               }
+                       elsif ($l =~ /^\s+\S/ && $foundstart) {
+                               # Continuation line for start
+                               $l = "#".$l;
+                               }
+                       elsif ($l =~ /^\S/ && $foundstart) {
+                               # Some other directive after start
                                last;
                                }
                        }
index b83a197..9fe0602 100644 (file)
@@ -206,5 +206,6 @@ upstart_eclash=A service with the same name already exists
 upstart_edesc=Missing service description
 upstart_eserver=No server command entered
 upstart_eserver2=Server command does not exist
+upstart_return=upstart service
 
 __norefs=1
index b04bd8a..b692750 100755 (executable)
@@ -53,4 +53,10 @@ if ($enable || $disable) {
                    join(" ", @sel));
        }
 
-&ui_print_footer("", $text{'index_return'});
+if ($in{'return'}) {
+       &ui_print_footer("edit_upstart.cgi?name=".&urlize($in{'return'}),
+                        $text{'upstart_return'});
+       }
+else {
+       &ui_print_footer("", $text{'index_return'});
+       }
index 3a1c87b..a8d257e 100755 (executable)
@@ -17,8 +17,9 @@ if (!$in{'new'}) {
 
 if ($in{'start'} || $in{'stop'}) {
        # Just redirect to the start page
-       &redirect("mass_upstarts.cgi?d=".&urlize($in{'name'}).
-                 ($in{'start'} ? "start=1" : "stop=1"));
+       &redirect("mass_upstarts.cgi?d=".&urlize($in{'name'})."&".
+                 ($in{'start'} ? "start=1" : "stop=1").
+                 "&return=".&urlize($in{'name'}));
        exit;
        }