if ($in{'new'}) {
# Service name
+ print &ui_table_row($text{'upstart_name'},
+ &ui_textbox("name", undef, 30));
# Description
+ print &ui_table_row($text{'upstart_desc'},
+ &ui_textbox("desc", undef, 60));
# Pre-start script
+ print &ui_table_row($text{'upstart_prestart'},
+ &ui_textarea("prestart", undef, 5, 80));
# Server command
+ print &ui_table_row($text{'upstart_server'},
+ &ui_textbox("server", undef, 60));
+
+ # Start at boot?
+ print &ui_table_row($text{'upstart_boot'},
+ &ui_yesno_radio("boot", 1));
}
else {
# Service name (non-editable)
upstart_elegacy=Not an upstart service!
upstart_header=Upstart service details
upstart_name=Service name
+upstart_desc=Service description
+upstart_prestart=Commands to run before starting server
+upstart_server=Server program and parameters
upstart_conf=Configuration file
upstart_boot=Start at boot time?
upstart_status=Current status
upstart_status1=Running with PID $1
upstart_err=Failed to save upstart service
upstart_econf=No configuration file contents entered
+upstart_ename=Missing or invalid-lookup upstart service name
+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
__norefs=1
&error_setup($text{'upstart_err'});
$access{'bootup'} || &error($text{'edit_ecannot'});
&ReadParse();
+@upstarts = &list_upstart_services();
# 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'});
# XXX
}
elsif ($in{'new'}) {
+ # Validate inputs and check for clash
+ $in{'name'} =~ /^[a-z0-9\.\_\-]+$/i ||
+ &error($text{'upstart_ename'});
+ ($clash) = grep { $_->{'name'} eq $in{'name'} } @upstarts;
+ $clash && &error($text{'upstart_eclash'});
+ $in{'desc'} || &error($text{'upstart_edesc'});
+ $in{'server'} =~ /\S/ || &error($text{'upstart_eserver'});
+ ($bin, $args) = split(/\s+/, $in{'server'});
+ &has_command($bin) || &error($text{'upstart_eserver2'});
+
# Create the config file
+ # XXX
- # Enable at boot
+ # Enable at boot if selected
+ &enable_at_boot($in{'name'}) if ($in{'boot'});
}
else {
# Just save the config file