4 # Edit the settings in the hostconfig file, or the
5 # StartupItems script or plist associated with the
6 # action described in the hostconfig file.
8 # Also create a new startup action with associated script and plist
9 # and manually modify hostconfig file.
11 require './init-lib.pl';
12 require './hostconfig-lib.pl';
14 $access{'bootup'} == 1 || &error($text{'edit_ecannot'});
18 # Editing an existing action in /etc/hostconfig
19 $action_to_edit = $ARGV[1];
20 &ui_print_header(undef, $text{'edit_title'}, "");
21 %startuphash = &hostconfig_gather(startscript);
22 $startscript = $startuphash{"$action_to_edit"};
23 if ( $startscript ne "") {
24 $startupdir = dirname("$startscript");
25 $plistedit = "$startupdir/$config{'plist'}";
31 #create the action edit table
32 $actionedit = &hostconfig_editaction("$action_to_edit", "$startscript");
33 print "<form action=modifyhostconfig.cgi method=post name=hostmod>\n";
34 print "<table width=\"100%\" border><tr $tb> <td><b>", &text('index_action'), "</b></td>\n";
35 print "<td><b>", &text('index_setting'), "</b></td></tr>\n";
36 print "<tr $cb><td valign=middle>$action_to_edit</td>\n";
37 print "<td>$actionedit</td></tr></table>\n";
38 print "<input type=submit value='$text{'save'}'></form>\n";
41 #create the edit file forms
42 if ($startscript ne "") {
44 print &text('edit_hostconfig_startup',
45 "<tt>$startscript</tt>"),"<br>\n";
47 print "<form action=save_startscript.cgi method=post>\n";
48 print "<textarea name=startup rows=20 cols=80>";
49 open(STARTSCRIPT, $startscript);
50 while(<STARTSCRIPT>) { print; }
52 print "</textarea><br>\n";
53 print "<input type=hidden name=\"action\" value=\"$action_to_edit\">\n";
54 print "<input type=submit value='$text{'save'}'></form>\n";
56 if ($plistedit ne "") {
58 print &text('edit_hostconfig_plist',
59 "<tt>$plistedit</tt>"),"<br>\n";
61 print "<form action=save_startscript.cgi method=post>\n";
62 print "<textarea name=plist rows=20 cols=80>";
63 open(PLIST, $plistedit);
64 while(<PLIST>) { print; }
66 print "</textarea><br>\n";
67 print "<input type=hidden name=\"action\" value=\"$action_to_edit\">\n";
68 # print "$plistedit</textarea><br>\n";
69 print "<input type=submit value='$text{'save'}'></form>\n";
74 &ui_print_header(undef, $text{'edit_hostconfig_new'}, "");
77 print "<P>\n", &text('edit_hostconfig_noquotes',
78 "<tt>$text{'edit_start'}</tt>"),"\n";
80 print "<P>\n", &text('edit_hostconfig_startitems',
81 "<tt>$text{'edit_hostconfig_actionname'}</tt>",
82 "<tt>$text{'edit_hostconfig_scriptname'}</tt>"),"\n";
84 print "<P>\n", &text('edit_hostconfig_array',
85 "<tt>Provides</tt>", "<tt>Requires</tt>", "<tt>Uses</tt>"),"\n";
87 print "<P>\n $text{'edit_hostconfig_further'}\n";
89 #print "<form method=post action=save_hostconfig_action.cgi enctype=multipart/form-data>\n";
90 print "<form method=post action=save_hostconfig_action.cgi>\n";
91 print "<table border>\n";
92 print "<tr $tb><td><b>Action Details</b></td></tr>\n";
93 print "<tr $cb><td><table cellpadding=3>\n";
95 # create the form fields
97 $textt=&hostconfig_createtext("Action Name","req");
98 print "<tr>", &hostconfig_createtext("$text{'edit_hostconfig_actionname'}","req");
99 print "<td><input size=20 name=action_name value=\"\"></td></tr>\n";
101 print "<tr>", &hostconfig_createtext("$text{'edit_hostconfig_scriptname'}","req");
102 print "<td><input size=20 name=script_name value=\"\"></td></tr>\n";
104 print "<tr>", &hostconfig_createtext("$text{'edit_start'}","req");
105 print "<td><font size=-1><textarea rows=5 cols=80 name=execute></textarea></font></td></tr>\n";
107 print "<tr>", &hostconfig_createtext("$text{'index_desc'}","");
108 print "<td><input size=60 name=description value=\"\"></td></tr>\n";
110 print "<tr>", &hostconfig_createtext("Provides","");
111 print "<td><input size=60 name=provides value=\"\"></td></tr>\n";
113 print "<tr>", &hostconfig_createtext("Requires","");
114 print "<td><input size=60 name=requires value=\"\"></td></tr>\n";
116 print "<tr>", &hostconfig_createtext("Uses","");
117 print "<td><input size=60 name=uses value=\"\"></td></tr>\n";
119 print "<tr>", &hostconfig_createtext("OrderPreference","");
120 print "<td><SELECT name=order><option value=First>First<option value=Early>Early<option value=None selected>None<option value=Late>Late<option value=Last>Last</select></td></tr>\n";
122 print "<tr>", &hostconfig_createtext("Start Message","");
123 print "<td><input size=60 name=start value=\"\"></td></tr>\n";
125 print "<tr>", &hostconfig_createtext("Stop Message","");
126 print "<td><input size=60 name=stop value=\"\"></td></tr>\n";
128 print "<tr>", &hostconfig_createtext("Start at boot time?","");
129 print "<td><input name=boot type=radio value=\"-YES-\"> Yes\n";
130 print "<input name=boot type=radio value=\"-NO-\" checked> No</td></tr>\n";
132 print "<tr><td><font size=-1 color=#ff0000>* required field</font></td><td> </td></tr>\n";
134 print "</td></tr></table>\n";
135 print "<input type=submit value=\"Create\"></form>\n";
141 &ui_print_header(undef, $text{'edit_hostconfig_title'}, "");
142 print &text('edit_hostconfig_hostconfig',
143 "<tt>$config{'hostconfig'}</tt>"),"<br>\n";
144 print "<form action=save_startscript.cgi method=post>\n";
145 print "<textarea name=hostconfig rows=20 cols=80>";
146 open(LOCAL, $config{'hostconfig'});
147 while(<LOCAL>) { print; }
149 print "</textarea><br>\n";
150 print "<input type=submit value='$text{'save'}'></form>\n";
153 #add reboot and shutdown messages to this page as well...
154 print "<table cellpadding=5 width=100%>\n";
155 if ($access{'reboot'}) {
156 print "<form action=reboot.cgi>\n";
157 print "<tr> <td><input type=submit ",
158 "value=\"$text{'index_reboot'}\"></td>\n";
160 print "<td>$text{'index_rebootmsg'}</td> </tr>\n";
163 if ($access{'shutdown'}) {
164 print "<form action=shutdown.cgi>\n";
165 print "<tr> <td><input type=submit ",
166 "value=\"$text{'index_shutdown'}\"></td>\n";
168 print "<td>$text{'index_shutdownmsg'}</td> </tr>\n";
173 &ui_print_footer("", $text{'index_return'});