mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
globals: thin out the file
o is_install_media() was being misused. In the instance of dhcp6, the backup file did not even exist, I think someone did copy+paste the IPv4 code back in the day and the actual backup was never added. o match_wireless_interface() was moved to interfaces.inc where it belongs.
This commit is contained in:
parent
743279d8d4
commit
1cb6d444b4
@ -46,27 +46,3 @@ $g = array(
|
||||
"product_copyright_url" => "https://www.deciso.com/",
|
||||
"latest_config" => "11.2",
|
||||
);
|
||||
|
||||
function is_install_media()
|
||||
{
|
||||
/*
|
||||
* Despite unionfs underneath, / is still not writeable,
|
||||
* making the following the perfect test for install media.
|
||||
*/
|
||||
|
||||
$file = '/.probe.for.install.media';
|
||||
$fd = @fopen($file, 'w');
|
||||
if ($fd) {
|
||||
fclose($fd);
|
||||
unlink($file);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function match_wireless_interface($int)
|
||||
{
|
||||
$wireless_regex = '/^(ndis|wi|ath|an|ral|ural|iwi|wlan|rum|run|bwn|zyd|mwl|bwi|ipw|iwn|malo|uath|upgt|urtw|wpi)/';
|
||||
return preg_match($wireless_regex, $int);
|
||||
}
|
||||
|
||||
@ -93,6 +93,12 @@ function convert_128bit_to_ipv6($ip6bin)
|
||||
return $ip6addr;
|
||||
}
|
||||
|
||||
function match_wireless_interface($int)
|
||||
{
|
||||
$wireless_regex = '/^(ndis|wi|ath|an|ral|ural|iwi|wlan|rum|run|bwn|zyd|mwl|bwi|ipw|iwn|malo|uath|upgt|urtw|wpi)/';
|
||||
return preg_match($wireless_regex, $int);
|
||||
}
|
||||
|
||||
function interfaces_bring_up($interface)
|
||||
{
|
||||
if (!$interface) {
|
||||
|
||||
@ -277,65 +277,65 @@ function setup_serial_port($sync = true)
|
||||
$loader_conf_file = '/boot/loader.conf';
|
||||
$boot_config_file = '/boot.config';
|
||||
|
||||
if (!is_install_media()) {
|
||||
/* serial console - write out /boot.config */
|
||||
if (file_exists($boot_config_file)) {
|
||||
$boot_config = file_get_contents($boot_config_file);
|
||||
} else {
|
||||
$boot_config = '';
|
||||
/* serial console - write out /boot.config */
|
||||
if (file_exists($boot_config_file)) {
|
||||
$boot_config = file_get_contents($boot_config_file);
|
||||
} else {
|
||||
$boot_config = '';
|
||||
}
|
||||
|
||||
$boot_config_split = explode("\n", $boot_config);
|
||||
$fd = fopen($boot_config_file,"w");
|
||||
if($fd) {
|
||||
foreach($boot_config_split as $bcs) {
|
||||
if(stristr($bcs, "-D") || stristr($bcs, "-h")) {
|
||||
/* DONT WRITE OUT, WE'LL DO IT LATER */
|
||||
} else {
|
||||
if($bcs <> "")
|
||||
fwrite($fd, "{$bcs}\n");
|
||||
}
|
||||
}
|
||||
if ($serial_enabled) {
|
||||
@fwrite($fd, "-S{$serialspeed} -D\n");
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
$boot_config = @file_get_contents($loader_conf_file);
|
||||
$boot_config_split = explode("\n", $boot_config);
|
||||
if(count($boot_config_split) > 0) {
|
||||
$new_boot_config = array();
|
||||
// Loop through and only add lines that are not empty, and which
|
||||
// do not contain a console directive.
|
||||
foreach($boot_config_split as $bcs) {
|
||||
if(!empty($bcs)
|
||||
&& (stripos($bcs, "console") === false)
|
||||
&& (stripos($bcs, "boot_multicons") === false)
|
||||
&& (stripos($bcs, "boot_serial") === false)
|
||||
&& (stripos($bcs, "hw.usb.no_pf") === false)
|
||||
&& (stripos($bcs, "autoboot_delay") === false)) {
|
||||
$new_boot_config[] = $bcs;
|
||||
}
|
||||
}
|
||||
|
||||
$boot_config_split = explode("\n", $boot_config);
|
||||
$fd = fopen($boot_config_file,"w");
|
||||
if($fd) {
|
||||
foreach($boot_config_split as $bcs) {
|
||||
if(stristr($bcs, "-D") || stristr($bcs, "-h")) {
|
||||
/* DONT WRITE OUT, WE'LL DO IT LATER */
|
||||
} else {
|
||||
if($bcs <> "")
|
||||
fwrite($fd, "{$bcs}\n");
|
||||
}
|
||||
if ($serial_enabled) {
|
||||
$new_boot_config[] = 'boot_multicons="YES"';
|
||||
$new_boot_config[] = 'boot_serial="YES"';
|
||||
$primaryconsole = $config['system']['primaryconsole'];
|
||||
switch ($primaryconsole) {
|
||||
case "video":
|
||||
$new_boot_config[] = 'console="vidconsole,comconsole"';
|
||||
break;
|
||||
case "serial":
|
||||
default:
|
||||
$new_boot_config[] = 'console="comconsole,vidconsole"';
|
||||
}
|
||||
if ($serial_enabled) {
|
||||
fwrite($fd, "-S{$serialspeed} -D\n");
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
$new_boot_config[] = 'comconsole_speed="' . $serialspeed . '"';
|
||||
$new_boot_config[] = 'hw.usb.no_pf="1"';
|
||||
$new_boot_config[] = 'autoboot_delay="3"';
|
||||
|
||||
$boot_config = @file_get_contents($loader_conf_file);
|
||||
$boot_config_split = explode("\n", $boot_config);
|
||||
if(count($boot_config_split) > 0) {
|
||||
$new_boot_config = array();
|
||||
// Loop through and only add lines that are not empty, and which
|
||||
// do not contain a console directive.
|
||||
foreach($boot_config_split as $bcs)
|
||||
if(!empty($bcs)
|
||||
&& (stripos($bcs, "console") === false)
|
||||
&& (stripos($bcs, "boot_multicons") === false)
|
||||
&& (stripos($bcs, "boot_serial") === false)
|
||||
&& (stripos($bcs, "hw.usb.no_pf") === false)
|
||||
&& (stripos($bcs, "autoboot_delay") === false))
|
||||
$new_boot_config[] = $bcs;
|
||||
|
||||
if ($serial_enabled) {
|
||||
$new_boot_config[] = 'boot_multicons="YES"';
|
||||
$new_boot_config[] = 'boot_serial="YES"';
|
||||
$primaryconsole = $config['system']['primaryconsole'];
|
||||
switch ($primaryconsole) {
|
||||
case "video":
|
||||
$new_boot_config[] = 'console="vidconsole,comconsole"';
|
||||
break;
|
||||
case "serial":
|
||||
default:
|
||||
$new_boot_config[] = 'console="comconsole,vidconsole"';
|
||||
}
|
||||
}
|
||||
$new_boot_config[] = 'comconsole_speed="' . $serialspeed . '"';
|
||||
$new_boot_config[] = 'hw.usb.no_pf="1"';
|
||||
$new_boot_config[] = 'autoboot_delay="3"';
|
||||
|
||||
file_put_contents($loader_conf_file, implode("\n", $new_boot_config) . "\n");
|
||||
}
|
||||
@file_put_contents($loader_conf_file, implode("\n", $new_boot_config) . "\n");
|
||||
}
|
||||
|
||||
$ttys = file_get_contents("/etc/ttys");
|
||||
|
||||
@ -1052,34 +1052,19 @@ function services_dhcpdv6_configure($blacklist = array())
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (file_exists("/var/run/booting")) {
|
||||
if (is_install_media()) {
|
||||
/* restore the leases, if we have them */
|
||||
if (file_exists('/conf/dhcp6leases.tgz')) {
|
||||
$dhcprestore = '';
|
||||
$dhcpreturn = '';
|
||||
exec('cd /;LANG=C /usr/bin/tar -xzf /conf/dhcp6leases.tgz 2>&1', $dhcprestore, $dhcpreturn);
|
||||
$dhcprestore = implode(' ', $dhcprestore);
|
||||
if($dhcpreturn <> 0) {
|
||||
log_error("DHCP leases v6 restore failed exited with $dhcpreturn, the error is: $dhcprestore\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$syscfg = $config['system'];
|
||||
if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6']))
|
||||
if (!isset($config['dhcpdv6']) || !is_array($config['dhcpdv6'])) {
|
||||
$config['dhcpdv6'] = array();
|
||||
}
|
||||
$dhcpdv6cfg = $config['dhcpdv6'];
|
||||
$Iflist = get_configured_interface_list();
|
||||
$Iflist = array_merge($Iflist, get_configured_pppoe_server_interfaces());
|
||||
|
||||
|
||||
if (file_exists("/var/run/booting"))
|
||||
if (file_exists("/var/run/booting")) {
|
||||
echo "Starting DHCPv6 service...";
|
||||
else
|
||||
} else {
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
/* we add a fake entry for interfaces that are set to track6 another WAN */
|
||||
foreach ($Iflist as $ifname) {
|
||||
|
||||
@ -29,6 +29,23 @@
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function is_install_media()
|
||||
{
|
||||
/*
|
||||
* Despite unionfs underneath, / is still not writeable,
|
||||
* making the following the perfect test for install media.
|
||||
*/
|
||||
|
||||
$file = '/.probe.for.install.media';
|
||||
$fd = @fopen($file, 'w');
|
||||
if ($fd) {
|
||||
fclose($fd);
|
||||
unlink($file);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function is_interface_mismatch()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user