diff options
Diffstat (limited to 'src/etc')
-rw-r--r-- | src/etc/inc/config.console.inc | 280 | ||||
-rw-r--r-- | src/etc/inc/config.inc | 87 | ||||
-rw-r--r-- | src/etc/inc/config.lib.inc | 42 | ||||
-rw-r--r-- | src/etc/inc/pfsense-utils.inc | 152 | ||||
-rwxr-xr-x | src/etc/pfSense-rc | 173 | ||||
-rwxr-xr-x | src/etc/rc.bootup | 48 | ||||
-rwxr-xr-x | src/etc/rc.cdrom | 54 | ||||
-rwxr-xr-x | src/etc/rc.initial | 15 |
8 files changed, 297 insertions, 554 deletions
diff --git a/src/etc/inc/config.console.inc b/src/etc/inc/config.console.inc index b4783da..3cf185d 100644 --- a/src/etc/inc/config.console.inc +++ b/src/etc/inc/config.console.inc @@ -47,14 +47,9 @@ function set_networking_interfaces_ports() { $iflist = get_interface_list(); - /* Function flow is based on $key and $auto_assign or the lack thereof */ + /* Function flow is based on $key or the lack thereof */ $key = null; - /* Only present auto interface option if running from the installer media and interface mismatch*/ - if ((preg_match("/cdrom/", $g['platform'])) && is_interface_mismatch()) { - $auto_assign = false; - } - echo <<<EOD Valid interfaces are: @@ -81,15 +76,6 @@ EOD; } } - if ($auto_assign) { - echo <<<EOD - - !!! Installation Media Detected: Auto Interface Option !!!! -BEGIN MANUAL CONFIGURATION OR THE SYSTEM WILL PROCEED WITH AUTO CONFIGURATION. - -EOD; - } - echo "\n" . gettext("Do VLANs need to be set up first?"); echo "\n" . gettext( @@ -98,211 +84,147 @@ EOD; "\n"; echo "\n" . gettext("Should VLANs be set up now [y|n]?") . " "; - if ($auto_assign) { - $key = timeout(); - } else { - $key = chop(fgets($fp)); - } - - if (!isset($key) and $auto_assign) { // Auto Assign Interfaces - do { - echo <<<EOD + $key = chop(fgets($fp)); - !!! Auto Assigning Interfaces !!! - -For setup purposes, there must be at least one NIC connected for -the LAN. If a second NIC is connected, it will be assigned to the -WAN. Otherwise, WAN will be temporarily assigned to the next -available NIC found regardless of activity. The WAN interface -should then be assigned and configured as required. - -Please make the pfSense NIC connections now. -The system will continue checking until they have been made. - -Searching for active interfaces... - -EOD; - unset($wanif, $lanif); + //Manually assign interfaces + if (in_array($key, array('y', 'Y'))) { + vlan_setup(); + } - $media_iflist = $plugged_in = array(); - $media_iflist = get_interface_list("media"); - foreach ($media_iflist as $iface => $ifa) { - if ($ifa['up']) { - $plugged_in[] = $iface; - } - } + if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { - $lanif = array_shift($plugged_in); - $wanif = array_shift($plugged_in); + echo "\n\n" . gettext("VLAN interfaces:") . "\n\n"; + foreach ($config['vlans']['vlan'] as $vlan) { - if (isset($lanif) && !isset($wanif)) { - foreach ($iflist as $iface => $ifa) { - if ($iface != $lanif) { - $wanif = $iface; - break; - } - } - } + echo sprintf("% -16s%s\n", "{$vlan['if']}_vlan{$vlan['tag']}", + "VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}"); - echo <<<EOD + $iflist[$vlan['if'] . '_vlan' . $vlan['tag']] = array(); + $ifsmallist = $ifsmallist . $vlan['if'] . '_vlan' . $vlan['tag'] . " "; + } + } -Assigned WAN to : $wanif -Assigned LAN to : $lanif + echo <<<EOD -If these assignments are not suitable, -press any key to go back to manual configuration. +If the names of the interfaces are not known, auto-detection can +be used instead. To use auto-detection, please disconnect all +interfaces before pressing 'a' to begin the process. EOD; - $key = timeout(20); - if (isset($key)) { - return; - } - } while (!isset($wanif)); - - $config['system']['enablesshd'] = 'enabled'; - $key = 'y'; - } else { - //Manually assign interfaces - if (in_array($key, array('y', 'Y'))) { - vlan_setup(); + do { + echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection") . " "; + printf(gettext("%s(%s or a): "), "\n", trim($ifsmallist)); + $wanif = chop(fgets($fp)); + if ($wanif === "") { + return; } - - if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { - - echo "\n\n" . gettext("VLAN interfaces:") . "\n\n"; - foreach ($config['vlans']['vlan'] as $vlan) { - - echo sprintf("% -16s%s\n", "{$vlan['if']}_vlan{$vlan['tag']}", - "VLAN tag {$vlan['tag']}, parent interface {$vlan['if']}"); - - $iflist[$vlan['if'] . '_vlan' . $vlan['tag']] = array(); - $ifsmallist = $ifsmallist . $vlan['if'] . '_vlan' . $vlan['tag'] . " "; - } + if ($wanif === "a") { + $wanif = autodetect_interface("WAN", $fp); + } else if (!array_key_exists($wanif, $iflist)) { + printf(gettext("%sInvalid interface name '%s'%s"), "\n", $wanif, "\n"); + unset($wanif); + continue; } + $ifsmallist = str_replace(" " . $wanif . " ", " ", $ifsmallist); + } while (!$wanif); - echo <<<EOD + do { + printf(gettext("%sEnter the LAN interface name or 'a' for auto-detection %s" . + "NOTE: this enables full Firewalling/NAT mode.%s" . + "(%s a or nothing if finished):%s"), "\n", "\n", "\n", trim($ifsmallist), " "); -If the names of the interfaces are not known, auto-detection can -be used instead. To use auto-detection, please disconnect all -interfaces before pressing 'a' to begin the process. + $lanif = chop(fgets($fp)); -EOD; + if ($lanif == "exit") { + exit; + } - do { - echo "\n" . gettext("Enter the WAN interface name or 'a' for auto-detection") . " "; - printf(gettext("%s(%s or a): "), "\n", trim($ifsmallist)); - $wanif = chop(fgets($fp)); - if ($wanif === "") { - return; - } - if ($wanif === "a") { - $wanif = autodetect_interface("WAN", $fp); - } else if (!array_key_exists($wanif, $iflist)) { - printf(gettext("%sInvalid interface name '%s'%s"), "\n", $wanif, "\n"); - unset($wanif); - continue; - } - $ifsmallist = str_replace(" " . $wanif . " ", " ", $ifsmallist); - } while (!$wanif); + if ($lanif == "") { + /* It is OK to have just a WAN, without a LAN so break if the user does not want LAN. */ + break; + } - do { - printf(gettext("%sEnter the LAN interface name or 'a' for auto-detection %s" . - "NOTE: this enables full Firewalling/NAT mode.%s" . - "(%s a or nothing if finished):%s"), "\n", "\n", "\n", trim($ifsmallist), " "); + if ($lanif === "a") { + $lanif = autodetect_interface("LAN", $fp); + } else if (!array_key_exists($lanif, $iflist)) { + printf(gettext("%sInvalid interface name '%s'%s"), "\n", $lanif, "\n"); + unset($lanif); + continue; + } + $ifsmallist = str_replace(" " . $lanif . " ", " ", $ifsmallist); + } while (!$lanif); - $lanif = chop(fgets($fp)); + /* optional interfaces */ + $i = 0; + $optif = array(); - if ($lanif == "exit") { - exit; + if ($lanif <> "") { + while (1) { + if ($optif[$i]) { + $i++; } + $io = $i + 1; - if ($lanif == "") { - /* It is OK to have just a WAN, without a LAN so break if the user does not want LAN. */ - break; + if ($config['interfaces']['opt' . $io]['descr']) { + printf(gettext("%sOptional interface %s description found: %s"), "\n", $io, $config['interfaces']['opt' . $io]['descr']); } - if ($lanif === "a") { - $lanif = autodetect_interface("LAN", $fp); - } else if (!array_key_exists($lanif, $iflist)) { - printf(gettext("%sInvalid interface name '%s'%s"), "\n", $lanif, "\n"); - unset($lanif); - continue; - } - $ifsmallist = str_replace(" " . $lanif . " ", " ", $ifsmallist); - } while (!$lanif); - - /* optional interfaces */ - $i = 0; - $optif = array(); + printf(gettext("%sEnter the Optional %s interface name or 'a' for auto-detection%s" . + "(%s a or nothing if finished):%s"), "\n", $io, "\n", trim($ifsmallist), " "); - if ($lanif <> "") { - while (1) { - if ($optif[$i]) { - $i++; - } - $io = $i + 1; - - if ($config['interfaces']['opt' . $io]['descr']) { - printf(gettext("%sOptional interface %s description found: %s"), "\n", $io, $config['interfaces']['opt' . $io]['descr']); - } + $optif[$i] = chop(fgets($fp)); - printf(gettext("%sEnter the Optional %s interface name or 'a' for auto-detection%s" . - "(%s a or nothing if finished):%s"), "\n", $io, "\n", trim($ifsmallist), " "); - - $optif[$i] = chop(fgets($fp)); - - if ($optif[$i]) { - if ($optif[$i] === "a") { - $ad = autodetect_interface(gettext("Optional") . " " . $io, $fp); - if ($ad) { - $optif[$i] = $ad; - } else { - unset($optif[$i]); - } - } else if (!array_key_exists($optif[$i], $iflist)) { - printf(gettext("%sInvalid interface name '%s'%s"), "\n", $optif[$i], "\n"); + if ($optif[$i]) { + if ($optif[$i] === "a") { + $ad = autodetect_interface(gettext("Optional") . " " . $io, $fp); + if ($ad) { + $optif[$i] = $ad; + } else { unset($optif[$i]); - continue; } - $ifsmallist = str_replace(" " . $optif[$i] . " ", " ", $ifsmallist); - } else { + } else if (!array_key_exists($optif[$i], $iflist)) { + printf(gettext("%sInvalid interface name '%s'%s"), "\n", $optif[$i], "\n"); unset($optif[$i]); - break; + continue; } + $ifsmallist = str_replace(" " . $optif[$i] . " ", " ", $ifsmallist); + } else { + unset($optif[$i]); + break; } } + } - /* check for double assignments */ - $ifarr = array_merge(array($lanif, $wanif), $optif); + /* check for double assignments */ + $ifarr = array_merge(array($lanif, $wanif), $optif); - for ($i = 0; $i < (count($ifarr)-1); $i++) { - for ($j = ($i+1); $j < count($ifarr); $j++) { - if ($ifarr[$i] == $ifarr[$j]) { - echo <<<EOD + for ($i = 0; $i < (count($ifarr)-1); $i++) { + for ($j = ($i+1); $j < count($ifarr); $j++) { + if ($ifarr[$i] == $ifarr[$j]) { + echo <<<EOD Error: The same interface name cannot be assigned twice! EOD; - fclose($fp); - return; - } + fclose($fp); + return; } } + } - echo "\n" . gettext("The interfaces will be assigned as follows:") . "\n\n"; + echo "\n" . gettext("The interfaces will be assigned as follows:") . "\n\n"; - echo "WAN -> " . $wanif . "\n"; - if ($lanif != "") { - echo "LAN -> " . $lanif . "\n"; - } - for ($i = 0; $i < count($optif); $i++) { - echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n"; - } - - echo "\n" . gettext("Do you want to proceed [y|n]?") . " "; - $key = chop(fgets($fp)); + echo "WAN -> " . $wanif . "\n"; + if ($lanif != "") { + echo "LAN -> " . $lanif . "\n"; } + for ($i = 0; $i < count($optif); $i++) { + echo "OPT" . ($i+1) . " -> " . $optif[$i] . "\n"; + } + + echo "\n" . gettext("Do you want to proceed [y|n]?") . " "; + $key = chop(fgets($fp)); if (in_array($key, array('y', 'Y'))) { if ($lanif) { @@ -316,7 +238,7 @@ EOD; } $config['interfaces']['lan']['if'] = $lanif; $config['interfaces']['lan']['enable'] = true; - } elseif (!platform_booting() && !$auto_assign) { + } elseif (!platform_booting()) { echo "\n" . gettext("You have chosen to remove the LAN interface.") . "\n"; echo "\n" . gettext("Would you like to remove the LAN IP address and \nunload the interface now [y|n]?") . " "; diff --git a/src/etc/inc/config.inc b/src/etc/inc/config.inc index 3efd2f3..f074ac7 100644 --- a/src/etc/inc/config.inc +++ b/src/etc/inc/config.inc @@ -98,63 +98,44 @@ if (platform_booting(true)) { /* check if there's already an fstab (NFS booting?) */ if (!file_exists("{$g['etc_path']}/fstab")) { echo "."; - if (strstr($g['platform'], "cdrom")) { - /* config is on floppy disk for CD-ROM version */ - $cfgdevice = $cfgpartition = "fd0"; - $_gb = exec('/sbin/dmesg -a', $dmesg); - if (preg_match("/da0/", $dmesg) == true) { - $cfgdevice = $cfgpartition = "da0" ; - if (mwexec("/sbin/mount -r /dev/{$cfgdevice} /cf")) { - /* could not mount, fallback to floppy */ - $cfgdevice = $cfgpartition = "fd0"; + /* probe kernel known disks until we find one with config.xml */ + $disks = explode(" ", get_single_sysctl("kern.disks")); + foreach ($disks as $mountdisk) { + /* skip mfs mounted filesystems */ + if (strstr($mountdisk, "md")) { + continue; + } + if (mwexec("/sbin/mount -r /dev/{$mountdisk}a {$g['cf_path']}") == 0) { + if (file_exists("{$g['cf_conf_path']}/config.xml")) { + /* found it */ + $cfgdevice = $mountdisk; + $cfgpartition = $cfgdevice . "a"; + $cfgfstype = "ufs"; + printf(gettext("Found configuration on %s.%s"), $cfgdevice, "\n"); + } + + mwexec("/sbin/umount -f {$g['cf_path']}"); + + if ($cfgdevice) { + break; } } - unset($dmesg); - $cfgfstype = "msdosfs"; - echo gettext("CDROM build") . "\n"; - echo " " . gettext("CFG:") . " {$cfgpartition}\n"; - echo " " . gettext("TYPE:") . " {$cfgfstype}\n"; - } else { - echo "."; - /* probe kernel known disks until we find one with config.xml */ - $disks = explode(" ", get_single_sysctl("kern.disks")); - foreach ($disks as $mountdisk) { - /* skip mfs mounted filesystems */ - if (strstr($mountdisk, "md")) { - continue; + if (mwexec("/sbin/mount -r /dev/{$mountdisk}d {$g['cf_path']}") == 0) { + if (platform_booting()) { + echo "."; } - if (mwexec("/sbin/mount -r /dev/{$mountdisk}a {$g['cf_path']}") == 0) { - if (file_exists("{$g['cf_conf_path']}/config.xml")) { - /* found it */ - $cfgdevice = $mountdisk; - $cfgpartition = $cfgdevice . "a"; - $cfgfstype = "ufs"; - printf(gettext("Found configuration on %s.%s"), $cfgdevice, "\n"); - } - - mwexec("/sbin/umount -f {$g['cf_path']}"); - - if ($cfgdevice) { - break; - } + if (file_exists("{$g['cf_conf_path']}/config.xml")) { + /* found it */ + $cfgdevice = $mountdisk; + $cfgpartition = $cfgdevice . "d"; + $cfgfstype = "ufs"; + printf(gettext("Found configuration on %s.%s"), $cfgdevice, "\n"); } - if (mwexec("/sbin/mount -r /dev/{$mountdisk}d {$g['cf_path']}") == 0) { - if (platform_booting()) { - echo "."; - } - if (file_exists("{$g['cf_conf_path']}/config.xml")) { - /* found it */ - $cfgdevice = $mountdisk; - $cfgpartition = $cfgdevice . "d"; - $cfgfstype = "ufs"; - printf(gettext("Found configuration on %s.%s"), $cfgdevice, "\n"); - } - - mwexec("/sbin/umount -f {$g['cf_path']}"); - - if ($cfgdevice) { - break; - } + + mwexec("/sbin/umount -f {$g['cf_path']}"); + + if ($cfgdevice) { + break; } } } diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc index c7bf59c..d2e5a19 100644 --- a/src/etc/inc/config.lib.inc +++ b/src/etc/inc/config.lib.inc @@ -228,32 +228,20 @@ function parse_config_bootup() { $lockkey = lock('config'); if (!file_exists("{$g['conf_path']}/config.xml")) { if (platform_booting()) { - if (strstr($g['platform'], "cdrom")) { - /* try copying the default config. to the floppy */ - echo gettext("Resetting factory defaults...") . "\n"; - reset_factory_defaults(true, false); - if (!file_exists("{$g['conf_path']}/config.xml")) { - echo gettext("No XML configuration file found - using factory defaults.\n" . - "Make sure that the configuration floppy disk with the conf/config.xml\n" . - "file is inserted. If it isn't, the configuration changes will be lost\n" . - "on reboot.\n"); - } - } else { - $last_backup = discover_last_backup(); - if ($last_backup) { - log_error("No config.xml found, attempting last known config restore."); - file_notice("config.xml", gettext("No config.xml found, attempting last known config restore."), "pfSenseConfigurator", ""); - restore_backup("/cf/conf/backup/{$last_backup}"); - } - if (!file_exists("{$g['conf_path']}/config.xml")) { - echo sprintf(gettext("XML configuration file not found. %s cannot continue booting."), $g['product_name']) . "\n"; - unlock($lockkey); - mwexec("/sbin/halt"); - exit; - } - log_error("Last known config found and restored. Please double check the configuration file for accuracy."); - file_notice("config.xml", gettext("Last known config found and restored. Please double check the configuration file for accuracy."), "pfSenseConfigurator", ""); + $last_backup = discover_last_backup(); + if ($last_backup) { + log_error("No config.xml found, attempting last known config restore."); + file_notice("config.xml", gettext("No config.xml found, attempting last known config restore."), "pfSenseConfigurator", ""); + restore_backup("/cf/conf/backup/{$last_backup}"); + } + if (!file_exists("{$g['conf_path']}/config.xml")) { + echo sprintf(gettext("XML configuration file not found. %s cannot continue booting."), $g['product_name']) . "\n"; + unlock($lockkey); + mwexec("/sbin/halt"); + exit; } + log_error("Last known config found and restored. Please double check the configuration file for accuracy."); + file_notice("config.xml", gettext("Last known config found and restored. Please double check the configuration file for accuracy."), "pfSenseConfigurator", ""); } else { unlock($lockkey); log_error(gettext("Could not find a usable configuration file! Exiting....")); @@ -811,10 +799,6 @@ function get_backups() { function backup_config() { global $config, $g; - if ($g['platform'] == "cdrom") { - return; - } - conf_mount_rw(); /* Create backup directory if needed */ diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index 236d02c..c258f1f 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -1083,92 +1083,90 @@ function setup_serial_port($when = "save", $path = "") { } $serialspeed = (is_numeric($config['system']['serialspeed'])) ? $config['system']['serialspeed'] : "115200"; - if ($g['platform'] != "cdrom") { - $serial_only = false; + $serial_only = false; - if (($g['platform'] == "nanobsd") && isset($g['enableserial_force'])) { + if (($g['platform'] == "nanobsd") && isset($g['enableserial_force'])) { + $serial_only = true; + } else { + $specific_platform = system_identify_specific_platform(); + if ($specific_platform['name'] == 'RCC-VE' || + $specific_platform['name'] == 'RCC' || + $specific_platform['name'] == 'RCC-DFF') { $serial_only = true; - } else { - $specific_platform = system_identify_specific_platform(); - if ($specific_platform['name'] == 'RCC-VE' || - $specific_platform['name'] == 'RCC' || - $specific_platform['name'] == 'RCC-DFF') { - $serial_only = true; - } } + } - $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_only === true) { - fwrite($fd, "-S{$serialspeed} -h"); - } else if (is_serial_enabled()) { - fwrite($fd, "-S{$serialspeed} -D"); - } - fclose($fd); - } - - /* serial console - write out /boot/loader.conf */ - if ($when == "upgrade") { - system("echo \"Reading {$loader_conf_file}...\" >> /conf/upgrade_log.txt"); - } - $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, "hint.uart.0.flags") === false) && - (stripos($bcs, "hint.uart.1.flags") === false)) { - $new_boot_config[] = $bcs; - } - } - - if ($serial_only === true) { - $new_boot_config[] = 'boot_serial="YES"'; - $new_boot_config[] = 'console="comconsole"'; - } else if (is_serial_enabled()) { - $new_boot_config[] = 'boot_multicons="YES"'; - $new_boot_config[] = 'boot_serial="YES"'; - $primaryconsole = isset($g['primaryconsole_force']) ? $g['primaryconsole_force'] : $config['system']['primaryconsole']; - switch ($primaryconsole) { - case "video": - $new_boot_config[] = 'console="vidconsole,comconsole"'; - break; - case "serial": - default: - $new_boot_config[] = 'console="comconsole,vidconsole"'; + $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"); } } - $new_boot_config[] = 'comconsole_speed="' . $serialspeed . '"'; + } + if ($serial_only === true) { + fwrite($fd, "-S{$serialspeed} -h"); + } else if (is_serial_enabled()) { + fwrite($fd, "-S{$serialspeed} -D"); + } + fclose($fd); + } - $specplatform = system_identify_specific_platform(); - if ($specplatform['name'] == 'RCC-VE' || - $specplatform['name'] == 'RCC' || - $specplatform['name'] == 'RCC-DFF') { - $new_boot_config[] = 'comconsole_port="0x2F8"'; - $new_boot_config[] = 'hint.uart.0.flags="0x00"'; - $new_boot_config[] = 'hint.uart.1.flags="0x10"'; + /* serial console - write out /boot/loader.conf */ + if ($when == "upgrade") { + system("echo \"Reading {$loader_conf_file}...\" >> /conf/upgrade_log.txt"); + } + $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, "hint.uart.0.flags") === false) && + (stripos($bcs, "hint.uart.1.flags") === false)) { + $new_boot_config[] = $bcs; + } + } + + if ($serial_only === true) { + $new_boot_config[] = 'boot_serial="YES"'; + $new_boot_config[] = 'console="comconsole"'; + } else if (is_serial_enabled()) { + $new_boot_config[] = 'boot_multicons="YES"'; + $new_boot_config[] = 'boot_serial="YES"'; + $primaryconsole = isset($g['primaryconsole_force']) ? $g['primaryconsole_force'] : $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[] = 'hw.usb.no_pf="1"'; + } + $new_boot_config[] = 'comconsole_speed="' . $serialspeed . '"'; - file_put_contents($loader_conf_file, implode("\n", $new_boot_config) . "\n"); + $specplatform = system_identify_specific_platform(); + if ($specplatform['name'] == 'RCC-VE' || + $specplatform['name'] == 'RCC' || + $specplatform['name'] == 'RCC-DFF') { + $new_boot_config[] = 'comconsole_port="0x2F8"'; + $new_boot_config[] = 'hint.uart.0.flags="0x00"'; + $new_boot_config[] = 'hint.uart.1.flags="0x10"'; } + $new_boot_config[] = 'hw.usb.no_pf="1"'; + + file_put_contents($loader_conf_file, implode("\n", $new_boot_config) . "\n"); } $ttys = file_get_contents($ttys_file); $ttys_split = explode("\n", $ttys); @@ -1208,7 +1206,7 @@ function is_serial_enabled() { if (!isset($g['enableserial_force']) && !isset($config['system']['enableserial']) && - ($g['platform'] == $g['product_name'] || $g['platform'] == "cdrom")) { + ($g['platform'] == $g['product_name'])) { return false; } diff --git a/src/etc/pfSense-rc b/src/etc/pfSense-rc index 9e3f39e..40d8d36 100755 --- a/src/etc/pfSense-rc +++ b/src/etc/pfSense-rc @@ -70,86 +70,84 @@ if [ -e /root/force_fsck ]; then /sbin/fsck -y -F -t ufs fi -if [ "${PLATFORM}" != "cdrom" ]; then - FSCK_ACTION_NEEDED=0 - /sbin/fsck -p -F - case $? in - 0) - echo "Filesystems are clean, continuing..." - echo "Mounting filesystems..." - ;; - 8) - echo "Preen mode recommended running a check that will be performed now." - FSCK_ACTION_NEEDED=1 - ;; - *) - echo "Stopping boot is recommended because filesystem manual action is needed, nevertheless automated repair of the filesystem will be attempted." - FSCK_ACTION_NEEDED=1 - ;; - esac - - if [ ${FSCK_ACTION_NEEDED} = 1 ]; then - echo "WARNING: Trying to recover filesystem from inconsistency..." - /sbin/fsck -yF - fi - +FSCK_ACTION_NEEDED=0 +/sbin/fsck -p -F +case $? in +0) + echo "Filesystems are clean, continuing..." + echo "Mounting filesystems..." + ;; +8) + echo "Preen mode recommended running a check that will be performed now." + FSCK_ACTION_NEEDED=1 + ;; +*) + echo "Stopping boot is recommended because filesystem manual action is needed, nevertheless automated repair of the filesystem will be attempted." + FSCK_ACTION_NEEDED=1 + ;; +esac + +if [ ${FSCK_ACTION_NEEDED} = 1 ]; then + echo "WARNING: Trying to recover filesystem from inconsistency..." + /sbin/fsck -yF +fi + +/sbin/mount -a 2>/dev/null +mount_rc=$? +attempts=0 +while [ ${mount_rc} -ne 0 -a ${attempts} -lt 3 ]; do + /sbin/fsck -yF /sbin/mount -a 2>/dev/null mount_rc=$? - attempts=0 - while [ ${mount_rc} -ne 0 -a ${attempts} -lt 3 ]; do - /sbin/fsck -yF - /sbin/mount -a 2>/dev/null - mount_rc=$? - attempts=$((attempts+1)) - done - - if [ "${PLATFORM}" = "nanobsd" ]; then - # XXX This script does need all filesystems rw!!!! - # Put this workaround for now until better ways are found. - /sbin/mount -u -w -o sync,noatime / - /sbin/mount -u -w -o sync,noatime /cf - fi + attempts=$((attempts+1)) +done - # If /conf is a directory, convert it to a symlink to /cf/conf - if [ -d "/conf" ]; then - # If item is not a symlink then rm and recreate - CONFPOINTSTO=`readlink /conf` - if ! test "x$CONFPOINTSTO" = "x/cf/conf"; then - /bin/rm -rf /conf - /bin/ln -s /cf/conf /conf - fi +if [ "${PLATFORM}" = "nanobsd" ]; then + # XXX This script does need all filesystems rw!!!! + # Put this workaround for now until better ways are found. + /sbin/mount -u -w -o sync,noatime / + /sbin/mount -u -w -o sync,noatime /cf +fi + +# If /conf is a directory, convert it to a symlink to /cf/conf +if [ -d "/conf" ]; then + # If item is not a symlink then rm and recreate + CONFPOINTSTO=`readlink /conf` + if ! test "x$CONFPOINTSTO" = "x/cf/conf"; then + /bin/rm -rf /conf + /bin/ln -s /cf/conf /conf fi +fi - USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar) - unset MOVE_PKG_DATA - if [ "$PLATFORM" = "${product}" ]; then - # If use MFS var is disabled, move files back to place - if [ "${USE_MFS_TMPVAR}" != "true" -a -f /root/var/db/pkg/local.sqlite ]; then - MOVE_PKG_DATA=1 - rm -rf /var/db/pkg 2>/dev/null - rm -rf /var/cache/pkg 2>/dev/null - mv /root/var/db/pkg /var/db - mv /root/var/cache/pkg /var/cache - # If use MFS var is enabled, move files to a safe place - elif [ "${USE_MFS_TMPVAR}" = "true" -a -f /var/db/pkg/local.sqlite ]; then - MOVE_PKG_DATA=1 - /bin/mkdir -p /root/var/db /root/var/cache - mv /var/db/pkg /root/var/db - mv /var/cache/pkg /root/var/cache - fi - elif [ "${PLATFORM}" = "nanobsd" ]; then +USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar) +unset MOVE_PKG_DATA +if [ "$PLATFORM" = "${product}" ]; then + # If use MFS var is disabled, move files back to place + if [ "${USE_MFS_TMPVAR}" != "true" -a -f /root/var/db/pkg/local.sqlite ]; then + MOVE_PKG_DATA=1 + rm -rf /var/db/pkg 2>/dev/null + rm -rf /var/cache/pkg 2>/dev/null + mv /root/var/db/pkg /var/db + mv /root/var/cache/pkg /var/cache + # If use MFS var is enabled, move files to a safe place + elif [ "${USE_MFS_TMPVAR}" = "true" -a -f /var/db/pkg/local.sqlite ]; then MOVE_PKG_DATA=1 + /bin/mkdir -p /root/var/db /root/var/cache + mv /var/db/pkg /root/var/db + mv /var/cache/pkg /root/var/cache fi +elif [ "${PLATFORM}" = "nanobsd" ]; then + MOVE_PKG_DATA=1 +fi - if [ "${PLATFORM}" = "nanobsd" ] || [ "${USE_MFS_TMPVAR}" = "true" ]; then - /etc/rc.embedded - fi +if [ "${PLATFORM}" = "nanobsd" ] || [ "${USE_MFS_TMPVAR}" = "true" ]; then + /etc/rc.embedded +fi - if [ -n "${MOVE_PKG_DATA}" -o "${USE_MFS_TMPVAR}" = "true" ]; then - /bin/mkdir -p /var/db /var/cache - ln -sf ../../root/var/db/pkg /var/db/pkg - ln -sf ../../root/var/cache/pkg /var/cache/pkg - fi +if [ -n "${MOVE_PKG_DATA}" -o "${USE_MFS_TMPVAR}" = "true" ]; then + /bin/mkdir -p /var/db /var/cache + ln -sf ../../root/var/db/pkg /var/db/pkg + ln -sf ../../root/var/cache/pkg /var/cache/pkg fi # Make sure /home exists @@ -179,8 +177,6 @@ elif [ "$PLATFORM" = "${product}" ]; then fi fi fi -elif [ "${PLATFORM}" = "cdrom" ]; then - /etc/rc.cdrom fi # Disable APM on ATA drives. Leaving this on will kill drives long-term, especially laptop drives, by generating excessive Load Cycles. @@ -217,24 +213,6 @@ if [ "$PLATFORM" = "${product}" ]; then /etc/rc.savecore fi -if [ "$PLATFORM" = "cdrom" ] ; then - echo -n "Mounting unionfs directories..." - /bin/mkdir /tmp/unionfs - /bin/mkdir /tmp/unionfs/usr - /bin/mkdir /tmp/unionfs/root - /bin/mkdir /tmp/unionfs/sbin - /bin/mkdir /tmp/unionfs/bin - /bin/mkdir /tmp/unionfs/boot - /bin/mkdir /tmp/unionfs/confdefault - /sbin/mount_unionfs /tmp/unionfs/usr /usr/ - /sbin/mount_unionfs /tmp/unionfs/root /root/ - /sbin/mount_unionfs /tmp/unionfs/bin /bin/ - /sbin/mount_unionfs /tmp/unionfs/sbin /sbin/ - /sbin/mount_unionfs /tmp/unionfs/boot /boot/ - /sbin/mount_unionfs /tmp/unionfs/confdefault /conf.default/ - echo "done." -fi - # make some directories in /var /bin/mkdir -p $varrunpath /var/log /var/etc /var/db/entropy /var/db/rrd /var/at/jobs/ /var/empty /var/log/nginx 2>/dev/null /bin/rm -rf $varrunpath/* @@ -300,17 +278,12 @@ if [ ! -h /tmp/tmp ]; then fi # Make sure our /tmp is 777 + Sticky -if [ ! "$PLATFORM" = "cdrom" ] ; then - /bin/rm -rf /tmp/* -fi /bin/chmod 1777 /tmp -if [ ! "$PLATFORM" = "cdrom" ] ; then - # Malloc debugging check - if [ -L /etc/malloc.conf ]; then - #ln -s aj /etc/malloc.conf - /bin/rm /etc/malloc.conf - fi +# Malloc debugging check +if [ -L /etc/malloc.conf ]; then + #ln -s aj /etc/malloc.conf + /bin/rm /etc/malloc.conf fi if [ ! -L /etc/dhclient.conf ]; then diff --git a/src/etc/rc.bootup b/src/etc/rc.bootup index 51b9215..134bb20 100755 --- a/src/etc/rc.bootup +++ b/src/etc/rc.bootup @@ -24,45 +24,6 @@ require_once("pkg-utils.inc"); -function rescue_detect_keypress() { - // How long do you want the script to wait before moving on (in seconds) - $timeout=9; - echo "\n"; - echo "[ Press R to enter recovery mode or ]\n"; - echo "[ press I to launch the installer ]\n\n"; - echo "(R)ecovery mode can assist by rescuing config.xml\n"; - echo "from a broken hard disk installation, etc.\n\n"; - echo "(I)nstaller will be invoked\n\n"; - echo "Timeout before auto boot continues (seconds): {$timeout}"; - $key = null; - exec("/bin/stty erase " . chr(8)); - while (!in_array($key, array("r", "R", "i", "I"))) { - echo chr(8) . "{$timeout}"; - `/bin/stty -icanon min 0 time 25`; - $key = trim(`KEY=\`dd count=1 2>/dev/null\`; echo \$KEY`); - `/bin/stty icanon`; - // Decrement our timeout value - $timeout--; - // If we have reached 0 exit and continue on - if ($timeout == 0) { - break; - } - } - // If R or I was pressed do our logic here - if (in_array($key, array("r", "R"))) { - putenv("TERM=xterm"); - echo "\n\nRecovery mode selected...\n"; - passthru("/usr/bin/env TERM=xterm /bin/tcsh"); - } else { - putenv("TERM=xterm"); - echo "\n\nInstaller mode selected...\n"; - passthru("/usr/bin/env TERM=xterm /bin/tcsh -c /scripts/lua_installer"); - } - - passthru("/etc/rc.reboot"); - exit; -} - echo " done.\n"; echo "Initializing..."; @@ -145,11 +106,6 @@ set_device_perms(); unmute_kernel_msgs(); echo "done.\n"; -// Display rescue configuration option -if ($g['platform'] == "cdrom") { - rescue_detect_keypress(); -} - echo "Loading configuration..."; parse_config_bootup(); echo "done.\n"; @@ -413,9 +369,7 @@ if (file_exists('/conf/needs_package_sync') && } /* Detect installed binary pkgs that are not registered in the system */ -if ($g['platform'] != "cdrom") { - register_all_installed_packages(); -} +register_all_installed_packages(); /* Give syslogd a kick after everything else has been initialized, otherwise it can occasionally fail to route syslog messages properly on both IPv4 and IPv6 */ diff --git a/src/etc/rc.cdrom b/src/etc/rc.cdrom deleted file mode 100755 index e28b575..0000000 --- a/src/etc/rc.cdrom +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# -# rc.cdrom -# -# part of pfSense (https://www.pfsense.org) -# Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate) -# All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Size of memory file system /cf/conf partition -partsize="6m" - -export VARMFS_COPYDBPKG=yes - -for i in tmp varmfs etcmfs; do - if [ -f /etc/rc.d/$i ]; then - sh /etc/rc.d/$i start - fi -done - -# Start PFI -/bin/sh /scripts/pfi start - -# If PFI did not find a config, we should create -# a tiny mfs under /cf/conf and populate with stock -# configuration. -if [ ! -f /conf/config.xml ]; then - echo -n "Generating a MFS /conf partition... " - device=$(mdconfig -a -t malloc -s ${partsize}) - newfs /dev/${device} > /dev/null 2>&1 - mount /dev/${device} /cf/conf - cp /conf.default/* /cf/conf - echo "done." -fi - -echo -n "Generating a MFS /home partition... " -device=$(mdconfig -a -t malloc -s ${partsize}) -newfs /dev/${device} > /dev/null 2>&1 -mount /dev/${device} /home -echo "done." - -# Create some needed directories -/bin/mkdir -p /var/tmp/vi.recover/ diff --git a/src/etc/rc.initial b/src/etc/rc.initial index 9d87a44..9ce1ac8 100755 --- a/src/etc/rc.initial +++ b/src/etc/rc.initial @@ -88,10 +88,6 @@ for i in /var/db/pfi/capable_*; do fi done -if [ "$PLATFORM" = "cdrom" ]; then - option99="99) Install ${product} to a hard drive, etc." -fi - # display a cheap menu echo "" echo " 0) Logout (SSH only) 9) pfTop" @@ -105,10 +101,6 @@ echo " 7) Ping host 16) Restart PHP-FPM" echo " 8) Shell" echo " ${option98} " -if [ "${option99}" != "" ]; then - /bin/echo "${option99}" -fi - echo read -p "Enter an option: " opmode echo @@ -171,13 +163,6 @@ case ${opmode} in /etc/rc.initial.store_config_to_removable_device fi ;; -99) - if [ -e /dev/ukbd0 ]; then - env TERM=xterm /scripts/lua_installer - else - /scripts/lua_installer - fi - ;; 100) if grep "$WORD" "$CONFIG"; then links "https://localhost" |