elsif ($init_mode eq "rc" || $init_mode eq "upstart") {
# Create RC or upstart script
&enable_at_boot($product, $ucproduct, "$config_directory/start",
- "$config_directory/stop");
+ "$config_directory/stop",
+ undef,
+ { 'fork' => 1 });
}
$config{'atboot_product'} = $product;
# Server command
print &ui_table_row($text{'upstart_server'},
- &ui_textbox("server", undef, 60));
+ &ui_textbox("server", undef, 60)."<br>\n".
+ &ui_checkbox("fork", 1, $text{'upstart_fork'}, 0));
# Start at boot?
print &ui_table_row($text{'upstart_boot'},
}
else {
print &ui_form_end([ [ undef, $text{'save'} ],
+ [ 'start', $text{'index_start'} ],
+ [ 'stop', $text{'index_stop'} ],
[ 'delete', $text{'delete'} ] ]);
}
}
}
-=head2 enable_at_boot(action, description, startcode, stopcode, statuscode)
+=head2 enable_at_boot(action, description, startcode, stopcode, statuscode, &opts)
Makes some action start at boot time, creating the script by copying the
specified file if necessary. The parameters are :
=item statuscode - Shell code to output the action's status.
+=item opts - Hash ref of additional options, like : fork -> server will fork into background
+
If this is called for a named action that already exists (even if it isn't
enabled), only the first parameter needs to be given.
}
else {
# Need to create config
- &create_upstart_service($_[0], $_[1], $_[2]);
+ &create_upstart_service($_[0], $_[1], $_[2], $_[5]->{'fork'});
&system_logged("insserv ".quotemeta($_[0])." >/dev/null 2>&1");
}
}
return (!$?, $out);
}
-=head2 create_upstart_service(name, description, command, [pre-script])
+=head2 create_upstart_service(name, description, command, [pre-script], [fork])
Create a new upstart service with the given details.
=cut
sub create_upstart_service
{
-my ($name, $desc, $server, $prestart) = @_;
+my ($name, $desc, $server, $prestart, $forks) = @_;
my $cfile = "/etc/init/$name.conf";
&open_lock_tempfile(CFILE, ">$cfile");
&print_tempfile(CFILE,
"\n".
"start on runlevel [2345]\n".
"stop on runlevel [!2345]\n".
- "\n".
- "expect fork\n".
"\n"
);
+if ($forks) {
+ &print_tempfile(CFILE,
+ "expect fork\n".
+ "\n"
+ );
+ }
if ($prestart) {
&print_tempfile(CFILE,
"pre-start script\n".
upstart_header=Upstart service details
upstart_name=Service name
upstart_desc=Service description
-upstart_prestart=Commands to run before starting server
+upstart_prestart=Commands to run before starting server<br>(Optional)
upstart_server=Server program and parameters
+upstart_fork=Server forks into the background?
upstart_conf=Configuration file
upstart_boot=Start at boot time?
upstart_status=Current status
$u->{'legacy'} && &error($text{'upstart_elegacy'});
}
+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"));
+ exit;
+ }
+
if ($in{'delete'}) {
# Delete the service
&disable_at_boot($in{'name'});
# Create the config file
&create_upstart_service($in{'name'}, $in{'desc'}, $in{'server'},
- $in{'prestart'});
+ $in{'prestart'}, $in{'fork'});
# Enable at boot if selected
if ($in{'boot'} == 0) {