Handle hostnames with upper-case letters
[webmin.git] / init / edit_rc.cgi
1 #!/usr/local/bin/perl
2 # Show a form for editing or creating a BSD rc script
3
4 require './init-lib.pl';
5 &ReadParse();
6 $access{'bootup'} || &error($text{'edit_ecannot'});
7
8 if ($in{'new'}) {
9         &ui_print_header(undef, $text{'create_title'}, "");
10         $rc = { 'enabled' => 1 };
11         }
12 else {
13         &ui_print_header(undef, $text{'edit_title'}, "");
14         @rcs = &list_rc_scripts();
15         ($rc) = grep { $_->{'name'} eq $in{'name'} } @rcs;
16         $rc || &error($text{'edit_egone'});
17         }
18
19 print &ui_form_start("save_rc.cgi", "post");
20 print &ui_hidden("new", $in{'new'});
21 print &ui_table_start($text{'edit_details'}, "width=100%", 2);
22
23 if ($in{'new'}) {
24         # When creating, show start/stop/status input fields
25         print &ui_table_row($text{'edit_name'},
26                 &ui_textbox("name", undef, 20));
27
28         print &ui_table_row($text{'edit_startcmd'},
29                 &ui_textbox("start_cmd", undef, 70));
30
31         print &ui_table_row($text{'edit_stopcmd'},
32                 &ui_textbox("stop_cmd", undef, 70));
33
34         print &ui_table_row($text{'edit_statuscmd'},
35                 &ui_textbox("status_cmd", undef, 70));
36         }
37 else {
38         # Just show fill action file contents
39         print &ui_table_row($text{'edit_name'}, "<tt>$in{'name'}</tt>");
40         print &ui_hidden("name", $in{'name'});
41
42         $script = &read_file_contents($rc->{'file'});
43         print &ui_table_row($text{'edit_script'},
44                 &ui_textarea("script", $script, 20, 70));
45         }
46
47 # Enabled at boot option
48 if ($rc->{'enabled'} != 2) {
49         print &ui_table_row($text{'edit_boot'},
50                 &ui_yesno_radio("enabled", int($rc->{'enabled'})));
51         }
52
53 print &ui_table_end();
54 if ($in{'new'}) {
55         print &ui_form_end([ [ "create", $text{'create'} ] ]);
56         }
57 else {
58         print &ui_form_end([ [ "save", $text{'save'} ],
59                              undef,
60                              [ "start", $text{'edit_startnow'} ],
61                              $rc->{'startstop'} ? 
62                                 ( [ "stop", $text{'edit_stopnow'} ] ) : ( ),
63                              undef,
64                              $rc->{'standard'} ?
65                                 ( ) : ( [ "delete", $text{'delete'} ] ) ]);
66         }
67
68 &ui_print_footer("", $text{'index_return'});
69