--- /dev/null
+#!/usr/local/bin/perl
+# Show a form for creating or editing an upstart action
+
+require './init-lib.pl';
+$access{'bootup'} || &error($text{'edit_ecannot'});
+&ReadParse();
+
+if ($in{'new'}) {
+ &ui_print_header(undef, $text{'upstart_title1'}, "");
+ $u = { };
+ }
+else {
+ &ui_print_header(undef, $text{'upstart_title2'}, "");
+ @upstarts = &list_upstart_services();
+ ($u) = grep { $_->{'name'} eq $in{'name'} } @upstarts;
+ $u || &error($text{'upstart_egone'});
+ $u->{'legacy'} && &error($text{'upstart_elegacy'});
+ }
+
+print &ui_form_start("save_upstart.cgi", "post");
+print &ui_hidden("new", $in{'new'});
+print &ui_hidden("name", $in{'name'}) if (!$in{'new'});
+print &ui_table_start($text{'upstart_header'}, undef, 2);
+
+if ($in{'new'}) {
+ # Service name
+
+ # Description
+
+ # Pre-start script
+
+ # Server command
+ }
+else {
+ # Service name (non-editable)
+ print &ui_table_row($text{'upstart_name'},
+ "<tt>$in{'name'}</tt>");
+
+ # Config file
+ $cfile = "/etc/init/$in{'name'}.conf";
+ $conf = &read_file_contents($cfile);
+ print &ui_table_row($text{'upstart_conf'},
+ &ui_textarea("conf", $conf, 20, 80));
+ }
+
+print &ui_table_end();
+if ($in{'new'}) {
+ print &ui_form_end([ [ undef, $text{'create'} ] ]);
+ }
+else {
+ print &ui_form_end([ [ undef, $text{'create'} ],
+ [ 'delete', $text{'delete'} ] ]);
+ }
+
+&ui_print_footer("", $text{'index_return'});
+
$text{'index_uboot'},
$text{'index_ustatus'}, ]);
foreach $u (&list_upstart_services()) {
+ if ($u->{'legacy'}) {
+ $l = "edit_action.cgi?0+".&urlize($u->{'name'});
+ }
+ else {
+ $l = "edit_upstart.cgi?name=".&urlize($u->{'name'});
+ }
print &ui_columns_row([
&ui_checkbox("d", $u->{'name'}, undef),
- "<a href='edit_upstart.cgi?name=".
- &urlize($u->{'name'})."'>$u->{'name'}</a>",
+ "<a href='$l'>$u->{'name'}</a>",
$u->{'desc'},
$u->{'boot'} eq 'start' ? $text{'yes'} :
$u->{'boot'} eq 'stop' ?
# Just use insserv to disable, and comment out start line in .conf file
&system_logged("insserv -r ".quotemeta($_[0])." >/dev/null 2>&1");
my $cfile = "/etc/init/$_[0].conf";
- my $lref = &read_file_lines($cfile);
- foreach my $l (@$lref) {
- if ($l =~ /^\s*start/) {
- $l = "#".$l;
- last;
+ if (-r $cfile) {
+ my $lref = &read_file_lines($cfile);
+ foreach my $l (@$lref) {
+ if ($l =~ /^\s*start/) {
+ $l = "#".$l;
+ last;
+ }
}
+ &flush_file_lines($cfile);
}
- &flush_file_lines($cfile);
}
if ($init_mode eq "init" || $init_mode eq "upstart") {
# Unlink or disable init script
return (!$?, $out);
}
-# stop_upstop_service(name)
+# stop_upstart_service(name)
# Shut down the upstop service with some name, and return an OK flag and output
-sub stop_upstop_service
+sub stop_upstart_service
{
my ($name) = @_;
my $out = &backquote_logged(
mass_stopping=Stopping action $1 ..
mass_failed=.. failed!
mass_ok=.. done.
+mass_ustart=Starting Services
+mass_urestart=Restarting Services
+mass_ustop=Stopping Services
+mass_uenable=Enabling service $1 at boot time.
+mass_udisable=Disabling service $1 at boot time.
+mass_ustarting=Starting service $1 ..
+mass_ustopping=Stopping service $1 ..
change_err=You are not allowed to switch runlevels
change_title=Switch Runlevel
mode_rc=FreeBSD RC scripts
mode_upstart=Upstart
+upstart_title1=Create Upstart Service
+upstart_title2=Edit Upstart Service
+upstart_egone=Service no longer exists!
+upstart_elegacy=Not an upstart service!
+upstart_header=Upstart service details
+upstart_name=Service name
+upstart_conf=Configuration file
+
__norefs=1
--- /dev/null
+#!/usr/local/bin/perl
+# Start or stop a bunch of upstart services
+
+require './init-lib.pl';
+&ReadParse();
+@sel = split(/\0/, $in{'d'});
+@sel || &error($text{'mass_enone'});
+
+$start = 1 if ($in{'start'} || $in{'addboot_start'});
+$stop = 1 if ($in{'stop'} || $in{'delboot_stop'});
+$enable = 1 if ($in{'addboot'} || $in{'addboot_start'});
+$disable = 1 if ($in{'delboot'} || $in{'delboot_stop'});
+
+&ui_print_unbuffered_header(undef, $start || $enable ? $text{'mass_ustart'}
+ : $text{'mass_ustop'}, "");
+
+if ($start || $stop) {
+ # Starting or stopping a bunch of services
+ $access{'bootup'} || &error($text{'ss_ecannot'});
+ foreach $s (@sel) {
+ if ($start) {
+ print &text('mass_ustarting', "<tt>$s</tt>"),"<p>\n";
+ ($ok, $out) = &start_upstart_service($s);
+ }
+ else {
+ print &text('mass_ustopping', "<tt>$s</tt>"),"<p>\n";
+ ($ok, $out) = &stop_upstart_service($s);
+ }
+ print "<pre>$out</pre>";
+ if (!$ok) {
+ print $text{'mass_failed'},"<p>\n";
+ }
+ else {
+ print $text{'mass_ok'},"<p>\n";
+ }
+ }
+ }
+
+if ($enable || $disable) {
+ # Enable or disable at boot
+ $access{'bootup'} == 1 || &error($text{'edit_ecannot'});
+ foreach $b (@sel) {
+ if ($enable) {
+ print &text('mass_uenable', "<tt>$b</tt>"),"<p>\n";
+ &enable_at_boot($b);
+ }
+ else {
+ print &text('mass_udisable', "<tt>$b</tt>"),"<p>\n";
+ &disable_at_boot($b);
+ }
+ }
+ &webmin_log($enable ? 'massenable' : 'massdisable', 'action',
+ join(" ", @sel));
+ }
+
+&ui_print_footer("", $text{'index_return'});