---- Changes since 1.310 ----
Added checkboxes and a button for deleting multiple processes at once.
+---- Changes since 1.390 ----
+Converted all code to use the new Webmin UI library, and remove now-useless code and scripts.
+Changed the module name to the less cryptic 'Initial System Bootup'.
#!/usr/local/bin/perl
require "./inittab-lib.pl";
-
&ReadParse();
-&ui_print_header(undef, &text( 'edit_inittab_title', $in{ 'id' } ), "", "index", 1, 1, undef );
-
-print(
- "<form action=save_inittab.cgi><p><table border width=\"100%\">",
- "<tr ", $tb, ">",
- "<td><b>", $text{ 'edit_inittab_details' }, "</b></td>",
- "</tr><tr ", $cb, "><td><table width=\"100%\">" );
-
-@inittab = &parse_inittab();
-($init) = grep { $_->{'id'} eq $in{'id'} } @inittab;
-
-print(
-"<tr>",
- "<td><b>", &hlink( $text{ 'inittab_id' }, "id" ), "</b></td>",
- "<td>", &p_entry( "id", $init->{'id'}, $config{ 'inittab_size' } ), "<input type=hidden name=oldid value='$init->{'id'}'></td>",
-"</tr>\n");
-print "<tr> <td><b>",&hlink($text{ 'inittab_active' },"active"),"</b></td>\n";
-printf "<td><input type=radio name=comment value=0 %s> %s\n",
- $init->{'comment'} ? "" : "checked", $text{'yes'};
-printf "<input type=radio name=comment value=1 %s> %s</td> </tr>\n",
- $init->{'comment'} ? "checked" : "", $text{'no'};
-print ("<tr> <td><b>", &hlink( $text{ 'inittab_runlevels' }, "runlevels" ),
- "</b></td><td>" );
-
-foreach $checkbox ( 0..6, "a", "b", "c" ) {
- local $runlevels;
-
- print( "<input type=checkbox name=", $checkbox, " value=1" );
- foreach $runlevel (@{$init->{'levels'}}) {
- print( " checked" ) if( $runlevel eq $checkbox );
- }
- print( ">", $checkbox, " " );
+if ($in{'new'}) {
+ # Creating a new one
+ $init = { };
+ }
+else {
+ # Find existing config
+ @inittab = &parse_inittab();
+ ($init) = grep { $_->{'id'} eq $in{'id'} } @inittab;
}
-print "</td></tr>\n";
+&ui_print_header(undef, &text('edit_inittab_title', $in{'id'}), "");
+
+print &ui_form_start("save_inittab.cgi");
+print &ui_hidden("oldid", $init->{'id'});
+print &ui_hidden("new", $in{'new'});
+print &ui_table_start($text{'edit_inittab_details'}, "width=100%", 2);
+
+# ID number
+print &ui_table_row(&hlink($text{'inittab_id'}, "id" ),
+ &ui_textbox("id", $init->{'id'}, $config{'inittab_size'}));
+
+# Active or not?
+print &ui_table_row(&hlink($text{ 'inittab_active' },"active"),
+ &ui_radio("comment", $init->{'comment'} ? 1 : 0,
+ [ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ]));
+
+# Levels to run in
+print &ui_table_row(&hlink($text{'inittab_runlevels'}, "runlevels"),
+ join(" ", map { &ui_checkbox($_, 1, $_, &indexof($_, @{$init->{'levels'}}) >= 0) } &list_runlevels()));
+
+# Action
$init->{'action'} = "kbdrequest" if ($init->{'action'} eq "kbrequest");
-print("<tr>",
- "<td><b>", &hlink( $text{ 'inittab_action' }, "action" ), "</b></td>",
- "<td>", &p_select_wdl( "action", $init->{'action'}, ( "respawn", $text{ 'inittab_respawn' }, "wait", $text{ 'inittab_wait' }, "once", $text{ 'inittab_once' }, "wait", $text{ 'inittab_wait' }, "ondemand", $text{ 'inittab_ondemand' }, "initdefault", $text{ 'inittab_initdefault' }, "sysinit", $text{ 'inittab_sysinit' }, "powerwait", $text{ 'inittab_powerwait' }, "powerfail", $text{ 'inittab_powerfail' }, "powerokwait", $text{ 'inittab_powerokwait' }, "powerfailnow", $text{ 'inittab_powerfailnow' }, "ctrlaltdel", $text{ 'inittab_ctrlaltdel' }, "kbdrequest", $text{ 'inittab_kbdrequest' }, "bootwait", $text{'inittab_bootwait'}, "boot", $text{'inittab_boot'}, "off", $text{'inittab_off'} ) ), "</td>",
-"</tr><tr>",
- "<td><b>", &hlink( $text{ 'inittab_process' }, "process" ), "</b></td>\n",
- "<td>", &p_entry( "process", $init->{'process'}, 50 ), "</td>",
-"</tr>" );
-
-print( "</td></tr></table></table>",
- "<table width=\"100%\">",
- "<tr>",
- "<td align=left>", &p_button( "button", $text{ 'save' } ), "</td>",
- "<td align=right>", &p_button( "button", $text{ 'edit_inittab_del' } ), "</td>",
- "</tr>",
- "</table></form>" );
+print &ui_table_row(&hlink($text{'inittab_action'}, "action"),
+ &ui_select("action", $init->{'action'}, [ &list_actions() ],
+ 1, 0, 1));
+
+# Command to run
+print &ui_table_row(&hlink($text{'inittab_process'}, "process"),
+ &ui_textbox("process", $init->{'process'}, 60));
+
+print &ui_table_end();
+if ($in{'new'}) {
+ print &ui_form_end([ [ "button", $text{'create'} ] ]);
+ }
+else {
+ print &ui_form_end([ [ "button", $text{'save'} ],
+ [ "button", $text{'edit_inittab_del'} ] ]);
+ }
&ui_print_footer( "", $text{ 'inittab_return' } );
# shutdown time for each level
require './inittab-lib.pl';
-&ui_print_header(undef, $text{'inittab_title'}, "", "index", 1, 1, 0,
+&ui_print_header(undef, $module_info{'desc'}, "", "index", 1, 1, 0,
&help_search_link("inittab", "man"));
print &ui_form_start("delete.cgi", "post");
@links = ( &select_all_link("d"),
&select_invert_link("d"),
- "<a href=new_inittab.cgi>$text{'inittab_new'}</a>" );
+ "<a href=edit_inittab.cgi?new=1>$text{'inittab_new'}</a>" );
print &ui_links_row(\@links);
@tds = ( "width=5" );
print &ui_columns_start([ "",
&flush_file_lines();
}
-sub p_link
+sub list_runlevels
{
- my ( $dest, $text ) = @_;
- return "<a href=\"". $dest. "\">". $text. "</a>";
+return ( 0..6, "a", "b", "c" );
}
-sub p_radio
+sub list_actions
{
- my ( $name, $checked, @list ) = @_;
- local ($out, $size, $i);
- $size = @list; $i = 0;
-
- do
- {
- $out .= " <input type=radio name=".$name." value=".$list[$i];
- $out .= " checked" if( $checked eq $list[$i++] );
- $out .="> ".$list[$i++];
- } while( $i < $size );
-
- return $out;
+return ( [ "respawn", $text{ 'inittab_respawn' } ],
+ [ "wait", $text{ 'inittab_wait' } ],
+ [ "once", $text{ 'inittab_once' } ],
+ [ "ondemand", $text{ 'inittab_ondemand' } ],
+ [ "initdefault", $text{ 'inittab_initdefault' } ],
+ [ "sysinit", $text{ 'inittab_sysinit' } ],
+ [ "powerwait", $text{ 'inittab_powerwait' } ],
+ [ "powerfail", $text{ 'inittab_powerfail' } ],
+ [ "powerokwait", $text{ 'inittab_powerokwait' } ],
+ [ "powerfailnow", $text{ 'inittab_powerfailnow' } ],
+ [ "ctrlaltdel", $text{ 'inittab_ctrlaltdel' } ],
+ [ "kbdrequest", $text{ 'inittab_kbdrequest' } ],
+ [ "bootwait", $text{'inittab_bootwait'} ],
+ [ "boot", $text{'inittab_boot'} ],
+ [ "off", $text{'inittab_off'} ],
+ );
}
-sub p_entry
-{
- my ( $name, $value, $size ) = @_;
- my $q = $_[1] =~ /'/ ? "\"" : "'";
-
- $size ? return "<input name=". $name. " size=". $size." value=$q". $value."$q>" : return "<input name=". $name. " value=$q". $value."$q>";
-}
-
-sub p_select_wdl
-{
- my ( $name, $selected, @list ) = @_;
- local $size = @list, $i = 0, $out = " <select name=".$name.">";
- do
- {
- $out .= "<option name=".$name." value=".$list[$i];
- $out .= " selected" if( $selected eq $list[$i++] );
- $out .= ">".$list[$i++];
- } while( $i < $size );
- $out .= "</select>";
-
- return $out;
-}
-
-sub p_select
-{
- my ( $name, $selected, @list ) = @_;
- local (@newlist, $item);
-
- foreach $item ( @list )
- {
- push( @newlist, $item, $item );
- }
-
- p_select_wdl( $name, $selected, @newlist );
-}
-
-sub p_button
-{
- my ( $name, $value ) = @_;
- return "<input type=submit name=". $name. " value=\"". $value. "\">";
-}
-inittab_title=SysV Init Configuration
inittab_new=Create a new init process.
inittab_id=ID
inittab_active=Active?
inittab_powerfailnow=Power fail
inittab_ctrlaltdel=Ctrl-Alt-Del
inittab_kbdrequest=Special key combination
+inittab_kbrequest=$inittab_kbdrequest
inittab_return=process list
inittab_apply=Apply Init Configuration
inittab_applymsg=Click this button to apply the current SysV Init Configuration by running the command <tt>telinit q</tt>. Be aware that any mistakes in your configuration may make the system unusable when this command is run.
category=system
desc_tr=SysV Açýlýþ Yapýlandýrmasý
os_support=solaris *-linux{-r "/etc/inittab"} hpux unixware openserver aix irix
-desc=SysV Init Configuration
+desc=Initial System Bootup
desc_es=Configuración de Inicio (SysV)
desc_sv=Startinställningar för SysV
desc_fr=Processus d'initialisation SysV
+++ /dev/null
-#!/usr/local/bin/perl
-
-require "./inittab-lib.pl";
-
-&ReadParse();
-
-&ui_print_header(undef, &text( 'new_inittab_title', $in{ 'id' } ), "", "index", 1, 1, undef );
-
-print(
-"<form action=save_inittab.cgi><p>",
-"<table border width=\"100%\">",
- "<tr ", $tb, ">",
- "<td><b>", $text{ 'edit_inittab_details' }, "</b></td>",
- "</tr><tr ", $cb, ">",
- "<td>",
- "<table width=\"100%\">",
- "<tr>",
- "<td><b>", &hlink( $text{ 'inittab_id' }, "id" ), "</b></td>",
- "<td>", &p_entry( "id", "", 4 ), "</td>",
- "</tr><tr>",
- "<td><b>",&hlink($text{ 'inittab_runlevels' }, "runlevels"),
- "</b></td>",
- "<td><input type=checkbox name=0 value=1>0 <input type=checkbox name=1 value=1>1 <input type=checkbox name=2 value=1>2 <input type=checkbox name=3 value=1>3 <input type=checkbox name=4 value=1>4 <input type=checkbox name=5 value=1>5 <input type=checkbox name=6 value=1>6 <input type=checkbox name=a value=1>A <input type=checkbox name=b value=1>B <input type=checkbox name=c value=1>C</td>",
- "</tr><tr>",
- "<td><b>",&hlink($text{'inittab_action'}, "action"),
- "</b></td>",
- "<td>", &p_select_wdl( "action", "", ( "respawn", $text{ 'inittab_respawn' }, "wait", $text{ 'inittab_wait' }, "once", $text{ 'inittab_once' }, "wait", $text{ 'inittab_wait' }, "ondemand", $text{ 'inittab_ondemand' }, "initdefault", $text{ 'inittab_initdefault' }, "sysinit", $text{ 'inittab_sysinit' }, "powerwait", $text{ 'inittab_powerwait' }, "powerfail", $text{ 'inittab_powerfail' }, "powerokwait", $text{ 'inittab_powerokwait' }, "powerfailnow", $text{ 'inittab_powerfailnow' }, "ctraltdel", $text{ 'inittab_ctrlaltdel' }, "kbdrequest", $text{ 'inittab_kbdrequest' } ) ), "</td>",
- "</tr><tr>",
- "<td><b>",&hlink($text{'inittab_process'}, "process"),
- "</b></td>",
- "<td>", &p_entry( "process", "" ), "</td>",
- "</tr>",
- "</table>",
- "</td>",
- "</tr>",
-"</table>",
-"<table width=\"100%\">",
- "<tr>",
- "<td align=left>", &p_button( "button", $text{ 'create' } ), "</td>",
- "</tr>",
-"</table></form>" );
-
-&ui_print_footer( "/inittab/index.cgi", $text{ 'inittab_return' } );