Menu

[r10367]: / legacy / www / system_advanced.php  Maximize  Restore  History

Download this file

285 lines (259 with data), 12.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/usr/local/bin/php
<?php
/*
system_advanced.php
Modified for XHTML by Daisuke Aoyama (aoyama@peach.ne.jp)
Copyright (C) 2010 Daisuke Aoyama <aoyama@peach.ne.jp>.
All rights reserved.
part of FreeNAS (http://www.freenas.org)
Copyright (C) 2005-2010 Olivier Cochard-Labbe <olivier@freenas.org>.
All rights reserved.
Based on m0n0wall (http://m0n0.ch/wall)
Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require("auth.inc");
require("guiconfig.inc");
$pgtitle = array(gettext("System"), gettext("Advanced"));
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
$pconfig['disablefm'] = isset($config['system']['disablefm']);
$pconfig['disablefirmwarecheck'] = isset($config['system']['disablefirmwarecheck']);
$pconfig['disablebeep'] = isset($config['system']['disablebeep']);
$pconfig['tune_enable'] = isset($config['system']['tune']);
$pconfig['zeroconf'] = isset($config['system']['zeroconf']);
$pconfig['powerd'] = isset($config['system']['powerd']);
$pconfig['motd'] = base64_decode($config['system']['motd']);
$pconfig['sysconsaver'] = isset($config['system']['sysconsaver']['enable']);
$pconfig['sysconsaverblanktime'] = $config['system']['sysconsaver']['blanktime'];
$pconfig['enableserialconsole'] = isset($config['system']['enableserialconsole']);
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
// Input validation.
if ($_POST['sysconsaver']) {
$reqdfields = explode(" ", "sysconsaverblanktime");
$reqdfieldsn = array(gettext("Blank time"));
$reqdfieldst = explode(" ", "numeric");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, &$input_errors);
}
if (!$input_errors) {
// Process system tuning.
if ($_POST['tune_enable']) {
sysctl_tune(1);
} else if (isset($config['system']['tune']) && (!$_POST['tune_enable'])) {
// Simply force a reboot to reset to default values.
// This makes programming easy :-) Also we are sure that
// system will use origin values (maybe default values
// change from one FreeBSD release to the next. This will
// reduce maintenance).
sysctl_tune(0);
touch($d_sysrebootreqd_path);
}
$bootconfig="boot.config";
if (!isset($_POST['enableserialconsole'])) {
if (file_exists("/$bootconfig")) {
unlink("/$bootconfig");
}
if (file_exists("{$g['cf_path']}/mfsroot.gz")
&& file_exists("{$g['cf_path']}/$bootconfig")) {
config_lock();
conf_mount_rw();
unlink("{$g['cf_path']}/$bootconfig");
conf_mount_ro();
config_unlock();
}
} else {
if (file_exists("/$bootconfig")) {
unlink("/$bootconfig");
}
file_put_contents("/$bootconfig", "-Dh\n");
if (file_exists("{$g['cf_path']}/mfsroot.gz")) {
config_lock();
conf_mount_rw();
if (file_exists("{$g['cf_path']}/$bootconfig")) {
unlink("{$g['cf_path']}/$bootconfig");
}
file_put_contents("{$g['cf_path']}/$bootconfig", "-Dh\n");
conf_mount_ro();
config_unlock();
}
}
if ((isset($config['system']['disablefm']) && (!$_POST['disablefm']))
|| (!isset($config['system']['disablefm']) && ($_POST['disablefm']))) {
// need restarting WebGUI
touch($d_sysrebootreqd_path);
}
$config['system']['disableconsolemenu'] = $_POST['disableconsolemenu'] ? true : false;
$config['system']['disablefm'] = $_POST['disablefm'] ? true : false;
$config['system']['disablefirmwarecheck'] = $_POST['disablefirmwarecheck'] ? true : false;
$config['system']['webgui']['noantilockout'] = $_POST['noantilockout'] ? true : false;
$config['system']['disablebeep'] = $_POST['disablebeep'] ? true : false;
$config['system']['tune'] = $_POST['tune_enable'] ? true : false;
$config['system']['zeroconf'] = $_POST['zeroconf'] ? true : false;
$config['system']['powerd'] = $_POST['powerd'] ? true : false;
$config['system']['motd'] = base64_encode($_POST['motd']); // Encode string, otherwise line breaks will get lost
$config['system']['sysconsaver']['enable'] = $_POST['sysconsaver'] ? true : false;
$config['system']['sysconsaver']['blanktime'] = $_POST['sysconsaverblanktime'];
$config['system']['enableserialconsole'] = $_POST['enableserialconsole'] ? true : false;
write_config();
$retval = 0;
if (!file_exists($d_sysrebootreqd_path)) {
config_lock();
$retval |= rc_exec_service("rcconf");
$retval |= rc_update_service("powerd");
$retval |= rc_update_service("mdnsresponder");
$retval |= rc_exec_service("motd");
if (isset($config['system']['tune']))
$retval |= rc_update_service("sysctl");
$retval |= rc_update_service("syscons");
$retval |= rc_update_service("webfm");
config_unlock();
}
$savemsg = get_std_save_message($retval);
}
}
function sysctl_tune($mode) {
global $config;
if (!is_array($config['system']['sysctl']['param']))
$config['system']['sysctl']['param'] = array();
array_sort_key($config['system']['sysctl']['param'], "name");
$a_sysctlvar = &$config['system']['sysctl']['param'];
$a_mib = array(
"net.inet.tcp.delayed_ack" => 0,
"net.inet.tcp.rfc1323" => 1,
"net.inet.tcp.sendspace" => 262144,
"net.inet.tcp.recvspace" => 262144,
"net.inet.tcp.sendbuf_max" => 4194304,
"net.inet.tcp.sendbuf_inc" => 262144,
"net.inet.tcp.sendbuf_auto" => 1,
"net.inet.tcp.recvbuf_max" => 4194304,
"net.inet.tcp.recvbuf_inc" => 262144,
"net.inet.tcp.recvbuf_auto" => 1,
"net.inet.udp.recvspace" => 65536,
"net.inet.udp.maxdgram" => 57344,
"net.local.stream.recvspace" => 65536,
"net.local.stream.sendspace" => 65536,
"kern.ipc.maxsockbuf" => 16777216,
"kern.ipc.somaxconn" => 8192,
"kern.ipc.nmbclusters" => 262144,
"kern.ipc.nmbjumbop" => 262144,
"kern.ipc.nmbjumbo9" => 131072,
"kern.ipc.nmbjumbo16" => 65536,
"kern.maxfiles" => 65536,
"kern.maxfilesperproc" => 32768,
"net.inet.icmp.icmplim" => 300,
"net.inet.icmp.icmplim_output" => 1,
//"net.inet.tcp.inflight.enable" => 0,
"net.inet.tcp.path_mtu_discovery" => 0,
"hw.intr_storm_threshold" => 9000,
);
switch ($mode) {
case 0:
// Remove system tune MIB's.
while (list($name, $value) = each($a_mib)) {
$id = array_search_ex($name, $a_sysctlvar, "name");
if (false === $id)
continue;
unset($a_sysctlvar[$id]);
}
break;
case 1:
// Add system tune MIB's.
while (list($name, $value) = each($a_mib)) {
$id = array_search_ex($name, $a_sysctlvar, "name");
if (false !== $id)
continue;
$param = array();
$param['uuid'] = uuid();
$param['name'] = $name;
$param['value'] = $value;
$param['comment'] = gettext("System tuning");
$param['enable'] = true;
$a_sysctlvar[] = $param;
}
break;
}
}
?>
<?php include("fbegin.inc");?>
<script type="text/javascript">
<!--
function sysconsaver_change() {
switch (document.iform.sysconsaver.checked) {
case true:
showElementById('sysconsaverblanktime_tr','show');
break;
case false:
showElementById('sysconsaverblanktime_tr','hide');
break;
}
}
//-->
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="tabnavtbl">
<ul id="tabnav">
<li class="tabact"><a href="system_advanced.php" title="<?=gettext("Reload page");?>"><span><?=gettext("Advanced");?></span></a></li>
<li class="tabinact"><a href="system_email.php"><span><?=gettext("Email");?></span></a></li>
<li class="tabinact"><a href="system_proxy.php"><span><?=gettext("Proxy");?></span></a></li>
<li class="tabinact"><a href="system_swap.php"><span><?=gettext("Swap");?></span></a></li>
<li class="tabinact"><a href="system_rc.php"><span><?=gettext("Command scripts");?></span></a></li>
<li class="tabinact"><a href="system_cron.php"><span><?=gettext("Cron");?></span></a></li>
<li class="tabinact"><a href="system_rcconf.php"><span><?=gettext("rc.conf");?></span></a></li>
<li class="tabinact"><a href="system_sysctl.php"><span><?=gettext("sysctl.conf");?></span></a></li>
</ul>
</td>
</tr>
<tr>
<td class="tabcont">
<form action="system_advanced.php" method="post" name="iform" id="iform">
<?php if ($input_errors) print_input_errors($input_errors);?>
<?php if ($savemsg) print_info_box($savemsg);?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<?php html_checkbox("disableconsolemenu", gettext("Console menu"), $pconfig['disableconsolemenu'] ? true : false, gettext("Disable console menu"), gettext("Changes to this option will take effect after a reboot."));?>
<?php html_checkbox("enableserialconsole", gettext("Serial Console"), $pconfig['enableserialconsole'] ? true : false, gettext("Enable serial console"), sprintf("<span class='red'><strong>%s</strong></span><br />%s", gettext("The COM port in BIOS has to be enabled before enabling this option."), gettext("Changes to this option will take effect after a reboot.")));?>
<?php html_checkbox("sysconsaver", gettext("Console screensaver"), $pconfig['sysconsaver'] ? true : false, gettext("Enable console screensaver"), "", false, "sysconsaver_change()");?>
<?php html_inputbox("sysconsaverblanktime", gettext("Blank time"), $pconfig['sysconsaverblanktime'], gettext("Turn the monitor to standby after N seconds."), true, 5);?>
<?php html_checkbox("disablefm", gettext("File Manager"), $pconfig['disablefm'] ? true : false, gettext("Disable File Manager"));?>
<?php if ("full" !== $g['platform']):?>
<?php html_checkbox("disablefirmwarecheck", gettext("Firmware version check"), $pconfig['disablefirmwarecheck'] ? true : false, gettext("Disable firmware version check"), sprintf(gettext("This will cause %s not to check for newer firmware versions when the <a href='%s'>%s</a> page is viewed."), get_product_name(), "system_firmware.php", gettext("System").": ".gettext("Firmware")));?>
<?php endif;?>
<?php html_checkbox("disablebeep", gettext("System Beep"), $pconfig['disablebeep'] ? true : false, gettext("Disable speaker beep on startup and shutdown"));?>
<?php html_checkbox("tune_enable", gettext("Tuning"), $pconfig['tune_enable'] ? true : false, gettext("Enable tuning of some kernel variables"));?>
<?php html_checkbox("powerd", gettext("Power Daemon"), $pconfig['powerd'] ? true : false, gettext("Enable the system power control utility"), gettext("The powerd utility monitors the system state and sets various power control options accordingly."));?>
<?php html_checkbox("zeroconf", gettext("Zeroconf/Bonjour"), $pconfig['zeroconf'] ? true : false, gettext("Enable Zeroconf/Bonjour to advertise services of this device"));?>
<?php html_textarea("motd", gettext("MOTD"), $pconfig['motd'], gettext("Message of the day."), false, 65, 7, false, false);?>
</table>
<div id="submit">
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
</div>
<?php include("formend.inc");?>
</form>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
sysconsaver_change();
//-->
</script>
<?php include("fend.inc");?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.