Commit 541318e7 authored by Ad Schellevis's avatar Ad Schellevis

remove platform code

parent a72ca73b
<?php
require_once("xmlparse.inc");
require_once("crypt.inc");
require_once("globals.inc");
require_once("script/load_phalcon.php");
/*
......@@ -76,7 +77,7 @@ function parse_config_bootup()
if (!file_exists($config_xml)) {
if (file_exists("/var/run/booting")) {
if (strstr($g['platform'], "cdrom")) {
if (is_install_media()) {
/* try copying the default config. to the floppy */
echo gettext("Resetting factory defaults...") . "\n";
reset_factory_defaults(true);
......
......@@ -55,7 +55,6 @@ $g = array(
"minimum_ram_warning" => "101",
"minimum_ram_warning_text" => "128 MB",
"wan_interface_name" => "wan",
"nopccard_platforms" => array("wrap", "net48xx"),
"xmlrpcbaseurl" => "https://not.supported.opnsense.org",
"captiveportal_path" => "/usr/local/captiveportal",
"captiveportal_element_path" => "/var/db/cpelements",
......@@ -73,10 +72,6 @@ $iptos = array("lowdelay", "throughput", "reliability");
/* TCP flags */
$tcpflags = array("syn", "ack", "fin", "rst", "psh", "urg", "ece", "cwr");
if(file_exists("/usr/local/etc/platform")) {
$g['platform'] = trim(file_get_contents("/usr/local/etc/platform"));
}
/* Default sysctls */
$sysctls = array(
"net.inet.ip.portrange.first" => "1024",
......
......@@ -656,7 +656,6 @@ function check_firmware_version($tocheck = "all", $return_php = true) {
$rawparams = array("firmware" => array("version" => trim(file_get_contents('/usr/local/opnsense/version/opnsense'))),
"kernel" => array("version" => $version[0]),
"base" => array("version" => $version[0]),
"platform" => trim(file_get_contents('/usr/local/etc/platform')),
"config_version" => $config['version']
);
unset($version);
......@@ -666,7 +665,6 @@ function check_firmware_version($tocheck = "all", $return_php = true) {
} else {
foreach($tocheck as $check) {
$params['check'] = $rawparams['check'];
$params['platform'] = $rawparams['platform'];
}
}
if($config['system']['firmware']['branch'])
......@@ -694,7 +692,6 @@ function host_firmware_version($tocheck = "") {
"firmware" => array("version" => trim(file_get_contents('/usr/local/opnsense/version/opnsense', " \n"))),
"kernel" => array("version" => $os_version),
"base" => array("version" => $os_version),
"platform" => trim(file_get_contents('/usr/local/etc/platform', " \n")),
"config_version" => $config['version']
);
}
......@@ -845,10 +842,9 @@ function setup_serial_port($when = 'save', $path = '')
fwrite($fd, "{$bcs}\n");
}
}
if (($g['platform'] == "nanobsd") && !file_exists("/etc/nano_use_vga.txt"))
fwrite($fd, "-S{$serialspeed} -h\n");
else if (is_serial_enabled())
if (is_serial_enabled()) {
fwrite($fd, "-S{$serialspeed} -D\n");
}
fclose($fd);
}
......@@ -870,10 +866,7 @@ function setup_serial_port($when = 'save', $path = '')
&& (stripos($bcs, "autoboot_delay") === false))
$new_boot_config[] = $bcs;
if (($g['platform'] == "nanobsd") && !file_exists("/etc/nano_use_vga.txt")) {
$new_boot_config[] = 'boot_serial="YES"';
$new_boot_config[] = 'console="comconsole"';
} else if (is_serial_enabled()) {
if (is_serial_enabled()) {
$new_boot_config[] = 'boot_multicons="YES"';
$new_boot_config[] = 'boot_serial="YES"';
$primaryconsole = $config['system']['primaryconsole'];
......
......@@ -76,7 +76,7 @@ function restore_rrd()
@unlink($xml_file);
}
/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) {
if (!isset($config['system']['use_mfs_tmpvar'])) {
unlink_if_exists('/conf/rrd.tgz');
}
return true;
......
......@@ -26,6 +26,7 @@
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require_once("globals.inc");
/* implement ipv6 route advertising deamon */
function services_radvd_configure($blacklist = array())
......@@ -343,7 +344,7 @@ function services_dhcpdv4_configure()
}
}
/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) {
if (!isset($config['system']['use_mfs_tmpvar'])) {
unlink_if_exists('/conf/dhcpleases.tgz');
}
}
......@@ -955,7 +956,7 @@ function services_dhcpdv6_configure($blacklist = array())
return 0;
if (file_exists("/var/run/booting")) {
if ($g['platform'] != "pfSense") {
if (is_install_media()) {
/* restore the leases, if we have them */
if (file_exists('/conf/dhcp6leases.tgz')) {
$dhcprestore = '';
......@@ -969,7 +970,7 @@ function services_dhcpdv6_configure($blacklist = array())
}
}
/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
if (($g['platform'] == "pfSense") && !isset($config['system']['use_mfs_tmpvar'])) {
if (isset($config['system']['use_mfs_tmpvar'])) {
unlink_if_exists('/conf/dhcp6leases.tgz');
}
}
......@@ -1917,8 +1918,6 @@ EOD;
}
$version = trim(file_get_contents('/usr/local/opnsense/version/opnsense'));
$platform = trim(file_get_contents('/usr/local/etc/platform'));
if (($platform == "pfSense") && ($g['product_name'] != "pfSense"))
$platform = $g['product_name'];
$sysDescr = "{$g['product_name']} " . php_uname("n") .
" {$version} {$platform} " . php_uname("s") .
......
......@@ -35,9 +35,6 @@ function activate_powerd()
}
if(isset($config['system']['powerd_enable'])) {
if ($g["platform"] == "nanobsd")
exec("/sbin/kldload cpufreq");
$ac_mode = "hadp";
if (!empty($config['system']['powerd_ac_mode']))
$ac_mode = $config['system']['powerd_ac_mode'];
......@@ -1808,72 +1805,7 @@ function enable_watchdog() {
}
}
function system_check_reset_button() {
global $g;
if($g['platform'] != "nanobsd")
return 0;
$specplatform = system_identify_specific_platform();
if ($specplatform['name'] != "wrap" && $specplatform['name'] != "alix")
return 0;
$retval = mwexec("/usr/local/sbin/" . $specplatform['name'] . "resetbtn");
if ($retval == 99) {
/* user has pressed reset button for 2 seconds -
reset to factory defaults */
echo <<<EOD
***********************************************************************
* Reset button pressed - resetting configuration to factory defaults. *
* The system will reboot after this completes. *
***********************************************************************
EOD;
reset_factory_defaults();
system_reboot(true);
exit(0);
}
return 0;
}
/* attempt to identify the specific platform (for embedded systems)
Returns an array with two elements:
name => platform string (e.g. 'wrap', 'alix' etc.)
descr => human-readable description (e.g. "PC Engines WRAP")
*/
function system_identify_specific_platform()
{
global $g;
/* the rest of the code only deals with 'embedded' platforms */
if ($g['platform'] != 'nanobsd')
return array('name' => $g['platform'], 'descr' => $g['platform']);
$dmesg = get_single_sysctl('hw.model');
if (strpos($dmesg, "PC Engines WRAP") !== false)
return array('name' => 'wrap', 'descr' => gettext('PC Engines WRAP'));
if (strpos($dmesg, "PC Engines ALIX") !== false)
return array('name' => 'alix', 'descr' => gettext('PC Engines ALIX'));
if (preg_match("/Soekris net45../", $dmesg, $matches))
return array('name' => 'net45xx', 'descr' => $matches[0]);
if (preg_match("/Soekris net48../", $dmesg, $matches))
return array('name' => 'net48xx', 'descr' => $matches[0]);
if (preg_match("/Soekris net55../", $dmesg, $matches))
return array('name' => 'net55xx', 'descr' => $matches[0]);
/* unknown embedded platform */
return array('name' => 'embedded', 'descr' => gettext('embedded (unknown)'));
}
function system_get_dmesg_boot() {
global $g;
......
......@@ -123,9 +123,6 @@ echo " done.\n";
/* save dmesg output to file */
system_dmesg_save();
/* check whether config reset is desired (via hardware button on WRAP/ALIX) */
system_check_reset_button();
/* remove previous firmware upgrade if present */
if (file_exists("/root/firmware.tgz"))
unlink("/root/firmware.tgz");
......
......@@ -335,11 +335,7 @@ function check_everything() {
<tr>
<td width="22%" valign="top" class="vtable">Local Logging</td>
<td width="78%" class="vtable"> <input name="disablelocallogging" type="checkbox" id="disablelocallogging" value="yes" <?php if ($pconfig['disablelocallogging']) echo "checked=\"checked\""; ?> onclick="enable_change(false)" />
<?php if ($g['platform'] == "pfSense"): ?>
<strong><?=gettext("Disable writing log files to the local disk");?></strong></td>
<?php else: ?>
<strong><?=gettext("Disable writing log files to the local RAM disk");?></strong></td>
<?php endif; ?>
</tr>
<tr>
<td width="22%" valign="top">Reset Logs</td>
......
......@@ -284,9 +284,6 @@ if(file_exists("/var/run/gmirror_active"))
$diagnostics_menu[] = array(gettext("GEOM Mirrors"), "/diag_gmirror.php" );
if($g['platform'] == "nanobsd")
$diagnostics_menu[] = array(gettext("NanoBSD"), "/diag_nanobsd.php");
if (isset($config['system']['developer'])) {
$diagnostics_menu[] = array(gettext("Restart HTTPD"), "/restart_httpd.php", "style" => "font-weight: bold; color: yellow;");
......
......@@ -479,7 +479,6 @@ include("head.inc");
<tr>
<td colspan="2" valign="top" class="listtopic"><?=gettext("RAM Disk Settings (Reboot to Apply Changes)"); ?></td>
</tr>
<?php if ($g['platform'] == "pfSense"): ?>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Use RAM Disks"); ?></td>
<td width="78%" class="vtable">
......@@ -489,11 +488,10 @@ include("head.inc");
"rather than use the hard disk. Setting this will cause the data in /tmp and /var to be lost at reboot, including log data. RRD and DHCP Leases will be retained."); ?>
</td>
</tr>
<?php endif; ?>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("/tmp RAM Disk Size"); ?></td>
<td width="78%" class="vtable">
<input name="use_mfs_tmp_size" id="use_mfs_tmp_size" type="text" value="<?php if ($pconfig['use_mfs_tmp_size'] <> "") echo $pconfig['use_mfs_tmp_size']; ?>" class="formfld unknown" <?php if (($g['platform'] == "pfSense") && ($pconfig['use_mfs_tmpvar'] == false)) echo "disabled=\"disabled\""; ?> /> MB
<input name="use_mfs_tmp_size" id="use_mfs_tmp_size" type="text" value="<?php if ($pconfig['use_mfs_tmp_size'] <> "") echo $pconfig['use_mfs_tmp_size']; ?>" class="formfld unknown" <?php if ($pconfig['use_mfs_tmpvar'] == false) echo "disabled=\"disabled\""; ?> /> MB
<br />
<?=gettext("Set the size, in MB, for the /tmp RAM disk. " .
"Leave blank for 40MB. Do not set lower than 40."); ?>
......@@ -502,7 +500,7 @@ include("head.inc");
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("/var RAM Disk Size"); ?></td>
<td width="78%" class="vtable">
<input name="use_mfs_var_size" id="use_mfs_var_size" type="text" value="<?php if ($pconfig['use_mfs_var_size'] <> "") echo $pconfig['use_mfs_var_size']; ?>" class="formfld unknown" <?php if (($g['platform'] == "pfSense") && ($pconfig['use_mfs_tmpvar'] == false)) echo "disabled=\"disabled\""; ?> /> MB
<input name="use_mfs_var_size" id="use_mfs_var_size" type="text" value="<?php if ($pconfig['use_mfs_var_size'] <> "") echo $pconfig['use_mfs_var_size']; ?>" class="formfld unknown" <?php if ($pconfig['use_mfs_tmpvar'] == false) echo "disabled=\"disabled\""; ?> /> MB
<br />
<?=gettext("Set the size, in MB, for the /var RAM disk. " .
"Leave blank for 60MB. Do not set lower than 60."); ?>
......@@ -512,7 +510,7 @@ include("head.inc");
<td width="22%" valign="top" class="vncell"><?=gettext("Periodic RRD Backup");?></td>
<td width="78%" class="vtable">
<?=gettext("Frequency:");?>
<select name="rrdbackup" class="selectpicker" data-style="btn-default" id="rrdbackup" <?php if (($g['platform'] == "pfSense") && ($pconfig['use_mfs_tmpvar'] == false)) echo "disabled=\"disabled\""; ?> >
<select name="rrdbackup" class="selectpicker" data-style="btn-default" id="rrdbackup" <?php if ($pconfig['use_mfs_tmpvar'] == false) echo "disabled=\"disabled\""; ?> >
<option value='0' <?php if (!isset($config['system']['rrdbackup']) || ($config['system']['rrdbackup'] == 0)) echo "selected='selected'"; ?>><?=gettext("Disable"); ?></option>
<?php for ($x=1; $x<=24; $x++) { ?>
<option value='<?= $x ?>' <?php if ($config['system']['rrdbackup'] == $x) echo "selected='selected'"; ?>><?= $x ?> <?=gettext("hour"); ?><?php if ($x>1) echo "s"; ?></option>
......@@ -528,7 +526,7 @@ include("head.inc");
<td width="22%" valign="top" class="vncell"><?=gettext("Periodic DHCP Leases Backup");?></td>
<td width="78%" class="vtable">
<?=gettext("Frequency:");?>
<select name="dhcpbackup" class="selectpicker" data-style="btn-default" id="dhcpbackup" <?php if (($g['platform'] == "pfSense") && ($pconfig['use_mfs_tmpvar'] == false)) echo "disabled=\"disabled\""; ?> >
<select name="dhcpbackup" class="selectpicker" data-style="btn-default" id="dhcpbackup" <?php if ($pconfig['use_mfs_tmpvar'] == false) echo "disabled=\"disabled\""; ?> >
<option value='0' <?php if (!isset($config['system']['dhcpbackup']) || ($config['system']['dhcpbackup'] == 0)) echo "selected='selected'"; ?>><?=gettext("Disable"); ?></option>
<?php for ($x=1; $x<=24; $x++) { ?>
<option value='<?= $x ?>' <?php if ($config['system']['dhcpbackup'] == $x) echo "selected='selected'"; ?>><?= $x ?> <?=gettext("hour"); ?><?php if ($x>1) echo "s"; ?></option>
......@@ -540,37 +538,6 @@ include("head.inc");
<br />
</td>
</tr>
<?php if($g['platform'] == "pfSenseDISABLED"): ?>
<tr>
<th colspan="2" valign="top" class="listtopic"><?=gettext("Hardware Settings"); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td width="22%" valign="top" class="vncell"><?=gettext("Hard disk standby time "); ?></td>
<td width="78%" class="vtable">
<select name="harddiskstandby" class="formselect selectpicker" data-style="btn-default">
<?php
## Values from ATA-2 http://www.t13.org/project/d0948r3-ATA-2.pdf (Page 66)
$sbvals = explode(" ", "0.5,6 1,12 2,24 3,36 4,48 5,60 7.5,90 10,120 15,180 20,240 30,241 60,242");
?>
<option value="" <?php if(!$pconfig['harddiskstandby']) echo('selected="selected"');?>><?=gettext("Always on"); ?></option>
<?php
foreach ($sbvals as $sbval):
list($min,$val) = explode(",", $sbval);
?>
<option value="<?=$val;?>" <?php if($pconfig['harddiskstandby'] == $val) echo('selected="selected"');?>><?=$min;?> <?=gettext("minutes"); ?></option>
<?php endforeach; ?>
</select>
<br />
<?=gettext("Puts the hard disk into standby mode when the selected amount of time after the last ".
"access has elapsed."); ?> <em><?=gettext("Do not set this for CF cards."); ?></em>
</td>
</tr>
<?php endif; ?>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
......
......@@ -127,31 +127,9 @@ $filesystems = get_mounted_filesystems();
<tr>
<td width="25%" class="vncellt"><?=gettext("Platform");?></td>
<td width="75%" class="listr">
<?=htmlspecialchars($g['platform'] == 'pfSense' ? 'OPNsense' : $g['platform']); /* Platform should not be used as product name */?>
<?php if (($g['platform'] == "nanobsd") && (file_exists("/etc/nanosize.txt"))) {
echo " (" . htmlspecialchars(trim(file_get_contents("/etc/nanosize.txt"))) . ")";
} ?>
<?=htmlspecialchars('OPNsense'); ?>
</td>
</tr>
<?php if ($g['platform'] == "nanobsd"): ?>
<?
global $SLICE, $OLDSLICE, $TOFLASH, $COMPLETE_PATH, $COMPLETE_BOOT_PATH;
global $GLABEL_SLICE, $UFS_ID, $OLD_UFS_ID, $BOOTFLASH;
global $BOOT_DEVICE, $REAL_BOOT_DEVICE, $BOOT_DRIVE, $ACTIVE_SLICE;
nanobsd_detect_slice_info();
$rw = is_writable("/") ? "(rw)" : "(ro)";
?>
<tr>
<td width="25%" class="vncellt"><?=gettext("NanoBSD Boot Slice");?></td>
<td width="75%" class="listr">
<?=htmlspecialchars(nanobsd_friendly_slice_name($BOOT_DEVICE));?> / <?=htmlspecialchars($BOOTFLASH);?> <?php echo $rw; ?>
<?php if ($BOOTFLASH != $ACTIVE_SLICE): ?>
<br /><br />Next Boot:<br />
<?=htmlspecialchars(nanobsd_friendly_slice_name($GLABEL_SLICE));?> / <?=htmlspecialchars($ACTIVE_SLICE);?>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
<tr>
<td width="25%" class="vncellt"><?=gettext("CPU Type");?></td>
<td width="75%" class="listr">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment