$conf = &read_file_contents($cfile);
print &ui_table_row($text{'upstart_conf'},
&ui_textarea("conf", $conf, 20, 80));
+
+ # Current status
+ if ($u->{'boot'} eq 'start' || $u->{'boot'} eq 'stop') {
+ print &ui_table_row($text{'upstart_boot'},
+ &ui_yesno_radio("boot", $u->{'boot'} eq 'start'));
+ }
+ if ($u->{'status'} eq 'waiting' || $u->{'status'} eq 'running') {
+ print &ui_table_row($text{'upstart_status'},
+ $u->{'status'} eq 'waiting' ? $text{'upstart_status0'} :
+ &text('upstart_status1', $u->{'pid'}));
+ }
}
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'create'} ] ]);
}
else {
- print &ui_form_end([ [ undef, $text{'create'} ],
+ print &ui_form_end([ [ undef, $text{'save'} ],
[ 'delete', $text{'delete'} ] ]);
}
upstart_header=Upstart service details
upstart_name=Service name
upstart_conf=Configuration file
+upstart_boot=Start at boot time?
+upstart_status=Current status
+upstart_status0=Not running
+upstart_status1=Running with PID $1
+upstart_err=Failed to save upstart service
+upstart_econf=No configuration file contents entered
__norefs=1
&disable_at_boot($b);
}
}
- &webmin_log($enable ? 'massenable' : 'massdisable', 'action',
+ &webmin_log($enable ? 'massenable' : 'massdisable', 'upstart',
join(" ", @sel));
}
--- /dev/null
+#!/usr/local/bin/perl
+# Create, update or delete an upstart service
+
+require './init-lib.pl';
+&error_setup($text{'upstart_err'});
+$access{'bootup'} || &error($text{'edit_ecannot'});
+&ReadParse();
+
+# Get the service
+if (!$in{'new'}) {
+ @upstarts = &list_upstart_services();
+ ($u) = grep { $_->{'name'} eq $in{'name'} } @upstarts;
+ $u || &error($text{'upstart_egone'});
+ $u->{'legacy'} && &error($text{'upstart_elegacy'});
+ }
+
+if ($in{'delete'}) {
+ # Delete the service
+ # XXX
+ }
+elsif ($in{'new'}) {
+ # Create the config file
+
+ # Enable at boot
+ }
+else {
+ # Just save the config file
+ $cfile = "/etc/init/$in{'name'}.conf";
+ $in{'conf'} =~ /\S/ || &error($text{'upstart_econf'});
+ $in{'conf'} =~ s/\r//g;
+ &open_lock_tempfile(CONF, ">$cfile");
+ &print_tempfile(CONF, $in{'conf'});
+ &close_tempfile(CONF);
+
+ # Enable or disable
+ if (defined($in{'boot'})) {
+ if ($in{'boot'} == 0) {
+ &disable_at_boot($in{'name'});
+ }
+ else {
+ &enable_at_boot($in{'name'});
+ }
+ }
+
+ &webmin_log("modify", "upstart", $in{'name'});
+ }
+&redirect("");
+